Fixed oscillations for real

Entities do not move after completing their moves...
This commit is contained in:
trotFunky 2019-06-10 20:05:46 +02:00
parent e1f23f67a2
commit b85d46e450

View file

@ -23,10 +23,13 @@ void Rule::update()
if (targetState == State::Moving || targetState == State::Fleeing) if (targetState == State::Moving || targetState == State::Fleeing)
{ {
pro_maat::GridPos target = findTarget(); pro_maat::GridPos target = findTarget();
if(target != previousPosition || entity->getPosition() != previousTarget) if(target != previousPosition && (entity->getPosition() != previousTarget || entity->getPosition() == previousPosition))
{ {
entity->nextTarget = target; entity->nextTarget = target;
entity->nextState = targetState; entity->nextState = targetState;
previousPosition = entity->getPosition();
previousTarget = entity->getTarget();
} }
else else
{ {
@ -47,9 +50,6 @@ void Rule::update()
entity->nextState = State::Idle; entity->nextState = State::Idle;
entity->update(); entity->update();
} }
previousPosition = entity->getPosition();
previousTarget = entity->getTarget();
} }
pro_maat::GridPos Rule::findTarget() pro_maat::GridPos Rule::findTarget()