<?phpnamespace App\Sim;/** * One Lumikin: a small lantern creature that walks straight ahead until told otherwise. * (x, y): x is the centre column, y the row of the ground pixel under its feet (the body is the rows above). */final class Lumi{ public const WALK = 'walk'; public const FALL = 'fall'; public const GLIDE = 'glide'; public const CLIMB = 'climb'; public const STOP = 'stop'; public const BRIDGE = 'bridge'; public const BASH = 'bash'; public const MINE = 'mine'; public const DIG = 'dig'; public const LEAVE = 'leave'; public string $state = self::FALL; /** ticks in the current state (animation, work rhythm) */ public int $frame = 0; /** pixels fallen since the fall began */ public int $fall = 0; public bool $climber = false; public bool $glider = false; /** ticks before it bursts, -1: no fuse */ public int $fuse = -1; public int $bricks = 0; public int $work = 0; public bool $alive = true; public function __construct(public readonly int $id, public int $x, public int $y, public int $dir = 1) { } public function is(string ...$states): bool { return in_array($this->state, $states, true); } public function set(string $state): void { $this->state = $state; $this->frame = 0; $this->work = 0; }}