Se till så att man inte går över maxenergy

This commit is contained in:
Erik Persson 2014-02-27 09:11:13 +01:00
parent ca715dbe05
commit 5ad5ad6f5f
1 changed files with 17 additions and 2 deletions

View File

@ -105,6 +105,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
void AttatchmentMassDriver::Update(float dt) void AttatchmentMassDriver::Update(float dt)
{ {
//update position of heldObject if there is an object being held //update position of heldObject if there is an object being held
if(hasObject) if(hasObject)
{ {
@ -116,13 +117,27 @@ void AttatchmentMassDriver::Update(float dt)
heldObject->SetPosition(pos); heldObject->SetPosition(pos);
heldObject->SetLinearVelocity(Oyster::Math::Float3::null); heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object if(currentEnergy < maxEnergy)
{
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object
}
} }
else else
{ {
currentEnergy += rechargeRate; if(currentEnergy < maxEnergy)
{
currentEnergy += rechargeRate;
if(currentEnergy == maxEnergy)
{
int trap = 0;
}
}
} }
if(currentEnergy > maxEnergy) currentEnergy = maxEnergy;
} }