26 lines
566 B
C#
26 lines
566 B
C#
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);
|
|
}
|
|
} |