public void UpdateAtmospheres() { if (RSSSettings != null) { AtmosphereFromGround[] AFGs = (AtmosphereFromGround[])Resources.FindObjectsOfTypeAll(typeof(AtmosphereFromGround)); foreach (ConfigNode node in RSSSettings.nodes) { foreach (CelestialBody body in FlightGlobals.Bodies) { if (body.name.Equals(node.name)) { print("*RSS* checking useLegacyAtmosphere for " + body.GetName()); if (node.HasValue("useLegacyAtmosphere")) { bool UseLegacyAtmosphere = true; bool.TryParse(node.GetValue("useLegacyAtmosphere"), out UseLegacyAtmosphere); //print("*RSSWatchDog* " + body.GetName() + ".useLegacyAtmosphere = " + body.useLegacyAtmosphere.ToString()); if (UseLegacyAtmosphere != body.useLegacyAtmosphere) { print("*RSSWatchDog* resetting useLegacyAtmosphere to " + UseLegacyAtmosphere.ToString()); body.useLegacyAtmosphere = UseLegacyAtmosphere; } } if (node.HasNode("AtmosphereFromGround")) { foreach (AtmosphereFromGround ag in AFGs) { if (ag != null && ag.planet != null) { if (ag.planet.name.Equals(node.name)) { RealSolarSystem.UpdateAFG(body, ag, node.GetNode("AtmosphereFromGround")); print("*RSSWatchDog* reapplying AtmosphereFromGround settings for " + body.name); } } } } } } } } }
private Body selectBody() { SolarSystem solarSystem; if (KspParentBodyDropDownList.Visible) { solarSystem = new KerbolSystem(); Body body = solarSystem.GetSystemBody(KspParentBodyDropDownList.SelectedItem.Text); return(body); } else if (RssParentBodyDropDownList.Visible) { solarSystem = new RealSolarSystem(); Body body = solarSystem.GetSystemBody(RssParentBodyDropDownList.SelectedItem.Text); return(body); } else { return(null); } }
public static bool setSite(ConfigNode KSC) { bool hasChanged = false; double dtmp; float ftmp; bool btmp; CelestialBody Kerbin = getKSCBody(); var mods = Kerbin.pqsController.transform.GetComponentsInChildren(typeof(PQSMod), true); ConfigNode pqsCity = KSC.GetNode("PQSCity"); ConfigNode pqsDecal = KSC.GetNode("PQSMod_MapDecalTangent"); if (pqsCity == null) { return(false); } foreach (var m in mods) { if (m.GetType().ToString().Equals("PQSCity")) { PQSCity mod = m as PQSCity; if (pqsCity.HasValue("KEYname")) { if (!(mod.name.Equals(pqsCity.GetValue("KEYname")))) { continue; } } if (pqsCity.HasValue("repositionRadial")) { mod.repositionRadial = KSPUtil.ParseVector3(pqsCity.GetValue("repositionRadial")); } if (pqsCity.HasValue("latitude") && pqsCity.HasValue("longitude")) { double lat, lon; double.TryParse(pqsCity.GetValue("latitude"), out lat); double.TryParse(pqsCity.GetValue("longitude"), out lon); mod.repositionRadial = RealSolarSystem.LLAtoECEF(lat, lon, 0, Kerbin.Radius); } if (pqsCity.HasValue("reorientInitialUp")) { mod.reorientInitialUp = KSPUtil.ParseVector3(pqsCity.GetValue("reorientInitialUp")); } if (pqsCity.HasValue("repositionToSphere")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphere"), out btmp)) { mod.repositionToSphere = btmp; } } if (pqsCity.HasValue("repositionToSphereSurface")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphereSurface"), out btmp)) { mod.repositionToSphereSurface = btmp; } } if (pqsCity.HasValue("repositionToSphereSurfaceAddHeight")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphereSurfaceAddHeight"), out btmp)) { mod.repositionToSphereSurfaceAddHeight = btmp; } } if (pqsCity.HasValue("reorientToSphere")) { if (bool.TryParse(pqsCity.GetValue("reorientToSphere"), out btmp)) { mod.reorientToSphere = btmp; } } if (pqsCity.HasValue("repositionRadiusOffset")) { if (double.TryParse(pqsCity.GetValue("repositionRadiusOffset"), out dtmp)) { mod.repositionRadiusOffset = dtmp; } } if (pqsCity.HasValue("lodvisibleRangeMult")) { if (double.TryParse(pqsCity.GetValue("lodvisibleRangeMult"), out dtmp)) { foreach (PQSCity.LODRange l in mod.lod) { l.visibleRange *= (float)dtmp; } } } if (pqsCity.HasValue("reorientFinalAngle")) { if (float.TryParse(pqsCity.GetValue("reorientFinalAngle"), out ftmp)) { mod.reorientFinalAngle = ftmp; } } print("*RSS* changed PQSCity"); hasChanged = true; mod.OnSetup(); mod.OnPostSetup(); SpaceCenter.Instance.transform.localPosition = mod.transform.localPosition; SpaceCenter.Instance.transform.localRotation = mod.transform.localRotation; } // KSC Flat area if (pqsDecal != null && m.GetType().ToString().Equals("PQSMod_MapDecalTangent")) { // thanks to asmi for this! PQSMod_MapDecalTangent mod = m as PQSMod_MapDecalTangent; if (pqsDecal.HasValue("position")) { mod.position = KSPUtil.ParseVector3(pqsDecal.GetValue("position")); } if (pqsDecal.HasValue("radius")) { if (double.TryParse(pqsDecal.GetValue("radius"), out dtmp)) { mod.radius = dtmp; } } if (pqsDecal.HasValue("heightMapDeformity")) { if (double.TryParse(pqsDecal.GetValue("heightMapDeformity"), out dtmp)) { mod.heightMapDeformity = dtmp; } } if (pqsDecal.HasValue("absoluteOffset")) { if (double.TryParse(pqsDecal.GetValue("absoluteOffset"), out dtmp)) { mod.absoluteOffset = dtmp; } } if (pqsDecal.HasValue("absolute")) { if (bool.TryParse(pqsDecal.GetValue("absolute"), out btmp)) { mod.absolute = btmp; } } if (pqsDecal.HasValue("latitude") && pqsDecal.HasValue("longitude")) { double lat, lon; double.TryParse(pqsDecal.GetValue("latitude"), out lat); double.TryParse(pqsDecal.GetValue("longitude"), out lon); mod.position = RealSolarSystem.LLAtoECEF(lat, lon, 0, Kerbin.Radius); } print("*RSS* changed MapDecal_Tangent"); hasChanged = true; mod.OnSetup(); } } if (hasChanged) { Kerbin.pqsController.RebuildSphere(); } return(hasChanged); }
public void setSite(string name) { ConfigNode site = getSite(name); if (site == null) { return; } bool hasChanged = false; double dtmp; float ftmp; bool btmp; CelestialBody Kerbin = FlightGlobals.Bodies.Find(body => body.name == "Kerbin"); if (Kerbin == null) { Kerbin = FlightGlobals.Bodies.Find(body => body.name == "Earth"); // temp fix } var mods = Kerbin.pqsController.transform.GetComponentsInChildren(typeof(PQSMod), true); ConfigNode pqsCity = site.GetNode("PQSCity"); ConfigNode pqsDecal = site.GetNode("PQSMod_MapDecalTangent"); if (pqsCity == null) { return; } foreach (var m in mods) { if (m.GetType().ToString().Equals("PQSCity")) { PQSCity mod = m as PQSCity; if (pqsCity.HasValue("KEYname")) { if (!(mod.name.Equals(pqsCity.GetValue("KEYname")))) { continue; } } if (pqsCity.HasValue("repositionRadial")) { mod.repositionRadial = KSPUtil.ParseVector3(pqsCity.GetValue("repositionRadial")); } if (pqsCity.HasValue("latitude") && pqsCity.HasValue("longitude")) { double lat, lon; double.TryParse(pqsCity.GetValue("latitude"), out lat); double.TryParse(pqsCity.GetValue("longitude"), out lon); mod.repositionRadial = RealSolarSystem.LLAtoECEF(lat, lon, 0, Kerbin.Radius); } if (pqsCity.HasValue("reorientInitialUp")) { mod.reorientInitialUp = KSPUtil.ParseVector3(pqsCity.GetValue("reorientInitialUp")); } if (pqsCity.HasValue("repositionToSphere")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphere"), out btmp)) { mod.repositionToSphere = btmp; } } if (pqsCity.HasValue("repositionToSphereSurface")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphereSurface"), out btmp)) { mod.repositionToSphereSurface = btmp; } } if (pqsCity.HasValue("repositionToSphereSurfaceAddHeight")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphereSurfaceAddHeight"), out btmp)) { mod.repositionToSphereSurfaceAddHeight = btmp; } } if (pqsCity.HasValue("reorientToSphere")) { if (bool.TryParse(pqsCity.GetValue("reorientToSphere"), out btmp)) { mod.reorientToSphere = btmp; } } if (pqsCity.HasValue("repositionRadiusOffset")) { if (double.TryParse(pqsCity.GetValue("repositionRadiusOffset"), out dtmp)) { mod.repositionRadiusOffset = dtmp; } } if (pqsCity.HasValue("lodvisibleRangeMult")) { if (double.TryParse(pqsCity.GetValue("lodvisibleRangeMult"), out dtmp)) { foreach (PQSCity.LODRange l in mod.lod) { l.visibleRange *= (float)dtmp; } } } if (pqsCity.HasValue("reorientFinalAngle")) { if (float.TryParse(pqsCity.GetValue("reorientFinalAngle"), out ftmp)) { mod.reorientFinalAngle = ftmp; } } print("*RSS* changed PQSCity"); hasChanged = true; mod.OnSetup(); } // KSC Flat area if (pqsDecal != null && m.GetType().ToString().Equals("PQSMod_MapDecalTangent")) { // thanks to asmi for this! PQSMod_MapDecalTangent mod = m as PQSMod_MapDecalTangent; if (pqsDecal.HasValue("position")) { mod.position = KSPUtil.ParseVector3(pqsDecal.GetValue("position")); } if (pqsDecal.HasValue("radius")) { if (double.TryParse(pqsDecal.GetValue("radius"), out dtmp)) { mod.radius = dtmp; } } if (pqsDecal.HasValue("heightMapDeformity")) { if (double.TryParse(pqsDecal.GetValue("heightMapDeformity"), out dtmp)) { mod.heightMapDeformity = dtmp; } } if (pqsDecal.HasValue("absoluteOffset")) { if (double.TryParse(pqsDecal.GetValue("absoluteOffset"), out dtmp)) { mod.absoluteOffset = dtmp; } } if (pqsDecal.HasValue("absolute")) { if (bool.TryParse(pqsDecal.GetValue("absolute"), out btmp)) { mod.absolute = btmp; } } if (pqsDecal.HasValue("latitude") && pqsDecal.HasValue("longitude")) { double lat, lon; double.TryParse(pqsDecal.GetValue("latitude"), out lat); double.TryParse(pqsDecal.GetValue("longitude"), out lon); mod.position = RealSolarSystem.LLAtoECEF(lat, lon, 0, Kerbin.Radius); } print("*RSS* changed MapDecal_Tangent"); hasChanged = true; mod.OnSetup(); } if (hasChanged) { print("*RSS* Rebuilding"); Kerbin.pqsController.RebuildSphere(); ScreenMessages.PostScreenMessage("Launch site changed to " + name, 2.5f, ScreenMessageStyle.LOWER_CENTER); showWindow = false; print("*RSS* Launch site change DONE"); } } }