public override void Start() { base.Start(); if (ullageSet == null) { ullageSet = new Ullage.UllageSet(this); } Fields["ignitions"].guiActive = Fields["ignitions"].guiActiveEditor = (ignitions >= 0); Fields["propellantStatus"].guiActive = Fields["propellantStatus"].guiActiveEditor = (pressureFed || ullage); igniteFailIgnitions = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: no ignitions remaining!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); igniteFailResources = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: insufficient resources to ignite!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); ullageFail = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: vapor in feedlines, shut down!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); }
public override void Start() { if (curveResource != string.Empty) { curveProp = propellants.FirstOrDefault(x => x.name.Equals(curveResource)); } useThrustCurve = curveProp is Propellant; CalcThrottleResponseRate(ref throttleResponseRate, ref instantThrottle); if (!HighLogic.LoadedSceneIsFlight) { ignited = false; } base.Start(); if (!(engineSolver is SolverRF)) { CreateEngine(); } ullageSet = new Ullage.UllageSet(this); ullageSet.Load(ullageNode); Fields[nameof(ignitions)].guiActive = ignitions >= 0 && RFSettings.Instance.limitedIgnitions; Fields[nameof(tags)].guiActiveEditor = ShowPropStatus; Fields[nameof(propellantStatus)].guiActive = Fields[nameof(propellantStatus)].guiActiveEditor = ShowPropStatus; Fields[nameof(sIgnitions)].guiActiveEditor = RFSettings.Instance.limitedIgnitions; igniteFailIgnitions = new ScreenMessage($"<color=orange>[{part.partInfo.title}]: no ignitions remaining!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); igniteFailResources = new ScreenMessage($"<color=orange>[{part.partInfo.title}]: insufficient resources to ignite!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); ullageFail = new ScreenMessage($"<color=orange>[{part.partInfo.title}]: vapor in feedlines, shut down!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); Fields[nameof(thrustPercentage)].guiActive = Fields[nameof(thrustPercentage)].guiActiveEditor = minFuelFlow != maxFuelFlow; Fields[nameof(thrustCurveDisplay)].guiActive = useThrustCurve; var group = Fields[nameof(propellantStatus)].group; Fields[nameof(engineTempString)].group = group; Fields[nameof(actualThrottle)].group = group; Fields[nameof(realIsp)].group = group; Fields[nameof(finalThrust)].group = group; Fields[nameof(propellantReqMet)].group = group; Fields[nameof(fuelFlowGui)].group = group; SetFields(); started = true; }
public override void Start() { base.Start(); if (ullageSet == null) { ullageSet = new Ullage.UllageSet(this); } showPropStatus = (pressureFed || (ullage && RFSettings.Instance.simulateUllage)); Fields["ignitions"].guiActive = Fields["ignitions"].guiActiveEditor = (ignitions >= 0 && RFSettings.Instance.limitedIgnitions); Fields["propellantStatus"].guiActive = Fields["propellantStatus"].guiActiveEditor = showPropStatus; Fields[nameof(pressureFed)].guiActive = true; igniteFailIgnitions = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: no ignitions remaining!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); igniteFailResources = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: insufficient resources to ignite!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); ullageFail = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: vapor in feedlines, shut down!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); }
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 Start() { base.Start(); if (ullageSet == null) ullageSet = new Ullage.UllageSet(this); Fields["ignitions"].guiActive = Fields["ignitions"].guiActiveEditor = (ignitions >= 0 && RFSettings.Instance.limitedIgnitions); Fields["propellantStatus"].guiActive = Fields["propellantStatus"].guiActiveEditor = (pressureFed || (ullage && RFSettings.Instance.simulateUllage)); igniteFailIgnitions = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: no ignitions remaining!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); igniteFailResources = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: insufficient resources to ignite!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); ullageFail = new ScreenMessage("<color=orange>[" + part.partInfo.title + "]: vapor in feedlines, shut down!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); }
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); } }
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); } }
public override void Start() { if (curveResource != string.Empty) { curveProp = propellants.FirstOrDefault(x => x.name.Equals(curveResource)); } useThrustCurve = curveProp is Propellant; CalcThrottleResponseRate(ref throttleResponseRate, ref instantThrottle); if (!HighLogic.LoadedSceneIsFlight) { partSeed = -1; calculatedResiduals = localResidualsThresholdBase; ignited = false; } else { if (partSeed == -1) { calculatedResiduals = localResidualsThresholdBase + UnityEngine.Random.Range(0f, (float)localVaryResiduals); partSeed = UnityEngine.Random.Range(0, int.MaxValue); } } base.Start(); if (!(engineSolver is SolverRF)) { CreateEngine(); } // Setup for mixture variation backupPropellantRatios.Clear(); oxidizerPropellant = fuelPropellant = null; for (int i = 0; i < propellants.Count(); ++i) { Propellant p = propellants[i]; backupPropellantRatios.Add(p.ratio); if (p.ignoreForIsp || p.resourceDef.density == 0d) { continue; } if (fuelPropellant == null) { fuelPropellant = p; } else if (oxidizerPropellant == null) { oxidizerPropellant = p; } } if (fuelPropellant != null && oxidizerPropellant != null) { mixtureRatio = (oxidizerPropellant.ratio * oxidizerPropellant.resourceDef.density) / (fuelPropellant.ratio * fuelPropellant.resourceDef.density); } ullageSet = new Ullage.UllageSet(this); ullageSet.Load(ullageNode); Fields[nameof(ignitions)].guiActive = ignitions >= 0 && RFSettings.Instance.limitedIgnitions; Fields[nameof(tags)].guiActiveEditor = ShowPropStatus; Fields[nameof(propellantStatus)].guiActive = Fields[nameof(propellantStatus)].guiActiveEditor = ShowPropStatus; Fields[nameof(sIgnitions)].guiActiveEditor = RFSettings.Instance.limitedIgnitions; igniteFailIgnitions = new ScreenMessage($"<color=orange>[{part.partInfo.title}]: no ignitions remaining!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); igniteFailResources = new ScreenMessage($"<color=orange>[{part.partInfo.title}]: insufficient resources to ignite!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); ullageFail = new ScreenMessage($"<color=orange>[{part.partInfo.title}]: vapor in feedlines, shut down!</color>", 5f, ScreenMessageStyle.UPPER_CENTER); Fields[nameof(thrustPercentage)].guiActive = Fields[nameof(thrustPercentage)].guiActiveEditor = minFuelFlow != maxFuelFlow; Fields[nameof(thrustCurveDisplay)].guiActive = useThrustCurve; var group = Fields[nameof(propellantStatus)].group; Fields[nameof(engineTempString)].group = group; Fields[nameof(actualThrottle)].group = group; Fields[nameof(realIsp)].group = group; Fields[nameof(finalThrust)].group = group; Fields[nameof(propellantReqMet)].group = group; Fields[nameof(fuelFlowGui)].group = group; SetFields(); started = true; }