public static JsonObject bodyJson(CelestialBody body, int index) { JsonObject json = new JsonObject(); if (body == null) { return(json); } JsonObject info = new JsonObject(); json.Add("info", info); info.Add("index", index); info.Add("name", body.name); info.Add("isStar", body.isStar); info.Add("isHomeWorld", body.isHomeWorld); info.Add("timeWarpAltitudeLimits", toJson(body.timeWarpAltitudeLimits)); info.Add("orbitingBodies", orbitingBodies(body)); JsonObject size = new JsonObject(); json.Add("size", size); size.Add("radius", body.Radius); size.Add("maxHeight", body.pqsController ? body.pqsController.mapMaxHeight : 0.0); size.Add("mass", body.Mass); size.Add("mu", body.gravParameter); size.Add("GeeASL", body.GeeASL); size.Add("g0", G0 * body.GeeASL); size.Add("sphereOfInfluence", body.sphereOfInfluence); size.Add("hillSphere", body.hillSphere); size.Add("oceanDensity", body.oceanDensity); JsonObject surface = new JsonObject(); json.Add("surface", surface); surface.Add("hasSolidSurface", body.hasSolidSurface); surface.Add("ocean", body.ocean); surface.Add("albedo", body.albedo); surface.Add("emissivity", body.emissivity); if (body.atmosphere) { JsonObject atmosphere = new JsonObject(); json.Add("atmosphere", atmosphere); atmosphere.Add("atmosphereDepth", body.atmosphereDepth); atmosphere.Add("atmosphereContainsOxygen", body.atmosphereContainsOxygen); } JsonObject rotation = new JsonObject(); json.Add("rotation", rotation); rotation.Add("axis", toJson(body.RotationAxis)); rotation.Add("solarDayLength", body.solarDayLength); rotation.Add("rotationPeriod", body.rotationPeriod); rotation.Add("solarRotationPeriod", body.solarRotationPeriod); rotation.Add("rotates", body.rotates); rotation.Add("tidallyLocked", body.tidallyLocked); rotation.Add("initialRotationRad", DEG2RAD * body.initialRotation); rotation.Add("initialRotationDeg", body.initialRotation); json.Add("orbit", orbitJson(body)); JsonObject science = new JsonObject(); json.Add("science", science); if (body.scienceValues != null) { CelestialBodyScienceParams sv = body.scienceValues; science.Add("flyingAltitudeThreshold", sv.flyingAltitudeThreshold); science.Add("spaceAltitudeThreshold", sv.spaceAltitudeThreshold); science.Add("InSpaceHighDataValue", sv.InSpaceHighDataValue); science.Add("InSpaceLowDataValue", sv.InSpaceLowDataValue); science.Add("FlyingLowDataValue", sv.FlyingLowDataValue); science.Add("FlyingHighDataValue", sv.FlyingHighDataValue); science.Add("LandedDataValue", sv.LandedDataValue); science.Add("SplashedDataValue", sv.SplashedDataValue); science.Add("RecoveryValue", sv.RecoveryValue); } science.Add("biomes", toJson(ResearchAndDevelopment.GetBiomeTags(body, false))); science.Add("miniBiomes", toJson(ResearchAndDevelopment.GetMiniBiomeTags(body))); JsonArray anomalies = new JsonArray(); PQSSurfaceObject[] aa = body.pqsSurfaceObjects; if (aa != null) { for (int i = 0; i < aa.Length; i++) { PQSSurfaceObject a = aa[i]; if (a != null && a.name != "Randolith") { JsonObject j = new JsonObject(); j.Add("name", a.name); Vector3d p = a.PlanetRelativePosition; j.Add("lat", Mathf.Rad2Deg * Mathf.Asin((float)p.normalized.y)); j.Add("lon", Mathf.Rad2Deg * Math.Atan2(p.z, p.x)); anomalies.Add(j); } } } json.Add("anomalies", anomalies); return(json); }