summaryrefslogtreecommitdiff
path: root/scripts/Entities/Items/ItemEntity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Entities/Items/ItemEntity.cs')
-rw-r--r--scripts/Entities/Items/ItemEntity.cs40
1 files changed, 38 insertions, 2 deletions
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<string, Variant> GetSaveData()
+ {
+ Dictionary<string, Variant> baseData = base.GetSaveData();
+ baseData.Add("item", Item.GetSaveData());
+
+ return baseData;
+ }
+
+ public new bool LoadSaveData(Dictionary<string, Variant> saveData)
+ {
+ Item = new();
+
+ if (!Item.LoadSaveData((Dictionary<string, Variant>)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