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/Magic/SpellBook.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/Magic/SpellBook.cs')
| -rw-r--r-- | scripts/Magic/SpellBook.cs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/Magic/SpellBook.cs b/scripts/Magic/SpellBook.cs index 8ccba71..914add6 100644 --- a/scripts/Magic/SpellBook.cs +++ b/scripts/Magic/SpellBook.cs @@ -1,8 +1,9 @@ using Godot; +using Godot.Collections; namespace TheLegendOfGustav.Magic; -public partial class SpellBook : Node +public partial class SpellBook : Node, ISaveable { public Godot.Collections.Array<SpellResource> KnownSpells { get; private set; } = []; @@ -17,4 +18,31 @@ public partial class SpellBook : Node public void ForgetSpell(SpellResource spell) { KnownSpells.Remove(spell); } + + public Dictionary<string, Variant> GetSaveData() + { + Array<string> spellPaths = []; + foreach(SpellResource spell in KnownSpells) + { + spellPaths.Add(spell.ResourcePath); + } + + return new() + { + {"spells", spellPaths} + }; + } + + public bool LoadSaveData(Dictionary<string, Variant> saveData) + { + Array<string> paths = (Array<string>)saveData["spells"]; + + foreach(string path in paths) + { + SpellResource spell = GD.Load<SpellResource>(path); + KnownSpells.Add(spell); + } + + return true; + } }
\ No newline at end of file |
