public void Load(ConfigNode node) { node.TryGetValue("ullageHeightMin", ref ullageHeightMin); node.TryGetValue("ullageHeightMax", ref ullageHeightMax); node.TryGetValue("ullageRadialMin", ref ullageRadialMin); node.TryGetValue("ullageRadialMax", ref ullageRadialMax); node.TryGetValue("UT", ref UT); }
public DefaultConfig(ConfigNode configNode) { configNode.TryGetValue("name", ref this.name); configNode.TryGetValue("description", ref this.description); Random random = new Random(); foreach (ConfigNode bodyNode in configNode.GetNodes("KRES_BODY")) { if (KRESUtils.IsCelestialBody(bodyNode.GetValue("name"))) { this.bodies.Add(new DefaultBody(bodyNode, random)); } } }
public DefaultResource(ConfigNode configNode, Random random) { configNode.TryGetValue("name", ref this.name); configNode.TryGetValue("type", ref this.type); configNode.TryGetValue("density", ref this.density); configNode.TryGetValue("octaves", ref this.octaves); configNode.TryGetValue("persistence", ref this.persistence); configNode.TryGetValue("frequency", ref this.frequency); configNode.TryGetValue("minAltitude", ref this.minAltitude); configNode.TryGetValue("maxAltitude", ref this.maxAltitude); configNode.TryGetValue("biomes", ref this.biomes); configNode.TryGetValue("excludedBiomes", ref this.excludedBiomes); if (this.type == "ore") { this.seed = random.Next(999999999); } }
public void Start() { foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM")) RSSSettings = node; if (RSSSettings != null) { RSSSettings.TryGetValue("dumpOrbits", ref dumpOrbits); RSSSettings.TryGetValue("useKeypressClip", ref useKeypressClip); } UpdateAtmospheres(); GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged); }
public void Load(ConfigNode node) { if (node != null) { node.TryGetValue("ullageHeightMin", ref ullageHeightMin); node.TryGetValue("ullageHeightMax", ref ullageHeightMax); node.TryGetValue("ullageRadialMin", ref ullageRadialMin); node.TryGetValue("ullageRadialMax", ref ullageRadialMax); node.TryGetValue("UT", ref UT); #if DEBUG string str = "Loaded from node. H,R: " + ullageHeightMin + "/" + ullageHeightMax + ", " + ullageRadialMin + "/" + ullageRadialMax + ". UT: " + UT; if (Planetarium.fetch) str += " with current UT " + Planetarium.GetUniversalTime(); MonoBehaviour.print("*U* UllageSim load: " + str); #endif } }
public ResourceItem(ConfigNode data, string resource, string body, string type, System.Random random) { DefaultResource defaultResource = DefaultLibrary.GetDefault(MapGenerator.DefaultName).GetBody(body).GetResourceOfType(resource, type); this.resource = PartResourceLibrary.Instance.GetDefinition(data.GetValue("name")); this.type = KRESUtils.GetResourceType(type); this.map = null; if (!data.TryGetValue("actualDensity", ref actualDensity)) { actualDensity = KRESUtils.Clamp01(defaultResource.Density * (0.97d + (random.NextDouble() * 0.06d))); } if (!data.TryGetValue("actualError", ref actualError)) { actualError = (random.NextDouble() * 2d) - 1d; data.AddValue("actualError", actualError); } }
public DefaultBody(ConfigNode configNode, Random random) { configNode.TryGetValue("name", ref this.name); foreach (ConfigNode resourceNode in configNode.GetNodes("KRES_RESOURCE")) { this.resources.Add(new DefaultResource(resourceNode, random)); } }
public void Load(ConfigNode node) { unlocked = false; node.TryGetValue("name", ref name); double cost = 0d; node.TryGetValue("cost", ref cost); node.TryGetValue("entryCost", ref entryCost); if(double.IsNaN(entryCost)) entryCost = Math.Max(0d, cost * RFSettings.Instance.configEntryCostMultiplier); node.TryGetValue("sciEntryCost", ref sciEntryCost); if(double.IsNaN(sciEntryCost)) sciEntryCost = Math.Max(0d, cost * RFSettings.Instance.configScienceCostMultiplier); node.TryGetValue("unlocked", ref unlocked); node.TryGetValue("techRequired", ref techRequired); if (node.HasNode("entryCostMultipliers")) LoadMultipliers(node.GetNode("entryCostMultipliers")); if (node.HasNode("entryCostSubtractors")) LoadSubtractors(node.GetNode("entryCostSubtractors")); node.TryGetValue("maxSubtraction", ref maxSubtraction); }
public TLUpgrade(ConfigNode node, ModuleEngineConfigs mec) { techLevelEntryCost = 0d; techLevelSciEntryCost = 0d; if (node.HasValue("name")) { bool calc = true, sciCalc = true; string cfgName = node.GetValue("name"); calc = !node.TryGetValue("entryCost", ref techLevelEntryCost); sciCalc = !node.TryGetValue("sciEntryCost", ref techLevelSciEntryCost); if (mec.part.partInfo != null) { double configCost = 0d; node.TryGetValue("cost", ref configCost); if (calc) { // calculate from what we know techLevelEntryCost += configCost * RFSettings.Instance.configEntryCostMultiplier; } if (sciCalc) { techLevelSciEntryCost += configCost * RFSettings.Instance.configScienceCostMultiplier; } techLevelEntryCost += mec.part.partInfo.entryCost; techLevelSciEntryCost += mec.part.partInfo.entryCost * RFSettings.Instance.configScienceCostMultiplier; } techLevelEntryCost = Math.Max(0d, techLevelEntryCost * RFSettings.Instance.techLevelEntryCostFraction); techLevelSciEntryCost = Math.Max(0d, techLevelSciEntryCost * RFSettings.Instance.techLevelScienceEntryCostFraction); currentTL = mec.techLevel; Load(node); // override the values if we have the real values. name = Utilities.GetPartName(mec.part) + cfgName; } }
public ResourceItem(ConfigNode data, string resource, string body, System.Random random) { DefaultResource defaultResource = DefaultLibrary.GetDefault(MapGenerator.DefaultName).GetBody(body).GetResourceOfType(resource, "ore"); this.resource = PartResourceLibrary.Instance.GetDefinition(resource); this.type = ResourceType.ORE; double density = defaultResource.Density; this.map = new ResourceMap(defaultResource, body); if (!data.TryGetValue("actualDensity", ref actualDensity)) { Texture2D texture = Map.GetTexture(); actualDensity = texture.GetPixels().Count(p => p.a > 0) / mapResolution; Texture2D.Destroy(texture); data.AddValue("actualDensity", actualDensity); } if (!data.TryGetValue("actualError", ref actualError)) { actualError = (random.NextDouble() * 2d) - 1d; data.AddValue("actualError", actualError); } }
public void Load(ConfigNode node) { if (node.HasNode(configNodeName)) { ConfigNode TSTStockPlanetOrderNode = new ConfigNode(); node.TryGetNode(configNodeName, ref TSTStockPlanetOrderNode); string tmpPlanetOrderString = ""; TSTStockPlanetOrderNode.TryGetValue("planets", ref tmpPlanetOrderString); string[] tmpPlanetOrder = tmpPlanetOrderString.Split(','); NHPlanetOrder = new string[tmpPlanetOrder.Length]; if (tmpPlanetOrder.Length > 0) { for (int i = 0; i < tmpPlanetOrder.Length; i++) { NHPlanetOrder[i] = tmpPlanetOrder[i]; } } } Utilities.Log_Debug("TSTNHPlanetOrder load complete"); }
/// <summary> /// Initiates all the texture and model nodes in this model config /// </summary> public TextureConfig(ConfigNode node) { node.TryGetValue("name", ref _name); this._cases = node.GetNodes("CASE_TEXTURE").Select(n => new CaseConfig(n)).ToDictionary(c => c.name, c => c); this._caseNames = this._cases.Keys.ToArray(); this._types = this._cases.Values.SelectMany(c => c.types).Distinct() .ToDictionary(t => t, t => this._cases.Values.Where(c => c.types.Contains(t)).Select(c => c.name).ToArray()); this._canopies = node.GetNodes("CANOPY_TEXTURE").Select(n => new CanopyConfig(n)).ToDictionary(c => c.name, c => c); this._canopyNames = this._canopies.Keys.ToArray(); this._models = node.GetNodes("CANOPY_MODEL").Select(n => new ModelConfig(n)).ToDictionary(m => m.name, m => m); this._modelNames = this._models.Keys.ToArray(); int max = this._models.Values.Select(m => m.parameters.Count).Max(); for (int i = 1; i <= max; i++) { this._parameters.Add(i, this.models.Values.Where(m => m.parameters.Count >= i).Select(m => m.name).ToArray()); } foreach (ModelConfig model in this._models.Values) { model.parameters.ForEach(p => this._transforms.Add(p.transformName, model)); } }
internal static AlarmInfo Load(ConfigNode node) { Guid vesselID = Utilities.GetNodeValue(node, "vesselID"); string Name = ""; node.TryGetValue("Name", ref Name); AlarmInfo info = new AlarmInfo(Name, vesselID); info.AlarmType = Utilities.GetNodeValue(node, "AlarmType", KACWrapper.KACAPI.AlarmTypeEnum.Raw); node.TryGetValue("Notes", ref info.Notes); node.TryGetValue("AlarmTime", ref info.AlarmTime); node.TryGetValue("AlarmMargin", ref info.AlarmMargin); node.TryGetValue("AlarmExecute", ref info.AlarmExecute); string frzkbllst = ""; node.TryGetValue("FrzKerbals", ref frzkbllst); string thwkbllst = ""; node.TryGetValue("ThwKerbals", ref thwkbllst); string[] frzStrings = frzkbllst.Split(','); if (frzStrings.Length > 0) { for (int i = 0; i < frzStrings.Length; i++) { info.FrzKerbals.Add(frzStrings[i]); } } string[] thwStrings = thwkbllst.Split(','); if (thwStrings.Length > 0) { for (int i = 0; i < thwStrings.Length; i++) { if (thwStrings[i].Length > 0) info.ThwKerbals.Add(thwStrings[i]); } } return info; }
private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, CelestialBody body, double origRadius) { #region ScaledSpace // Scaled space Transform scaledSpaceTransform = null; Transform atmo = null; guiMinor = "Scaled Space"; //OnGui(); if (ScaledSpace.Instance != null) { float SSTScale = 1.0f; node.TryGetValue("SSTScale", ref SSTScale); foreach (Transform t in ScaledSpace.Instance.scaledSpaceTransforms) { if (t.name.Equals(node.name)) { print("*RSS* Found scaledspace transform for " + t.name + ", scale " + t.localScale.x); scaledSpaceTransform = t; // replace int replaceColor = 0; string path = ""; if (node.HasValue("SSColor")) { replaceColor = 1; path = node.GetValue("SSColor"); } if (node.HasValue("SSColor32")) { replaceColor = 2; path = node.GetValue("SSColor32"); } if (replaceColor > 0) { guiExtra = "Color map"; Texture2D map = null; bool local = Utils.LoadTexture(path, ref map, true, true, true); if ((object)map != null) { Texture oldColor = t.gameObject.renderer.material.GetTexture("_MainTex"); if ((object)oldColor != null) { foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material))) { if (m.GetTexture("_MainTex") == oldColor) m.SetTexture("_MainTex", map); } DestroyImmediate(oldColor); oldColor = null; yield return null; } } } yield return null; guiExtra = ""; if (node.HasValue("SSBump")) { guiExtra = "Normal Map"; path = node.GetValue("SSBump"); Texture2D map = null; bool local = Utils.LoadTexture(path, ref map, loadInfo.compressNormals, true, true); yield return null; if ((object)map != null) { Texture oldBump = t.gameObject.renderer.material.GetTexture("_BumpMap"); if (oldBump != null) { foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material))) { if (m.GetTexture("_BumpMap") == oldBump) m.SetTexture("_BumpMap", map); } t.gameObject.renderer.material.SetTexture("_BumpMap", map); // in case one wasn't set. DestroyImmediate(oldBump); oldBump = null; yield return null; } } yield return null; guiExtra = ""; //OnGui(); } /*if (t.gameObject.renderer.material.GetTexture("_rimColorRamp") != null) { try { System.IO.File.WriteAllBytes(KSPUtil.ApplicationRootPath + body.name + "Ramp.png", ((Texture2D)t.gameObject.renderer.material.GetTexture("_rimColorRamp")).EncodeToPNG()); } catch (Exception e) { print("*RSS* Failed to get/write ramp for " + body.name + ", exception: " + e.Message); } }*/ guiExtra = "Ramp and Specularity"; yield return null; if (node.HasValue("SSRampRef")) { //if (t.gameObject.renderer.material.GetTexture("_rimColorRamp") != null) // for now try setting anyway. Texture map = null; map = GetRamp(node.GetValue("SSRampRef")); if (map != null) t.gameObject.renderer.material.SetTexture("_rimColorRamp", map); else print("*RSS* *ERROR* texture does not exist! " + node.GetValue("SSRamp")); } if (node.HasValue("SSRamp")) { Texture2D map = null; bool localLoad = Utils.LoadTexture(node.GetValue("SSRamp"), ref map, true, true, true); if ((object)map != null) { t.gameObject.renderer.material.SetTexture("_rimColorRamp", map); } else print("*RSS* *ERROR* texture does not exist! " + node.GetValue("SSRamp")); } yield return null; if (node.HasValue("SSSpec")) { try { Vector4 col = KSPUtil.ParseVector4(node.GetValue("SSSpec")); Color c = new Color(col.x, col.y, col.z, col.w); t.gameObject.renderer.material.SetColor("_SpecColor", c); } catch (Exception e) { print("*RSS* Error reading SSSpec as color4: original text: " + node.GetValue("SSSpec") + " --- exception " + e.Message); } } yield return null; // Fix mesh guiExtra = "Wrapping mesh"; yield return null; bool rescale = true; bool doWrapHere = loadInfo.doWrap; node.TryGetValue("wrap", ref doWrapHere); bool sphereVal = loadInfo.spheresOnly; bool sphereHere = node.TryGetValue("useSphericalSSM", ref sphereVal); float origLocalScale = t.localScale.x; // assume uniform scale if (body.pqsController != null && doWrapHere) { MeshFilter m = (MeshFilter)t.GetComponent(typeof(MeshFilter)); if (m == null || m.mesh == null) { print("*RSS* Failure getting SSM for " + body.pqsController.name + ": mesh is null"); } else { char sep = System.IO.Path.DirectorySeparatorChar; string filePath = KSPUtil.ApplicationRootPath + "GameData" + sep + "RealSolarSystem" + sep + "Plugins" + sep + "PluginData" + sep + t.name; filePath += ".obj"; bool wrap = true; if (File.Exists(filePath)) { try { print("*RSS* loading cached ScaledSpace mesh " + m.name); ProfileTimer.Push("LoadSSM_" + body.name); Mesh tMesh = new Mesh(); Utils.CopyMesh(loadInfo.joolMesh.mesh, tMesh); ObjLib.UpdateMeshFromFile(tMesh, filePath); m.mesh = tMesh; m.mesh.RecalculateBounds(); print("*RSS* Loaded " + filePath + " and wrapped."); ProfileTimer.Pop("LoadSSM_" + body.name); wrap = false; } catch (Exception ex) { Print("*RSS* Failed to load cached SSM: {0}", ex); } yield return null; } if (wrap) { try { ProfileTimer.Push("Wrap time for " + body.name); Mesh tMesh = new Mesh(); Utils.CopyMesh(loadInfo.joolMesh.mesh, tMesh); if (sphereVal) { float scaleFactor = (float)(origRadius / (1000 * 6000 * (double)origLocalScale)); // scale mesh such that it will end up right. // (need to scale it such that in the end localScale will = origLocalScale * radius/origRadius) print("*RSS* using Jool scaledspace mesh (spherical) for body " + body.pqsController.name + ". Vertex Scale " + scaleFactor); Utils.ScaleVerts(tMesh, scaleFactor); } else { print("*RSS* wrapping ScaledSpace mesh " + m.name + " to PQS " + body.pqsController.name); float scaleFactor = (float)(origRadius / (1000 * 6000 * (double)origLocalScale)); // scale mesh such that it will end up right. // (need to scale it such that in the end localScale will = origLocalScale * radius/origRadius) Utils.MatchVerts(tMesh, body.pqsController, body.ocean ? body.Radius : 0.0, scaleFactor); //ProfileTimer.Push("Recalc Normals"); tMesh.RecalculateNormals(); //ProfileTimer.Pop("Recalc Normals"); ObjLib.UpdateTangents(tMesh); //print("*RSS* wrapped."); } m.mesh = tMesh; try { ObjLib.MeshToFile(m, filePath); } catch (Exception e) { print("*RSS* Exception saving wrapped mesh " + filePath + ": " + e.Message); } //print("*RSS*: Done wrapping and exporting. Setting scale"); tMesh.RecalculateBounds(); // do normal rescaling below. ProfileTimer.Pop("Wrap time for " + body.name); } catch (Exception e) { print("*RSS* Exception wrapping: " + e.Message); } } yield return null; //OnGui(); } } atmo = t.FindChild("Atmosphere"); //OnGui(); if (rescale) { float scaleFactor = (float)((double)origLocalScale * body.Radius / origRadius * SSTScale); t.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor); } else { // rescale only atmo if (atmo != null) { guiExtra = "Atmosphere"; yield return null; print("*RSS* found atmo transform for " + node.name); float scaleFactor = loadInfo.SSAtmoScale; // default to global default if (!node.TryGetValue("SSAtmoScale", ref scaleFactor)) // if no override multiplier { if (loadInfo.defaultAtmoScale) // use stock KSP multiplier scaleFactor *= 1.025f; else // or use atmosphere height-dependent multiplier scaleFactor *= (float)((body.Radius + body.maxAtmosphereAltitude) / body.Radius); } scaleFactor *= origLocalScale / t.localScale.x * (float)(body.Radius / origRadius); // since our parent transform changed, we no longer are the same scale as the planet. atmo.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor); print("*RSS* final scale of atmo for " + body.name + " in scaledspace: " + atmo.localScale.x); } } print("*RSS* final scale of " + body.name + " in scaledspace: " + t.localScale.x); yield return null; guiExtra = ""; } } } #region AtmosphereFromGround guiExtra = "AtmosphereFromGround"; yield return null; foreach (AtmosphereFromGround ag in Resources.FindObjectsOfTypeAll(typeof(AtmosphereFromGround))) { //print("*RSS* Found AG " + ag.name + " " + (ag.tag == null ? "" : ag.tag) + ". Planet " + (ag.planet == null ? "NULL" : ag.planet.name)); if (ag != null && ag.planet != null) { // generalized version of Starwaster's code. Thanks Starwaster! if (ag.planet.name.Equals(node.name)) { print("Found atmo for " + node.name + ": " + ag.name + ", has localScale " + ag.transform.localScale.x); UpdateAFG(body, ag, node.GetNode("AtmosphereFromGround")); print("Atmo updated"); } } } yield return null; guiExtra = ""; #endregion #endregion }
public RSSLoadInfo(ConfigNode RSSnode) { useEpoch = RSSnode.TryGetValue("Epoch", ref epoch); RSSnode.TryGetValue("wrap", ref doWrap); RSSnode.TryGetValue("compressNormals", ref compressNormals); RSSnode.TryGetValue("spheresOnly", ref spheresOnly); RSSnode.TryGetValue("orbitCalc", ref orbitCalc); RSSnode.TryGetValue("defaultAtmoScale", ref defaultAtmoScale); RSSnode.TryGetValue("SSAtmoScale", ref SSAtmoScale); node = new ConfigNode(); RSSnode.CopyTo(node); // get spherical scaledspace mesh if (ScaledSpace.Instance != null) { //print("*RSS* Printing ScaledSpace Transforms"); foreach (Transform t in ScaledSpace.Instance.scaledSpaceTransforms) { /*print("***** TRANSFROM: " + t.name); Utils.PrintTransformUp(t); Utils.PrintTransformRecursive(t);*/ if (t.name.Equals("Jool")) joolMesh = (MeshFilter)t.GetComponent(typeof(MeshFilter)); } //print("*RSS* InverseScaleFactor = " + ScaledSpace.InverseScaleFactor); } }
private IEnumerator<YieldInstruction> LoadCB(ConfigNode node, CelestialBody body) { bool updateMass = false; //OnGui(); #region CBChanges print("Fixing CB " + node.name + " of radius " + body.Radius); guiMinor = "CelestialBody"; //OnGui(); double origRadius = body.Radius; double origAtmo = body.maxAtmosphereAltitude; #region CBMassRadius node.TryGetValue("bodyName", ref body.bodyName); node.TryGetValue("bodyDescription", ref body.bodyDescription); if (node.TryGetValue("Radius", ref body.Radius)) updateMass = true; print("Radius ratio: " + body.Radius / origRadius); if (node.TryGetValue("Mass", ref body.Mass)) { MassToOthers(body); } if (node.TryGetValue("GeeASL", ref body.GeeASL)) { GeeASLToOthers(body); updateMass = false; } if (node.TryGetValue("gravParameter", ref body.gravParameter)) { GravParamToOthers(body); updateMass = false; } #endregion #region CBAtmosphereTemperature node.TryGetValue("atmosphericAmbientColor", ref body.atmosphericAmbientColor); node.TryGetValue("atmosphere", ref body.atmosphere); node.TryGetValue("atmosphereScaleHeight", ref body.atmosphereScaleHeight); node.TryGetValue("atmosphereMultiplier", ref body.atmosphereMultiplier); node.TryGetValue("maxAtmosphereAltitude", ref body.maxAtmosphereAltitude); node.TryGetValue("staticPressureASL", ref body.staticPressureASL); node.TryGetValue("useLegacyAtmosphere", ref body.useLegacyAtmosphere); if (!body.useLegacyAtmosphere) { ConfigNode PCnode = node.GetNode("pressureCurve"); if (PCnode != null) { body.altitudeMultiplier = 1f; body.pressureMultiplier = 1f; AnimationCurve pressureCurve = Utils.LoadAnimationCurve(PCnode); if (pressureCurve != null) body.pressureCurve = pressureCurve; else { body.useLegacyAtmosphere = true; Debug.LogWarning("Unable to load pressureCurve data for " + body.name + ": Using legacy atmosphere"); } print("*RSS* finished with " + body.GetName() + ".pressureCurve (" + body.pressureCurve.keys.Length.ToString() + " keys)"); } else { print("*RSS* useLegacyAtmosphere = False but pressureCurve not found!"); } } if (node.HasNode("temperatureCurve")) { ConfigNode TCnode = node.GetNode("temperatureCurve"); if (TCnode != null) { AnimationCurve temperatureCurve = Utils.LoadAnimationCurve(TCnode); if (temperatureCurve != null) { body.temperatureCurve = temperatureCurve; // Following two lines corrects situations where planets without atmosphere's have these two fields zeroed out // Maybe think about making these configurable in the planet's config node? yes? no? meh? body.atmoshpereTemperatureMultiplier = 1f; body.altitudeMultiplier = 1f; print("*RSS* found and loaded temperatureCurve data for " + body.name); } } } #endregion #region CBRotation node.TryGetValue("rotationPeriod", ref body.rotationPeriod); node.TryGetValue("tidallyLocked", ref body.tidallyLocked); node.TryGetValue("initialRotation", ref body.initialRotation); node.TryGetValue("inverseRotation", ref body.inverseRotation); #endregion if (updateMass) GeeASLToOthers(body); /*if (node.HasValue("axialTilt")) { if (!body.inverseRotation && double.TryParse(node.GetValue("axialTilt"), out dtmp)) { CBRotationFixer.CBRotations.Add(body.name, new CBRotation(body.name, dtmp, body.rotationPeriod, body.initialRotation)); body.rotationPeriod = 0; } }*/ yield return null; #region CBOrbit ConfigNode onode = node.GetNode("Orbit"); if (body.orbitDriver != null && body.orbit != null && onode != null) { if (loadInfo.useEpoch) body.orbit.epoch = loadInfo.epoch; onode.TryGetValue("semiMajorAxis", ref body.orbit.semiMajorAxis); onode.TryGetValue("eccentricity", ref body.orbit.eccentricity); onode.TryGetValue("meanAnomalyAtEpoch", ref body.orbit.meanAnomalyAtEpoch); if (onode.TryGetValue("meanAnomalyAtEpochD", ref body.orbit.meanAnomalyAtEpoch)) body.orbit.meanAnomalyAtEpoch *= DEG2RAD; onode.TryGetValue("inclination", ref body.orbit.inclination); onode.TryGetValue("period", ref body.orbit.period); onode.TryGetValue("LAN", ref body.orbit.LAN); onode.TryGetValue("argumentOfPeriapsis", ref body.orbit.argumentOfPeriapsis); if (onode.HasValue("orbitColor")) { try { Vector4 col = KSPUtil.ParseVector4(onode.GetValue("orbitColor")); Color c = new Color(col.x, col.y, col.z, col.w); body.GetOrbitDriver().orbitColor = c; } catch (Exception e) { print("*RSS* Error parsing as color4: original text: " + onode.GetValue("orbitColor") + " --- exception " + e.Message); } } string bodyname = ""; if (onode.TryGetValue("referenceBody", ref bodyname)) { if (body.orbit.referenceBody == null || !body.orbit.referenceBody.Equals(bodyname)) { foreach (CelestialBody b in FlightGlobals.Bodies) { if (b.name.Equals(bodyname)) { if (body.orbit.referenceBody) { body.orbit.referenceBody.orbitingBodies.Remove(body); } b.orbitingBodies.Add(body); body.orbit.referenceBody = b; break; } } } } } yield return null; // SOI and HillSphere done at end body.CBUpdate(); #endregion #endregion #region SSPQSFade // Scaled space fader float SSFMult = 1.0f; float SSFStart = -1, SSFEnd = -1; node.TryGetValue("SSFStart", ref SSFStart); node.TryGetValue("SSFEnd", ref SSFEnd); node.TryGetValue("SSFMult", ref SSFMult); foreach (ScaledSpaceFader ssf in Resources.FindObjectsOfTypeAll(typeof(ScaledSpaceFader))) { if (ssf.celestialBody != null) { if (ssf.celestialBody.name.Equals(node.name)) { if (SSFStart >= 0) ssf.fadeStart = SSFStart; else ssf.fadeStart *= SSFMult; if (SSFEnd >= 0) ssf.fadeEnd = SSFEnd; else ssf.fadeEnd *= SSFMult; } } } // The CBT that fades out the PQS // Should probably do this as just another PQSMod, actually. foreach (PQSMod_CelestialBodyTransform c in Resources.FindObjectsOfTypeAll(typeof(PQSMod_CelestialBodyTransform))) { try { if (c.body != null) { if (c.body.name.Equals(node.name)) { print("Found CBT for " + node.name); node.TryGetValue("PQSdeactivateAltitude", ref c.deactivateAltitude); if (c.planetFade != null) { node.TryGetValue("PQSfadeStart", ref c.planetFade.fadeStart); node.TryGetValue("PQSfadeEnd", ref c.planetFade.fadeEnd); if (c.secondaryFades != null) { foreach (PQSMod_CelestialBodyTransform.AltitudeFade af in c.secondaryFades) { node.TryGetValue("PQSSecfadeStart", ref af.fadeStart); node.TryGetValue("PQSSecfadeEnd", ref af.fadeEnd); } } } } } } catch (Exception e) { print("CBT fix for " + node.name + " failed: " + e.Message); } } print("Did CBT for " + node.name); yield return null; #endregion #region Science // Science if (node.HasNode("CelestialBodyScienceParams")) { guiMinor = "Science"; //OnGui(); ConfigNode spNode = node.GetNode("CelestialBodyScienceParams"); if (body.scienceValues != null) { foreach (ConfigNode.Value val in spNode.values) { // meh, for now hard-code it. Saves worry of GIGO. /*if(body.scienceValues.GetType().GetField(val.name) != null) if(float.TryParse(val.value, out ftmp)) body.scienceValues.GetType().GetField(val.name).SetValue(*/ spNode.TryGetValue("LandedDataValue", ref body.scienceValues.LandedDataValue); spNode.TryGetValue("SplashedDataValue", ref body.scienceValues.SplashedDataValue); spNode.TryGetValue("FlyingLowDataValue", ref body.scienceValues.FlyingLowDataValue); spNode.TryGetValue("FlyingHighDataValue", ref body.scienceValues.FlyingHighDataValue); spNode.TryGetValue("InSpaceLowDataValue", ref body.scienceValues.InSpaceLowDataValue); spNode.TryGetValue("InSpaceHighDataValue", ref body.scienceValues.InSpaceHighDataValue); spNode.TryGetValue("RecoveryValue", ref body.scienceValues.RecoveryValue); spNode.TryGetValue("flyingAltitudeThreshold", ref body.scienceValues.flyingAltitudeThreshold); spNode.TryGetValue("spaceAltitudeThreshold", ref body.scienceValues.spaceAltitudeThreshold); } } guiMinor = ""; //OnGui(); } yield return null; #endregion }
public override void OnLoad(ConfigNode node) { if (thrustCurve == null) thrustCurve = new FloatCurve(); base.OnLoad(node); // Manually reload ignitions if not in editor if(!HighLogic.LoadedSceneIsEditor) node.TryGetValue("ignited", ref ignited); int pCount = propellants.Count; // thrust curve useThrustCurve = false; if (node.HasNode("thrustCurve") && node.HasValue("curveResource")) { if (node.GetValue("curveResource") != curveResource) { Debug.Log("*RFE* ERROR: curveResource doesn't match node's!"); curveResource = node.GetValue("curveResource"); } if (thrustCurve == null) { Debug.Log("*RFE* ERROR: have curve node but thrustCurve is null!"); thrustCurve = new FloatCurve(); thrustCurve.Load(node.GetNode("thrustCurve")); } if (curveResource != "") { for (int i = 0; i < pCount; ++i) { if (propellants[i].name.Equals(curveResource)) { curveProp = i; break; } } if (curveProp != -1) { useThrustCurve = true; } } } // Set from propellants bool instantThrottle = true; for (int i = 0; i < pCount; ++i) { if (RFSettings.Instance.instantThrottleProps.Contains(propellants[i].name)) { instantThrottle = false; } // any other stuff } // FIXME calculating throttle change rate if (!instantThrottle) throttleResponseRate = (float)(10d / Math.Sqrt(Math.Sqrt(part.mass * maxThrust))); else throttleResponseRate = 1000000f; // set fields Fields["thrustCurveDisplay"].guiActive = useThrustCurve; CreateEngine(); if (ullageSet == null) ullageSet = new Ullage.UllageSet(this); // Get thrust axis (only on create prefabs) if (part.partInfo == null || part.partInfo.partPrefab == null) { thrustAxis = Vector3.zero; foreach(Transform t in part.FindModelTransforms(thrustVectorTransformName)) { thrustAxis -= t.forward; } thrustAxis = thrustAxis.normalized; } ullageSet.SetThrustAxis(thrustAxis); // ullage if (node.HasNode("Ullage")) { ullageSet.Load(node.GetNode("Ullage")); } ullageSet.SetUllageEnabled(ullage); // load ignition resources if (node.HasNode("IGNITOR_RESOURCE")) ignitionResources.Clear(); foreach (ConfigNode n in node.GetNodes("IGNITOR_RESOURCE")) { ModuleResource res = new ModuleResource(); res.Load(n); ignitionResources.Add(res); } }
//Settings Functions Follow public void Load(ConfigNode node) { if (node.HasNode(configNodeName)) { ConfigNode TSTsettingsNode = new ConfigNode(); node.TryGetNode(configNodeName, ref TSTsettingsNode); TSTsettingsNode.TryGetValue( "FwindowPosX", ref FwindowPosX); TSTsettingsNode.TryGetValue( "FwindowPosY", ref FwindowPosY); TSTsettingsNode.TryGetValue( "SCwindowPosX", ref FwindowPosX); TSTsettingsNode.TryGetValue( "SCwindowPosY", ref FwindowPosY); TSTsettingsNode.TryGetValue( "CwindowPosX", ref CwindowPosX); TSTsettingsNode.TryGetValue( "CwindowPosY", ref CwindowPosY); TSTsettingsNode.TryGetValue( "GalwindowPosX", ref GalwindowPosX); TSTsettingsNode.TryGetValue( "GalwindowPosY", ref GalwindowPosY); TSTsettingsNode.TryGetValue( "BodwindowPosX", ref BodwindowPosX); TSTsettingsNode.TryGetValue( "BodwindowPosY", ref BodwindowPosY); TSTsettingsNode.TryGetValue( "ChemwinSml", ref ChemwinSml); TSTsettingsNode.TryGetValue( "ChemwinLge", ref ChemwinLge); TSTsettingsNode.TryGetValue( "TelewinSml", ref TelewinSml); TSTsettingsNode.TryGetValue( "TelewinLge", ref TelewinLge); TSTsettingsNode.TryGetValue( "UseAppLauncher", ref UseAppLauncher); TSTsettingsNode.TryGetValue( "debugging", ref debugging); TSTsettingsNode.TryGetValue( "Tooltips", ref Tooltips); Utilities.debuggingOn = debugging; TSTsettingsNode.TryGetValue( "maxChemCamContracts", ref maxChemCamContracts); TSTsettingsNode.TryGetValue( "photoOnlyChemCamContracts", ref photoOnlyChemCamContracts); TSTsettingsNode.TryGetValue("ZoomSkyBox", ref ZoomSkyBox); TSTsettingsNode.TryGetValue("scienceUndiscoveredScope", ref scienceUndiscoveredScope); TSTsettingsNode.TryGetValue("scienceDiscoveredScope", ref scienceDiscoveredScope); TSTsettingsNode.TryGetValue("repUndiscoveredScope", ref repUndiscoveredScope); TSTsettingsNode.TryGetValue("repDiscoveredScope", ref repDiscoveredScope); TSTsettingsNode.TryGetValue("fundsUndiscoveredScope", ref fundsUndiscoveredScope); TSTsettingsNode.TryGetValue("fundsdiscoveredScope", ref fundsdiscoveredScope); TSTsettingsNode.TryGetValue("scienceUndiscoveredChem", ref scienceUndiscoveredChem); TSTsettingsNode.TryGetValue("scienceDiscoveredChem", ref scienceDiscoveredChem); TSTsettingsNode.TryGetValue("repUndiscoveredChem", ref repUndiscoveredChem); TSTsettingsNode.TryGetValue("repDiscoveredChem", ref repDiscoveredChem); TSTsettingsNode.TryGetValue("fundsUndiscoveredChem", ref fundsUndiscoveredChem); TSTsettingsNode.TryGetValue("fundsdiscoveredChem", ref fundsdiscoveredChem); Utilities.Log_Debug("TSTSettings load complete"); } }
public void Load(ConfigNode node) { node.TryGetValue("name", ref name); node.TryGetValue("currentTL", ref currentTL); node.TryGetValue("techLevelEntryCost", ref techLevelEntryCost); node.TryGetValue("techLevelSciEntryCost", ref techLevelSciEntryCost); }
public virtual void SetDEVConfiguration(string newChamber, string newNozzle) { #if DEBUG Debug.Log($"replacing {chamber} & {nozzle} with:"); Debug.Log(newChamber +"&"+ newNozzle); #endif chamberConfig = chambers.Find(c => c.GetValue("name").Equals(newChamber)); nozzleConfig = nozzles.Find(c => c.GetValue("name").Equals(newNozzle)); string s = ""; bool validate = chamberConfig.TryGetValue("type", ref s)&&nozzleConfig.TryGetValue("type", ref s); try { if (!validate) { Debug.Log("*RFMEC*DEV�� ERROR could not find configuration of name " + newChamber+"&" + newNozzle); chamberConfig = chambers.First(); nozzleConfig = nozzles.First(); } chamber = chamberConfig.GetValue("name"); nozzle = nozzleConfig.GetValue("name"); } catch (System.Exception ex) { Debug.Log("*RFMEC*DEV�� ERROR no configuration availble " + newChamber + "&" + newNozzle+",params unchanged"); Debug.LogException(ex); return; } if (pModule is ModuleEnginesDEV) { ModuleEnginesDEV pMDEV = (pModule as ModuleEnginesDEV); pMDEV.nominalPcns = float.Parse(chamberConfig.GetValue("nominalPcns")); pMDEV.maxMassFlow = float.Parse(chamberConfig.GetValue("maxMassFlow")); pMDEV.minMassFlow = float.Parse(chamberConfig.GetValue("minMassFlow")); pMDEV.At = float.Parse(nozzleConfig.GetValue("At")); pMDEV.nominalPe = float.Parse(nozzleConfig.GetValue("nominalPe")); pMDEV.nozzleType = nozzleConfig.GetValue("type"); pMDEV.chamberType = chamberConfig.GetValue("type"); pMDEV.CreateEngine(); } pMInfo = pModule.GetInfo(); }
/// <summary> /// Loads the Parachute from a ConfigNode. /// </summary> /// <param name="node">Node to load the Parachute from</param> private void Load(ConfigNode node) { node.TryGetValue("material", ref this.material); node.TryGetValue("preDeployedDiameter", ref this.preDeployedDiameter); node.TryGetValue("deployedDiameter", ref this.deployedDiameter); node.TryGetValue("minIsPressure", ref this.minIsPressure); node.TryGetValue("capOff", ref this.capOff); node.TryGetValue("minDeployment", ref this.minDeployment); node.TryGetValue("minPressure", ref this.minPressure); node.TryGetValue("deploymentAlt", ref this.deploymentAlt); node.TryGetValue("cutAlt", ref this.cutAlt); node.TryGetValue("preDeploymentSpeed", ref this.preDeploymentSpeed); node.TryGetValue("deploymentSpeed", ref this.deploymentSpeed); node.TryGetValue("time", ref this.time); node.TryGetValue("parachuteName", ref this.parachuteName); node.TryGetValue("baseParachuteName", ref this.baseParachuteName); node.TryGetValue("capName", ref this.capName); node.TryGetValue("preDeploymentAnimation", ref this.preDeploymentAnimation); node.TryGetValue("deploymentAnimation", ref this.deploymentAnimation); node.TryGetValue("forcedOrientation", ref this.forcedOrientation); node.TryGetValue("depState", ref this.depState); MaterialsLibrary.instance.TryGetMaterial(this.material, ref this.mat); Transform p = this.part.FindModelTransform(this.parachuteName); if (p != null) { p.gameObject.SetActive(false); } }
public void Start() { if (!CompatibilityChecker.IsCompatible()) { isCompatible = false; return; } if (!(HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.SPACECENTER)) return; foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM")) RSSSettings = node; if (RSSSettings != null) { RSSSettings.TryGetValue("dumpOrbits", ref dumpOrbits); } UpdateAtmospheres(); GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged); }
public override void OnLoad(ConfigNode node) { node.TryGetValue("mirrorTexturing", ref isMirrored); if (WPDebug.logEvents) DebugLogWithID("OnLoad", "Invoked"); //WingProceduralManager.LoadConfigs(); }
/// <summary> /// Loads the ChuteTemplate from the given ConfigNode /// </summary> /// <param name="node">ConfigNode to load the object from</param> private void Load(ConfigNode node) { node.TryGetValue("chuteID", ref chuteID); node.TryGetValue("modelID", ref modelID); node.TryGetValue("typeID", ref typeID); node.TryGetValue("lastTypeID", ref lastTypeID); node.TryGetValue("position", ref position); node.TryGetValue("isPressure", ref isPressure); node.TryGetValue("calcSelect", ref calcSelect); node.TryGetValue("getMass", ref getMass); node.TryGetValue("useDry", ref useDry); node.TryGetValue("preDepDiam", ref preDepDiam); node.TryGetValue("depDiam", ref depDiam); node.TryGetValue("predepClause", ref predepClause); node.TryGetValue("mass", ref mass); node.TryGetValue("landingSpeed", ref landingSpeed); node.TryGetValue("deceleration", ref deceleration); node.TryGetValue("refDepAlt", ref refDepAlt); node.TryGetValue("chuteCount", ref chuteCount); node.TryGetValue("deploymentAlt", ref deploymentAlt); node.TryGetValue("cutAlt", ref cutAlt); node.TryGetValue("preDepSpeed", ref preDepSpeed); node.TryGetValue("depSpeed", ref depSpeed); }
/// <summary> /// Loads the ChuteTemplate from the given ConfigNode /// </summary> /// <param name="node">ConfigNode to load the object from</param> private void Load(ConfigNode node) { int t = 0; node.TryGetValue("chuteID", ref this.templateGUI.chuteID); node.TryGetValue("modelID", ref this.templateGUI.modelID); if (node.TryGetValue("typeID", ref t)) { this.templateGUI.typeID = t; } if (node.TryGetValue("lastTypeID", ref t)) { this.templateGUI.lastTypeID = t; } node.TryGetValue("position", ref this.position); node.TryGetValue("isPressure", ref this.templateGUI.isPressure); node.TryGetValue("calcSelect", ref this.templateGUI.calcSelect); node.TryGetValue("getMass", ref this.templateGUI.getMass); node.TryGetValue("useDry", ref this.templateGUI.useDry); node.TryGetValue("preDepDiam", ref this.templateGUI.preDepDiam); node.TryGetValue("depDiam", ref this.templateGUI.depDiam); node.TryGetValue("predepClause", ref this.templateGUI.predepClause); node.TryGetValue("mass", ref this.templateGUI.mass); node.TryGetValue("landingSpeed", ref this.templateGUI.landingSpeed); node.TryGetValue("deceleration", ref this.templateGUI.deceleration); node.TryGetValue("refDepAlt", ref this.templateGUI.refDepAlt); node.TryGetValue("chuteCount", ref this.templateGUI.chuteCount); node.TryGetValue("deploymentAlt", ref this.templateGUI.deploymentAlt); node.TryGetValue("cutAlt", ref this.templateGUI.cutAlt); node.TryGetValue("preDepSpeed", ref this.templateGUI.preDepSpeed); node.TryGetValue("depSpeed", ref this.templateGUI.depSpeed); }
public static void UpdateAFG(CelestialBody body, AtmosphereFromGround afg, ConfigNode modNode = null) { if(modNode != null) { float ftmp; // the default afg.outerRadius = (float)body.Radius * 1.025f * ScaledSpace.InverseScaleFactor; if (modNode.TryGetValue("outerRadius", ref afg.outerRadius)) { afg.outerRadius *= ScaledSpace.InverseScaleFactor; } else if (modNode.HasValue("outerRadiusAtmo")) { afg.outerRadius = ((float)body.Radius + body.maxAtmosphereAltitude) * ScaledSpace.InverseScaleFactor; } else if (modNode.TryGetValue("outerRadiusMult", ref afg.outerRadius)) { afg.outerRadius *= (float)body.Radius * ScaledSpace.InverseScaleFactor; } // the default afg.innerRadius = afg.outerRadius * 0.975f; if (modNode.TryGetValue("innerRadius", ref afg.innerRadius)) { afg.innerRadius *= ScaledSpace.InverseScaleFactor; } else if (modNode.TryGetValue("innerRadiusMult", ref afg.innerRadius)) { afg.innerRadius *= afg.outerRadius; } modNode.TryGetValue("doScale", ref afg.doScale); if (modNode.HasValue("transformScale")) { if (float.TryParse(modNode.GetValue("transformScale"), out ftmp) && afg.transform != null) afg.transform.localScale = new Vector3(ftmp, ftmp, ftmp); } else if (modNode.HasValue("transformAtmo")) { afg.transform.localScale = Vector3.one * ((float)(body.Radius + body.maxAtmosphereAltitude) / (float)body.Radius); } if (modNode.HasValue("invWaveLength")) { //will be recomputed by SQUAD anyway so no point. // so instead, compute waveLength from it try { Vector4 col = KSPUtil.ParseVector4(modNode.GetValue("invWaveLength")); afg.invWaveLength = new Color(col.x, col.y, col.z, col.w); afg.waveLength = new Color((float)Math.Pow(1/col.x, 0.25), (float)Math.Pow(1/col.y, 0.25), (float)Math.Pow(1/col.z, 0.25), 1f); } catch(Exception e) { print("*RSS* Error parsing as color4: original text: " + modNode.GetValue("invWaveLength") + " --- exception " + e.Message); } } if (modNode.HasValue("waveLength")) { try { Vector4 col = KSPUtil.ParseVector4(modNode.GetValue("waveLength")); afg.waveLength = new Color(col.x, col.y, col.z, col.w); } catch(Exception e) { print("*RSS* Error parsing as color4: original text: " + modNode.GetValue("waveLength") + " --- exception " + e.Message); } } modNode.TryGetValue("Kr", ref afg.Kr); modNode.TryGetValue("Km", ref afg.Km); modNode.TryGetValue("ESun", ref afg.ESun); modNode.TryGetValue("g", ref afg.g); modNode.TryGetValue("samples", ref afg.samples); } else { // the defaults afg.outerRadius = (float)body.Radius * 1.025f * ScaledSpace.InverseScaleFactor; afg.innerRadius = afg.outerRadius * 0.975f; } afg.KrESun = afg.Kr * afg.ESun; afg.KmESun = afg.Km * afg.ESun; afg.Kr4PI = afg.Kr * 4f * (float)Math.PI; afg.Km4PI = afg.Km * 4f * (float)Math.PI; afg.g2 = afg.g * afg.g; afg.outerRadius2 = afg.outerRadius * afg.outerRadius; afg.innerRadius2 = afg.innerRadius * afg.innerRadius; afg.scale = 1f / (afg.outerRadius - afg.innerRadius); afg.scaleDepth = -0.25f; afg.scaleOverScaleDepth = afg.scale / afg.scaleDepth; try { MethodInfo setMaterial = afg.GetType().GetMethod("SetMaterial", BindingFlags.NonPublic | BindingFlags.Instance); setMaterial.Invoke(afg, new object[] { true }); } catch (Exception e) { print("*RSS* *ERROR* setting AtmosphereFromGround " + afg.name + " for body " + body.name + ": " + e); } }
internal static PartInfo Load(ConfigNode node) { string PartName = "Unknown"; node.TryGetValue("PartName", ref PartName); double lastUpdate = 0.0; node.TryGetValue("lastUpdate", ref lastUpdate); string tmpvesselID = ""; node.TryGetValue("vesselID", ref tmpvesselID); Guid vesselID = Guid.Empty; try { vesselID = new Guid(tmpvesselID); } catch (Exception ex) { vesselID = Guid.Empty; Debug.Log("DFInterface - Load of GUID VesselID for known part failed Err: " + ex); } PartInfo info = new PartInfo(vesselID, PartName, lastUpdate); node.TryGetValue("numSeats", ref info.numSeats); node.TryGetValue("numCrew", ref info.numCrew); string CrewString = ""; node.TryGetValue("crewMembers", ref CrewString); string[] CrewStrings = CrewString.Split(','); if (CrewStrings.Length > 0) { for (int i = 0; i < CrewStrings.Length; i++) { info.crewMembers.Add(CrewStrings[i]); } } string CrewTraitString = ""; node.TryGetValue("crewMemberTraits", ref CrewTraitString); string[] CrewTStrings = CrewTraitString.Split(','); if (CrewTStrings.Length > 0) { for (int i = 0; i < CrewTStrings.Length; i++) { info.crewMemberTraits.Add(CrewTStrings[i]); } } node.TryGetValue("numFrznCrew", ref info.numFrznCrew); node.TryGetValue("hibernating", ref info.hibernating); node.TryGetValue("hasextDoor", ref info.hasextDoor); node.TryGetValue("hasextPod", ref info.hasextPod); node.TryGetValue("timeLastElectricity", ref info.timeLastElectricity); node.TryGetValue("frznChargeRequired", ref info.frznChargeRequired); node.TryGetValue("timeLastTempCheck", ref info.timeLastTempCheck); node.TryGetValue("deathCounter", ref info.deathCounter); node.TryGetValue("tmpdeathCounter", ref info.tmpdeathCounter); node.TryGetValue("outofEC", ref info.outofEC); info.TmpStatus = Utilities.GetNodeValue(node, "TmpStatus", FrzrTmpStatus.OK); node.TryGetValue("cabinTemp", ref info.cabinTemp); node.TryGetValue("ECWarning", ref info.ECWarning); node.TryGetValue("TempWarning", ref info.TempWarning); return info; }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); node.TryGetValue("mirrorTexturing", ref isMirrored); }