| 58 | } |
| 59 | |
| 60 | SystemLocation jsonToSystemLocation(Json const& json) { |
| 61 | if (auto location = json.optArray()) { |
| 62 | if (location->get(0).type() == Json::Type::String) { |
| 63 | String type = location->get(0).toString(); |
| 64 | if (type == "coordinate") |
| 65 | return CelestialCoordinate(location->get(1)); |
| 66 | else if (type == "orbit") |
| 67 | return CelestialOrbit::fromJson(location->get(1)); |
| 68 | else if (type == "object") |
| 69 | return Uuid(location->get(1).toString()); |
| 70 | } else if (auto position = jsonToMaybe<Vec2F>(*location, jsonToVec2F)) { |
| 71 | return *position; |
| 72 | } |
| 73 | } |
| 74 | return {}; |
| 75 | } |
| 76 | |
| 77 | Json jsonFromSystemLocation(SystemLocation const& location) { |
| 78 | if (auto coordinate = location.maybe<CelestialCoordinate>()) |
no test coverage detected