tick method

int tick(
  1. double dtSeconds
)

Advances by dtSeconds (Flame's Component.update(dt) convention — a double in seconds) and publishes the new elapsed.

Implementation

int tick(double dtSeconds) {
  final owningSession = session;
  if (owningSession != null) {
    // BUG-54: was `phase == GameSessionPhase.paused` — only that exact
    // phase froze the clock, so `elapsed` kept advancing during
    // loading/ready/won/lost too (e.g. a win/lose overlay still rendered
    // on top of a live game loop). Any phase other than `playing` must
    // freeze it.
    _clock.paused =
        owningSession.snapshot.value.phase != GameSessionPhase.playing;
  }
  final steps = _clock.advance(
    Duration(
      microseconds: (dtSeconds * Duration.microsecondsPerSecond).round(),
    ),
  );
  elapsed.value = _clock.elapsed;
  return steps;
}