Changeset 10071
- Timestamp:
- May 22, 2014, 2:18:47 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc
r10058 r10071 143 143 switch (this->targetParam_) { 144 144 case null: 145 if (!this->parent_->getParent()->getShipPartByName(targetName_)) 146 return; 145 147 this->parent_->getParent()->getShipPartByName(targetName_)->setEventExecution(false); 146 148 this->parent_->getParent()->killShipPart(targetName_); -
code/branches/modularships/src/orxonox/items/ShipPart.cc
r10068 r10071 55 55 this->setAlive(true); 56 56 this->setEventExecution(true); 57 this->healthMem_ = 100; 57 58 } 58 59 … … 102 103 // Remove this ShipPart from the parent. 103 104 this->parent_->removeShipPart(this); 105 delete this; 104 106 } 105 107 … … 201 203 { 202 204 this->health_ = health; 205 } 206 207 void ShipPart::setAlive(bool var) 208 { 209 this->alive_ = var; 210 orxout() << "ShipPart " << this->getName() << " alive_: " << this->alive_ << endl; 203 211 } 204 212 … … 236 244 237 245 // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented. 238 if (this->health_ < 0.2 * this->maxHealth_) 239 { 246 if ((this->health_ < 0.2 * this->maxHealth_) && (this->healthMem_ == 40)) 247 { 248 this->healthMem_ = 20; 240 249 ChatManager::message("ShipPart " + this->getName() + " remaining health is 20%!"); 241 250 return; 242 251 } 243 if (this->health_ < 0.4 * this->maxHealth_) 244 { 252 if ((this->health_ < 0.4 * this->maxHealth_) && (this->healthMem_ == 60)) 253 { 254 this->healthMem_ = 40; 245 255 ChatManager::message("ShipPart " + this->getName() + " remaining health is 40%!"); 246 256 return; 247 257 } 248 if (this->health_ < 0.6 * this->maxHealth_) 249 { 258 if ((this->health_ < 0.6 * this->maxHealth_) && (this->healthMem_ == 80)) 259 { 260 this->healthMem_ = 60; 250 261 ChatManager::message("ShipPart " + this->getName() + " remaining health is 60%!"); 251 262 return; 252 263 } 253 if (this->health_ < 0.8 * this->maxHealth_) 254 { 264 if ((this->health_ < 0.8 * this->maxHealth_) && (this->healthMem_ == 100)) 265 { 266 this->healthMem_ = 80; 255 267 ChatManager::message("ShipPart " + this->getName() + " remaining health is 80%!"); 256 268 return; -
code/branches/modularships/src/orxonox/items/ShipPart.h
r10067 r10071 72 72 { return this->parent_; } 73 73 74 inline void setAlive(bool var) 75 { this->alive_ = var; } 74 void setAlive(bool var); 76 75 inline bool isAlive() 77 76 { return this->alive_; } … … 125 124 bool eventExecution_; 126 125 126 float healthMem_; 127 127 128 Vector3 explosionPosition_; 128 129 -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10067 r10071 50 50 namespace orxonox 51 51 { 52 SetConsoleCommand("ModularSpaceShip", "killshippart", &ModularSpaceShip::killShipPart );52 SetConsoleCommand("ModularSpaceShip", "killshippart", &ModularSpaceShip::killShipPartStatic); 53 53 54 54 RegisterClass(ModularSpaceShip); … … 174 174 /** 175 175 @brief 176 STATIC: Needed for consolecommand. Kills the ShipPart with the given name. Used from the console-command "ModularSpaceShip killshippart [string]". 177 @param name 178 The name of the part to be killed. 179 */ 180 void ModularSpaceShip::killShipPartStatic(std::string name) 181 { 182 for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it) 183 { 184 if (it->second->getName() == name) 185 { 186 it->second->setAlive(false); 187 return; 188 } 189 } 190 orxout(internal_warning) << "Could not apply damage to ShipPart \"" << name << "\". Part not found." << endl; 191 } 192 193 /** 194 @brief 176 195 Kills the ShipPart with the given name. Used from the console-command "ModularSpaceShip killshippart [string]". 177 196 @param name … … 180 199 void ModularSpaceShip::killShipPart(std::string name) 181 200 { 182 for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_ s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it)201 for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_.begin(); it != ModularSpaceShip::partMap_.end(); ++it) 183 202 { 184 203 if (it->second->getName() == name) 185 204 { 186 it->second-> death();205 it->second->setAlive(false); 187 206 return; 188 207 } -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
r10058 r10071 113 113 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 114 114 115 static void killShipPart(std::string name); 115 static void killShipPartStatic(std::string name); 116 void killShipPart(std::string name); 116 117 117 118 void addShipPart(ShipPart* part);
Note: See TracChangeset
for help on using the changeset viewer.