<?php/* * dmmotor — a flickering fire light (fireflicker_t of p_lights.c). * Copyright (C) 1993-1996 by id Software, Inc.; PHP port for dmmotor. GPL v2 (see LICENSE). */namespace App\Dm\Play;use App\Dm\Sector;final class FireFlicker implements Thinker{ public int $count = 4; public int $maxLight = 0; public int $minLight = 0; public function __construct(public Sector $sector) { } public static function spawn(World $w, Sector $sec): self { $sec->special = 0; $f = new self($sec); $f->maxLight = $sec->lightLevel; $f->minLight = World::minSurroundingLight($sec, $sec->lightLevel) + 16; return $f; } public function think(World $w): void { if (--$this->count > 0) { return; } $amount = (Random::p() & 3) * 16; if ($this->sector->lightLevel - $amount < $this->minLight) { $this->sector->lightLevel = $this->minLight; } else { $this->sector->lightLevel = $this->maxLight - $amount; } $this->count = 4; } public function isRemoved(): bool { return false; }}