Changeset 8576
- Timestamp:
- May 25, 2011, 7:03:45 PM (14 years ago)
- Location:
- code/branches/gameimmersion/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc
r8574 r8576 52 52 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 53 53 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController:: toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress);54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::keepBoost ).addShortcut().keybindMode(KeybindMode::OnHold); 55 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 56 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 67 67 68 68 HumanController* HumanController::localController_s = 0; 69 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f; 69 70 70 71 HumanController::HumanController(BaseObject* creator) : Controller(creator) … … 72 73 RegisterObject(HumanController); 73 74 74 controlPaused_ = false;75 this->controlPaused_ = false; 75 76 this->boosting_ = false; 76 77 77 78 HumanController::localController_s = this; 79 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); 80 this->boostingTimeout_.stopTimer(); 78 81 } 79 82 … … 167 170 /** 168 171 @brief 169 Static method, toggles boosting.172 Static method,keeps boosting. 170 173 */ 171 /*static*/ void HumanController::toggleBoost() 172 { 173 COUT(3) << "Toggling boost!" << endl; // TODO: Remove! 174 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 175 HumanController::localController_s->toggleBoosting(); 174 /*static*/ void HumanController::keepBoost() 175 { 176 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 177 HumanController::localController_s->keepBoosting(); 176 178 } 177 179 178 180 /** 179 181 @brief 180 Toggles the boosting mode.181 Changes the keybind mode of the boost console command and tells the ControllableEntity to boost (or not boost anymore).182 Starts, or keeps the boosting mode. 183 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 182 184 */ 183 void HumanController:: toggleBoosting(void)184 { 185 this->boosting_ = !this->boosting_;186 187 // The keybind mode of the boosting console command is onRelease if in boosting mode and onPress of not in boosting mode.188 if(this->boosting_)189 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnRelease);185 void HumanController::keepBoosting(void) 186 { 187 if(this->boostingTimeout_.isActive()) 188 { 189 this->boostingTimeout_.stopTimer(); 190 this->boostingTimeout_.startTimer(); 191 } 190 192 else 191 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress); 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(); 192 210 193 211 this->controllableEntity_->boost(this->boosting_); 212 COUT(4) << "Stop boosting" << endl; 194 213 } 195 214 -
code/branches/gameimmersion/src/orxonox/controllers/HumanController.h
r8574 r8576 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "tools/Timer.h" 34 35 #include "tools/interfaces/Tickable.h" 35 36 #include "Controller.h" … … 64 65 static void reload(); 65 66 66 static void toggleBoost(); // Static method, toggles boosting.67 static void keepBoost(); // Static method, keeps boosting. 67 68 /** 68 69 @brief Check whether the HumanController is in boosting mode. … … 71 72 inline bool isBoosting(void) 72 73 { return this->boosting_; } 73 void toggleBoosting(void); // Toggles the boosting mode. 74 void keepBoosting(void); 75 void terminateBoosting(void); 74 76 75 77 static void greet(); … … 103 105 private: 104 106 bool boosting_; // Whether the HumanController is in boosting mode or not. 107 Timer boostingTimeout_; // A timer to check whether the player is no longer boosting. 108 static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting. 105 109 106 110 }; // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.