summaryrefslogtreecommitdiff
path: root/scripts/Entities/Actions/MovementAction.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-09 19:09:34 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-09 19:09:34 -0300
commitc6bbb834f7758027c0df338f1520f34fad3befea (patch)
tree1818cd23c24be16fbe19b16dd0a510874d440d83 /scripts/Entities/Actions/MovementAction.cs
parentf1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff)
Organização
Diffstat (limited to 'scripts/Entities/Actions/MovementAction.cs')
-rw-r--r--scripts/Entities/Actions/MovementAction.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/Entities/Actions/MovementAction.cs b/scripts/Entities/Actions/MovementAction.cs
new file mode 100644
index 0000000..0ac842c
--- /dev/null
+++ b/scripts/Entities/Actions/MovementAction.cs
@@ -0,0 +1,30 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actors;
+using TheLegendOfGustav.Map;
+
+namespace TheLegendOfGustav.Entities.Actions;
+
+/// <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 bool Perform()
+ {
+ // Não anda se o destino for um tile sólido.
+ if (!MapData.GetTile(Destination).IsWalkable) return true;
+
+ // Não anda se o destino for oculpado por um ator.
+ // Na maioria dos casos, essa condição nunca é verdadeira.
+ if (GetTarget() != null) return true;
+
+ Actor.Walk(Offset);
+ Actor.Energy -= Cost;
+
+ return true;
+ }
+}