From cb1421b91b2f8ffa71f7ee009dad4e237ed36e2c Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 6 Jul 2021 11:38:05 -0400 Subject: Added moonwalking to pathfinding behaviour This flag will make the sprite appear to be walking backwards. --- src/behaviour_system.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/behaviour_system.cpp') diff --git a/src/behaviour_system.cpp b/src/behaviour_system.cpp index ce980f6..f4dc388 100644 --- a/src/behaviour_system.cpp +++ b/src/behaviour_system.cpp @@ -7,6 +7,7 @@ #include "character_system.h" #include "direction.h" #include "transform_system.h" +#include "animation_system.h" bool pathfindingOptionsContains(PathfindingOptions options, PathfindingOptions value) { return (static_cast(options) & static_cast(value)) != 0; @@ -71,6 +72,9 @@ void BehaviourSystem::tick(double dt) { } else { if (sprite.characterState == CharacterState::Still || sprite.movementDir != sprite.path.front().dir) { game_.getSystem().moveInDirection(spriteId, sprite.path.front().dir); + if (sprite.moonwalking) { + game_.getSystem().setSpriteDirection(spriteId, oppositeDirection(sprite.path.front().dir)); + } } } } @@ -83,6 +87,7 @@ void BehaviourSystem::directSpriteToLocation(int spriteId, vec2i pos, Pathfindin sprite.behaviourType = BehaviourType::Path; sprite.pathfindingDestination = pos; sprite.cardinalDirectionsOnly = pathfindingOptionsContains(options, PathfindingOptions::CardinalDirectionsOnly); + sprite.moonwalking = pathfindingOptionsContains(options, PathfindingOptions::Moonwalking); createPath(spriteId); } -- cgit 1.4.1