using Godot; namespace Babushka.scripts.CSharp.Common.Inventory; public partial class ItemOnGround : Node3D { private ItemInstance _itemInstance; [Export] private bool _infiniteSupply = false; private Label3D _itemLabel => GetNode("ItemLabel"); private Label3D _pickupErrorLabel => GetNode("PickupErrorLabel"); public ItemInstance itemInstance { get => _itemInstance; set { _itemInstance = value; UpdateVisuals(); } } public void TryPickUp() { var result = InventoryManager.Instance.CollectItem(itemInstance.Clone()); if (result == InventoryActionResult.Success) { if (!_infiniteSupply) { QueueFree(); } } else { _pickupErrorLabel.Text = "Inventory Full"; var tween = GetTree().CreateTween(); tween.TweenInterval(2); tween.TweenCallback(Callable.From(() => _pickupErrorLabel.Text = "")); } } public void UpdateVisuals() { _itemLabel.Text = itemInstance.blueprint?.name ?? "Error Item"; } }