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/Entity.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'scripts/Entities/Entity.cs') diff --git a/scripts/Entities/Entity.cs b/scripts/Entities/Entity.cs index b7dbcc2..76002b1 100644 --- a/scripts/Entities/Entity.cs +++ b/scripts/Entities/Entity.cs @@ -1,4 +1,5 @@ using Godot; +using Godot.Collections; using TheLegendOfGustav.Map; using TheLegendOfGustav.Utils; @@ -18,7 +19,7 @@ public enum EntityType /// /// Classe para elementos móveis que o jogador pode interagir. /// -public abstract partial class Entity : Sprite2D +public abstract partial class Entity : Sprite2D, ISaveable { private Vector2I gridPosition = Vector2I.Zero; @@ -138,4 +139,26 @@ public abstract partial class Entity : Sprite2D Type = definition.Type; Texture = definition.texture; } + + public Dictionary GetSaveData() + { + return new() + { + {"position_x", GridPosition.X}, + {"position_y", GridPosition.Y}, + {"blocks_movement", BlocksMovement}, + {"name", DisplayName}, + {"layer", (int)Type}, + + }; + } + + public bool LoadSaveData(Dictionary saveData) + { + GridPosition = new((int)saveData["position_x"], (int)saveData["position_y"]); + BlocksMovement = (bool)saveData["blocks_movement"]; + DisplayName = (string)saveData["name"]; + Type = (EntityType)(int)saveData["layer"]; + return true; + } } \ No newline at end of file -- cgit v1.2.3