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; } }