From c6bbb834f7758027c0df338f1520f34fad3befea Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 9 Sep 2025 19:09:34 -0300 Subject: Organização MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Entities/Actors/Inventory.cs | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/Entities/Actors/Inventory.cs (limited to 'scripts/Entities/Actors/Inventory.cs') diff --git a/scripts/Entities/Actors/Inventory.cs b/scripts/Entities/Actors/Inventory.cs new file mode 100644 index 0000000..f65dc59 --- /dev/null +++ b/scripts/Entities/Actors/Inventory.cs @@ -0,0 +1,46 @@ +using Godot; +using TheLegendOfGustav.Entities.Items; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.Entities.Actors; + +public partial class Inventory(int capacity) : Node +{ + private Player Player { get; set; } + public int Capacity { get; private set; } = capacity; + public Godot.Collections.Array Items { get; private set; } = []; + + public override void _Ready() + { + base._Ready(); + Player = GetParent(); + } + + public void Drop(ConsumableItem 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}."); + } + + public void Add(ConsumableItem item) + { + if (Items.Count >= Capacity) return; + + Items.Add(item); + } + + public void RemoveItem(ConsumableItem item) + { + Items.Remove(item); + } +} \ No newline at end of file -- cgit v1.2.3