Changeset 3236 in orxonox.OLD for orxonox/trunk/src/world.h
- Timestamp:
- Dec 20, 2004, 1:39:51 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world.h
r3226 r3236 85 85 }; 86 86 87 /**88 \brief spawn a new WorldEntity at a Location89 \param loc: the Location where the Entity should be spawned90 \param owner: a pointer to the parent of the Entity91 \return a pointer to the new WorldEntity or NULL if there was an error92 93 You can use this function to spawn any derivation of WorldEntity you want, just specify the desired94 class within the template specification brackets. Do not attempt to spawn any classes that have NOT been95 derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn()96 works with both free and bound WorldEntities.97 */98 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL)99 {100 Location zeroloc;101 T* entity = new T();102 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);103 if( loc == NULL)104 {105 zeroloc.dist = 0;106 zeroloc.part = 0;107 zeroloc.pos = Vector();108 zeroloc.rot = Quaternion();109 loc = &zeroloc;110 }111 entity->init (loc, owner);112 if (entity->bFree)113 {114 track[loc->part].map_coords( loc, entity->get_placement());115 }116 entity->post_spawn ();117 return entity;118 }119 120 /**121 \brief spawn a new WorldEntity at a Placement122 \param lplc: the placement where the Entity should be spawned123 \param owner: a pointer to the parent of the Entity124 \return a pointer to the new WorldEntity or NULL if there was an error125 126 You can use this function to spawn any FREE derivation of WorldEntity you want, just specify the desired127 class within the template specification brackets. Do not attempt to spawn any classes that have NOT been128 derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn()129 works with free WorldEntities only, you will provoke an error message if you try to spawn a bound Entity with130 a Placement.131 */132 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL)133 {134 T* entity = new T();135 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT);136 entity->init (plc, owner);137 if (!entity->bFree)138 {139 printf("Can't spawn unfree entity with placement\n");140 entities->remove( (WorldEntity*)entity, LIST_FIND_FW);141 return NULL;142 }143 entity->post_spawn ();144 return entity;145 }146 147 87 #endif /* _WORLD_H */
Note: See TracChangeset
for help on using the changeset viewer.