From ca782d7310f2df854a8727535ac92337c85ed445 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 17 Aug 2025 19:32:36 -0300 Subject: Gigantesco refactor --- scripts/actors/actions/MovementAction.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/actors/actions/MovementAction.cs (limited to 'scripts/actors/actions/MovementAction.cs') 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); + } +} -- cgit v1.2.3