private void LoadConfig() { double effectiveIspMultiplier = (type == (int)ElectricEngineType.ARCJET) ? CurrentPropellant.DecomposedIspMult : CurrentPropellant.IspMultiplier; string propName = CurrentPropellant.Propellant.name; var moduleConfig = new ConfigNode("MODULE"); moduleConfig.AddValue("thrusterPower", attachedRCS.thrusterPower. ToString("F3")); moduleConfig.AddValue("resourceName", propName); moduleConfig.AddValue("resourceFlowMode", "STAGE_PRIORITY_FLOW"); var propellantConfigNode = moduleConfig.AddNode("PROPELLANT"); propellantConfigNode.AddValue("name", propName); propellantConfigNode.AddValue("ratio", "1"); propellantConfigNode.AddValue("DrawGauge", "True"); propellantConfigNode.AddValue("resourceFlowMode", "STAGE_PRIORITY_FLOW"); attachedRCS.Load(propellantConfigNode); currentThrustMultiplier = hasSufficientPower ? CurrentPropellant. ThrustMultiplier : CurrentPropellant.ThrustMultiplierCold; var effectiveBaseIsp = hasSufficientPower ? maxIsp : minIsp; maxPropellantIsp = (float)(effectiveBaseIsp * effectiveIspMultiplier * currentThrustMultiplier); var atmosphereCurve = new ConfigNode("atmosphereCurve"); atmosphereCurve.AddValue("key", "0 " + maxPropellantIsp.ToString("F3")); if (type == (int)ElectricEngineType.VACUUMTHRUSTER) { atmosphereCurve.AddValue("key", "1 " + (maxPropellantIsp).ToString("F3")); } else { atmosphereCurve.AddValue("key", "1 " + (maxPropellantIsp * 0.5). ToString("F3")); atmosphereCurve.AddValue("key", "4 " + (maxPropellantIsp * 0.00001). ToString("F3")); } moduleConfig.AddNode(atmosphereCurve); attachedRCS.Load(moduleConfig); thrustIspMultiplier = currentThrustMultiplier.ToString("F2") + " / " + maxPropellantIsp.ToString("F0") + " s"; }
private void SetupPropellants(bool moveNext = true, int maxSwitching = 0) { Current_propellant = fuel_mode < _propellants.Count ? _propellants[fuel_mode] : _propellants.FirstOrDefault(); fuel_mode_name = Current_propellant.PropellantName; if ((Current_propellant.SupportedEngines & type) != type) { SwitchPropellant(moveNext, --maxSwitching); return; } Propellant new_propellant = Current_propellant.Propellant; if (HighLogic.LoadedSceneIsFlight) { // you can have any fuel you want in the editor but not in flight var totalpartresources = part.GetConnectedResources(new_propellant.name).ToList(); if (!totalpartresources.Any() && maxSwitching > 0) { SwitchPropellant(moveNext, --maxSwitching); return; } } if (PartResourceLibrary.Instance.GetDefinition(new_propellant.name) != null) { var effectiveIspMultiplier = type == 2 ? Current_propellant.DecomposedIspMult : Current_propellant.IspMultiplier; //var effectiveThrust = (thrustLimiter / 100) * Current_propellant.ThrustMultiplier * baseThrust / effectiveIspMultiplier; var moduleConfig = new ConfigNode("MODULE"); moduleConfig.AddValue("thrusterPower", attachedRCS.thrusterPower.ToString("0.000")); moduleConfig.AddValue("resourceName", new_propellant.name); moduleConfig.AddValue("resourceFlowMode", "STAGE_PRIORITY_FLOW"); //var newPropNode = new ConfigNode(); ConfigNode propellantConfigNode = moduleConfig.AddNode("PROPELLANT"); propellantConfigNode.AddValue("name", new_propellant.name); propellantConfigNode.AddValue("ratio", "1"); propellantConfigNode.AddValue("DrawGauge", "True"); propellantConfigNode.AddValue("resourceFlowMode", "STAGE_PRIORITY_FLOW"); attachedRCS.Load(propellantConfigNode); currentThrustMultiplier = hasSufficientPower ? Current_propellant.ThrustMultiplier : Current_propellant.ThrustMultiplierCold; //var effectiveThrustModifier = currentThrustMultiplier * (currentThrustMultiplier / Current_propellant.ThrustMultiplier); var effectiveBaseIsp = hasSufficientPower ? maxIsp : minIsp; maxPropellantIsp = (float)(effectiveBaseIsp * effectiveIspMultiplier * currentThrustMultiplier); var atmosphereCurve = new ConfigNode("atmosphereCurve"); atmosphereCurve.AddValue("key", "0 " + (maxPropellantIsp).ToString("0.000")); if (type != 8) { atmosphereCurve.AddValue("key", "1 " + (maxPropellantIsp * 0.5).ToString("0.000")); atmosphereCurve.AddValue("key", "4 " + (maxPropellantIsp * 0.00001).ToString("0.000")); } else { atmosphereCurve.AddValue("key", "1 " + (maxPropellantIsp).ToString("0.000")); } moduleConfig.AddNode(atmosphereCurve); attachedRCS.Load(moduleConfig); } else if (maxSwitching > 0) { Debug.Log("ElectricRCSController SetupPropellants switching mode because no definition found for " + new_propellant.name); SwitchPropellant(moveNext, --maxSwitching); return; } }