Changeset 6417 for code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r5929 r6417 38 38 #include "PawnManager.h" 39 39 #include "infos/PlayerInfo.h" 40 #include "controllers/Controller.h" 40 41 #include "gametypes/Gametype.h" 41 42 #include "graphics/ParticleSpawner.h" … … 52 53 CreateFactory(Pawn); 53 54 54 registerMemberNetworkFunction( Pawn, doFire );55 56 55 Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator) 57 56 { … … 69 68 70 69 this->spawnparticleduration_ = 3.0f; 70 71 this->aimPosition_ = Vector3::ZERO; 71 72 72 73 this->getPickups().setOwner(this); … … 110 111 XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); 111 112 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 112 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack , getWeaponPack, xmlelement, mode);113 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 113 114 } 114 115 … … 119 120 registerVariable(this->initialHealth_, VariableDirection::ToClient); 120 121 registerVariable(this->bReload_, VariableDirection::ToServer); 122 registerVariable(this->aimPosition_, Bidirectionality::ServerMaster, 0, true); 121 123 } 122 124 … … 166 168 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 167 169 { 168 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) )170 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 169 171 { 170 172 this->damage(damage, originator); … … 175 177 } 176 178 179 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 180 { 181 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 182 { 183 this->damage(damage, originator); 184 185 if ( this->getController() ) 186 this->getController()->hit(originator, contactpoint, damage); 187 188 // play hit effect 189 } 190 } 191 177 192 void Pawn::kill() 178 193 { … … 184 199 { 185 200 // play spawn effect 186 if ( this->spawnparticlesource_ != "")201 if (!this->spawnparticlesource_.empty()) 187 202 { 188 203 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); … … 263 278 } 264 279 265 void Pawn::fire(unsigned int firemode) 266 { 267 this->doFire(firemode); 268 } 269 270 void Pawn::doFire(uint8_t firemode) 271 { 272 if(GameMode::isMaster()) 273 { 274 if (this->weaponSystem_) 275 this->weaponSystem_->fire(firemode); 276 } 277 else 278 { 279 callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode); 280 if (this->weaponSystem_) 281 this->weaponSystem_->fire(firemode); 282 } 280 void Pawn::fired(unsigned int firemode) 281 { 282 if (this->weaponSystem_) 283 this->weaponSystem_->fire(firemode); 283 284 } 284 285 … … 341 342 } 342 343 344 void Pawn::addWeaponPackXML(WeaponPack * wPack) 345 { 346 if (this->weaponSystem_) 347 if (!this->weaponSystem_->addWeaponPack(wPack)) 348 wPack->destroy(); 349 } 350 343 351 WeaponPack * Pawn::getWeaponPack(unsigned int index) const 344 352 {
Note: See TracChangeset
for help on using the changeset viewer.