Changeset 10058 for code/branches/modularships/src/orxonox
- Timestamp:
- May 15, 2014, 3:53:11 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/controllers/NewHumanController.cc
r9939 r10058 220 220 if (!controlPaused_ ) 221 221 { 222 if (this->getControllableEntity() && ( this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))222 if (this->getControllableEntity() && ((this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || (this->getControllableEntity()->isExactlyA(ClassByString("ModularSpaceShip")))) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket")))) 223 223 this->showOverlays(); 224 224 else if (this->getControllableEntity() && this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer"))) … … 498 498 this->controlMode_ = 0; 499 499 this->centerCursor(); 500 if (this->getControllableEntity() && ( this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))500 if (this->getControllableEntity() && ((this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || (this->getControllableEntity()->isExactlyA(ClassByString("ModularSpaceShip")))) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket")))) 501 501 { 502 502 this->showOverlays_ = true; -
code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc
r10055 r10058 83 83 void PartDestructionEvent::execute() 84 84 { 85 orxout() << "Executing PartDestructionEvent " << this->getName() << endl;86 87 85 // Do not execute if this event is invalid 88 86 if(!isValid()) … … 109 107 this->parent_->getParent()->setBoostPowerRate(operate(this->parent_->getParent()->getBoostPowerRate())); 110 108 break; 109 case rotationthrust: 110 this->parent_->getParent()->setRotationThrust(operate(this->parent_->getParent()->getRotationThrust())); 111 break; 111 112 default: 112 113 break; … … 120 121 switch (this->targetParam_) { 121 122 case null: 122 for(unsigned int i = 0; i < this->parent_->getParent()->getEngineList().size(); i++) // FIXME: (noep) segfault on .size() 123 { 124 if(this->parent_->getParent()->getEngine(i)->getName() == this->targetName_) 125 { 126 orxout() << "engine found" << endl; 127 this->parent_->getParent()->removeEngine(this->parent_->getParent()->getEngine(i)); 128 break; 129 } 130 } 123 this->parent_->getParent()->removeEngine(this->parent_->getParent()->getEngineByName(targetName_)); 131 124 break; 132 125 case boostfactor: 133 for(unsigned int i = 0; i < this->parent_->getParent()->getEngineList().size(); i++) 134 { 135 if(this->parent_->getParent()->getEngine(i)->getName() == this->targetName_) 136 this->parent_->getParent()->getEngine(i)->setBoostFactor(operate(this->parent_->getParent()->getEngine(i)->getBoostFactor())); 137 break; 138 } 126 this->parent_->getParent()->getEngineByName(targetName_)->setBoostFactor(operate(this->parent_->getParent()->getEngineByName(targetName_)->getBoostFactor())); 127 break; 128 case speedfront: 129 this->parent_->getParent()->getEngineByName(targetName_)->setMaxSpeedFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getMaxSpeedFront())); 130 break; 131 case accelerationfront: 132 this->parent_->getParent()->getEngineByName(targetName_)->setAccelerationFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getAccelerationFront())); 133 break; 134 default: 135 break; 136 } 137 this->setValid(false); 138 return; 139 } 140 141 if (this->targetType_ == "part") 142 { 143 switch (this->targetParam_) { 144 case null: 145 this->parent_->getParent()->getShipPartByName(targetName_)->setEventExecution(false); 146 this->parent_->getParent()->killShipPart(targetName_); 139 147 break; 140 148 default: … … 159 167 void PartDestructionEvent::setTargetType(std::string type) 160 168 { 161 if ((type == "ship") || (type == "engine") || (type == "weapon") )169 if ((type == "ship") || (type == "engine") || (type == "weapon") || (type == "part")) 162 170 { 163 171 this->targetType_ = type; … … 166 174 167 175 // Error, if invalid target-type was entered. 168 orxout(internal_warning) << "\"" << type << "\" is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon " << endl;176 orxout(internal_warning) << "\"" << type << "\" is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon part" << endl; 169 177 this->setValid(false); 170 178 return; … … 229 237 // weapon: 230 238 231 // ship: shieldhealth (maxshieldhealth shieldabsorption shieldrechargerate) boostpower boostpowerrate 239 // ship: shieldhealth (maxshieldhealth shieldabsorption shieldrechargerate) boostpower boostpowerrate rotationthrust 232 240 if (this->targetType_ == "ship") 233 241 { … … 247 255 return; 248 256 } 249 250 orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"ship\". Valid types are: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate boostpower boostpowerrate" << endl; 257 if (param == "rotationthrust") 258 { 259 this->targetParam_ = rotationthrust; 260 return; 261 } 262 263 orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"ship\". Valid types are: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate boostpower boostpowerrate rotationthrust" << endl; 264 return; 265 } 266 267 if (this->targetType_ == "part") 268 { 269 if (param == "NULL") 270 { 271 this->targetParam_ = null; 272 return; 273 } 274 275 orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"part\". Valid types are: NULL (set operation to \"destroy\")" << endl; 251 276 return; 252 277 } … … 265 290 { 266 291 // * + - destroy 267 if ((operation == "*") || (operation == "+") || (operation == "-") || (operation == " destroy"))292 if ((operation == "*") || (operation == "+") || (operation == "-") || (operation == "set") || (operation == "destroy")) 268 293 { 269 294 this->operation_ = operation; … … 271 296 } 272 297 this->operation_ = "NULL"; 273 orxout(internal_warning) << "\"" << operation << "\" is not a valid operation for a PartDestructionEvent. Valid operations are: * + - destroy" << endl;298 orxout(internal_warning) << "\"" << operation << "\" is not a valid operation for a PartDestructionEvent. Valid operations are: * + - set destroy" << endl; 274 299 } 275 300 … … 292 317 The value which should be modified 293 318 @return 294 Returns the product / sum / difference of input and configured value, or 0 if the operation is "destroy" 319 Returns the product / sum / difference of input and configured value, 320 the configured value if the operation is "set", 321 or 0 if the operation is "destroy" 295 322 */ 296 323 float PartDestructionEvent::operate(float input) … … 302 329 if (this->operation_ == "-") 303 330 return input - this->value_; 331 if (this->operation_ == "set") 332 return this->value_; 304 333 if (this->operation_ == "destroy") 305 334 { -
code/branches/modularships/src/orxonox/items/PartDestructionEvent.h
r10055 r10058 90 90 boostpower, // Amount of available boost 91 91 boostpowerrate, // Recharge-rate of boost 92 rotationthrust, 92 93 boostfactor, 93 94 speedfront, -
code/branches/modularships/src/orxonox/items/ShipPart.cc
r10055 r10058 52 52 RegisterObject(ShipPart); 53 53 this->setAlive(true); 54 this->setEventExecution(true); 54 55 } 55 56 … … 103 104 this->setAlive(false); 104 105 105 // Execute all destruction events 106 for (unsigned int i = 0; i < this->eventList_.size(); i++) 107 { 108 orxout() << "executing" << endl; 109 this->getDestructionEvent(i)->execute(); 106 if(eventExecution_) 107 { 108 // Execute all destruction events 109 for (unsigned int i = 0; i < this->eventList_.size(); i++) 110 { 111 this->getDestructionEvent(i)->execute(); 112 } 110 113 } 111 114 -
code/branches/modularships/src/orxonox/items/ShipPart.h
r10055 r10058 78 78 { return this->alive_; } 79 79 80 inline void setEventExecution(bool var) 81 { this->eventExecution_ = var; } 82 inline bool isEventExecution() 83 { return this->eventExecution_; } 84 80 85 virtual void setHealth(float health); 81 86 inline void addHealth(float health) … … 114 119 115 120 bool alive_; 121 bool eventExecution_; 116 122 117 123 -
code/branches/modularships/src/orxonox/worldentities/StaticEntity.cc
r9667 r10058 34 34 #include "util/OrxAssert.h" 35 35 #include "core/CoreIncludes.h" 36 #include "worldentities/BigExplosion.h" 36 37 37 38 namespace orxonox … … 115 116 worldTrans.setRotation(btQuaternion(node_->getOrientation().x, node_->getOrientation().y, node_->getOrientation().z, node_->getOrientation().w)); 116 117 } 118 117 119 } -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10055 r10058 40 40 41 41 #include "items/ShipPart.h" 42 #include "items/Engine.h" 42 43 #include "worldentities/StaticEntity.h" 43 44 #include "collisionshapes/WorldEntityCollisionShape.h" … … 230 231 /** 231 232 @brief 233 Looks for an attached ShipPart with a certain name. 234 @param name 235 The name of the ShipPart to be returned. 236 @return 237 Pointer to the ShipPart with the given name, or NULL if not found. 238 */ 239 ShipPart* ModularSpaceShip::getShipPartByName(std::string name) 240 { 241 for(std::vector<ShipPart*>::iterator it = this->partList_.begin(); it != this->partList_.end(); ++it) 242 { 243 if(orxonox_cast<ShipPart*>(*it)->getName() == name) 244 { 245 return orxonox_cast<ShipPart*>(*it); 246 } 247 } 248 orxout(internal_warning) << "Couldn't find ShipPart with name \"" << name << "\"." << endl; 249 return NULL; 250 } 251 252 /** 253 @brief 232 254 Check whether the SpaceShip has a particular Engine. 233 255 @param engine … … 285 307 /** 286 308 @brief 309 Looks for an attached Engine with a certain name. 310 @param name 311 The name of the engine to be returned. 312 @return 313 Pointer to the engine with the given name, or NULL if not found. 314 */ 315 Engine* ModularSpaceShip::getEngineByName(std::string name) 316 { 317 for(std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); ++it) 318 { 319 if(orxonox_cast<Engine*>(*it)->getName() == name) 320 { 321 return orxonox_cast<Engine*>(*it); 322 } 323 } 324 orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl; 325 return NULL; 326 } 327 328 /** 329 @brief 287 330 Detaches a child WorldEntity from this instance. 288 331 */ … … 297 340 298 341 // collision shapes 299 orxout() << "MSS: detach()" << endl;300 342 301 343 //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0); … … 314 356 315 357 object->notifyDetached(); 316 orxout() << "MSS: detach() completed." << endl;317 358 } 318 359 } -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
r10055 r10058 117 117 void addShipPart(ShipPart* part); 118 118 ShipPart* getShipPart(unsigned int index); 119 ShipPart* getShipPartByName(std::string name); 119 120 bool hasShipPart(ShipPart* part) const; 120 121 void removeShipPart(ShipPart* part); 121 122 123 inline void setRotationThrust(float val) 124 { this->rotationThrust_ = val; } 125 inline float getRotationThrust() 126 { return this->rotationThrust_; } 127 128 Engine* getEngineByName(std::string name); 122 129 void detach(WorldEntity* object); 123 130 -
code/branches/modularships/src/orxonox/worldentities/pawns/SpaceShip.h
r9667 r10058 270 270 float stallSpeed_; //!< The forward speed where no more lift is added. 271 271 272 std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip. 273 272 274 private: 273 275 void registerVariables(); … … 284 286 void backupCamera(); // Save the original position and orientation of the camera. 285 287 void resetCamera(); // Reset the camera to its original position. 286 287 std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.288 288 289 289 Timer timer_; //!< Timer for the cooldown duration.
Note: See TracChangeset
for help on using the changeset viewer.