EntitySpawnListener mixin
Hears every entity spawning and despawning, anywhere in the game.
The broad counterpart to EntityLifecycleListener. Mixed into a
GameListener - typically a GameSystem - and collected by GameState's
composition walk, so it hears the whole world:
class SpatialIndexSystem extends GameSystem with EntitySpawnListener {
@override
void onEntitySpawned(Entity entity) {
if (entity.tryGet<Collider2D>() != null) index.insert(entity);
}
}
Filtering by archetype is expected here, not a smell: a listener at this scope asked to see everything. Use EntityLifecycleListener instead when a struct only cares about its own entities - that one needs no filter.
- Superclass constraints
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- listensToEvents → bool
-
Whether this listener should receive events right now.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
disableAfterUncaught(
) → void -
Stops this listener receiving events, after it threw out of one.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onEntityDespawned(
Entity entity) → void -
entityis going away. Its row is still readable here and never again afterwards. -
onEntitySpawned(
Entity entity) → void -
entityhas been created, with its field defaults already stamped into the row. Fired from the same call site as EntityLifecycleListener.onEntityMounted, so the two cannot disagree about when a spawn happened. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited