class

PointClickEngine::Core::Events::EventBus

Inherits Reference < Object

Central event bus for the entire engine

Example usage:

bus = EventBus.new

# Subscribe to specific event type
bus.subscribe(PlayerMovedEvent) do |event|
  puts "Player moved to #{event.position}"
end

# Publish an event
bus.publish(PlayerMovedEvent.new(position, old_position))

# Process queued events
bus.process

Instance methods

clear

Clear everything

Source
clear_handlers

Clear all handlers

Source
clear_queue

Clear all pending events

Source
emit(event : GameEvent)

Alias for publish

Source
handler_count(event_class : T.class) : Int32 forall T

Get handler count for an event type

Source
has_handlers?(event_class : T.class) : Bool forall T

Check if any handlers exist for an event type

Source
pending?

Check if there are pending events

Source
pending_count

Get number of pending events

Source
process

Process all queued events

Source
process_one

Process a single event from the queue

Source
publish(event : GameEvent)

Queue an event for deferred processing

Source
publish_sync(event : GameEvent)

Publish an event immediately (synchronous)

Source
stats

Get statistics

Source
subscribe(event_class : T.class, priority : HandlerPriority = HandlerPriority::Normal, owner : String | Nil = nil, &handler : T -> Nil) : UInt64 forall T

Subscribe to a specific event type with a typed handler

Returns a subscription ID that can be used to unsubscribe

Source
subscribe(event_class : T.class, priority : Int32, owner : String | Nil = nil, &handler : T -> Nil) : UInt64 forall T

Subscribe with explicit priority value

Source
unsubscribe(subscription_id : UInt64) : Bool

Unsubscribe a handler by its ID

Source
unsubscribe_all(owner : String)

Unsubscribe all handlers for a specific owner

Source
unsubscribe_all_for(event_class : T.class) forall T

Unsubscribe all handlers for a specific event type

Source