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 List <PartResource> 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("name", "FNModuleRCSFX"); moduleConfig.AddValue("thrusterPower", attachedRCS.thrusterPower.ToString("0.000")); moduleConfig.AddValue("resourceName", new_propellant.name); moduleConfig.AddValue("resourceFlowMode", "STAGE_PRIORITY_FLOW"); 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")); atmosphereCurve.AddValue("key", "1 " + (maxPropellantIsp * 0.5).ToString("0.000")); atmosphereCurve.AddValue("key", "4 " + (maxPropellantIsp * 0.00001).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; } }
private void SetupPropellants(bool moveNext, int maxSwitching) { Current_propellant = fuel_mode < _propellants.Count ? _propellants[fuel_mode] : _propellants.FirstOrDefault(); 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 //List<PartResource> totalpartresources = part.GetConnectedResources(new_propellant.name).ToList(); //if (!totalpartresources.Any() && maxSwitching > 0) //{ // SwitchPropellant(moveNext, --maxSwitching); // return; //} var resourceDefinition = PartResourceLibrary.Instance.GetDefinition(new_propellant.name); double amount; double maxAmount; part.GetConnectedResourceTotals(resourceDefinition.id, out amount, out maxAmount); if (maxAmount > 0 && maxSwitching > 0) { SwitchPropellant(moveNext, --maxSwitching); return; } } if (PartResourceLibrary.Instance.GetDefinition(new_propellant.name) != null) { currentThrustMultiplier = hasSufficientPower ? Current_propellant.ThrustMultiplier : Current_propellant.ThrustMultiplierCold; var moduleConfig = new ConfigNode("MODULE"); moduleConfig.AddValue("name", "ModuleRCSFX"); moduleConfig.AddValue("thrusterPower", ((thrustLimiter / 100) * currentThrustMultiplier * baseThrust / Current_propellant.IspMultiplier).ToString("0.000")); moduleConfig.AddValue("resourceName", new_propellant.name); moduleConfig.AddValue("resourceFlowMode", "STAGE_PRIORITY_FLOW"); maxPropellantIsp = (hasSufficientPower ? maxIsp : minIsp) * Current_propellant.IspMultiplier * currentThrustMultiplier; var atmosphereCurve = new ConfigNode("atmosphereCurve"); atmosphereCurve.AddValue("key", "0 " + (maxPropellantIsp).ToString("0.000")); atmosphereCurve.AddValue("key", "1 " + (maxPropellantIsp * 0.5).ToString("0.000")); atmosphereCurve.AddValue("key", "4 " + (maxPropellantIsp * 0.00001).ToString("0.000")); moduleConfig.AddNode(atmosphereCurve); attachedRCS.Load(moduleConfig); } else if (maxSwitching > 0) { SwitchPropellant(moveNext, --maxSwitching); return; } }