Changeset 3238 in orxonox.OLD for orxonox/branches/nico/src/world.h
- Timestamp:
- Dec 20, 2004, 2:42:54 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/nico/src/world.h
r2822 r3238 4 4 */ 5 5 6 #ifndef WORLD_H7 #define WORLD_H6 #ifndef _WORLD_H 7 #define _WORLD_H 8 8 9 9 #include "stdincl.h" … … 22 22 World (char* name); 23 23 World (int worldID); 24 ~World ();24 virtual ~World (); 25 25 26 26 template<typename T> 27 T* spawn (Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity27 T* spawn (Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity 28 28 template<typename T> 29 T* spawn (Placement* plc, WorldEntity* owner);29 T* spawn (Placement* plc, WorldEntity* owner); 30 30 31 virtual Error init();32 virtual Error start();33 virtual Error stop();34 virtual Error pause();35 virtual Error resume();31 virtual ErrorMessage init (); 32 virtual ErrorMessage start (); 33 virtual ErrorMessage stop (); 34 virtual ErrorMessage pause (); 35 virtual ErrorMessage resume (); 36 36 37 virtual void load(); 37 virtual void load (); 38 virtual void destroy (); 38 39 39 void time _slice (Uint32 deltaT);40 void timeSlice (Uint32 deltaT); 40 41 void collide (); 41 42 void draw (); 42 43 void update (); // maps Locations to Placements 43 void calc _camera_pos (Location* loc, Placement* plc);44 void calcCameraPos (Location* loc, Placement* plc); 44 45 45 46 void unload (); 47 bool command (Command* cmd); 46 48 47 void setTrackLen (Uint32 tracklen);48 int getTrackLen ();49 bool system_command (Command* cmd);50 Camera* getCamera ();49 void setTrackLen (Uint32 tracklen); 50 int getTrackLen (); 51 //bool system_command (Command* cmd); 52 Camera* getCamera (); 51 53 52 void spawn (WorldEntity* entity);53 void spawn (WorldEntity* entity, Location* loc);54 void spawn (WorldEntity* entity, Placement* plc);54 void spawn (WorldEntity* entity); 55 void spawn (WorldEntity* entity, Location* loc); 56 void spawn (WorldEntity* entity, Placement* plc); 55 57 56 58 tList<WorldEntity>* entities; … … 74 76 WorldEntity* localPlayer; 75 77 76 void mainLoop ();77 void synchronize ();78 void handle _input();79 void time _slice();80 void collision ();81 void display ();82 void debug ();78 void mainLoop (); 79 void synchronize (); 80 void handleInput (); 81 void timeSlice (); 82 void collision (); 83 void display (); 84 void debug (); 83 85 }; 84 86 85 /** 86 \brief spawn a new WorldEntity at a Location 87 \param loc: the Location where the Entity should be spawned 88 \param owner: a pointer to the parent of the Entity 89 \return a pointer to the new WorldEntity or NULL if there was an error 90 91 You can use this function to spawn any derivation of WorldEntity you want, just specify the desired 92 class within the template specification brackets. Do not attempt to spawn any classes that have NOT been 93 derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn() 94 works with both free and bound WorldEntities. 95 */ 96 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL) 97 { 98 Location zeroloc; 99 T* entity = new T(); 100 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 101 if( loc == NULL) 102 { 103 zeroloc.dist = 0; 104 zeroloc.part = 0; 105 zeroloc.pos = Vector(); 106 zeroloc.rot = Quaternion(); 107 loc = &zeroloc; 108 } 109 entity->init (loc, owner); 110 if (entity->bFree) 111 { 112 track[loc->part].map_coords( loc, entity->get_placement()); 113 } 114 entity->post_spawn (); 115 return entity; 116 } 117 118 /** 119 \brief spawn a new WorldEntity at a Placement 120 \param lplc: the placement where the Entity should be spawned 121 \param owner: a pointer to the parent of the Entity 122 \return a pointer to the new WorldEntity or NULL if there was an error 123 124 You can use this function to spawn any FREE derivation of WorldEntity you want, just specify the desired 125 class within the template specification brackets. Do not attempt to spawn any classes that have NOT been 126 derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn() 127 works with free WorldEntities only, you will provoke an error message if you try to spawn a bound Entity with 128 a Placement. 129 */ 130 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL) 131 { 132 T* entity = new T(); 133 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 134 entity->init (plc, owner); 135 if (!entity->bFree) 136 { 137 printf("Can't spawn unfree entity with placement\n"); 138 entities->remove( (WorldEntity*)entity, LIST_FIND_FW); 139 return NULL; 140 } 141 entity->post_spawn (); 142 return entity; 143 } 144 145 #endif 87 #endif /* _WORLD_H */
Note: See TracChangeset
for help on using the changeset viewer.