Add inventory and pickup components with associated resources and presenters

This commit is contained in:
2025-10-13 18:29:58 +02:00
parent ad3e631d8c
commit 329a942de7
5 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using CryptonymThunder.Code.Autoloads;
using GameCore.ECS;
using GameCore.ECS.Interfaces;
using GameCore.Physics;
using Godot;
namespace CryptonymThunder.Code.Presenters;
public partial class PickupPresenter : Area3D, IEntityPresenter, IPresenterComponent
{
private World _world;
private PresenterRegistry _presenterRegistry;
public Entity CoreEntity { get; set; }
public override void _Ready()
{
BodyEntered += OnBodyEnter;
}
private void OnBodyEnter(Node3D body)
{
if (_presenterRegistry.TryGetEntity(body.GetInstanceId(), out var hitEntity))
{
_world.AddComponent(hitEntity, new CollisionEventComponent(CoreEntity));
}
}
public void Initialize(Entity coreEntity, World world)
{
CoreEntity = coreEntity;
_world = world;
_presenterRegistry = GetNode<PresenterRegistry>("/root/PresenterRegistry");
BodyEntered += OnBodyEnter;
}
public void SyncToPresentation(float delta)
{
}
public void SyncToCore(float delta)
{
}
}