summaryrefslogtreecommitdiff
path: root/scripts/Entities/Actors/Enemy.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/Actors/Enemy.cs
parentf1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff)
Organização
Diffstat (limited to 'scripts/Entities/Actors/Enemy.cs')
-rw-r--r--scripts/Entities/Actors/Enemy.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/Entities/Actors/Enemy.cs b/scripts/Entities/Actors/Enemy.cs
new file mode 100644
index 0000000..c152a0b
--- /dev/null
+++ b/scripts/Entities/Actors/Enemy.cs
@@ -0,0 +1,54 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actors.AI;
+using TheLegendOfGustav.Map;
+
+namespace TheLegendOfGustav.Entities.Actors;
+
+/// <summary>
+/// Um inimigo é uma espécie de ator que é
+/// hostil ao jogador. Inimigos são controlados por IA.
+/// </summary>
+public partial class Enemy : Actor
+{
+ public Enemy(Vector2I initialPosition, MapData map, EnemyDefinition definition) : base(initialPosition, map, definition)
+ {
+ Definition = definition;
+ SetDefinition(definition);
+ }
+
+ /// <summary>
+ /// A alma do ator. Gera ações que são executadas todo turno.
+ /// </summary>
+ public BaseAI Soul { get; private set; }
+
+ private EnemyDefinition Definition { get; set; }
+
+ /// <summary>
+ /// Além de definir as características gerais de um ator,
+ /// também define qual IA utilizar.
+ /// </summary>
+ /// <param name="definition">Definição do inimigo.</param>
+ public void SetDefinition(EnemyDefinition definition)
+ {
+ // Definimos as características do ator.
+ base.SetDefinition(Definition);
+
+ // Definimos qual IA utilizar.
+ switch (definition.AI)
+ {
+ case AIType.None:
+ break;
+ case AIType.DefaultHostile:
+ Soul = new HostileEnemyAI();
+ AddChild(Soul);
+ break;
+ }
+ }
+
+ public override void Die()
+ {
+ Soul.QueueFree();
+ Soul = null;
+ base.Die();
+ }
+}