Added pickup error text

This commit is contained in:
cblech
2025-04-14 17:36:29 +02:00
parent 1062193785
commit e99b574d1f
3 changed files with 43 additions and 14 deletions
+15 -12
View File
@@ -5,6 +5,12 @@ public partial class ItemOnGround : Node3D
{
private ItemInstance _itemInstance;
[Export]
private bool _infiniteSupply = false;
private Label3D _itemLabel => GetNode<Label3D>("ItemLabel");
private Label3D _pickupErrorLabel => GetNode<Label3D>("PickupErrorLabel");
public ItemInstance itemInstance
{
get => _itemInstance;
@@ -22,25 +28,22 @@ public partial class ItemOnGround : Node3D
var result = InventoryManager.Instance.CollectItem(itemInstance);
if (result == InventoryActionResult.Success)
{
QueueFree();
if (!_infiniteSupply)
{
QueueFree();
}
}
else
{
GD.Print("Inventory is full");
// TODO: player message
_pickupErrorLabel.Text = "Inventory Full";
var tween = GetTree().CreateTween();
tween.TweenInterval(2);
tween.TweenCallback(Callable.From(() => _pickupErrorLabel.Text = ""));
}
}
public void UpdateVisuals()
{
var label = GetNode<Label3D>("ItemLabel");
if (itemInstance.blueprint != null)
{
label.Text = itemInstance.blueprint.name;
}
else
{
label.Text = "Error Item";
}
_itemLabel.Text = itemInstance.blueprint?.name ?? "Error Item";
}
}