Changeset 2101 in orxonox.OLD for orxonox/branches/chris/src/world.h
- Timestamp:
- Jul 10, 2004, 2:00:04 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/world.h
r2100 r2101 3 3 #define WORLD_H 4 4 5 #include "stdincl.h" 6 5 7 class Track; 8 class WorldEntity; 6 9 7 10 class World { … … 11 14 ~World (); 12 15 13 template< classT>14 T* spawn <T>(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity15 template< classT>16 T* spawn <T>(Placement* plc, WorldEntity* owner);16 template<typename T> 17 T* spawn(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity 18 template<typename T> 19 T* spawn(Placement* plc, WorldEntity* owner); 17 20 18 21 void time_slice (Uint32 deltaT); … … 37 40 }; 38 41 42 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL) 43 { 44 Location zeroloc; 45 T* entity = new T(); 46 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 47 if( loc == NULL) 48 { 49 zeroloc.dist = 0; 50 zeroloc.part = 0; 51 zeroloc.pos = Vector(); 52 zeroloc.rot = Rotation(); 53 loc = &zeroloc; 54 } 55 entity->init (loc, owner); 56 if (entity->bFree) 57 { 58 track[loc->part].map_coords( loc, entity->get_placement()); 59 } 60 entity->post_spawn (); 61 return entity; 62 } 63 64 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL) 65 { 66 T* entity = new T(); 67 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 68 entity->init (plc, owner); 69 if (!entity->bFree) 70 { 71 printf("Can't spawn unfree entity with placement\n"); 72 entities->remove( (WorldEntity*)entity, LIST_FIND_FW); 73 return NULL; 74 } 75 entity->post_spawn (); 76 return entity; 77 } 78 39 79 #endif
Note: See TracChangeset
for help on using the changeset viewer.