diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-26 20:02:15 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-26 20:02:15 -0300 |
| commit | f4ed469fc9eaeebf39093fbf6601581cc10c6e2f (patch) | |
| tree | d8f29ae3288e950b5fb1f5251845d57949ca2ac0 /scripts/Entities/Actors/Enemy.cs | |
| parent | 639cd8cef403e9e66bf31e7888e786effac2b292 (diff) | |
feat:save AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
O vazio dentro de mim é como uma xícara de café esquecida
no canto da mesa.
Diffstat (limited to 'scripts/Entities/Actors/Enemy.cs')
| -rw-r--r-- | scripts/Entities/Actors/Enemy.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/scripts/Entities/Actors/Enemy.cs b/scripts/Entities/Actors/Enemy.cs index d398176..4994534 100644 --- a/scripts/Entities/Actors/Enemy.cs +++ b/scripts/Entities/Actors/Enemy.cs @@ -1,4 +1,5 @@ using Godot; +using Godot.Collections; using TheLegendOfGustav.Entities.Actors.AI; using TheLegendOfGustav.Map; @@ -8,7 +9,7 @@ namespace TheLegendOfGustav.Entities.Actors; /// Um inimigo é uma espécie de ator que é /// hostil ao jogador. Inimigos são controlados por IA. /// </summary> -public partial class Enemy : Actor +public partial class Enemy : Actor, ISaveable { private EnemyDefinition definition; @@ -17,6 +18,9 @@ public partial class Enemy : Actor this.definition = definition; SetDefinition(definition); } + public Enemy(Vector2I initialPosition, MapData map) : base(initialPosition, map) + { + } /// <summary> /// A alma do ator. Gera ações que são executadas todo turno. @@ -30,9 +34,12 @@ public partial class Enemy : Actor /// <param name="definition">Definição do inimigo.</param> public void SetDefinition(EnemyDefinition definition) { + this.definition = definition; // Definimos as características do ator. base.SetDefinition(this.definition); + Soul?.QueueFree(); + // Definimos qual IA utilizar. switch (definition.AI) { @@ -51,4 +58,27 @@ public partial class Enemy : Actor Soul = null; base.Die(); } + + public new Dictionary<string, Variant> GetSaveData() + { + Dictionary<string, Variant> baseData = base.GetSaveData(); + baseData.Add("definition", definition.ResourcePath); + + return baseData; + } + + public new bool LoadSaveData(Dictionary<string, Variant> saveData) + { + string definitionPath = (string)saveData["definition"]; + EnemyDefinition definition = GD.Load<EnemyDefinition>(definitionPath); + + SetDefinition(definition); + + if (!base.LoadSaveData(saveData)) + { + return false; + } + + return true; + } } |
