Implement inventory system with item management and pickup functionality
This commit is contained in:
26
GameCore/Inventory/InventorySystem.cs
Normal file
26
GameCore/Inventory/InventorySystem.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Events;
|
||||
|
||||
namespace GameCore.Inventory;
|
||||
|
||||
public class InventorySystem : ISystem
|
||||
{
|
||||
private readonly World _world;
|
||||
|
||||
public InventorySystem(World world)
|
||||
{
|
||||
_world = world;
|
||||
_world.Subscribe<AddItemToInventoryEvent>(OnAddItem);
|
||||
}
|
||||
|
||||
public void Update(World world, float deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnAddItem(AddItemToInventoryEvent e)
|
||||
{
|
||||
var inventory = _world.GetComponent<InventoryComponent>(e.Target);
|
||||
inventory?.AddItem(e.Item);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user