Changeset 8223 for code/branches/steering/src
- Timestamp:
- Apr 10, 2011, 11:09:36 AM (14 years ago)
- Location:
- code/branches/steering/src/orxonox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/steering/src/orxonox/controllers/HumanController.cc
r8079 r8223 42 42 extern const std::string __CC_fire_name = "fire"; 43 43 extern const std::string __CC_suicide_name = "suicide"; 44 const std::string __CC_boost_name = "boost"; 44 45 45 46 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); … … 51 52 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 52 53 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 53 SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold);54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress); 54 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 55 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 72 73 73 74 controlPaused_ = false; 75 this->boosting_ = false; 74 76 75 77 HumanController::localController_s = this; … … 163 165 } 164 166 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 167 /** 168 @brief 169 Static method,toggles boosting. 170 */ 171 /*static*/ void HumanController::toggleBoost() 172 { 173 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 174 HumanController::localController_s->toggleBoosting(); 175 } 176 177 /** 178 @brief 179 Toggles the boosting mode. 180 Changes the keybind mode of the boost console command and tells the ControllableEntity to boost (or not boost anymore). 181 */ 182 void HumanController::toggleBoosting(void) 183 { 184 this->boosting_ = !this->boosting_; 185 186 // The keybind mode of the boosting console command is onRelease if in boosting mode and onPress of not in boosting mode. 187 if(this->boosting_) 188 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnRelease); 189 else 190 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress); 191 192 this->controllableEntity_->boost(this->boosting_); 169 193 } 170 194 -
code/branches/steering/src/orxonox/controllers/HumanController.h
r8079 r8223 64 64 static void reload(); 65 65 66 static void boost(); 66 static void toggleBoost(); // Static method,toggles boosting. 67 /** 68 @brief Check whether the HumanController is in boosting mode. 69 @return Returns true if it is, false if not. 70 */ 71 inline bool isBoosting(void) 72 { return this->boosting_; } 73 void toggleBoosting(void); // Toggles the boosting mode. 74 67 75 static void greet(); 68 76 static void switchCamera(); … … 92 100 static HumanController* localController_s; 93 101 bool controlPaused_; 102 103 private: 104 bool boosting_; // Whether the HumanController is in boosting mode or not. 105 94 106 }; // tolua_export 95 107 } // tolua_export -
code/branches/steering/src/orxonox/items/Engine.cc
r8079 r8223 204 204 this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd()))); 205 205 206 if (!this->ship_->getPermanentBoost())207 this->ship_->setBoost(false);208 206 this->ship_->setSteeringDirection(Vector3::ZERO); 209 207 -
code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc
r7892 r8223 84 84 this->client_angular_velocity_ = Vector3::ZERO; 85 85 86 87 86 this->setConfigValues(); 88 87 this->setPriority( Priority::VeryHigh ); -
code/branches/steering/src/orxonox/worldentities/ControllableEntity.h
r7889 r8223 93 93 virtual void reload() {} 94 94 95 virtual void boost() {} 95 /** 96 @brief Tells the ControllableEntity to either start or stop boosting. 97 This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will. 98 @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop. 99 */ 100 virtual void boost(bool bBoost) {} 101 96 102 virtual void greet() {} 97 103 virtual void switchCamera(); -
code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.cc
r7860 r8223 53 53 this->localAngularAcceleration_.setValue(0, 0, 0); 54 54 this->bBoost_ = false; 55 this->bPermanentBoost_ = false;56 55 this->steering_ = Vector3::ZERO; 57 56 this->engine_ = 0; … … 103 102 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 104 103 registerVariable(this->rotationThrust_, VariableDirection::ToClient); 104 registerVariable(this->boostPower_, VariableDirection::ToClient); 105 registerVariable(this->boostPowerRate_, VariableDirection::ToClient); 106 registerVariable(this->boostRate_, VariableDirection::ToClient); 107 registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient); 105 108 } 106 109 … … 207 210 } 208 211 209 // TODO: something seems to call this function every tick, could probably handled a little more efficiently! 210 void SpaceShip::setBoost(bool bBoost) 211 { 212 if(bBoost == this->bBoost_) 213 return; 214 215 if(bBoost) 216 this->boost(); 217 else 218 { 212 void SpaceShip::fire() 213 { 214 } 215 216 /** 217 @brief 218 Starts or stops boosting. 219 @param bBoost 220 Whether to start or stop boosting. 221 */ 222 void SpaceShip::boost(bool bBoost) 223 { 224 if(bBoost && !this->bBoostCooldown_) 225 this->bBoost_ = true; 226 if(!bBoost) 219 227 this->bBoost_ = false; 220 }221 }222 223 void SpaceShip::fire()224 {225 }226 227 void SpaceShip::boost()228 {229 if(!this->bBoostCooldown_)230 this->bBoost_ = true;231 228 } 232 229 -
code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.h
r7801 r8223 59 59 60 60 virtual void fire(); 61 virtual void boost( );61 virtual void boost(bool bBoost); // Starts or stops boosting. 62 62 63 63 void setEngine(Engine* engine); … … 70 70 { return this->steering_; } 71 71 72 void setBoost(bool bBoost);73 72 inline bool getBoost() const 74 73 { return this->bBoost_; } … … 79 78 { return this->enginetemplate_; } 80 79 81 inline void setPermanentBoost(bool bPermanent)82 { this->bPermanentBoost_ = bPermanent; }83 inline bool getPermanentBoost() const84 { return this->bPermanentBoost_; }85 86 80 protected: 87 81 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const; … … 90 84 bool bBoost_; 91 85 bool bBoostCooldown_; 92 bool bPermanentBoost_;93 86 float boostPower_; 94 87 float initialBoostPower_;
Note: See TracChangeset
for help on using the changeset viewer.