Changeset 3053 for code/trunk/src/orxonox/objects/worldentities/pawns
- Timestamp:
- May 25, 2009, 4:19:14 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/weapons (added) merged: 2898,2901,2912,2914-2915,2918-2924,2969,2979,2981,2983,2987,3012
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
r3038 r3053 39 39 #include "objects/worldentities/ParticleSpawner.h" 40 40 #include "objects/worldentities/ExplosionChunk.h" 41 #include "objects/weaponsystem/WeaponSystem.h" 42 #include "objects/weaponsystem/WeaponSlot.h" 43 #include "objects/weaponsystem/WeaponPack.h" 44 #include "objects/weaponsystem/WeaponSet.h" 41 45 42 46 namespace orxonox … … 52 56 this->fire_ = 0x0; 53 57 this->firehack_ = 0x0; 58 this->bReload_ = false; 54 59 55 60 this->health_ = 0; … … 66 71 { 67 72 this->weaponSystem_ = new WeaponSystem(this); 68 this->weaponSystem_->setPa rentPawn(this);73 this->weaponSystem_->setPawn(this); 69 74 } 70 75 else … … 100 105 XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 101 106 102 XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode);103 XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode);104 XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);107 XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); 108 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 109 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode); 105 110 } 106 111 … … 111 116 registerVariable(this->initialHealth_, variableDirection::toclient); 112 117 registerVariable(this->fire_, variableDirection::toserver); 118 registerVariable(this->bReload_, variableDirection::toserver); 113 119 } 114 120 … … 117 123 SUPER(Pawn, tick, dt); 118 124 119 if (this->weaponSystem_) 120 { 121 if (this->fire_ & WeaponMode::fire) 122 this->weaponSystem_->fire(WeaponMode::fire); 123 if (this->fire_ & WeaponMode::altFire) 124 this->weaponSystem_->fire(WeaponMode::altFire); 125 if (this->fire_ & WeaponMode::altFire2) 126 this->weaponSystem_->fire(WeaponMode::altFire2); 127 } 125 if (this->weaponSystem_ && GameMode::isMaster()) 126 { 127 for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++) 128 if (this->fire_ & WeaponSystem::getFiremodeMask(firemode)) 129 this->weaponSystem_->fire(firemode); 130 131 if (this->bReload_) 132 this->weaponSystem_->reload(); 133 } 134 128 135 this->fire_ = this->firehack_; 129 136 this->firehack_ = 0x0; 137 this->bReload_ = false; 130 138 131 139 if (this->health_ <= 0) … … 251 259 } 252 260 253 void Pawn::fire(WeaponMode::Enum fireMode) 254 { 255 this->firehack_ |= fireMode; 261 void Pawn::fire(unsigned int firemode) 262 { 263 this->firehack_ |= WeaponSystem::getFiremodeMask(firemode); 264 } 265 266 void Pawn::reload() 267 { 268 this->bReload_ = true; 256 269 } 257 270 … … 274 287 * --> e.g. Pickup-Items 275 288 */ 276 void Pawn:: setWeaponSlot(WeaponSlot * wSlot)289 void Pawn::addWeaponSlot(WeaponSlot * wSlot) 277 290 { 278 291 this->attach(wSlot); 279 292 if (this->weaponSystem_) 280 this->weaponSystem_->a ttachWeaponSlot(wSlot);293 this->weaponSystem_->addWeaponSlot(wSlot); 281 294 } 282 295 … … 284 297 { 285 298 if (this->weaponSystem_) 286 return this->weaponSystem_->getWeaponSlot Pointer(index);299 return this->weaponSystem_->getWeaponSlot(index); 287 300 else 288 301 return 0; 289 302 } 290 303 291 void Pawn::setWeaponPack(WeaponPack * wPack) 292 { 293 if (this->weaponSystem_) 294 { 295 wPack->setParentWeaponSystem(this->weaponSystem_); 296 wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_); 297 this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() ); 298 wPack->attachNeededMunitionToAllWeapons(); 299 } 300 } 301 302 WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const 303 { 304 if (this->weaponSystem_) 305 return this->weaponSystem_->getWeaponPackPointer(firemode); 304 void Pawn::addWeaponSet(WeaponSet * wSet) 305 { 306 if (this->weaponSystem_) 307 this->weaponSystem_->addWeaponSet(wSet); 308 } 309 310 WeaponSet * Pawn::getWeaponSet(unsigned int index) const 311 { 312 if (this->weaponSystem_) 313 return this->weaponSystem_->getWeaponSet(index); 306 314 else 307 315 return 0; 308 316 } 309 317 310 void Pawn:: setWeaponSet(WeaponSet * wSet)311 { 312 if (this->weaponSystem_) 313 this->weaponSystem_->a ttachWeaponSet(wSet);314 } 315 316 Weapon Set * Pawn::getWeaponSet(unsigned int index) const317 { 318 if (this->weaponSystem_) 319 return this->weaponSystem_->getWeapon SetPointer(index);318 void Pawn::addWeaponPack(WeaponPack * wPack) 319 { 320 if (this->weaponSystem_) 321 this->weaponSystem_->addWeaponPack(wPack); 322 } 323 324 WeaponPack * Pawn::getWeaponPack(unsigned int index) const 325 { 326 if (this->weaponSystem_) 327 return this->weaponSystem_->getWeaponPack(index); 320 328 else 321 329 return 0; -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
r3038 r3053 34 34 #include "objects/worldentities/ControllableEntity.h" 35 35 #include "objects/RadarViewable.h" 36 #include "objects/weaponSystem/WeaponSystem.h"37 36 38 37 namespace orxonox … … 40 39 class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable 41 40 { 41 friend class WeaponSystem; 42 42 43 public: 43 44 Pawn(BaseObject* creator); … … 76 77 virtual void kill(); 77 78 78 virtual void fire(WeaponMode::Enum fireMode); 79 virtual void fire(unsigned int firemode); 80 virtual void reload(); 79 81 virtual void postSpawn(); 80 82 81 void setWeaponSlot(WeaponSlot * wSlot);83 void addWeaponSlot(WeaponSlot * wSlot); 82 84 WeaponSlot * getWeaponSlot(unsigned int index) const; 83 void setWeaponPack(WeaponPack * wPack); 84 WeaponPack * getWeaponPack(unsigned int firemode) const; 85 void setWeaponSet(WeaponSet * wSet); 85 void addWeaponSet(WeaponSet * wSet); 86 86 WeaponSet * getWeaponSet(unsigned int index) const; 87 void addWeaponPack(WeaponPack * wPack); 88 WeaponPack * getWeaponPack(unsigned int index) const; 87 89 88 90 inline const WorldEntity* getWorldEntity() const … … 130 132 unsigned int fire_; 131 133 unsigned int firehack_; 134 bool bReload_; 132 135 133 136 std::string spawnparticlesource_; 134 137 float spawnparticleduration_; 135 138 unsigned int numexplosionchunks_; 139 140 private: 141 inline void setWeaponSystem(WeaponSystem* weaponsystem) 142 { this->weaponSystem_ = weaponsystem; } 136 143 }; 137 144 -
code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc
r3039 r3053 196 196 } 197 197 198 void Spectator::fire( WeaponMode::Enum fireMode)198 void Spectator::fire(unsigned int firemode) 199 199 { 200 200 if (this->getPlayer()) -
code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.h
r3038 r3053 54 54 virtual void rotateRoll(const Vector2& value); 55 55 56 virtual void fire( WeaponMode::Enum fireMode);56 virtual void fire(unsigned int firemode); 57 57 virtual void greet(); 58 58
Note: See TracChangeset
for help on using the changeset viewer.