diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-24 21:25:15 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-24 21:25:15 -0300 |
| commit | 639cd8cef403e9e66bf31e7888e786effac2b292 (patch) | |
| tree | a1b3872a91ad599a71629d0d62c72125138c5c14 /scripts/Entities/Actors/Inventory.cs | |
| parent | 52c32a24044aa574c9e7bf7aa4e2499349cc36b2 (diff) | |
refactor: Sistema de itens reescrito
Em tese, este novo sistema é mais fácil de serializar.
Descanse em paz pergaminhos, eu não quero reimplementá-los
neste novo sistema.
Diffstat (limited to 'scripts/Entities/Actors/Inventory.cs')
| -rw-r--r-- | scripts/Entities/Actors/Inventory.cs | 21 |
1 files changed, 10 insertions, 11 deletions
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<ConsumableItem> Items { get; private set; } = []; + public Godot.Collections.Array<Item> Items { get; private set; } = []; public override void _Ready() { @@ -17,29 +17,28 @@ public partial class Inventory(int capacity) : Node player = GetParent<Player>(); } - 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); } |
