operator + method

Entity operator +(
  1. Component component
)

Adds component to the entity.

Implementation

Entity operator +(Component component) {
  assert(!isDestroyed.value, 'Tried adding component to destroyed entity: ${toJson()}');
  final copy = Map<Type, Component>.from(components.value);
  // Create new list and then add.
  copy[component.runtimeType] = component..ref = this;
  components.add(copy);
  // Call onAdded.
  component.onAdded();
  return this;
}