item on ground and pickup
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user