item on ground and pickup

This commit is contained in:
cblech
2025-04-14 16:49:29 +02:00
parent 9190b2a16a
commit 1062193785
10 changed files with 147 additions and 3 deletions
@@ -0,0 +1,46 @@
using Godot;
namespace Babushka.scripts.CSharp.Common.Inventory;
public partial class ItemOnGround : Node3D
{
private ItemInstance _itemInstance;
public ItemInstance itemInstance
{
get => _itemInstance;
set
{
_itemInstance = value;
UpdateVisuals();
}
}
public void TryPickUp()
{
GD.Print("Trying to pick up item");
var result = InventoryManager.Instance.CollectItem(itemInstance);
if (result == InventoryActionResult.Success)
{
QueueFree();
}
else
{
GD.Print("Inventory is full");
// TODO: player message
}
}
public void UpdateVisuals()
{
var label = GetNode<Label3D>("ItemLabel");
if (itemInstance.blueprint != null)
{
label.Text = itemInstance.blueprint.name;
}
else
{
label.Text = "Error Item";
}
}
}