addSystem method

void addSystem(
  1. EntitySystem system, {
  2. bool passive = false,
  3. int group = 0,
})

Adds a system to this world that will be processed by process(). If passive is set to true the system will not be processed by the world. If a group is set, this system will only be processed when calling process() with the same group.

Implementation

void addSystem(EntitySystem system, {bool passive = false, int group = 0}) {
  if (_systems.containsKey(system.runtimeType)) {
    throw ArgumentError.value(
        system,
        'system',
        'A system of type "${system.runtimeType}" has already been added to '
            'the world.');
  }
  system
    .._world = this
    .._passive = passive
    .._group = group;

  _systems[system.runtimeType] = system;
  _systemsList.add(system);
  _time.putIfAbsent(group, () => 0.0);
  _frame.putIfAbsent(group, () => 0);
  componentManager._registerSystem(system);
}