- Timestamp:
- May 25, 2011, 9:41:29 PM (13 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/controllers/HumanController.cc
r8579 r8580 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::keepBoost ).addShortcut().keybindMode(KeybindMode::OnHold); 54 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 55 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 66 67 67 68 HumanController* HumanController::localController_s = 0; 69 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f; 68 70 69 71 HumanController::HumanController(BaseObject* creator) : Controller(creator) … … 71 73 RegisterObject(HumanController); 72 74 73 controlPaused_ = false; 75 this->controlPaused_ = false; 76 this->boosting_ = false; 74 77 75 78 HumanController::localController_s = this; 79 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); 80 this->boostingTimeout_.stopTimer(); 76 81 } 77 82 … … 163 168 } 164 169 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 170 /** 171 @brief 172 Static method,keeps boosting. 173 */ 174 /*static*/ void HumanController::keepBoost() 175 { 176 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 177 HumanController::localController_s->keepBoosting(); 178 } 179 180 /** 181 @brief 182 Starts, or keeps the boosting mode. 183 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 184 */ 185 void HumanController::keepBoosting(void) 186 { 187 if(this->boostingTimeout_.isActive()) 188 { 189 this->boostingTimeout_.stopTimer(); 190 this->boostingTimeout_.startTimer(); 191 } 192 else 193 { 194 this->boosting_ = true; 195 this->boostingTimeout_.startTimer(); 196 197 this->controllableEntity_->boost(this->boosting_); 198 COUT(4) << "Start boosting" << endl; 199 } 200 } 201 202 /** 203 @brief 204 Terminates the boosting mode. 205 */ 206 void HumanController::terminateBoosting(void) 207 { 208 this->boosting_ = false; 209 this->boostingTimeout_.stopTimer(); 210 211 this->controllableEntity_->boost(this->boosting_); 212 COUT(4) << "Stop boosting" << endl; 169 213 } 170 214
Note: See TracChangeset
for help on using the changeset viewer.