[Orxonox-commit 3537] r8223 - in code/branches/steering/src/orxonox: controllers items worldentities worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Sun Apr 10 11:09:36 CEST 2011
Author: dafrick
Date: 2011-04-10 11:09:36 +0200 (Sun, 10 Apr 2011)
New Revision: 8223
Modified:
code/branches/steering/src/orxonox/controllers/HumanController.cc
code/branches/steering/src/orxonox/controllers/HumanController.h
code/branches/steering/src/orxonox/items/Engine.cc
code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc
code/branches/steering/src/orxonox/worldentities/ControllableEntity.h
code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Streamlining boost.
Modified: code/branches/steering/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/steering/src/orxonox/controllers/HumanController.cc 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/controllers/HumanController.cc 2011-04-10 09:09:36 UTC (rev 8223)
@@ -41,6 +41,7 @@
{
extern const std::string __CC_fire_name = "fire";
extern const std::string __CC_suicide_name = "suicide";
+ const std::string __CC_boost_name = "boost";
SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand();
SetConsoleCommand("HumanController", "moveRightLeft", &HumanController::moveRightLeft ).addShortcut().setAsInputCommand();
@@ -50,7 +51,7 @@
SetConsoleCommand("HumanController", "rotateRoll", &HumanController::rotateRoll ).addShortcut().setAsInputCommand();
SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold);
SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut();
- SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold);
+ SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress);
SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut();
SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut();
SetConsoleCommand("HumanController", "mouseLook", &HumanController::mouseLook ).addShortcut();
@@ -71,6 +72,7 @@
RegisterObject(HumanController);
controlPaused_ = false;
+ this->boosting_ = false;
HumanController::localController_s = this;
}
@@ -162,12 +164,34 @@
HumanController::localController_s->controllableEntity_->reload();
}
- void HumanController::boost()
+ /**
+ @brief
+ Static method,toggles boosting.
+ */
+ /*static*/ void HumanController::toggleBoost()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->boost();
+ HumanController::localController_s->toggleBoosting();
}
+
+ /**
+ @brief
+ Toggles the boosting mode.
+ Changes the keybind mode of the boost console command and tells the ControllableEntity to boost (or not boost anymore).
+ */
+ void HumanController::toggleBoosting(void)
+ {
+ this->boosting_ = !this->boosting_;
+
+ // The keybind mode of the boosting console command is onRelease if in boosting mode and onPress of not in boosting mode.
+ if(this->boosting_)
+ ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnRelease);
+ else
+ ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress);
+ this->controllableEntity_->boost(this->boosting_);
+ }
+
void HumanController::greet()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
Modified: code/branches/steering/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/steering/src/orxonox/controllers/HumanController.h 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/controllers/HumanController.h 2011-04-10 09:09:36 UTC (rev 8223)
@@ -63,7 +63,15 @@
virtual void doFire(unsigned int firemode);
static void reload();
- static void boost();
+ static void toggleBoost(); // Static method,toggles boosting.
+ /**
+ @brief Check whether the HumanController is in boosting mode.
+ @return Returns true if it is, false if not.
+ */
+ inline bool isBoosting(void)
+ { return this->boosting_; }
+ void toggleBoosting(void); // Toggles the boosting mode.
+
static void greet();
static void switchCamera();
static void mouseLook();
@@ -91,6 +99,10 @@
protected:
static HumanController* localController_s;
bool controlPaused_;
+
+ private:
+ bool boosting_; // Whether the HumanController is in boosting mode or not.
+
}; // tolua_export
} // tolua_export
Modified: code/branches/steering/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/steering/src/orxonox/items/Engine.cc 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/items/Engine.cc 2011-04-10 09:09:36 UTC (rev 8223)
@@ -203,8 +203,6 @@
this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
- if (!this->ship_->getPermanentBoost())
- this->ship_->setBoost(false);
this->ship_->setSteeringDirection(Vector3::ZERO);
if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
Modified: code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc 2011-04-10 09:09:36 UTC (rev 8223)
@@ -83,7 +83,6 @@
this->server_angular_velocity_ = Vector3::ZERO;
this->client_angular_velocity_ = Vector3::ZERO;
-
this->setConfigValues();
this->setPriority( Priority::VeryHigh );
this->registerVariables();
Modified: code/branches/steering/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/steering/src/orxonox/worldentities/ControllableEntity.h 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/worldentities/ControllableEntity.h 2011-04-10 09:09:36 UTC (rev 8223)
@@ -92,7 +92,13 @@
virtual void fired(unsigned int firemode) {}
virtual void reload() {}
- virtual void boost() {}
+ /**
+ @brief Tells the ControllableEntity to either start or stop boosting.
+ This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will.
+ @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop.
+ */
+ virtual void boost(bool bBoost) {}
+
virtual void greet() {}
virtual void switchCamera();
virtual void mouseLook();
Modified: code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-04-10 09:09:36 UTC (rev 8223)
@@ -52,7 +52,6 @@
this->localLinearAcceleration_.setValue(0, 0, 0);
this->localAngularAcceleration_.setValue(0, 0, 0);
this->bBoost_ = false;
- this->bPermanentBoost_ = false;
this->steering_ = Vector3::ZERO;
this->engine_ = 0;
@@ -102,6 +101,10 @@
registerVariable(this->primaryThrust_, VariableDirection::ToClient);
registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
registerVariable(this->rotationThrust_, VariableDirection::ToClient);
+ registerVariable(this->boostPower_, VariableDirection::ToClient);
+ registerVariable(this->boostPowerRate_, VariableDirection::ToClient);
+ registerVariable(this->boostRate_, VariableDirection::ToClient);
+ registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient);
}
void SpaceShip::setConfigValues()
@@ -206,28 +209,22 @@
Pawn::rotateRoll(value);
}
- // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
- void SpaceShip::setBoost(bool bBoost)
- {
- if(bBoost == this->bBoost_)
- return;
-
- if(bBoost)
- this->boost();
- else
- {
- this->bBoost_ = false;
- }
- }
-
void SpaceShip::fire()
{
}
- void SpaceShip::boost()
+ /**
+ @brief
+ Starts or stops boosting.
+ @param bBoost
+ Whether to start or stop boosting.
+ */
+ void SpaceShip::boost(bool bBoost)
{
- if(!this->bBoostCooldown_)
+ if(bBoost && !this->bBoostCooldown_)
this->bBoost_ = true;
+ if(!bBoost)
+ this->bBoost_ = false;
}
void SpaceShip::loadEngineTemplate()
Modified: code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.h 2011-04-10 03:29:18 UTC (rev 8222)
+++ code/branches/steering/src/orxonox/worldentities/pawns/SpaceShip.h 2011-04-10 09:09:36 UTC (rev 8223)
@@ -58,7 +58,7 @@
virtual void rotateRoll(const Vector2& value);
virtual void fire();
- virtual void boost();
+ virtual void boost(bool bBoost); // Starts or stops boosting.
void setEngine(Engine* engine);
inline Engine* getEngine() const
@@ -69,7 +69,6 @@
inline const Vector3& getSteeringDirection() const
{ return this->steering_; }
- void setBoost(bool bBoost);
inline bool getBoost() const
{ return this->bBoost_; }
@@ -78,18 +77,12 @@
inline const std::string& getEngineTemplate() const
{ return this->enginetemplate_; }
- inline void setPermanentBoost(bool bPermanent)
- { this->bPermanentBoost_ = bPermanent; }
- inline bool getPermanentBoost() const
- { return this->bPermanentBoost_; }
-
protected:
virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const;
bool bInvertYAxis_;
bool bBoost_;
bool bBoostCooldown_;
- bool bPermanentBoost_;
float boostPower_;
float initialBoostPower_;
float boostRate_;
More information about the Orxonox-commit
mailing list