diff options
Diffstat (limited to 'scripts/entities/actors/Inventory.cs')
| -rw-r--r-- | scripts/entities/actors/Inventory.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/entities/actors/Inventory.cs b/scripts/entities/actors/Inventory.cs new file mode 100644 index 0000000..ea9569f --- /dev/null +++ b/scripts/entities/actors/Inventory.cs @@ -0,0 +1,35 @@ +using Godot; + +public partial class Inventory : Node { + private Player player; + + public Godot.Collections.Array<ConsumableItem> Items { get; private set; } = []; + + public int Capacity { get; private set; } + + public Inventory(int capacity) { + Capacity = capacity; + } + + public override void _Ready() { + base._Ready(); + player = GetParent<Player>(); + } + + public void Drop(ConsumableItem item) { + Items.Remove(item); + MapData data = player.Map_Data; + data.InsertEntity(item); + data.EmitSignal(MapData.SignalName.EntityPlaced, item); + item.Map_Data = 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); + } +}
\ No newline at end of file |
