Changeset 10023 for code/branches/modularships/src/orxonox/items
- Timestamp:
- Apr 9, 2014, 9:50:45 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox/items
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/items/ShipPart.cc
r10019 r10023 37 37 #include "Item.h" 38 38 #include "worldentities/pawns/Pawn.h" 39 #include "worldentities/pawns/ModularSpaceShip.h" 39 40 #include "gametypes/Gametype.h" 40 41 #include "worldentities/StaticEntity.h" … … 56 57 } 57 58 59 void ShipPart::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 { 61 SUPER(ShipPart, XMLPort, xmlelement, mode); 62 63 XMLPortParam(ShipPart, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 64 XMLPortParam(ShipPart, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 65 XMLPortParam(ShipPart, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); 66 67 XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5); 68 69 /* 70 XMLPortParam(ShipPart, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0); 71 XMLPortParam(ShipPart, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0); 72 XMLPortParam(ShipPart, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100); 73 XMLPortParam(ShipPart, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0); 74 75 XMLPortParam(ShipPart, "sShipPartparticlesource", setSShipPartParticleSource, getSShipPartParticleSource, xmlelement, mode); 76 XMLPortParam(ShipPart, "sShipPartparticleduration", setSShipPartParticleDuration, getSShipPartParticleDuration, xmlelement, mode).defaultValues(3.0f); 77 XMLPortParam(ShipPart, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 78 79 XMLPortParam(ShipPart, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0); 80 XMLPortParam(ShipPart, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); 81 82 XMLPortParam(ShipPart, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode); 83 84 XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode ); 85 */ 86 } 87 88 void ShipPart::death() 89 { 90 this->parent_->removeShipPart(this); 91 } 58 92 59 93 /** … … 112 146 { 113 147 this->damageAbsorption_ = value; 148 } 149 150 void ShipPart::setParent(ModularSpaceShip* ship) 151 { 152 this->parent_ = ship; 114 153 } 115 154 … … 152 191 } 153 192 } 193 if (this->health_ < 0) 194 this->death(); 195 orxout() << "Health of ShipPart " << this->getName() << " is " << this->getHealth() << endl; 154 196 } 155 197 -
code/branches/modularships/src/orxonox/items/ShipPart.h
r10019 r10023 46 46 virtual ~ShipPart(); 47 47 48 //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 50 virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator); 51 52 virtual void death(); 51 53 52 54 //virtual void attachTo(Pawn* newParent); … … 63 65 { return this->damageAbsorption_; } 64 66 67 void setParent(ModularSpaceShip* ship); 68 inline ModularSpaceShip* getParent() 69 { return this->parent_; } 70 65 71 virtual void setHealth(float health); 66 72 inline void addHealth(float health) … … 71 77 { return this->health_; } 72 78 79 inline void setMaxHealth(float maxhealth) 80 { this->maxHealth_ = maxhealth; this->setHealth(this->health_); } 81 inline float getMaxHealth() const 82 { return this->maxHealth_; } 83 84 inline void setInitialHealth(float initialhealth) 85 { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); } 86 inline float getInitialHealth() const 87 { return this->initialHealth_; } 88 73 89 74 90 // FIXME: (noep) Why doesn't this work? Works fine in Engine.h … … 76 92 77 93 protected: 78 Pawn* parent_;94 ModularSpaceShip* parent_; 79 95 unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on. 80 96 81 97 float damageAbsorption_; 82 98 float health_; 99 float maxHealth_; 100 float initialHealth_; 83 101 84 102 private:
Note: See TracChangeset
for help on using the changeset viewer.