From f4ed469fc9eaeebf39093fbf6601581cc10c6e2f Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 26 Oct 2025 20:02:15 -0300 Subject: feat:save AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O vazio dentro de mim é como uma xícara de café esquecida no canto da mesa. --- scripts/Entities/Items/ItemEntity.cs | 40 ++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'scripts/Entities/Items/ItemEntity.cs') diff --git a/scripts/Entities/Items/ItemEntity.cs b/scripts/Entities/Items/ItemEntity.cs index e646e40..66944ce 100644 --- a/scripts/Entities/Items/ItemEntity.cs +++ b/scripts/Entities/Items/ItemEntity.cs @@ -1,10 +1,11 @@ using Godot; +using Godot.Collections; using TheLegendOfGustav.Entities; using TheLegendOfGustav.Map; namespace TheLegendOfGustav.Entities.Items; -public partial class ItemEntity : Entity +public partial class ItemEntity : Entity, ISaveable { public Item Item { get; private set; } @@ -14,7 +15,7 @@ public partial class ItemEntity : Entity // Eu quero muito reescrever o jogo do zero, mas não tenho tempo :( EntityDefinition sad = new() { - blocksMovement = true, + blocksMovement = false, name = item.Definition.DisplayName, texture = item.Definition.Icon, Type = EntityType.ITEM, @@ -22,4 +23,39 @@ public partial class ItemEntity : Entity SetDefinition(sad); } + public ItemEntity(Vector2I initialPosition, MapData map) : base(initialPosition, map) + { + } + + public new Dictionary GetSaveData() + { + Dictionary baseData = base.GetSaveData(); + baseData.Add("item", Item.GetSaveData()); + + return baseData; + } + + public new bool LoadSaveData(Dictionary saveData) + { + Item = new(); + + if (!Item.LoadSaveData((Dictionary)saveData["item"])) + { + return false; + } + // Eu quero muito reescrever o jogo do zero, mas não tenho tempo :( + EntityDefinition sad = new() + { + blocksMovement = false, + name = Item.Definition.DisplayName, + texture = Item.Definition.Icon, + Type = EntityType.ITEM, + }; + + SetDefinition(sad); + + base.LoadSaveData(saveData); + + return true; + } } \ No newline at end of file -- cgit v1.2.3