<?phpnamespace App\Engine\Map;/** A wall line between two vertices: front side on its right (line_t). */final class Line{ public const BLOCKING = 1; // players and monsters public const BLOCK_MONSTERS = 2; public const TWO_SIDED = 4; public const UNPEG_TOP = 8; public const UNPEG_BOTTOM = 16; public const SECRET = 32; // drawn as a wall on the map public const SOUND_BLOCK = 64; public const MAPPED = 256; public float $dx; public float $dy; public float $length; /** bounding box: top, bottom, left, right */ public array $bbox; public int $flags = 0; /** use / walk action: '', 'door', 'exit', 'switch', 'lift'... */ public string $special = ''; /** extra data of the action: key, target sector char... */ public array $args = []; public ?Side $back = null; public ?Sector $backSector = null; public Sector $frontSector; public int $validCount = 0; public bool $mapped = false; public function __construct(public int $id, public float $x1, public float $y1, public float $x2, public float $y2, public Side $front) { $this->dx = $x2 - $x1; $this->dy = $y2 - $y1; $this->length = sqrt($this->dx ** 2 + $this->dy ** 2); $this->bbox = [max($y1, $y2), min($y1, $y2), min($x1, $x2), max($x1, $x2)]; $this->frontSector = $front->sector; } public function setBack(Side $back): void { $this->back = $back; $this->backSector = $back->sector; $this->flags |= self::TWO_SIDED; } /** 0 = front (right) side, 1 = back (P_PointOnLineSide). */ public function side(float $x, float $y): int { return (($x - $this->x1) * $this->dy - ($y - $this->y1) * $this->dx) >= 0 ? 0 : 1; }}