Changeset 8706 for code/trunk/src/orxonox/controllers/HumanController.cc
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/controllers/HumanController.cc
r8079 r8706 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; 77 this->boosting_ = false; 74 78 75 79 HumanController::localController_s = this; 80 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); 81 this->boostingTimeout_.stopTimer(); 76 82 } 77 83 … … 163 169 } 164 170 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 171 /** 172 @brief 173 Static method,keeps boosting. 174 */ 175 /*static*/ void HumanController::keepBoost() 176 { 177 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 178 HumanController::localController_s->keepBoosting(); 179 } 180 181 /** 182 @brief 183 Starts, or keeps the boosting mode. 184 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 185 */ 186 void HumanController::keepBoosting(void) 187 { 188 if(this->boostingTimeout_.isActive()) 189 { 190 this->boostingTimeout_.stopTimer(); 191 this->boostingTimeout_.startTimer(); 192 } 193 else 194 { 195 this->boosting_ = true; 196 this->boostingTimeout_.startTimer(); 197 198 this->controllableEntity_->boost(this->boosting_); 199 COUT(4) << "Start boosting" << endl; 200 } 201 } 202 203 /** 204 @brief 205 Terminates the boosting mode. 206 */ 207 void HumanController::terminateBoosting(void) 208 { 209 this->boosting_ = false; 210 this->boostingTimeout_.stopTimer(); 211 212 this->controllableEntity_->boost(this->boosting_); 213 COUT(4) << "Stop boosting" << endl; 169 214 } 170 215
Note: See TracChangeset
for help on using the changeset viewer.