diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-17 19:32:36 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-17 19:32:36 -0300 |
| commit | ca782d7310f2df854a8727535ac92337c85ed445 (patch) | |
| tree | 7df571c01d48cac56fb8362d4d091bdd2a55c09a /scripts/actors/actions | |
| parent | adb86dd1725276457c13e9a4d37372fda628dea3 (diff) | |
Gigantesco refactor
Diffstat (limited to 'scripts/actors/actions')
| -rw-r--r-- | scripts/actors/actions/Action.cs | 6 | ||||
| -rw-r--r-- | scripts/actors/actions/Action.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/actors/actions/MovementAction.cs | 22 | ||||
| -rw-r--r-- | scripts/actors/actions/MovementAction.cs.uid | 1 |
4 files changed, 30 insertions, 0 deletions
diff --git a/scripts/actors/actions/Action.cs b/scripts/actors/actions/Action.cs new file mode 100644 index 0000000..21efa1a --- /dev/null +++ b/scripts/actors/actions/Action.cs @@ -0,0 +1,6 @@ +using Godot; +using System; + +public abstract partial class Action : RefCounted { + public abstract void Perform(Game game, Actor actor); +} diff --git a/scripts/actors/actions/Action.cs.uid b/scripts/actors/actions/Action.cs.uid new file mode 100644 index 0000000..9523b0a --- /dev/null +++ b/scripts/actors/actions/Action.cs.uid @@ -0,0 +1 @@ +uid://dlejckfyro2ch 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); + } +} diff --git a/scripts/actors/actions/MovementAction.cs.uid b/scripts/actors/actions/MovementAction.cs.uid new file mode 100644 index 0000000..07569ef --- /dev/null +++ b/scripts/actors/actions/MovementAction.cs.uid @@ -0,0 +1 @@ +uid://cdtpdaeg7hh6p |
