From 79daad81a4c613383d6bb05d9b47a02889bf23ab Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 28 Feb 2021 10:25:26 -0500 Subject: Pathfinding should be more biased toward straight lines now --- src/behaviour_system.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/behaviour_system.cpp') diff --git a/src/behaviour_system.cpp b/src/behaviour_system.cpp index 3637b3e..4a194f0 100644 --- a/src/behaviour_system.cpp +++ b/src/behaviour_system.cpp @@ -156,8 +156,10 @@ void BehaviourSystem::createPath(int spriteId) { Direction::up, Direction::right }; - const std::vector* directionList = sprite.cardinalDirectionsOnly ? &cardinalDirections : &allDirections; - for (Direction dir : *directionList) { + std::vector directionList = sprite.cardinalDirectionsOnly ? cardinalDirections : allDirections; + directionList.push_back(nodeInfo.dirFromPreviousPoint); + + for (Direction dir : directionList) { vec2i newPos = searchNode.point + unitVecInDirection(dir) * sprite.movementSpeed; if (newPos.x() < 0 || newPos.y() < 0 || newPos.x() >= mapBounds.w() || newPos.y() >= mapBounds.h()) { -- cgit 1.4.1