railShape = $railShape; } protected function writeStateToMeta() : int{ //TODO: railShape won't be plain metadata in the future return $this->railShape; } public function getStateBitmask() : int{ return 0b111; } protected function setShapeFromConnections(array $connections) : void{ $railShape = self::searchState($connections, RailConnectionInfo::CONNECTIONS); if($railShape === null){ throw new \InvalidArgumentException("No rail shape matches these connections"); } $this->railShape = $railShape; } protected function getCurrentShapeConnections() : array{ return RailConnectionInfo::CONNECTIONS[$this->railShape]; } public function getShape() : int{ return $this->railShape; } /** @return $this */ public function setShape(int $shape) : self{ if(!isset(RailConnectionInfo::CONNECTIONS[$shape])){ throw new \InvalidArgumentException("Invalid rail shape, must be one of " . implode(", ", array_keys(RailConnectionInfo::CONNECTIONS))); } $this->railShape = $shape; return $this; } }