<?phpnamespace App\Game;/** A room as it is during play: the room file's record with names. Saved back when the player leaves. */final class RoomState{ /** @var RoomExtra[] */ public array $extras = []; public int $nExtras = 0; public int $title = 0; /** @var Entity[] the two permanent creatures */ public array $ents; /** @var Door[] left 1, left 2, right 1, right 2 */ public array $doors; public Spot $heart; public Spot $hazard; public Spot $lockA; public Spot $lockB; public int $pickupY = Values::NONE; public int $pickupX = 0; /** @var FloorObject[] */ public array $floor; public function __construct() { $this->ents = [new Entity(), new Entity()]; $this->doors = [new Door(), new Door(), new Door(), new Door()]; $this->heart = new Spot(); $this->hazard = new Spot(); $this->lockA = new Spot(); $this->lockB = new Spot(); $this->floor = []; for ($i = 0; $i < 4; $i++) { $this->floor[] = new FloorObject(); } } public static function from(RoomState $o): self { $s = new self(); foreach ($o->extras as $e) { $s->extras[] = RoomExtra::from($e); } $s->nExtras = $o->nExtras; $s->title = $o->title; foreach ($o->ents as $i => $e) { $s->ents[$i]->copyFrom($e); } foreach ($o->doors as $i => $d) { $s->doors[$i]->copyFrom($d); } $s->heart->copyFrom($o->heart); $s->hazard->copyFrom($o->hazard); $s->lockA->copyFrom($o->lockA); $s->lockB->copyFrom($o->lockB); $s->pickupY = $o->pickupY; $s->pickupX = $o->pickupX; foreach ($o->floor as $i => $f) { $s->floor[$i]->copyFrom($f); } return $s; }}