- Timestamp:
- May 31, 2006, 4:33:31 PM (18 years ago)
- Location:
- branches/network/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/multi_player_world.cc
r7954 r8036 86 86 87 87 /** 88 * kicks the CDEngine to detect the collisions between the object groups in the world 89 */ 90 void MultiPlayerWorld::collide() 91 { 92 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 93 this->dataTank->objectManager->getObjectList(OM_PLAYERS)); 94 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 95 this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ)); 96 97 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 98 this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); 99 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), 100 this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ)); 101 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 102 this->dataTank->objectManager->getObjectList(OM_GROUP_01)); 103 104 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 105 this->dataTank->objectManager->getObjectList(OM_COMMON)); 106 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), 107 this->dataTank->objectManager->getObjectList(OM_COMMON)); 108 109 } 110 111 112 /** 88 113 * some debug ouptut - shell command 89 114 */ -
branches/network/src/story_entities/multi_player_world.h
r6512 r8036 31 31 protected: 32 32 virtual void synchronize(); 33 virtual void collide(); 33 34 }; 34 35 -
branches/network/src/util/object_manager.h
r7836 r8036 20 20 OM_BACKGROUND, 21 21 OM_COMMON, 22 23 OM_PLAYERS, 24 OM_PLAYERS_PROJ, 22 25 23 26 OM_GROUP_00, -
branches/network/src/world_entities/spawning_point.cc
r7357 r8036 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 -
branches/network/src/world_entities/spawning_point.h
r7370 r8036 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.