Changeset 8068 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jun 1, 2006, 2:28:16 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/WorldEntities.am
r7785 r8068 39 39 world_entities/space_ships/turbine_hover.cc \ 40 40 world_entities/creatures/md2_creature.cc \ 41 world_entities/spectator.cc \ 41 42 \ 42 43 \ … … 90 91 space_ships/turbine_hover.h \ 91 92 creatures/md2_creature.h \ 93 spectator.h \ 92 94 \ 93 95 environments/water.h \ -
trunk/src/world_entities/spawning_point.cc
r7357 r8068 20 20 #include "util/loading/factory.h" 21 21 22 #include "world_entity.h" 23 22 24 #include "compiler.h" 25 26 #include <map> 23 27 24 28 … … 26 30 * constructor 27 31 */ 28 SpawningPoint::SpawningPoint (ClassID class ID, const Vector& position)32 SpawningPoint::SpawningPoint (ClassID classid, const Vector& position) 29 33 { 30 34 this->setAbsCoor(position); 31 this->class ID = classID;35 this->classid = classid; 32 36 this->mode = SPT_ALL_AT_ONCE; 33 37 this->delay = 0; … … 40 44 * standard constructor 41 45 */ 42 SpawningPoint::SpawningPoint (const Vector& position, ClassID class ID, SpawningPointMode mode, float delay)46 SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay) 43 47 { 44 48 this->setAbsCoor(position); 45 this->class ID = classID;49 this->classid = classid; 46 50 this->mode = mode; 47 51 this->delay = delay; … … 90 94 91 95 96 97 /** 98 * pushes a world entity to the spawning queue 99 * @param entity WorldEntity to be added 100 */ 101 void SpawningPoint::pushEntity(WorldEntity* entity, float delay) 102 { 103 this->queue[entity] = this->localTimer + delay; 104 } 105 106 92 107 /** 93 108 * spawn the entity 94 109 */ 95 void SpawningPoint::spawn( )110 void SpawningPoint::spawn(WorldEntity* entity) 96 111 { 97 PRINTF( 5)("Spangingpoint creates a new Entity (id: %i, delay: %f, mode: %f)\n", this->classID,98 this->delay, this->mode); 112 PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName()); 113 99 114 100 115 //BaseObject* spawningEntity = Factory::fabricate(this->classID); 101 102 // if( likely(this->world != NULL)) 103 // this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity)); 116 // if( likely(this->world != NULL)) 117 // this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity)); 104 118 } 105 119 … … 114 128 { 115 129 this->localTimer += dt; 116 if( this->localTimer > this->delay) 130 131 std::map<WorldEntity*, float>::iterator it = this->queue.begin(); 132 for( ; it != this->queue.end(); it++) 117 133 { 118 this->spawn(); 119 this->localTimer = 0.0f; 134 // 135 if( it->second <= this->localTimer) 136 { 137 //spawn the player 138 this->spawn(it->first); 139 } 120 140 } 141 121 142 } 122 143 -
trunk/src/world_entities/spawning_point.h
r7370 r8068 9 9 10 10 #include "world_entity.h" 11 12 #include <map> 11 13 12 14 class World; … … 43 45 44 46 /** sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */ 45 void SpawningPoint::setSpawningEntity(ClassID class ID) { this->classID = classID; }47 void SpawningPoint::setSpawningEntity(ClassID classid) { this->classid = classid; } 46 48 /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */ 47 49 void SpawningPoint::setSpawningDelay(float delay) { this->delay = delay; } … … 49 51 void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; } 50 52 53 void pushEntity(WorldEntity* entity, float delay = 0); 51 54 52 55 /** activates the spawning point */ 53 void activate() { this->bSpawning = true; }56 inline void activate() { this->bSpawning = true; } 54 57 /** deactivates the spawning point */ 55 void deactivate() { this->bSpawning = false; } 58 inline void deactivate() { this->bSpawning = false; } 59 inline bool isActive() const { return this->bSpawning; } 56 60 57 61 … … 61 65 62 66 private: 63 void spawn( );67 void spawn(WorldEntity* entity); 64 68 65 69 66 70 private: 67 float delay; //!< the timer that counts down until the next spawn68 float localTimer; //!< the local timer69 float seed; //!< the random seed of the position70 ClassID classID; //!< the classid of the entity to spawn71 SpawningPointMode mode; //!< the mode of the spawning point72 ObjectManager::EntityListqueue; //!< queue of waiting WorldEntities to be spawned73 bool bSpawning; //!< flag to indicate if this spawning point is active or not71 float delay; //!< the timer that counts down until the next spawn 72 float localTimer; //!< the local timer 73 float seed; //!< the random seed of the position 74 ClassID classid; //!< the classid of the entity to spawn 75 SpawningPointMode mode; //!< the mode of the spawning point 76 std::map<WorldEntity*, float> queue; //!< queue of waiting WorldEntities to be spawned 77 bool bSpawning; //!< flag to indicate if this spawning point is active or not 74 78 }; 75 79
Note: See TracChangeset
for help on using the changeset viewer.