blob: ea9569f21eed9da5bd7200d18c5c7e0b0c954818 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
}
}
|