Changeset 6121 in orxonox.OLD for branches/objectmanager
- Timestamp:
- Dec 15, 2005, 1:34:32 AM (19 years ago)
- Location:
- branches/objectmanager/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/objectmanager/src/story_entities/world.cc
r6120 r6121 141 141 SoundEngine::getInstance()->flushAllSources(); 142 142 143 delete ObjectManager::getInstance(); 143 if (State::getObjectManager() == &this->objectManager) 144 State::setObjectManager(NULL); 144 145 // erease everything that is left. 145 146 delete PNode::getNullParent(); … … 214 215 ErrorMessage World::preLoad() 215 216 { 217 State::setObjectManager(&this->objectManager); 216 218 State::setWorldEntityList(this->entities = new tList<WorldEntity>()); 217 219 this->cycle = 0; -
branches/objectmanager/src/story_entities/world.h
r6048 r6121 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 #include "object_manager.h" 13 14 14 class World; 15 15 16 class WorldEntity; 16 17 class Camera; … … 18 19 class GLMenuImageScreen; 19 20 class Terrain; 20 class GarbageCollector;21 class Text;22 21 class TiXmlElement; 23 22 24 23 class Shell; 25 24 class OggPlayer; 25 26 26 template<class T> class tList; 27 27 … … 104 104 bool bPause; //!< pause mode 105 105 106 ObjectManager objectManager; //!< The ObjectManager of this World. 107 106 108 GLMenuImageScreen* glmis; //!< The Level-Loader Display 107 109 -
branches/objectmanager/src/util/object_manager.cc
r6120 r6121 22 22 23 23 #include "shell_command.h" 24 25 #include <assert.h> 26 24 27 using namespace std; 25 28 SHELL_COMMAND(debug, ObjectManager, debug) … … 37 40 } 38 41 39 /**40 * the singleton reference to this class41 */42 ObjectManager* ObjectManager::singletonRef = NULL;43 42 44 43 /** … … 50 49 { 51 50 this->flush(); 52 ObjectManager::singletonRef = NULL;53 51 } 54 52 … … 78 76 void ObjectManager::toList (WorldEntity* entity, OM_LIST omList) 79 77 { 78 assert (omList != OM_SIZE); 79 80 80 if (likely(entity->getOMListNumber() != OM_INIT)) 81 81 this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator()); … … 127 127 * @brief print out nice debug information about Elements in the list OM_LIST 128 128 * @param omList the List to debug. 129 */ 130 void ObjectManager::debug(OM_LIST omList) const 129 * @param level: level 0: only show list info; level 1: also show entities and their names. 130 */ 131 void ObjectManager::debug(OM_LIST omList, unsigned int level) const 131 132 { 132 133 if (omList != OM_INIT || omList == OM_SIZE) 133 134 { 134 135 PRINT(0)(" +ObjectManager-LIST: '%s'-size='%d'-----\n", ObjectManager::OMListToString((OM_LIST) omList), this->objectLists[omList].size()); 135 std::list<WorldEntity*>::const_iterator entity; 136 for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++) 136 if (level > 1) 137 137 { 138 PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName()); 138 std::list<WorldEntity*>::const_iterator entity; 139 for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++) 140 { 141 PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName()); 142 } 139 143 } 140 144 } … … 147 151 * @brief prints out very nice debug information 148 152 * @param listName the Name of the list to get Debug information from 149 */ 150 void ObjectManager::debug(const char* listName) 151 { 153 * @param level: level 0: only show list info; level 1: also show entities and their names. 154 */ 155 void ObjectManager::debug(const char* listName, unsigned int level) 156 { 157 PRINT(0)("=================================\n"); 152 158 PRINT(0)("=ObjectManager-DEBUG=============\n"); 159 PRINT(0)("=================================\n"); 153 160 if (listName == NULL || listName[0] == '\0') 154 161 for (unsigned int i = 0; i < OM_SIZE; ++i) 155 debug((OM_LIST) i );162 debug((OM_LIST) i, level); 156 163 else 157 164 debug(ObjectManager::StringToOMList(listName)); … … 198 205 "null", 199 206 "dead", 207 "dead-tick" 200 208 "environ-notick", 201 209 "environ", -
branches/objectmanager/src/util/object_manager.h
r6120 r6121 1 1 /*! 2 2 * @file object_manager.h 3 * @brief Definition of the ... singleton Class4 */3 * @brief Definition of the ObjectManager. 4 */ 5 5 6 6 #ifndef _OBJECT_MANAGER_H … … 15 15 OM_NULL = 0, 16 16 OM_DEAD, 17 OM_DEAD_TICK, 17 18 OM_ENVIRON_NOTICK, 18 19 OM_ENVIRON, … … 65 66 class WorldEntity; 66 67 67 //! A default singleton class.68 //! A powerfull handler for the Object (WorldEntities) in the World. 68 69 class ObjectManager : public BaseObject { 69 70 70 71 public: 71 virtual ~ObjectManager(void); 72 /** @returns a Pointer to the only object of this Class */ 73 inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager(); return ObjectManager::singletonRef; } 72 ObjectManager(); 73 virtual ~ObjectManager(); 74 74 75 75 void flush(); … … 84 84 static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID); 85 85 86 void debug(OM_LIST omList ) const;87 void debug(const char* listName = NULL );86 void debug(OM_LIST omList, unsigned int level = 0) const; 87 void debug(const char* listName = NULL, unsigned int level = 0); 88 88 89 89 static OM_LIST StringToOMList(const char* listName); … … 91 91 92 92 private: 93 ObjectManager(void);94 static ObjectManager* singletonRef;95 96 93 const std::list<BaseObject>* pNodeList; 97 94 -
branches/objectmanager/src/util/state.cc
r4836 r6121 29 29 const PNode* State::cameraTarget = NULL; 30 30 31 ObjectManager* State::objectManager = NULL; 31 32 tList<WorldEntity>* State::worldEntityList = NULL; 32 33 -
branches/objectmanager/src/util/state.h
r5405 r6121 11 11 class WorldEntity; 12 12 template<class T> class tList; 13 //template<class T> class tStack;13 class ObjectManager; 14 14 15 15 //! handles states about orxonox's most importatn objects … … 22 22 23 23 public: 24 // CAMERA // 24 ////////////// 25 /// CAMERA /// 26 ////////////// 25 27 /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */ 26 28 static void setCamera(const PNode* camera, const PNode* cameraTarget); … … 30 32 static inline const PNode* getCameraTarget() { return State::cameraTarget; }; 31 33 32 // WORLD_ENTITY_LIST // 34 ////////////////////// 35 /// OBJECT-MANAGER /// 36 ////////////////////// 37 /** @param objectManager the new Current ObjectManager */ 38 static inline void setObjectManager(ObjectManager* objectManager) { State::objectManager = objectManager; }; 39 /** @returns the current ObjectManager. */ 40 static inline ObjectManager* getObjectManager() { return State::objectManager; }; 41 42 ///////////////////////// 43 /// WORLD_ENTITY_LIST /// 44 ///////////////////////// 33 45 /** @param worldEntityList The World's List of WorldEntities */ 34 46 static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; }; … … 42 54 static const PNode* cameraTarget; //!< A reference to the cameraTarget 43 55 static PNode* nullParent; //!< A reference to the Null-PNode. 56 static ObjectManager* objectManager; //!< A referenct to the current ObjectManager 44 57 45 58 static tList<WorldEntity>* worldEntityList; //!< The List of the worldEntities -
branches/objectmanager/src/world_entities/npcs/npc.cc
r6054 r6121 33 33 { 34 34 this->setClassID(CL_NPC, "NPC"); 35 35 this->toList(OM_GROUP_00); 36 36 } 37 37 -
branches/objectmanager/src/world_entities/playable.cc
r5915 r6121 46 46 PRINTF(4)("PLAYABLE INIT\n"); 47 47 48 this->toList(OM_GROUP_01); 48 49 this->weaponMan = new WeaponManager(this); 49 50 -
branches/objectmanager/src/world_entities/power_ups/power_up.cc
r5439 r6121 27 27 { 28 28 this->setClassID(CL_POWER_UP, "PowerUp"); 29 this->toList(OM_COMMON); 29 30 30 31 } -
branches/objectmanager/src/world_entities/skybox.cc
r6022 r6121 65 65 { 66 66 this->setClassID(CL_SKYBOX, "SkyBox"); 67 67 this->toList(OM_ENVIRON_NOTICK); 68 68 this->size = 100.0; 69 69 -
branches/objectmanager/src/world_entities/world_entity.cc
r6089 r6121 57 57 this->objectListIterator = NULL; 58 58 59 ObjectManager::getInstance()->toList(this,OM_NULL);59 this->toList(OM_NULL); 60 60 } 61 61 … … 73 73 this->setModel(NULL, i); 74 74 75 ObjectManager::getInstance()->toList(this, OM_INIT);75 State::getObjectManager()->toList(this, OM_INIT); 76 76 } 77 77 … … 106 106 if (strchr(fileName, '#') != NULL) 107 107 { 108 109 110 111 112 113 114 115 116 117 118 119 108 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 109 char* lodFile = new char[strlen(fileName)+1]; 110 strcpy(lodFile, fileName); 111 char* depth = strchr(lodFile, '#'); 112 for (unsigned int i = 0; i < 5; i++) 113 { 114 *depth = 48+(int)i; 115 printf("-------%s\n", lodFile); 116 if (ResourceManager::isInDataDir(lodFile)) 117 this->loadModel(lodFile, scaling, i); 118 } 119 return; 120 120 } 121 121 … … 181 181 } 182 182 } 183 184 /** 185 * @brief moves this entity to the List OM_List 186 * @param list the list to set this Entity to. 187 * 188 * this is the same as a call to State::getObjectManager()->toList(entity , list); 189 * directly, but with an easier interface. 190 */ 191 void WorldEntity::toList(OM_LIST list) 192 { 193 State::getObjectManager()->toList(this, list); 194 } 195 183 196 184 197 -
branches/objectmanager/src/world_entities/world_entity.h
r6089 r6121 66 66 // CharacterAttributes* getCharacterAttributes(); 67 67 68 void toList(OM_LIST list); 69 68 70 /** @returns a Reference to the objectListNumber to set. */ 69 71 OM_LIST& getOMListNumber() { return this->objectListNumber; }
Note: See TracChangeset
for help on using the changeset viewer.