feat: add extensible item inventory and world system
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user