public static PQSMod_MapDecalTangent findKSCMapDecal(CelestialBody home) { if (home != null) { if (home.pqsController != null && home.pqsController.transform != null) { Transform t = home.pqsController.transform.Find("KSC"); if (t != null) { PQSMod_MapDecalTangent decal = (PQSMod_MapDecalTangent)t.GetComponent(typeof(PQSMod_MapDecalTangent)); if (decal != null) { return(decal); } } } } PQSMod_MapDecalTangent[] decals = Resources.FindObjectsOfTypeAll <PQSMod_MapDecalTangent>(); foreach (PQSMod_MapDecalTangent d in decals) { if (d.name == "KSC") { return(d); } } 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 static bool setSite(ConfigNode KSC) { bool hasChanged = false; double dtmp; float ftmp; bool btmp; ConfigNode pqsCity = KSC.GetNode("PQSCity"); if (pqsCity == null) { return(false); } ConfigNode pqsDecal = KSC.GetNode("PQSMod_MapDecalTangent"); CelestialBody home = getKSCBody(); PQSCity ksc = findKSC(home); if (ksc != null) { if (pqsCity.HasValue("KEYname")) { if (!(ksc.name.Equals(pqsCity.GetValue("KEYname")))) { Debug.Log("KSCSwitcher: Could not retrieve KSC to move, reporting failure and moving on."); return(false); } } if (pqsCity.HasValue("repositionRadial")) { ksc.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); ksc.repositionRadial = KSCSwitcher.LLAtoECEF(lat, lon, 0, home.Radius); } if (pqsCity.HasValue("reorientInitialUp")) { ksc.reorientInitialUp = KSPUtil.ParseVector3(pqsCity.GetValue("reorientInitialUp")); } if (pqsCity.HasValue("repositionToSphere")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphere"), out btmp)) { ksc.repositionToSphere = btmp; } } if (pqsCity.HasValue("repositionToSphereSurface")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphereSurface"), out btmp)) { ksc.repositionToSphereSurface = btmp; } } if (pqsCity.HasValue("repositionToSphereSurfaceAddHeight")) { if (bool.TryParse(pqsCity.GetValue("repositionToSphereSurfaceAddHeight"), out btmp)) { ksc.repositionToSphereSurfaceAddHeight = btmp; } } if (pqsCity.HasValue("reorientToSphere")) { if (bool.TryParse(pqsCity.GetValue("reorientToSphere"), out btmp)) { ksc.reorientToSphere = btmp; } } if (pqsCity.HasValue("repositionRadiusOffset")) { if (double.TryParse(pqsCity.GetValue("repositionRadiusOffset"), out dtmp)) { ksc.repositionRadiusOffset = dtmp; } } if (pqsCity.HasValue("lodvisibleRangeMult")) { if (double.TryParse(pqsCity.GetValue("lodvisibleRangeMult"), out dtmp)) { foreach (PQSCity.LODRange l in ksc.lod) { l.visibleRange *= (float)dtmp; } } } if (pqsCity.HasValue("reorientFinalAngle")) { if (float.TryParse(pqsCity.GetValue("reorientFinalAngle"), out ftmp)) { ksc.reorientFinalAngle = ftmp; } } print("KSCSwitcher changed PQSCity"); hasChanged = true; ksc.OnSetup(); ksc.OnPostSetup(); SpaceCenter.Instance.transform.localPosition = ksc.transform.localPosition; SpaceCenter.Instance.transform.localRotation = ksc.transform.localRotation; } else { Debug.LogError("KSCSwitcher: Could not retrieve KSC to move, reporting failure and moving on."); return(false); } PQSMod_MapDecalTangent decal = findKSCMapDecal(home); if (decal != null && pqsDecal != null) { // KSC Flat area if (pqsDecal.HasValue("position")) { decal.position = KSPUtil.ParseVector3(pqsDecal.GetValue("position")); } if (pqsDecal.HasValue("radius")) { if (double.TryParse(pqsDecal.GetValue("radius"), out dtmp)) { decal.radius = dtmp; } } if (pqsDecal.HasValue("heightMapDeformity")) { if (double.TryParse(pqsDecal.GetValue("heightMapDeformity"), out dtmp)) { decal.heightMapDeformity = dtmp; } } if (pqsDecal.HasValue("absoluteOffset")) { if (double.TryParse(pqsDecal.GetValue("absoluteOffset"), out dtmp)) { decal.absoluteOffset = dtmp; } } if (pqsDecal.HasValue("absolute")) { if (bool.TryParse(pqsDecal.GetValue("absolute"), out btmp)) { decal.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); decal.position = KSCSwitcher.LLAtoECEF(lat, lon, 0, home.Radius); } print("KSCSwitcher changed MapDecal_Tangent"); hasChanged = true; decal.OnSetup(); } if (hasChanged) { SpaceCenter.Instance.Start(); // 1.0.5 if (KSC.HasValue("name")) { KSCLoader.instance.Sites.lastSite = LastKSC.fetch.lastSite = KSC.GetValue("name"); print("KSCSwitcher changed MapDecal_Tangent"); } } return(hasChanged); }
// Apply the patches public void Start() { // Get the KSC-object from Kerbins PQS if (FlightGlobals.Bodies != null) { body = FlightGlobals.Bodies.First(b => b.isHomeWorld); ksc = body.pqsController.GetComponentsInChildren <PQSCity>(true).First(m => m.name == "KSC"); mapDecal = body.pqsController.GetComponentsInChildren <PQSMod_MapDecalTangent>(true).First(m => m.name == "KSC"); } else { CelestialBody[] bodies = Resources.FindObjectsOfTypeAll <CelestialBody>(); foreach (CelestialBody b in bodies) { if (!b.isHomeWorld) { continue; } if (b.pqsController == null) { continue; } ksc = b.pqsController.GetComponentsInChildren <PQSCity>(true).First(m => m.name == "KSC"); if (ksc != null) { body = b; mapDecal = body.pqsController.GetComponentsInChildren <PQSMod_MapDecalTangent>(true).First(m => m.name == "KSC"); break; } } } if (ksc == null) { Debug.LogError("[Kopernicus] KSC: Unable to find homeworld body with PQSCity named KSC"); return; } if (mapDecal == null) { Debug.LogError("[Kopernicus] KSC: Unable to find homeworld body with PQSMod_MapDecalTangent named KSC"); return; } // Load new data into the PQSCity if (latitude.HasValue && longitude.HasValue) { ksc.repositionRadial = LLAtoECEF(latitude.Value, longitude.Value, 0, body.Radius); } else if (repositionRadial.HasValue) { ksc.repositionRadial = repositionRadial.Value; } else { repositionRadial = ksc.repositionRadial; } if (reorientInitialUp.HasValue) { ksc.reorientInitialUp = reorientInitialUp.Value; } else { reorientInitialUp = ksc.reorientInitialUp; } if (repositionToSphere.HasValue) { ksc.repositionToSphere = repositionToSphere.Value; } else { repositionToSphere = ksc.repositionToSphere; } if (repositionToSphereSurface.HasValue) { ksc.repositionToSphereSurface = repositionToSphereSurface.Value; } else { repositionToSphereSurface = ksc.repositionToSphereSurface; } if (repositionToSphereSurfaceAddHeight.HasValue) { ksc.repositionToSphereSurfaceAddHeight = repositionToSphereSurfaceAddHeight.Value; } else { repositionToSphereSurfaceAddHeight = ksc.repositionToSphereSurfaceAddHeight; } if (reorientToSphere.HasValue) { ksc.reorientToSphere = reorientToSphere.Value; } else { reorientToSphere = ksc.reorientToSphere; } if (repositionRadiusOffset.HasValue) { ksc.repositionRadiusOffset = repositionRadiusOffset.Value; } else { repositionRadiusOffset = ksc.repositionRadiusOffset; } if (lodvisibleRangeMult.HasValue) { foreach (PQSCity.LODRange lodRange in ksc.lod) { lodRange.visibleRange *= (Single)lodvisibleRangeMult.Value; } } else { lodvisibleRangeMult = 1; } if (reorientFinalAngle.HasValue) { ksc.reorientFinalAngle = reorientFinalAngle.Value; } else { reorientFinalAngle = ksc.reorientFinalAngle; } // Load new data into the MapDecal if (radius.HasValue) { mapDecal.radius = radius.Value; } else { radius = mapDecal.radius; } if (heightMapDeformity.HasValue) { mapDecal.heightMapDeformity = heightMapDeformity.Value; } else { heightMapDeformity = mapDecal.heightMapDeformity; } if (absoluteOffset.HasValue) { mapDecal.absoluteOffset = absoluteOffset.Value; } else { absoluteOffset = mapDecal.absoluteOffset; } if (absolute.HasValue) { mapDecal.absolute = absolute.Value; } else { absolute = mapDecal.absolute; } if (decalLatitude.HasValue && decalLongitude.HasValue) { mapDecal.position = LLAtoECEF(decalLatitude.Value, decalLongitude.Value, 0, body.Radius); } else if (position.HasValue) { mapDecal.position = position.Value; } else { position = mapDecal.position; } // Move the SpaceCenter if (SpaceCenter.Instance != null) { SpaceCenter.Instance.transform.localPosition = ksc.transform.localPosition; SpaceCenter.Instance.transform.localRotation = ksc.transform.localRotation; // Reset the SpaceCenter SpaceCenter.Instance.Start(); } else { Debug.Log("[Kopernicus]: KSC: No SpaceCenter instance!"); } // Add a material fixer DontDestroyOnLoad(gameObject.AddComponent <MaterialFixer>()); // Events Events.OnSwitchKSC.Fire(this); }
static bool PatchPQS(CelestialBody body, ConfigNode node, double origRadius) { List <string> PQSs = new List <string>(); bool modified = false; bool custom = false; if (node != null && node.HasNode("PQS")) { foreach (ConfigNode n in node.GetNode("PQS").nodes) { PQSs.Add(n.name); } custom = true; } else { if (body.Radius != origRadius) { PQSs.Add(body.bodyName); PQSs.Add(body.bodyName + "Ocean"); } } foreach (string pName in PQSs) { print("**Patching PQS " + pName); // yeah, slow, but juuuuuuuuust in case. foreach (PQS p in Resources.FindObjectsOfTypeAll(typeof(PQS))) { if (p.name.Equals(pName)) { /*if (body.pqsController != p) * if (body.pqsController != p.parentSphere) * continue;*/ if (p.radius != body.Radius) { modified = true; } p.radius = body.Radius; // do nothing yet, because I don't want to copy-paste all my code var mods = p.transform.GetComponentsInChildren(typeof(PQSMod), true); // rebuilding should catch it, but... foreach (var m in mods) { if (m is PQSCity) { PQSCity mod = (PQSCity)m; try { mod.OnSetup(); mod.OnPostSetup(); } catch { } //SpaceCenter.Instance.transform.localPosition = mod.transform.localPosition; //SpaceCenter.Instance.transform.localRotation = mod.transform.localRotation; } if (m is PQSMod_MapDecal) { PQSMod_MapDecal mod = (PQSMod_MapDecal)m; mod.radius *= globalRescale; mod.position *= (float)globalRescale; try { mod.OnSetup(); mod.OnPostSetup(); } catch { } } if (m is PQSMod_MapDecalTangent) { PQSMod_MapDecalTangent mod = (PQSMod_MapDecalTangent)m; mod.radius *= globalRescale; mod.position *= (float)globalRescale; try { mod.OnSetup(); mod.OnPostSetup(); } catch { } } } try { p.RebuildSphere(); } catch (Exception e) { print("Rebuild sphere for " + node.name + " failed: " + e.Message); } } } } return(modified); }
// Apply the patches public void Start() { // Get the KSC-object from Kerbins PQS if (FlightGlobals.Bodies != null) { body = FlightGlobals.Bodies.First(b => b.isHomeWorld); ksc = body.pqsController.GetComponentsInChildren<PQSCity>(true).First(m => m.name == "KSC"); mapDecal = body.pqsController.GetComponentsInChildren<PQSMod_MapDecalTangent>(true).First(m => m.name == "KSC"); } else { CelestialBody[] bodies = Resources.FindObjectsOfTypeAll<CelestialBody>(); foreach (CelestialBody b in bodies) { if (!b.isHomeWorld) continue; if (b.pqsController == null) continue; ksc = b.pqsController.GetComponentsInChildren<PQSCity>(true).First(m => m.name == "KSC"); if (ksc != null) { body = b; mapDecal = body.pqsController.GetComponentsInChildren<PQSMod_MapDecalTangent>(true).First(m => m.name == "KSC"); break; } } } if (ksc == null) { Debug.LogError("[Kopernicus]: KSC: Unable to find homeworld body with PQSCity named KSC"); return; } if (mapDecal == null) { Debug.LogError("[Kopernicus]: KSC: Unable to find homeworld body with PQSMod_MapDecalTangent named KSC"); return; } // Load new data into the PQSCity if (latitude.HasValue && longitude.HasValue) ksc.repositionRadial = LLAtoECEF(latitude.Value, longitude.Value, 0, body.Radius); else if (repositionRadial.HasValue) ksc.repositionRadial = repositionRadial.Value; if (reorientInitialUp.HasValue) ksc.reorientInitialUp = reorientInitialUp.Value; if (repositionToSphere.HasValue) ksc.repositionToSphere = repositionToSphere.Value; if (repositionToSphereSurface.HasValue) ksc.repositionToSphereSurface = repositionToSphereSurface.Value; if (repositionToSphereSurfaceAddHeight.HasValue) ksc.repositionToSphereSurfaceAddHeight = repositionToSphereSurfaceAddHeight.Value; if (reorientToSphere.HasValue) ksc.reorientToSphere = reorientToSphere.Value; if (repositionRadiusOffset.HasValue) ksc.repositionRadiusOffset = repositionRadiusOffset.Value; if (lodvisibleRangeMult.HasValue) { foreach (PQSCity.LODRange lodRange in ksc.lod) lodRange.visibleRange *= (float)lodvisibleRangeMult.Value; } if (reorientFinalAngle.HasValue) ksc.reorientFinalAngle = reorientFinalAngle.Value; // Load new data into the MapDecal if (radius.HasValue) mapDecal.radius = radius.Value; if (heightMapDeformity.HasValue) mapDecal.heightMapDeformity = heightMapDeformity.Value; if (absoluteOffset.HasValue) mapDecal.absoluteOffset = absoluteOffset.Value; if (absolute.HasValue) mapDecal.absolute = absolute.Value; if (decalLatitude.HasValue && decalLongitude.HasValue) mapDecal.position = LLAtoECEF(decalLatitude.Value, decalLongitude.Value, 0, body.Radius); else if (position.HasValue) mapDecal.position = position.Value; // Move the SpaceCenter if (SpaceCenter.Instance != null) { SpaceCenter.Instance.transform.localPosition = ksc.transform.localPosition; SpaceCenter.Instance.transform.localRotation = ksc.transform.localRotation; // Reset the SpaceCenter SpaceCenter.Instance.Start(); } else Debug.Log("[Kopernicus]: KSC: No SpaceCenter instance!"); // Add a material fixer DontDestroyOnLoad(gameObject.AddComponent<MaterialFixer>()); }
// Apply the patches public void Start() { _body = GetComponent <CelestialBody>(); if (!_body.isHomeWorld) { Destroy(this); return; } _ksc = _body.pqsController.GetComponentsInChildren <PQSCity>(true).First(m => m.name == "KSC"); _mapDecal = _body.pqsController.GetComponentsInChildren <PQSMod_MapDecalTangent>(true) .First(m => m.name == "KSC"); if (_ksc == null) { Debug.LogError("[Kopernicus] KSC: Unable to find homeworld body with PQSCity named KSC"); return; } if (_mapDecal == null) { Debug.LogError( "[Kopernicus] KSC: Unable to find homeworld body with PQSMod_MapDecalTangent named KSC"); return; } // Load new data into the PQSCity if (latitude.HasValue && longitude.HasValue) { _ksc.repositionRadial = Utility.LLAtoECEF(latitude.Value, longitude.Value, 0, _body.Radius); } else if (repositionRadial.HasValue) { _ksc.repositionRadial = repositionRadial.Value; } else { repositionRadial = _ksc.repositionRadial; } if (reorientInitialUp.HasValue) { _ksc.reorientInitialUp = reorientInitialUp.Value; } else { reorientInitialUp = _ksc.reorientInitialUp; } if (repositionToSphere.HasValue) { _ksc.repositionToSphere = repositionToSphere.Value; } else { repositionToSphere = _ksc.repositionToSphere; } if (repositionToSphereSurface.HasValue) { _ksc.repositionToSphereSurface = repositionToSphereSurface.Value; } else { repositionToSphereSurface = _ksc.repositionToSphereSurface; } if (repositionToSphereSurfaceAddHeight.HasValue) { _ksc.repositionToSphereSurfaceAddHeight = repositionToSphereSurfaceAddHeight.Value; } else { repositionToSphereSurfaceAddHeight = _ksc.repositionToSphereSurfaceAddHeight; } if (reorientToSphere.HasValue) { _ksc.reorientToSphere = reorientToSphere.Value; } else { reorientToSphere = _ksc.reorientToSphere; } if (repositionRadiusOffset.HasValue) { _ksc.repositionRadiusOffset = repositionRadiusOffset.Value; } else { repositionRadiusOffset = _ksc.repositionRadiusOffset; } if (lodvisibleRangeMult.HasValue) { foreach (PQSCity.LODRange lodRange in _ksc.lod) { lodRange.visibleRange *= (Single)lodvisibleRangeMult.Value; } } else { lodvisibleRangeMult = 1; } if (reorientFinalAngle.HasValue) { _ksc.reorientFinalAngle = reorientFinalAngle.Value; } else { reorientFinalAngle = _ksc.reorientFinalAngle; } // Load new data into the MapDecal if (radius.HasValue) { _mapDecal.radius = radius.Value; } else { radius = _mapDecal.radius; } if (heightMapDeformity.HasValue) { _mapDecal.heightMapDeformity = heightMapDeformity.Value; } else { heightMapDeformity = _mapDecal.heightMapDeformity; } if (absoluteOffset.HasValue) { _mapDecal.absoluteOffset = absoluteOffset.Value; } else { absoluteOffset = _mapDecal.absoluteOffset; } if (absolute.HasValue) { _mapDecal.absolute = absolute.Value; } else { absolute = _mapDecal.absolute; } if (decalLatitude.HasValue && decalLongitude.HasValue) { _mapDecal.position = Utility.LLAtoECEF(decalLatitude.Value, decalLongitude.Value, 0, _body.Radius); } else if (position.HasValue) { _mapDecal.position = position.Value; } else { position = _mapDecal.position; } // Move the SpaceCenter if (SpaceCenter.Instance != null) { Transform spaceCenterTransform = SpaceCenter.Instance.transform; Transform kscTransform = _ksc.transform; spaceCenterTransform.localPosition = kscTransform.localPosition; spaceCenterTransform.localRotation = kscTransform.localRotation; // Reset the SpaceCenter SpaceCenter.Instance.Start(); } else { Debug.Log("[Kopernicus]: KSC: No SpaceCenter instance!"); } // Add a material fixer DontDestroyOnLoad(gameObject.AddComponent <MaterialFixer>()); // Events Events.OnSwitchKSC.Fire(this); }
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"); } } }
public MapDecalTangent(PQSMod template) { _mod = template as PQSMod_MapDecalTangent; _mod.transform.parent = Utility.Deactivator; base.mod = _mod; }
public MapDecalTangent() { // Create the base mod GameObject modObject = new GameObject("MapDecalTangent"); modObject.transform.parent = Utility.Deactivator; _mod = modObject.AddComponent<PQSMod_MapDecalTangent>(); base.mod = _mod; }