Add inventory and pickup components with associated resources and presenters
This commit is contained in:
43
Code/Presenters/PickupPresenter.cs
Normal file
43
Code/Presenters/PickupPresenter.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user