Added pickup error text
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user