Changeset 6417 for code/trunk/src/orxonox/worldentities/pawns
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 6 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 { -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r5781 r6417 75 75 { return this->lastHitOriginator_; } 76 76 77 virtual void damage(float damage, Pawn* originator = 0);78 77 virtual void hit(Pawn* originator, const Vector3& force, float damage); 78 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 79 79 virtual void kill(); 80 80 81 virtual void fire (unsigned int firemode);81 virtual void fired(unsigned int firemode); 82 82 virtual void reload(); 83 virtual void doFire(uint8_t firemode);84 83 virtual void postSpawn(); 85 84 … … 89 88 WeaponSet * getWeaponSet(unsigned int index) const; 90 89 void addWeaponPack(WeaponPack * wPack); 90 void addWeaponPackXML(WeaponPack * wPack); 91 91 WeaponPack * getWeaponPack(unsigned int index) const; 92 92 … … 117 117 virtual void startLocalHumanControl(); 118 118 119 void setAimPosition( Vector3 position ) 120 { this->aimPosition_ = position; } 121 Vector3 getAimPosition() 122 { return this->aimPosition_; } 123 119 124 protected: 120 125 virtual void setPlayer(PlayerInfo* player); … … 125 130 virtual void deatheffect(); 126 131 virtual void spawneffect(); 132 133 virtual void damage(float damage, Pawn* originator = 0); 127 134 128 135 bool bAlive_; … … 146 153 inline void setWeaponSystem(WeaponSystem* weaponsystem) 147 154 { this->weaponSystem_ = weaponsystem; } 155 156 Vector3 aimPosition_; 148 157 }; 149 158 } -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r5929 r6417 187 187 void SpaceShip::loadEngineTemplate() 188 188 { 189 if ( this->enginetemplate_ != "")189 if (!this->enginetemplate_.empty()) 190 190 { 191 191 Template* temp = Template::getTemplate(this->enginetemplate_); -
code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
r5929 r6417 189 189 } 190 190 191 void Spectator::fire (unsigned int firemode)191 void Spectator::fired(unsigned int firemode) 192 192 { 193 193 if (this->getPlayer()) -
code/trunk/src/orxonox/worldentities/pawns/Spectator.h
r5781 r6417 55 55 virtual void rotateRoll(const Vector2& value); 56 56 57 virtual void fire (unsigned int firemode);57 virtual void fired(unsigned int firemode); 58 58 virtual void greet(); 59 59
Note: See TracChangeset
for help on using the changeset viewer.