From b85d46e4507d46c935f66810ee63120c0088d005 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 10 Jun 2019 20:05:46 +0200 Subject: [PATCH] Fixed oscillations for real Entities do not move after completing their moves... --- src/Rule.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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()