EventChannel<T extends EcsEvent> class

A type-safe event channel that stores events in ECS DataColumns.

Event channels use ring buffers on dense column arrays for optimal performance. Storage automatically selects between FloatColumn, IntColumn, and ObjectColumn based on event structure for SoA layout and SIMD compatibility.

Events have a frame-bound lifecycle:

  1. Send events during frame execution
  2. Read events during frame execution
  3. Clear events at end of frame/schedule

Example:

// Register channel in plugin
class MyPlugin extends Plugin {
  @override
  void install(World world) {
    world.events.register<DamageEvent>();
  }
}

// Use in systems
void damageSystem(World world) {
  final writer = world.events.writer<DamageEvent>();
  final reader = world.events.reader<DamageEvent>();

  // Send events
  writer.send(DamageEvent(entity: target, amount: 10));

  // Read events
  for (final event in reader.iter()) {
    // Handle event
  }
}
Implemented types

Constructors

EventChannel.withColumn({required DataColumn column, required EventColumnConfig<T> config, required int capacity, EventCapacityPolicy capacityPolicy = EventCapacityPolicy.dropNew, void metricsHook(EventCapacityOverflow)?})
A type-safe event channel that stores events in ECS DataColumns.

Properties

capacity → int
Maximum number of events this channel can hold.
final
capacityPolicy → EventCapacityPolicy
Policy for handling buffer overflow.
final
hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Whether the channel is empty.
no setter
isFull → bool
Whether the channel is full.
no setter
length → int
Current number of events in the channel.
no setter
metricsHook → void Function(EventCapacityOverflow)?
Optional hook for capacity overflow metrics.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stats → EventChannelStats
Lifecycle counters for this channel — the "channel watermark".
no setter

Methods

clear() → void
Clear all events from this channel.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readBatch(int count) → List<T>
Read multiple events in batch.
resetStats() → void
Zero all watermark counters (does not touch buffered events).
send(T event) → bool
Send an event to this channel.
sendBatch(List<T> events) → int
Send multiple events in batch.
toReader() → EventReader<T>
Create an iterator for reading events.
toString() → String
A string representation of this object.
inherited
toWriter() → EventWriter<T>
Create a writer for sending events.

Operators

operator ==(Object other) → bool
The equality operator.
inherited