resume method

Implementation

SdkResult<GameSessionSnapshot> resume(GamePauseReason reason) {
  final current = snapshot.value;
  if (current.phase != GameSessionPhase.paused ||
      !current.pauseReasons.contains(reason)) {
    return _reject('Pause reason is not active');
  }
  final reasons = {...current.pauseReasons}..remove(reason);
  final nextPhase = reasons.isEmpty
      ? GameSessionPhase.playing
      : GameSessionPhase.paused;
  snapshot.value = current.copyWith(phase: nextPhase, pauseReasons: reasons);
  // Same reasoning as `pause()` above: only the resume that actually
  // clears every pause reason (phase genuinely returns to playing) is a
  // real transition worth recording — a resume that leaves another
  // reason still active doesn't change the observable phase.
  if (nextPhase == GameSessionPhase.playing) {
    events.add(GameSessionPhase.playing);
    _appendTimelineEntry(GameSessionPhase.playing);
  } else {
    _recordPauseReasons(reasons);
  }
  return SdkSuccess(snapshot.value);
}