findBehaviors<T extends Behavior<EntityMixin>> method

Iterable<T> findBehaviors<T extends Behavior<EntityMixin>>()

Returns a list of behaviors with the given type, that are attached to this entity.

This will only return behaviors that have a completed lifecycle, aka they are fully mounted.

Implementation

Iterable<T> findBehaviors<T extends Behavior>() {
  if (_behaviors == null) {
    children.register<Behavior>();
    _behaviors ??= children.query<Behavior>();
  }
  return _behaviors!.whereType<T>();
}