Changeset 8802 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jun 26, 2006, 4:46:25 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/npcs/generic_npc.cc
r8783 r8802 30 30 #include "generic_npc.h" 31 31 32 #include "animation/animation3d.h" 33 32 34 using namespace std; 33 35 … … 55 57 */ 56 58 GenericNPC::~GenericNPC () 57 {} 59 { 60 if( this->currentAnim != NULL) 61 delete this->currentAnim; 62 } 58 63 59 64 … … 138 143 float GenericNPC::walkTo(float x, float y, float z, float qu, float qx, float qy, float qz) 139 144 { 140 141 return true; 145 Vector destCoor = Vector(x, y, z); 146 Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu); 147 148 // check if this is the current goal 149 if( this->destCoor != destCoor && this->destDir != destDir) 150 { 151 this->destCoor = Vector(x, y, 0.0f); 152 this->destDir = Quaternion(Vector(qx, qy, qz), qu); 153 154 float time = 5.0f; 155 156 if( this->currentAnim != NULL) 157 delete this->currentAnim; 158 159 this->currentAnim = new Animation3D(this); 160 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f); 161 this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time); 162 } 163 164 // calculate the distance 165 Vector distance = this->getAbsCoor() - this->destCoor; 166 return distance.len(); 167 } 168 169 170 171 /** 172 * walk to a specific place with direction 173 * 174 * @param x: x coordinate to go to 175 * @param y: y coordinate to go to 176 * @param qu: angle to rotate 177 * @param qx: x coordinate of rotation vector 178 * @param qy: y coordinate of rotation vector 179 * @param qz: z coordinate of rotation vector 180 * 181 */ 182 float GenericNPC::walkTo(float x, float y, float qu, float qx, float qy, float qz) 183 { 184 return this->walkTo(x, y, 0.0f, qu, qx, qy, qz); 142 185 } 143 186 -
trunk/src/world_entities/npcs/generic_npc.h
r8796 r8802 22 22 23 23 class TiXmlElement; 24 class Animation3D; 24 25 25 26 … … 71 72 Vector destCoor; 72 73 Quaternion destDir; 74 75 Animation3D* currentAnim; 73 76 }; 74 77 -
trunk/src/world_entities/spawning_point.cc
r8068 r8802 24 24 #include "compiler.h" 25 25 26 #include <map> 26 #include "state.h" 27 #include "game_rules.h" 27 28 28 29 … … 59 60 { 60 61 this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); 62 63 this->teamId = -1; 61 64 } 62 65 … … 81 84 LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay) 82 85 .describe("sets the delay of the spawning point"); 86 87 /* load teamId */ 88 LoadParam(root, "teamId", this, SpawningPoint, setTeamId) 89 .describe("sets teamId"); 83 90 84 91 … … 101 108 void SpawningPoint::pushEntity(WorldEntity* entity, float delay) 102 109 { 103 this->queue[entity] = this->localTimer + delay; 110 QueueEntry qe; 111 qe.entity = entity; 112 qe.list = entity->getOMListNumber(); 113 qe.respawnTime = this->localTimer + delay; 114 115 queue.push_back( qe ); 104 116 } 105 117 … … 113 125 114 126 115 //BaseObject* spawningEntity = Factory::fabricate(this->classID); 116 // if( likely(this->world != NULL)) 117 // this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity)); 127 entity->setAbsCoor( this->getAbsCoor() ); 128 entity->setAbsDir( this->getAbsDir() ); 129 130 //TODO set camera (not smooth) 118 131 } 119 132 … … 129 142 this->localTimer += dt; 130 143 131 std:: map<WorldEntity*, float>::iterator it = this->queue.begin();132 for( ; it != this->queue.end(); it++)144 std::list<QueueEntry>::iterator it = this->queue.begin(); 145 for( ; it != this->queue.end(); ) 133 146 { 134 //135 if( it-> second<= this->localTimer)147 148 if( it->respawnTime <= this->localTimer) 136 149 { 137 150 //spawn the player 138 this->spawn(it->first); 151 this->spawn(it->entity); 152 153 it->entity->toList( it->list ); 154 155 if ( State::getGameRules() ) 156 { 157 (State::getGameRules())->registerSpawn( it->entity ); 158 } 159 160 std::list<QueueEntry>::iterator delit = it; 161 it++; 162 163 queue.erase( delit ); 164 165 continue; 139 166 } 167 168 it++; 140 169 } 141 170 -
trunk/src/world_entities/spawning_point.h
r8068 r8802 8 8 #define _SPAWNING_POINT 9 9 10 #include " world_entity.h"10 #include "playable.h" 11 11 12 #include < map>12 #include <list> 13 13 14 14 class World; 15 15 class TiXmlElement; 16 16 17 struct QueueEntry 18 { 19 float respawnTime; 20 WorldEntity * entity; 21 OM_LIST list; 22 }; 17 23 18 24 //!< used to indicate what type of objects are spawned by this spawning point … … 50 56 /** sets the spawning point mode @param mode: the mode */ 51 57 void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; } 58 59 inline int getTeamId(){ return this->teamId; } 60 inline void setTeamId( int teamId ){ this->teamId = teamId; } 52 61 53 62 void pushEntity(WorldEntity* entity, float delay = 0); … … 72 81 float localTimer; //!< the local timer 73 82 float seed; //!< the random seed of the position 83 int teamId; //!< only spawn players of this team 74 84 ClassID classid; //!< the classid of the entity to spawn 75 85 SpawningPointMode mode; //!< the mode of the spawning point 76 std:: map<WorldEntity*, float>queue; //!< queue of waiting WorldEntities to be spawned86 std::list<QueueEntry> queue; //!< queue of waiting WorldEntities to be spawned 77 87 bool bSpawning; //!< flag to indicate if this spawning point is active or not 78 88 };
Note: See TracChangeset
for help on using the changeset viewer.