Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Hypercube.Ecs/Events/IEventBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ void Subscribe<TComponent, TEvent>(Handling.EventHandler<TComponent, TEvent> han
void Unsubscribe<TComponent, TEvent>(Handling.EventHandler<TComponent, TEvent> handler)
where TComponent : IComponent
where TEvent : struct, IEvent;

void Subscribe<TEvent>(Handling.EventHandler<TEvent> handler, int priority = EventHandlerList.NoPriority)
where TEvent : struct, IEvent;

void Unsubscribe<TEvent>(Handling.EventHandler<TEvent> handler)
where TEvent : struct, IEvent;

void Raise<TComponent, TEvent>(Entity entity, ref TComponent component, TEvent args)
where TComponent : IComponent
Expand All @@ -20,4 +26,10 @@ void Raise<TComponent, TEvent>(Entity entity, ref TComponent component, TEvent a
void Raise<TComponent, TEvent>(Entity entity, ref TComponent component, ref TEvent args)
where TComponent : IComponent
where TEvent : struct, IEvent;

void Raise<TEvent>(TEvent args)
where TEvent : struct, IEvent;

void Raise<TEvent>(ref TEvent args)
where TEvent : struct, IEvent;
}
16 changes: 16 additions & 0 deletions src/Hypercube.Ecs/System/EntitySystem.World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,20 @@ protected void Raise<TComponent, TEvent>(Entity entity, ref TComponent component
where TComponent : IComponent
where TEvent : struct, IEvent
=> World.Events.Raise(entity, ref component, ref args);

protected void Subscribe<TEvent>(Events.Handling.EventHandler<TEvent> handler, int priority = EventHandlerList.NoPriority)
where TEvent : struct, IEvent
=> World.Events.Subscribe(handler, priority);

protected void Unsubscribe<TEvent>(Events.Handling.EventHandler<TEvent> handler)
where TEvent : struct, IEvent
=> World.Events.Unsubscribe(handler);

protected void Raise<TEvent>(TEvent args)
where TEvent : struct, IEvent
=> World.Events.Raise(ref args);

protected void Raise<TEvent>(ref TEvent args)
where TEvent : struct, IEvent
=> World.Events.Raise(ref args);
}
Loading