From 639cd8cef403e9e66bf31e7888e786effac2b292 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 24 Oct 2025 21:25:15 -0300 Subject: refactor: Sistema de itens reescrito MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Em tese, este novo sistema é mais fácil de serializar. Descanse em paz pergaminhos, eu não quero reimplementá-los neste novo sistema. --- scripts/Entities/Actors/Inventory.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'scripts/Entities/Actors') diff --git a/scripts/Entities/Actors/Inventory.cs b/scripts/Entities/Actors/Inventory.cs index 057316a..5ae61b4 100644 --- a/scripts/Entities/Actors/Inventory.cs +++ b/scripts/Entities/Actors/Inventory.cs @@ -9,7 +9,7 @@ public partial class Inventory(int capacity) : Node { private Player player; public int Capacity { get; private set; } = capacity; - public Godot.Collections.Array Items { get; private set; } = []; + public Godot.Collections.Array Items { get; private set; } = []; public override void _Ready() { @@ -17,29 +17,28 @@ public partial class Inventory(int capacity) : Node player = GetParent(); } - public void Drop(ConsumableItem item) + public void Drop(Item item) { Items.Remove(item); MapData data = player.MapData; - - data.InsertEntity(item); - data.EmitSignal(MapData.SignalName.EntityPlaced, item); - - item.MapData = data; - item.GridPosition = player.GridPosition; - MessageLogData.Instance.AddMessage($"Você descarta {item.DisplayName}."); + ItemEntity itemEnt = new(player.GridPosition, data, item); + + data.InsertEntity(itemEnt); + data.EmitSignal(MapData.SignalName.EntityPlaced, itemEnt); + + MessageLogData.Instance.AddMessage($"Você descarta {item.Definition.DisplayName}."); } - public void Add(ConsumableItem item) + public void Add(Item item) { if (Items.Count >= Capacity) return; Items.Add(item); } - public void RemoveItem(ConsumableItem item) + public void RemoveItem(Item item) { Items.Remove(item); } -- cgit v1.2.3