diff --git a/src/Rule.cpp b/src/Rule.cpp index f29612b..15ce9e9 100644 --- a/src/Rule.cpp +++ b/src/Rule.cpp @@ -23,10 +23,13 @@ void Rule::update() if (targetState == State::Moving || targetState == State::Fleeing) { pro_maat::GridPos target = findTarget(); - if(target != previousPosition || entity->getPosition() != previousTarget) + if(target != previousPosition && (entity->getPosition() != previousTarget || entity->getPosition() == previousPosition)) { entity->nextTarget = target; entity->nextState = targetState; + + previousPosition = entity->getPosition(); + previousTarget = entity->getTarget(); } else { @@ -47,9 +50,6 @@ void Rule::update() entity->nextState = State::Idle; entity->update(); } - - previousPosition = entity->getPosition(); - previousTarget = entity->getTarget(); } pro_maat::GridPos Rule::findTarget()