43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
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))
|
|
{
|
|
GD.Print($"Collision detected between {CoreEntity.Id} and {hitEntity.Id}");
|
|
_world.AddComponent(hitEntity, new CollisionEventComponent(CoreEntity));
|
|
}
|
|
}
|
|
|
|
public void Initialize(Entity coreEntity, World world)
|
|
{
|
|
CoreEntity = coreEntity;
|
|
_world = world;
|
|
_presenterRegistry = GetNode<PresenterRegistry>("/root/PresenterRegistry");
|
|
}
|
|
|
|
public void SyncToPresentation(float delta)
|
|
{
|
|
}
|
|
|
|
public void SyncToCore(float delta)
|
|
{
|
|
}
|
|
} |