specialData = $this; $this->tag = $sector->tag; } public static function start(Sector $sec, int $type): self { $c = new self($sec); $c->type = $type; switch ($type) { case self::FAST_CRUSH_AND_RAISE: $c->crush = true; $c->topHeight = $sec->ceilingHeight; $c->bottomHeight = $sec->floorHeight + 8; $c->direction = -1; $c->speed = self::CEILSPEED * 2; break; case self::SILENT_CRUSH_AND_RAISE: case self::CRUSH_AND_RAISE: case self::LOWER_AND_CRUSH: case self::LOWER_TO_FLOOR: if ($type === self::SILENT_CRUSH_AND_RAISE || $type === self::CRUSH_AND_RAISE) { $c->crush = true; $c->topHeight = $sec->ceilingHeight; } $c->bottomHeight = $sec->floorHeight + ($type !== self::LOWER_TO_FLOOR ? 8 : 0); $c->direction = -1; break; case self::RAISE_TO_HIGHEST: $c->topHeight = World::highestCeilingSurrounding($sec); $c->direction = 1; break; } return $c; } public function think(World $w): void { $sec = $this->sector; $silent = $this->type === self::SILENT_CRUSH_AND_RAISE; switch ($this->direction) { case 1: $res = $w->movePlane($sec, $this->speed, $this->topHeight, false, true, 1); if (!($w->levelTime & 7) && !$silent) { $w->sectorSound($sec, 'stnmov'); } if ($res === World::MOVE_PASTDEST) { if ($this->type === self::RAISE_TO_HIGHEST) { $w->removeActiveCeiling($this); } elseif ($silent || $this->type === self::FAST_CRUSH_AND_RAISE || $this->type === self::CRUSH_AND_RAISE) { if ($silent) { $w->sectorSound($sec, 'pstop'); } $this->direction = -1; } } break; case -1: $res = $w->movePlane($sec, $this->speed, $this->bottomHeight, $this->crush, true, -1); if (!($w->levelTime & 7) && !$silent) { $w->sectorSound($sec, 'stnmov'); } if ($res === World::MOVE_PASTDEST) { if ($silent || $this->type === self::CRUSH_AND_RAISE || $this->type === self::FAST_CRUSH_AND_RAISE) { if ($silent) { $w->sectorSound($sec, 'pstop'); } if ($this->type === self::CRUSH_AND_RAISE || $silent) { $this->speed = self::CEILSPEED; } $this->direction = 1; } elseif ($this->type === self::LOWER_AND_CRUSH || $this->type === self::LOWER_TO_FLOOR) { $w->removeActiveCeiling($this); } } elseif ($res === World::MOVE_CRUSHED) { if ($silent || $this->type === self::CRUSH_AND_RAISE || $this->type === self::LOWER_AND_CRUSH) { $this->speed = self::CEILSPEED / 8; // slow down on what it crushes } } break; } } public function isRemoved(): bool { return $this->removed; } }