summaryrefslogtreecommitdiff
path: root/scripts/Entities/Actors/Actor.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-10-26 20:02:15 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-10-26 20:02:15 -0300
commitf4ed469fc9eaeebf39093fbf6601581cc10c6e2f (patch)
treed8f29ae3288e950b5fb1f5251845d57949ca2ac0 /scripts/Entities/Actors/Actor.cs
parent639cd8cef403e9e66bf31e7888e786effac2b292 (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/Actor.cs')
-rw-r--r--scripts/Entities/Actors/Actor.cs49
1 files changed, 48 insertions, 1 deletions
diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs
index ec00e30..71a32a5 100644
--- a/scripts/Entities/Actors/Actor.cs
+++ b/scripts/Entities/Actors/Actor.cs
@@ -1,4 +1,5 @@
using Godot;
+using Godot.Collections;
using TheLegendOfGustav.Magic;
using TheLegendOfGustav.Map;
using TheLegendOfGustav.Utils;
@@ -9,7 +10,7 @@ namespace TheLegendOfGustav.Entities.Actors;
/// A classe de ator define um personagem no jogo.
/// </summary>
[GlobalClass]
-public partial class Actor : Entity
+public partial class Actor : Entity, ISaveable
{
#region Fields
private int mp;
@@ -29,6 +30,9 @@ public partial class Actor : Entity
{
SetDefinition(definition);
}
+ public Actor(Vector2I initialPosition, MapData map) : base(initialPosition, map)
+ {
+ }
#endregion
#region Signals
@@ -278,5 +282,48 @@ public partial class Actor : Entity
MapData.UnregisterBlockingEntity(this);
EmitSignal(SignalName.Died);
}
+
+ public new Dictionary<string, Variant> GetSaveData()
+ {
+ Dictionary<string, Variant> baseData = base.GetSaveData();
+ baseData.Add("energy", Energy);
+ baseData.Add("max_hp", MaxHp);
+ baseData.Add("hp", Hp);
+ baseData.Add("max_mp", MaxMp);
+ baseData.Add("mp", MaxMp);
+ baseData.Add("atk", Atk);
+ baseData.Add("def", Def);
+ baseData.Add("men", Men);
+ baseData.Add("mp_regen_rate", MpRegenRate);
+ baseData.Add("mp_regen_per_turn", MpRegenPerTurn);
+ baseData.Add("spell_book", SpellBook.GetSaveData());
+
+ return baseData;
+ }
+
+ public new bool LoadSaveData(Dictionary<string, Variant> saveData)
+ {
+ if (!base.LoadSaveData(saveData))
+ {
+ return false;
+ }
+
+ if (!SpellBook.LoadSaveData((Dictionary<string, Variant>)saveData["spell_book"]))
+ {
+ return false;
+ }
+
+ Energy = (int)saveData["energy"];
+ MaxHp = (int)saveData["max_hp"];
+ Hp = (int)saveData["hp"];
+ MaxMp = (int)saveData["max_mp"];
+ Mp = (int)saveData["max_mp"];
+ Atk = (int)saveData["atk"];
+ Def = (int)saveData["def"];
+ Men = (int)saveData["men"];
+ MpRegenRate = (int)saveData["mp_regen_rate"];
+ MpRegenPerTurn = (int)saveData["mp_regen_per_turn"];
+ return true;
+ }
#endregion
} \ No newline at end of file