diff options
Diffstat (limited to 'scripts/entities/actors/actions/MovementAction.cs')
| -rw-r--r-- | scripts/entities/actors/actions/MovementAction.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/entities/actors/actions/MovementAction.cs b/scripts/entities/actors/actions/MovementAction.cs new file mode 100644 index 0000000..3608357 --- /dev/null +++ b/scripts/entities/actors/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.IsTileWalkable(Destination)) return; + + // Não anda se o destino for oculpado por um ator. + // Na maioria dos casos, essa condição nunca é verdadeira. + if (GetTargetActor() != null) return; + + actor.Walk(Offset); + actor.Energy -= cost; + } +} |
