system<T extends WorldSystem> method
- T make(
- World world
The world's system of type T, made with make the first time.
Throws a StateError if the world was disposed.
Implementation
T system<T extends WorldSystem>(T Function(World world) make) {
if (isDisposed) throw StateError('this World was disposed');
if (_systemsByType[T] case final T system) return system;
final system = make(this);
_systemsByType[T] = system;
// A new list, so a hook running over the old one, which made this
// system, runs no system twice.
final order = system.order;
var at = _systems.length;
while (at > 0 && _systems[at - 1].order > order) {
at--;
}
_systems = [..._systems]..insert(at, system);
return system;
}