tick static method

Future<void> tick()

A single simulation tick.

Takes the simulator through all actions within the next pending timestamp, and passes through all events and phases on the way.

If there are no timestamps pending to execute, nothing will execute.

Implementation

static Future<void> tick() async {
  if (_injectedActions.isNotEmpty) {
    // injected actions will automatically be executed during tickExecute
    await tickExecute(() {});

    // don't continue through the tick for injected actions, come back around
    return;
  }

  final nextTimeStamp = _pendingTimestamps.firstKey();
  if (nextTimeStamp == null) {
    return;
  }

  _currentTimestamp = nextTimeStamp;

  await tickExecute(() async {
    for (final func in _pendingTimestamps[nextTimeStamp]!) {
      await func();
    }
  });
  _pendingTimestamps.remove(_currentTimestamp);
}