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/Items/Item.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/Items/Item.cs')
| -rw-r--r-- | scripts/Entities/Items/Item.cs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/scripts/Entities/Items/Item.cs b/scripts/Entities/Items/Item.cs index 0eeffd8..17c318c 100644 --- a/scripts/Entities/Items/Item.cs +++ b/scripts/Entities/Items/Item.cs @@ -1,11 +1,12 @@ using System.Reflection.Metadata; using Godot; +using Godot.Collections; using TheLegendOfGustav.Entities.Actions; using TheLegendOfGustav.Entities.Actors; namespace TheLegendOfGustav.Entities.Items; -public partial class Item : RefCounted +public partial class Item : RefCounted, ISaveable { public Item(ItemResource definition) @@ -14,6 +15,10 @@ public partial class Item : RefCounted Uses = Definition.MaxUses; } + public Item() + { + } + public ItemResource Definition { get; private set; } public int Uses { get; set; } @@ -58,4 +63,21 @@ public partial class Item : RefCounted Inventory inventory = consumer.Inventory; inventory.RemoveItem(this); } + + public Dictionary<string, Variant> GetSaveData() + { + return new() + { + {"definition", Definition.ResourcePath}, + {"uses", Uses} + }; + } + + public bool LoadSaveData(Dictionary<string, Variant> saveData) + { + Definition = GD.Load<ItemResource>((string)saveData["definition"]); + Uses = (int)saveData["uses"]; + + return true; + } }
\ No newline at end of file |
