summaryrefslogtreecommitdiff
path: root/scripts/entities/actions/MovementAction.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-04 17:04:52 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-04 17:04:52 -0300
commit396c0788cea3bc68022c4bc5a96c82e058bc9b93 (patch)
tree0eeecb67a14f61c4f42f363a94685539d09b2201 /scripts/entities/actions/MovementAction.cs
parent6f2c2edd52171a4df7f35de695c9b2e7801d3e5f (diff)
Move move
Diffstat (limited to 'scripts/entities/actions/MovementAction.cs')
-rw-r--r--scripts/entities/actions/MovementAction.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/entities/actions/MovementAction.cs b/scripts/entities/actions/MovementAction.cs
new file mode 100644
index 0000000..2c394fc
--- /dev/null
+++ b/scripts/entities/actions/MovementAction.cs
@@ -0,0 +1,24 @@
+using Godot;
+
+/// <summary>
+/// Ação de movimento. Movimenta o ator para a direção de seu Offset.
+/// </summary>
+public partial class MovementAction : DirectionalAction
+{
+ public MovementAction(Actor actor, Vector2I offset) : base(actor, offset)
+ {
+ }
+
+ public override void Perform()
+ {
+ // Não anda se o destino for um tile sólido.
+ if (!Map_Data.GetTile(Destination).IsWalkable) return;
+
+ // Não anda se o destino for oculpado por um ator.
+ // Na maioria dos casos, essa condição nunca é verdadeira.
+ if (GetTarget() != null) return;
+
+ actor.Walk(Offset);
+ actor.Energy -= cost;
+ }
+}