summary refs log tree commit diff stats
path: root/src/behaviour_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/behaviour_system.cpp')
-rw-r--r--src/behaviour_system.cpp5
1 files changed, 5 insertions, 0 deletions
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 @@
7#include "character_system.h" 7#include "character_system.h"
8#include "direction.h" 8#include "direction.h"
9#include "transform_system.h" 9#include "transform_system.h"
10#include "animation_system.h"
10 11
11bool pathfindingOptionsContains(PathfindingOptions options, PathfindingOptions value) { 12bool pathfindingOptionsContains(PathfindingOptions options, PathfindingOptions value) {
12 return (static_cast<int>(options) & static_cast<int>(value)) != 0; 13 return (static_cast<int>(options) & static_cast<int>(value)) != 0;
@@ -71,6 +72,9 @@ void BehaviourSystem::tick(double dt) {
71 } else { 72 } else {
72 if (sprite.characterState == CharacterState::Still || sprite.movementDir != sprite.path.front().dir) { 73 if (sprite.characterState == CharacterState::Still || sprite.movementDir != sprite.path.front().dir) {
73 game_.getSystem<CharacterSystem>().moveInDirection(spriteId, sprite.path.front().dir); 74 game_.getSystem<CharacterSystem>().moveInDirection(spriteId, sprite.path.front().dir);
75 if (sprite.moonwalking) {
76 game_.getSystem<AnimationSystem>().setSpriteDirection(spriteId, oppositeDirection(sprite.path.front().dir));
77 }
74 } 78 }
75 } 79 }
76 } 80 }
@@ -83,6 +87,7 @@ void BehaviourSystem::directSpriteToLocation(int spriteId, vec2i pos, Pathfindin
83 sprite.behaviourType = BehaviourType::Path; 87 sprite.behaviourType = BehaviourType::Path;
84 sprite.pathfindingDestination = pos; 88 sprite.pathfindingDestination = pos;
85 sprite.cardinalDirectionsOnly = pathfindingOptionsContains(options, PathfindingOptions::CardinalDirectionsOnly); 89 sprite.cardinalDirectionsOnly = pathfindingOptionsContains(options, PathfindingOptions::CardinalDirectionsOnly);
90 sprite.moonwalking = pathfindingOptionsContains(options, PathfindingOptions::Moonwalking);
86 91
87 createPath(spriteId); 92 createPath(spriteId);
88} 93}