feat: add extensible item inventory and world system

This commit is contained in:
2026-08-23 23:16:49 +02:00
parent 25e32f20d9
commit f4331f426c
48 changed files with 693 additions and 0 deletions
@@ -0,0 +1,42 @@
using Game.Features.Items.Contracts;
using Godot;
namespace Game.Features.Items.Godot;
public sealed class PlayerHeldItemPresenter(
ItemWorldController itemWorld,
Node3D leftHandAnchor,
Node3D rightHandAnchor
) : IHeldItemPresenter
{
public bool TryShowHeld(IItemInstance item, Hand hand)
{
if (!itemWorld.TryGetController(item.Info.Id, out WorldItemController controller))
{
return false;
}
Node3D anchor = hand == Hand.Left ? leftHandAnchor : rightHandAnchor;
controller.SetHeld(anchor, item);
return true;
}
public bool TryShowDropped(IItemInstance item, Vector3 worldPosition)
{
if (!itemWorld.TryGetController(item.Info.Id, out WorldItemController controller))
{
return false;
}
controller.SetDropped(worldPosition, item);
return true;
}
public void Refresh(IItemInstance item)
{
if (itemWorld.TryGetController(item.Info.Id, out WorldItemController controller))
{
controller.ApplyState(item);
}
}
}