EN
games/dmmotor / src / Dm / Play / Glow.php · commit 9d248a4
<?php/* * dmmotor — a light that glows up and down (glow_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 Glow implements Thinker{    private const GLOWSPEED = 8;    public int $minLight = 0;    public int $maxLight = 0;    public int $direction = -1;    public function __construct(public Sector $sector)    {    }    public static function spawn(World $w, Sector $sec): self    {        $g = new self($sec);        $g->minLight = World::minSurroundingLight($sec, $sec->lightLevel);        $g->maxLight = $sec->lightLevel;        $sec->special = 0;        return $g;    }    public function think(World $w): void    {        $s = $this->sector;        if ($this->direction === -1) {            $s->lightLevel -= self::GLOWSPEED;            if ($s->lightLevel <= $this->minLight) {                $s->lightLevel += self::GLOWSPEED;                $this->direction = 1;            }        } else {            $s->lightLevel += self::GLOWSPEED;            if ($s->lightLevel >= $this->maxLight) {                $s->lightLevel -= self::GLOWSPEED;                $this->direction = -1;            }        }    }    public function isRemoved(): bool    {        return false;    }}