flightListener = function (array $event): void { if ($this->scenes()->current() !== $this) { return; } $address = trim((string) ($event['address'] ?? '')); if ($address !== '') { $this->scenes()->switchTo(GeoFlightScene::class, ['address' => $address], false); } }; $this->engine->bridge->on('fly-to-address', $this->flightListener); $this->missionListener = function (array $event): void { if ($this->scenes()->current() !== $this) { return; } $address = trim((string) ($event['address'] ?? '')); if ($address !== '') { $this->scenes()->switchTo(PlayScene::class, ['address' => $address], false); } }; $this->engine->bridge->on('mission-at-address', $this->missionListener); } public function exit(): void { if ($this->flightListener !== null) { $this->engine->bridge->removeListener('fly-to-address', $this->flightListener); $this->flightListener = null; } if ($this->missionListener !== null) { $this->engine->bridge->removeListener('mission-at-address', $this->missionListener); $this->missionListener = null; } } protected function items(): array { return [ ['START MISSION', null, fn () => $this->scenes()->switchTo(PlayScene::class)], ['MISSION A L ADRESSE', null, fn () => $this->scenes()->switchTo(AddressEntryScene::class, ['purpose' => 'mission'])], ['SURVOL A L ADRESSE', null, fn () => $this->scenes()->switchTo(AddressEntryScene::class, ['purpose' => 'flight'])], ['SURVOL LIBRE', null, fn () => $this->scenes()->switchTo(GeoFlightScene::class)], ]; } protected function renderBackground(Renderer $r): void { $r->clear([32, 57, 53]); $r->fillRect(20, 22, 280, 436, [47, 73, 59]); $r->fillRect(35, 42, 250, 2, [211, 189, 130]); $this->font()->draw($r, '1940 - ARCADE FICTION', 160, 170, 1, [229, 213, 160], 'center'); $this->font()->draw($r, 'ARROWS / WASD + SPACE', 160, 345, 1, [241, 237, 217], 'center'); } }