blob: 057316acc5037d40b8abda74002ccf61da63fcf5 (
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
36
37
38
39
40
41
42
43
44
45
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;
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);
}
}
|