public override void OnLoad(ConfigNode node) { 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.LogError("*RFE* ERROR: curveResource doesn't match node's!"); curveResource = node.GetValue("curveResource"); } if (thrustCurve == null) { Debug.LogError("*RFE* ERROR: have curve node but thrustCurve is null!"); thrustCurve = new FloatCurve(); thrustCurve.Load(node.GetNode("thrustCurve")); } if (curveResource != string.Empty) { for (int i = 0; i < pCount; ++i) { if (propellants[i].name.Equals(curveResource)) { curveProp = i; break; } } if (curveProp != -1) { useThrustCurve = true; } } Fields["thrustPercentage"].guiActive = Fields["thrustPercentage"].guiActiveEditor = (minFuelFlow != maxFuelFlow); } // Set from propellants bool instantThrottle = false; for (int i = 0; i < pCount; ++i) { if (RFSettings.Instance.instantThrottleProps.Contains(propellants[i].name)) { instantThrottle = true; } // any other stuff } // FIXME calculating throttle change rate if (!instantThrottle) { if (throttleResponseRate <= 0f) { throttleResponseRate = (float)(RFSettings.Instance.throttlingRate / Math.Log(Math.Max(RFSettings.Instance.throttlingClamp, Math.Sqrt(part.mass * maxThrust * maxThrust)))); } } else { throttleResponseRate = 1000000f; } minThrottle = minFuelFlow / maxFuelFlow; // 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")); } if (node.HasValue("pressureFed")) { bool.TryParse(node.GetValue("pressureFed"), out pressureFed); Debug.Log(this.name + ".pressureFed = " + this.pressureFed); } 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); } }
public override void OnLoad(ConfigNode node) { if (thrustCurve == null) { thrustCurve = new FloatCurve(); } base.OnLoad(node); 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); } }