Entity constructor

Entity({
  1. Iterable<Component>? children,
  2. int? priority,
  3. Iterable<Behavior<EntityMixin>>? behaviors,
})

The entity is the building block of a game. It represents a game object that can hold multiple Behaviors, which in turn define how the entity behaves.

The visualization of the entity is defined by the Components that are attached to it.

Implementation

Entity({
  super.children,
  super.priority,
  Iterable<Behavior>? behaviors,
}) : assert(
        children?.whereType<Behavior>().isEmpty ?? true,
        'Behaviors cannot be added to as a child directly.',
      ) {
  if (behaviors != null) {
    addAll(behaviors);
  }
}