Class EventBus
- Namespace
- Core
- Assembly
- Core.dll
High-performance event bus for decoupled system communication Features: Type-safe events, zero-allocation processing, frame-coherent batching Performance: ZERO allocations during gameplay (no boxing), batch event processing
Architecture: Uses typed EventQueue{T} wrapper to avoid boxing and reflection See: Assets/Archon-Engine/Docs/Engine/data-flow-architecture.md
public class EventBus
- Inheritance
-
objectEventBus
Constructors
EventBus()
public EventBus()
Properties
EventsInQueue
public int EventsInQueue { get; }
Property Value
- int
EventsProcessedTotal
public int EventsProcessedTotal { get; }
Property Value
- int
IsActive
public bool IsActive { get; }
Property Value
- bool
Methods
Clear()
Clear all events and listeners - useful for scene changes
public void Clear()
Dispose()
public void Dispose()
Emit<T>(T)
Emit an event - queued for frame-coherent processing ZERO ALLOCATION: Event stays as struct T in EventQueue{T}
public void Emit<T>(T gameEvent) where T : struct, IGameEvent
Parameters
gameEventT
Type Parameters
T
LogDebugInfo()
Debug information for editor
public void LogDebugInfo()
ProcessEvents()
Process all queued events - call once per frame Frame-coherent processing ensures consistent event ordering ZERO ALLOCATION: No boxing, events stay as struct T throughout
public void ProcessEvents()
Subscribe<T>(Action<T>)
Subscribe to events of a specific type. Returns a token that can be disposed to unsubscribe.
public IDisposable Subscribe<T>(Action<T> handler) where T : struct, IGameEvent
Parameters
handlerAction<T>
Returns
- IDisposable
Type Parameters
T
Unsubscribe<T>(Action<T>)
Unsubscribe from events of a specific type
public void Unsubscribe<T>(Action<T> handler) where T : struct, IGameEvent
Parameters
handlerAction<T>
Type Parameters
T