summaryrefslogtreecommitdiff
path: root/scripts/actors/actions/MovementAction.cs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/actors/actions/MovementAction.cs')
-rw-r--r--scripts/actors/actions/MovementAction.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/actors/actions/MovementAction.cs b/scripts/actors/actions/MovementAction.cs
new file mode 100644
index 0000000..f29e2e8
--- /dev/null
+++ b/scripts/actors/actions/MovementAction.cs
@@ -0,0 +1,22 @@
+using Godot;
+using System;
+
+public partial class MovementAction : Action
+{
+ public Vector2I Offset { get; private set; }
+ public MovementAction(Vector2I offset)
+ {
+ Offset = offset;
+ }
+
+ public override void Perform(Game game, Actor actor)
+ {
+ Vector2I finalDestination = actor.GridPosition + Offset;
+
+ TileData tile = game.Dungeon.GetCellTileData(finalDestination);
+
+ if (tile == null || !(bool) tile.GetCustomData("isWalkable")) return;
+
+ actor.Walk(Offset);
+ }
+}