Changeset 6412 for code/branches/pickup2/src/orxonox/worldentities/pawns
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc
r6405 r6412 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 //TODO: Remove. … … 111 112 XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); 112 113 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 113 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack , getWeaponPack, xmlelement, mode);114 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 114 115 } 115 116 … … 120 121 registerVariable(this->initialHealth_, VariableDirection::ToClient); 121 122 registerVariable(this->bReload_, VariableDirection::ToServer); 123 registerVariable(this->aimPosition_, Bidirectionality::ServerMaster, 0, true); 122 124 } 123 125 … … 167 169 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 168 170 { 169 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) )171 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 170 172 { 171 173 this->damage(damage, originator); … … 176 178 } 177 179 180 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 181 { 182 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 183 { 184 this->damage(damage, originator); 185 186 if ( this->getController() ) 187 this->getController()->hit(originator, contactpoint, damage); 188 189 // play hit effect 190 } 191 } 192 178 193 void Pawn::kill() 179 194 { … … 185 200 { 186 201 // play spawn effect 187 if ( this->spawnparticlesource_ != "")202 if (!this->spawnparticlesource_.empty()) 188 203 { 189 204 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); … … 264 279 } 265 280 266 void Pawn::fire(unsigned int firemode) 267 { 268 this->doFire(firemode); 269 } 270 271 void Pawn::doFire(uint8_t firemode) 272 { 273 if(GameMode::isMaster()) 274 { 275 if (this->weaponSystem_) 276 this->weaponSystem_->fire(firemode); 277 } 278 else 279 { 280 callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode); 281 if (this->weaponSystem_) 282 this->weaponSystem_->fire(firemode); 283 } 281 void Pawn::fired(unsigned int firemode) 282 { 283 if (this->weaponSystem_) 284 this->weaponSystem_->fire(firemode); 284 285 } 285 286 … … 343 344 } 344 345 346 void Pawn::addWeaponPackXML(WeaponPack * wPack) 347 { 348 if (this->weaponSystem_) 349 if (!this->weaponSystem_->addWeaponPack(wPack)) 350 wPack->destroy(); 351 } 352 345 353 WeaponPack * Pawn::getWeaponPack(unsigned int index) const 346 354 { -
code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h
r6405 r6412 76 76 { return this->lastHitOriginator_; } 77 77 78 virtual void damage(float damage, Pawn* originator = 0);79 78 virtual void hit(Pawn* originator, const Vector3& force, float damage); 79 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 80 80 virtual void kill(); 81 81 82 virtual void fire (unsigned int firemode);82 virtual void fired(unsigned int firemode); 83 83 virtual void reload(); 84 virtual void doFire(uint8_t firemode);85 84 virtual void postSpawn(); 86 85 … … 90 89 WeaponSet * getWeaponSet(unsigned int index) const; 91 90 void addWeaponPack(WeaponPack * wPack); 91 void addWeaponPackXML(WeaponPack * wPack); 92 92 WeaponPack * getWeaponPack(unsigned int index) const; 93 93 … … 119 119 virtual void startLocalHumanControl(); 120 120 121 void setAimPosition( Vector3 position ) 122 { this->aimPosition_ = position; } 123 Vector3 getAimPosition() 124 { return this->aimPosition_; } 125 121 126 protected: 122 127 virtual void setPlayer(PlayerInfo* player); … … 127 132 virtual void deatheffect(); 128 133 virtual void spawneffect(); 134 135 virtual void damage(float damage, Pawn* originator = 0); 129 136 130 137 bool bAlive_; … … 149 156 inline void setWeaponSystem(WeaponSystem* weaponsystem) 150 157 { this->weaponSystem_ = weaponsystem; } 158 159 Vector3 aimPosition_; 151 160 }; 152 161 } -
code/branches/pickup2/src/orxonox/worldentities/pawns/SpaceShip.cc
r5929 r6412 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/branches/pickup2/src/orxonox/worldentities/pawns/Spectator.cc
r5929 r6412 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/branches/pickup2/src/orxonox/worldentities/pawns/Spectator.h
r5781 r6412 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.