<?phpnamespace App\Alis;/** * "Skip intro" (not in the C): the films and credits of Robinson's Requiem's introduction skipped, as a player does * it with Escape, until the next step: the flags (the language) before them, the options panel after them. * The phase comes from the files the VM opened (SysVars::$opened): flags.io (loaded early, while the logo film * plays) until baratine.io = the logo and the language (only a playing film is skipped there), then until * newprefs / prefs = the introduction, then done. */final class IntroSkip{ public bool $skipping = false; private float $clock = 0.0; private bool $down = false; private int $seen = 0; private string $phase = 'logo'; /** logo | flags | intro | done */ public function phase(): string { $opened = SysVars::$opened; for ($n = count($opened); $this->seen < $n; $this->seen++) { $name = strtolower(basename((string) $opened[$this->seen])); if ($this->phase === 'logo' && str_starts_with($name, 'flags.')) { $this->phase = 'flags'; } elseif ($this->phase === 'flags' && str_starts_with($name, 'baratin')) { $this->phase = 'intro'; } elseif ($this->phase !== 'done' && (str_starts_with($name, 'newpref') || str_starts_with($name, 'prefs'))) { $this->phase = 'done'; } } if ($this->phase === 'done') { $this->skipping = false; } return $this->phase; } /** * The button is shown: a film before the options panel (the logo, the introduction), or the rest of the * introduction (its titles and credits). Never on the flags, never once the game has started. */ public function offered(): bool { $p = $this->phase(); if ($p === 'done') { return false; } return $p === 'intro' || (isset(FilmVars::$bfilm) && FilmVars::$bfilm->playing !== 0); } /** Each frame: while skipping, Escape pressed and let go, again and again, until the phase changes. */ public function update(float $dt): void { if ($this->skipping && !$this->offered()) { $this->skipping = false; // the flags, or the game: the next step is the player's } if (!$this->skipping) { if ($this->down) { unset(SysVars::$held[\SDLK_ESCAPE]); $this->down = false; } return; } // Escape held 0.12 s, let go 0.12 s, again (set every frame: the host clears the keys not really held) $this->clock = fmod($this->clock + $dt, 0.24); if ($this->clock < 0.12) { SysVars::$held[\SDLK_ESCAPE] = true; SysVars::$button = \SDLK_ESCAPE; $this->down = true; } elseif ($this->down) { unset(SysVars::$held[\SDLK_ESCAPE]); $this->down = false; } }}