diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-26 22:59:57 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-26 22:59:57 -0300 |
| commit | 6c7e2ac133986efa57b43df52a5498c6f7efcf75 (patch) | |
| tree | 8404bfd3415a8dfcf7073191cbfdf58cc7c905ed /scripts/actors/AI/HostileEnemyAI.cs | |
| parent | a3103718796a472da76838bf6fd72ba5d8409d79 (diff) | |
AI
Diffstat (limited to 'scripts/actors/AI/HostileEnemyAI.cs')
| -rw-r--r-- | scripts/actors/AI/HostileEnemyAI.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/actors/AI/HostileEnemyAI.cs b/scripts/actors/AI/HostileEnemyAI.cs new file mode 100644 index 0000000..061295f --- /dev/null +++ b/scripts/actors/AI/HostileEnemyAI.cs @@ -0,0 +1,38 @@ +using Godot; + +public partial class HostileEnemyAI : BaseAI +{ + private Godot.Collections.Array<Vector2> path = []; + + public override void Perform() + { + Player target = body.Map_Data.Player; + Vector2I offset = target.GridPosition - body.GridPosition; + int distance = int.Max(int.Abs(offset.X), int.Abs(offset.Y)); + + Action action; + + if (body.Map_Data.GetTile(body.GridPosition).IsInView) { + if (distance <= 1) { + action = new MeleeAction(body, offset); + action.Perform(); + return; + } + path = GetPathTo(target.GridPosition); + GD.Print($"Arno Breker: {path}"); + path.RemoveAt(0); + } + + if (path.Count > 0) { + Vector2I destination = (Vector2I) path[0]; + GD.Print(destination); + if (body.Map_Data.GetBlockingActorAtPosition(destination) != null) { + return; + } + + action = new MovementAction(body, destination - body.GridPosition); + action.Perform(); + path.RemoveAt(0); + } + } +}
\ No newline at end of file |
