You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/Inventory/ItemOnGround.cs

47 lines
988 B

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";
}
}
}