diff options
| -rw-r--r-- | res/scripts/common.lua | 3 | ||||
| -rw-r--r-- | src/behaviour_system.cpp | 5 | ||||
| -rw-r--r-- | src/behaviour_system.h | 3 | ||||
| -rw-r--r-- | src/sprite.h | 1 |
4 files changed, 10 insertions, 2 deletions
| diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 46f2275..559d8bd 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
| @@ -48,7 +48,8 @@ ChangeMapOptions = { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | PathfindingOptions = { | 50 | PathfindingOptions = { |
| 51 | CARDINAL_DIRECTIONS_ONLY = 1 | 51 | CARDINAL_DIRECTIONS_ONLY = 1, |
| 52 | MOONWALKING = 2 -- Causes the sprite to walk backwards | ||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | gamestate = {} | 55 | gamestate = {} |
| 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 | ||
| 11 | bool pathfindingOptionsContains(PathfindingOptions options, PathfindingOptions value) { | 12 | bool 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 | } |
| diff --git a/src/behaviour_system.h b/src/behaviour_system.h index 1ddce4a..d338c79 100644 --- a/src/behaviour_system.h +++ b/src/behaviour_system.h | |||
| @@ -7,7 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | enum class PathfindingOptions { | 8 | enum class PathfindingOptions { |
| 9 | None = 0, | 9 | None = 0, |
| 10 | CardinalDirectionsOnly = 1 << 0 | 10 | CardinalDirectionsOnly = 1 << 0, |
| 11 | Moonwalking = 1 << 1 | ||
| 11 | }; | 12 | }; |
| 12 | 13 | ||
| 13 | class Game; | 14 | class Game; |
| diff --git a/src/sprite.h b/src/sprite.h index 406053e..86474ca 100644 --- a/src/sprite.h +++ b/src/sprite.h | |||
| @@ -134,6 +134,7 @@ public: | |||
| 134 | BehaviourType behaviourType = BehaviourType::None; | 134 | BehaviourType behaviourType = BehaviourType::None; |
| 135 | vec2i pathfindingDestination; | 135 | vec2i pathfindingDestination; |
| 136 | bool cardinalDirectionsOnly = false; | 136 | bool cardinalDirectionsOnly = false; |
| 137 | bool moonwalking = false; | ||
| 137 | std::deque<PathfindingInstruction> path; | 138 | std::deque<PathfindingInstruction> path; |
| 138 | int followSpriteId = -1; | 139 | int followSpriteId = -1; |
| 139 | 140 | ||
