Add inventory and pickup components with associated resources and presenters
This commit is contained in:
@@ -10,6 +10,7 @@ using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Events;
|
||||
using GameCore.Input;
|
||||
using GameCore.Inventory;
|
||||
using GameCore.Movement;
|
||||
using Godot;
|
||||
|
||||
@@ -54,6 +55,8 @@ public partial class GamePresenter : Node
|
||||
_world.RegisterSystem(new JumpSystem());
|
||||
|
||||
_world.RegisterSystem(new AttributeSystem());
|
||||
_world.RegisterSystem(new PickupSystem());
|
||||
_world.RegisterSystem(new InventorySystem(_world));
|
||||
|
||||
_world.RegisterSystem(new WeaponSystem());
|
||||
_world.RegisterSystem(new ProjectileSystem());
|
||||
|
||||
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