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 committed by Dander7BD
parent 22bc079ed7
commit e43996bdc8
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,12 +117,26 @@ void AttatchmentMassDriver::Update(float dt)
heldObject->SetPosition(pos); heldObject->SetPosition(pos);
heldObject->SetLinearVelocity(Oyster::Math::Float3::null); heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
if(currentEnergy < maxEnergy)
{
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object
} }
}
else else
{
if(currentEnergy < maxEnergy)
{ {
currentEnergy += rechargeRate; currentEnergy += rechargeRate;
if(currentEnergy == maxEnergy)
{
int trap = 0;
} }
}
}
if(currentEnergy > maxEnergy) currentEnergy = maxEnergy;
} }