diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
| commit | c6bbb834f7758027c0df338f1520f34fad3befea (patch) | |
| tree | 1818cd23c24be16fbe19b16dd0a510874d440d83 /scripts/Entities/Actors/Inventory.cs | |
| parent | f1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff) | |
Organização
Diffstat (limited to 'scripts/Entities/Actors/Inventory.cs')
| -rw-r--r-- | scripts/Entities/Actors/Inventory.cs | 46 |
1 files changed, 46 insertions, 0 deletions
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<ConsumableItem> Items { get; private set; } = []; + + public override void _Ready() + { + base._Ready(); + Player = GetParent<Player>(); + } + + 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 |
