diff --git a/src/Hypercube.Ecs/Events/IEventBus.cs b/src/Hypercube.Ecs/Events/IEventBus.cs index 240dcfc..f9e5ba1 100644 --- a/src/Hypercube.Ecs/Events/IEventBus.cs +++ b/src/Hypercube.Ecs/Events/IEventBus.cs @@ -12,6 +12,12 @@ void Subscribe(Handling.EventHandler han void Unsubscribe(Handling.EventHandler handler) where TComponent : IComponent where TEvent : struct, IEvent; + + void Subscribe(Handling.EventHandler handler, int priority = EventHandlerList.NoPriority) + where TEvent : struct, IEvent; + + void Unsubscribe(Handling.EventHandler handler) + where TEvent : struct, IEvent; void Raise(Entity entity, ref TComponent component, TEvent args) where TComponent : IComponent @@ -20,4 +26,10 @@ void Raise(Entity entity, ref TComponent component, TEvent a void Raise(Entity entity, ref TComponent component, ref TEvent args) where TComponent : IComponent where TEvent : struct, IEvent; + + void Raise(TEvent args) + where TEvent : struct, IEvent; + + void Raise(ref TEvent args) + where TEvent : struct, IEvent; } diff --git a/src/Hypercube.Ecs/System/EntitySystem.World.cs b/src/Hypercube.Ecs/System/EntitySystem.World.cs index 269a479..3a4b0c9 100644 --- a/src/Hypercube.Ecs/System/EntitySystem.World.cs +++ b/src/Hypercube.Ecs/System/EntitySystem.World.cs @@ -74,4 +74,20 @@ protected void Raise(Entity entity, ref TComponent component where TComponent : IComponent where TEvent : struct, IEvent => World.Events.Raise(entity, ref component, ref args); + + protected void Subscribe(Events.Handling.EventHandler handler, int priority = EventHandlerList.NoPriority) + where TEvent : struct, IEvent + => World.Events.Subscribe(handler, priority); + + protected void Unsubscribe(Events.Handling.EventHandler handler) + where TEvent : struct, IEvent + => World.Events.Unsubscribe(handler); + + protected void Raise(TEvent args) + where TEvent : struct, IEvent + => World.Events.Raise(ref args); + + protected void Raise(ref TEvent args) + where TEvent : struct, IEvent + => World.Events.Raise(ref args); }