コード例 #1
0
            public LengthConfiguration(ConfigNode node)
            {
                node.TryGetValue("subtypeName", ref subtypeName);
                node.TryGetValue("subtypeAlias", ref subtypeAlias);
                node.TryGetValue("minThrust", ref minThrust);
                node.TryGetValue("maxThrust", ref maxThrust);
                node.TryGetValue("heatProduction", ref heatProduction);
                node.TryGetValue("totalLength", ref partLength);

                string str = "";

                node.TryGetValue("NozzlePosition", ref str);
                string[] strSplit = str.Split(","[0]);
                localPosition = new Vector3(float.Parse(strSplit[0]),
                                            float.Parse(strSplit[1]),
                                            float.Parse(strSplit[2]));

                atmosphereCurve = Utils.GetValue(node, "atmosphereCurve", new FloatCurve());
                ConfigNode[] varNodes = node.GetNodes("PROPELLANT");
                propellants = new List <Propellant>();
                for (int i = 0; i < varNodes.Length; i++)
                {
                    Propellant p = new Propellant();
                    p.Load(varNodes[i]);
                    propellants.Add(p);
                }
            }
コード例 #2
0
    public void SwitchEngine()
    {
        ConfigNode nextEngine;

        if (currentMode == primaryModeName)
        {
            currentMode = secondaryModeName;
            nextEngine  = secondaryEngine;
        }
        else
        {
            currentMode = primaryModeName;
            nextEngine  = primaryEngine;
        }

        var engineActive = ActiveEngine.getIgnitionState;

        ActiveEngine.propellants = new List <Propellant> ();

        if (meter != null)
        {
            part.stackIcon.RemoveInfo(meter);
            meter = null;
        }

        ActiveEngine.velocityCurve   = new FloatCurve();
        ActiveEngine.atmosphereCurve = new FloatCurve();

        ActiveEngine.Fields.Load(nextEngine);

        if (nextEngine.HasValue("useVelocityCurve") && (nextEngine.GetValue("useVelocityCurve").ToLowerInvariant() == "true"))
        {
            ActiveEngine.velocityCurve.Load(nextEngine.GetNode("velocityCurve"));
        }
        else
        {
            ActiveEngine.useVelocityCurve = false;
        }

        foreach (ConfigNode n in nextEngine.nodes)
        {
            if (n.name == "PROPELLANT")
            {
                var prop = new Propellant();
                prop.Load(n);
                ActiveEngine.propellants.Add(prop);
            }
        }

        ActiveEngine.SetupPropellant();

        if (engineActive)
        {
            ActiveEngine.Actions ["ActivateAction"].Invoke(new KSPActionParam(KSPActionGroup.None, KSPActionType.Activate));
        }
    }
コード例 #3
0
 public ElectricEnginePropellant(ConfigNode node) {
     propellantname = node.GetValue("name");
     propellantguiname = node.GetValue("guiName");
     ispMultiplier = Convert.ToDouble(node.GetValue("ispMultiplier"));
     efficiency = Convert.ToDouble(node.GetValue("efficiency"));
     prop_type = Convert.ToInt32(node.GetValue("type"));
     effectname = node.GetValue("effectName");
     ConfigNode propellantnode = node.GetNode("PROPELLANT");
     propellant = new Propellant();
     propellant.Load(propellantnode);
 }
コード例 #4
0
ファイル: ModuleRCSFX.cs プロジェクト: enceos/ExplorationPack
 public void LoadPropellants(ConfigNode node)
 {
     propellants.Clear();
     foreach (ConfigNode prop in node.GetNodes("PROPELLANT"))
     {
         Propellant fuel = new Propellant();
         fuel.Load(prop);
         propellants.Add(fuel);
     }
     SetupPropellant();
 }
コード例 #5
0
        public ElectricEnginePropellant(ConfigNode node)
        {
            propellantname    = node.GetValue("name");
            propellantguiname = node.GetValue("guiName");
            ispMultiplier     = Convert.ToDouble(node.GetValue("ispMultiplier"));
            efficiency        = Convert.ToDouble(node.GetValue("efficiency"));
            prop_type         = Convert.ToInt32(node.GetValue("type"));
            effectname        = node.GetValue("effectName");
            ConfigNode propellantnode = node.GetNode("PROPELLANT");

            propellant = new Propellant();
            propellant.Load(propellantnode);
        }
コード例 #6
0
 public ElectricEnginePropellant(ConfigNode node)
 {
     propellantname = node.GetValue("name");
     propellantguiname = node.GetValue("guiName");
     ispMultiplier = Convert.ToSingle(node.GetValue("ispMultiplier"));
     thrustMultiplier = node.HasValue("thrustMultiplier") ? Convert.ToSingle(node.GetValue("thrustMultiplier")) : 1;
     thrustMultiplierCold = node.HasValue("thrustMultiplierCold") ? Convert.ToSingle(node.GetValue("thrustMultiplierCold")) : thrustMultiplier;
     wasteheatMultiplier = node.HasValue("wasteheatMultiplier") ? Convert.ToDouble(node.GetValue("wasteheatMultiplier")) : 1;
     efficiency = Convert.ToDouble(node.GetValue("efficiency"));
     prop_type = Convert.ToInt32(node.GetValue("type"));
     effectname = node.GetValue("effectName");
     techRquirement = node.HasValue("techRequirement") ? node.GetValue("techRequirement") : String.Empty;
     ConfigNode propellantnode = node.GetNode("PROPELLANT");
     propellant = new Propellant();
     propellant.Load(propellantnode);
 }
コード例 #7
0
        public ElectricEnginePropellant(ConfigNode node)
        {
            propellantname       = node.GetValue("name");
            propellantguiname    = node.GetValue("guiName");
            ispMultiplier        = Convert.ToSingle(node.GetValue("ispMultiplier"));
            thrustMultiplier     = node.HasValue("thrustMultiplier") ? Convert.ToSingle(node.GetValue("thrustMultiplier")) : 1;
            thrustMultiplierCold = node.HasValue("thrustMultiplierCold") ? Convert.ToSingle(node.GetValue("thrustMultiplierCold")) : thrustMultiplier;
            wasteheatMultiplier  = node.HasValue("wasteheatMultiplier") ? Convert.ToDouble(node.GetValue("wasteheatMultiplier")) : 1;
            efficiency           = Convert.ToDouble(node.GetValue("efficiency"));
            prop_type            = Convert.ToInt32(node.GetValue("type"));
            effectname           = node.GetValue("effectName");
            techRquirement       = node.HasValue("techRequirement") ? node.GetValue("techRequirement") : String.Empty;
            ConfigNode propellantnode = node.GetNode("PROPELLANT");

            propellant = new Propellant();
            propellant.Load(propellantnode);
        }
        public ElectricEnginePropellant(ConfigNode node)
        {
            PropellantName = node.GetValue("name");

            PropellantGUIName    = node.HasValue("guiName") ? node.GetValue("guiName") : PropellantName;
            IsInfinite           = node.HasValue("isInfinite") && Convert.ToBoolean(node.GetValue("isInfinite"));
            IspMultiplier        = node.HasValue("ispMultiplier") ? Convert.ToSingle(node.GetValue("ispMultiplier")) : 1;
            DecomposedIspMult    = node.HasValue("decomposedIspMult") ? Convert.ToDouble(node.GetValue("decomposedIspMult")) : IspMultiplier;
            ThrustMultiplier     = node.HasValue("thrustMultiplier") ? Convert.ToDouble(node.GetValue("thrustMultiplier")) : 1;
            ThrustMultiplierCold = node.HasValue("thrustMultiplierCold") ? Convert.ToDouble(node.GetValue("thrustMultiplierCold")) : ThrustMultiplier;
            WasteHeatMultiplier  = node.HasValue("wasteheatMultiplier") ? Convert.ToDouble(node.GetValue("wasteheatMultiplier")) : 1;
            Efficiency           = node.HasValue("efficiency") ? Convert.ToDouble(node.GetValue("efficiency")) : 1;
            PropType             = node.HasValue("type") ? Convert.ToInt32(node.GetValue("type")) : 1;
            ParticleFXName       = node.HasValue("effectName")  ? node.GetValue("effectName") : "none";
            TechRequirement      = node.HasValue("techRequirement") ? node.GetValue("techRequirement") : String.Empty;

            ConfigNode propellantNode = node.GetNode("PROPELLANT");

            Propellant = new Propellant();
            Propellant.Load(propellantNode);
        }
コード例 #9
0
		public void setupPropellants() {
			ConfigNode chosenpropellant = propellants[fuel_mode];
			ConfigNode[] assprops = chosenpropellant.GetNodes("PROPELLANT");
			List<Propellant> list_of_propellants = new List<Propellant>();
			// loop though propellants until we get to the selected one, then set it up
			foreach(ConfigNode prop_node in assprops) 
            {
				fuelmode = chosenpropellant.GetValue("guiName");
				ispMultiplier = float.Parse(chosenpropellant.GetValue("ispMultiplier"));
				isLFO = bool.Parse(chosenpropellant.GetValue("isLFO"));
				currentpropellant_is_jet = false;
				if(chosenpropellant.HasValue("isJet")) {
					currentpropellant_is_jet = bool.Parse(chosenpropellant.GetValue("isJet"));
				}
				//print (currentpropellant_is_jet);

				Propellant curprop = new Propellant();
				curprop.Load(prop_node);
				if (curprop.drawStackGauge && HighLogic.LoadedSceneIsFlight) {
					curprop.drawStackGauge = false;
					if (currentpropellant_is_jet) {
						fuel_gauge.SetMessage("Atmosphere");
					}else {
						fuel_gauge.SetMessage(curprop.name);
                        myAttachedEngine.thrustPercentage = 100;
                        part.temperature = 1;
					}
					fuel_gauge.SetMsgBgColor(XKCDColors.DarkLime);
					fuel_gauge.SetMsgTextColor(XKCDColors.ElectricLime);
					fuel_gauge.SetProgressBarColor(XKCDColors.Yellow);
					fuel_gauge.SetProgressBarBgColor(XKCDColors.DarkLime);
					fuel_gauge.SetValue(0f);
				}
				list_of_propellants.Add(curprop);
			}
            
			// update the engine with the new propellants
			if (PartResourceLibrary.Instance.GetDefinition(list_of_propellants[0].name) != null) {
				myAttachedEngine.propellants.Clear();
				myAttachedEngine.propellants = list_of_propellants;
				myAttachedEngine.SetupPropellant();
			}

            if (HighLogic.LoadedSceneIsFlight) { // you can have any fuel you want in the editor but not in flight
                // should we switch to another propellant because we have none of this one?
                bool next_propellant = false;
                List<Propellant> curEngine_propellants_list = new List<Propellant>();
                curEngine_propellants_list = myAttachedEngine.propellants;
                foreach (Propellant curEngine_propellant in curEngine_propellants_list) {
                    List<PartResource> partresources = part.GetConnectedResources(curEngine_propellant.name).ToList();

                    if (partresources.Count == 0 || !PartResourceLibrary.Instance.resourceDefinitions.Contains(list_of_propellants[0].name)) {
                        next_propellant = true;
                    }
                }

                // do the switch if needed
                if (next_propellant && fuel_mode != 1) {
                    TogglePropellant();
                }
            } else {
                if (!PartResourceLibrary.Instance.resourceDefinitions.Contains(list_of_propellants[0].name) && fuel_mode != 1) { // Still ignore propellants that don't exist
                    TogglePropellant();
                }
                estimateEditorPerformance(); // update editor estimates
            }

		}
コード例 #10
0
        public void setupPropellants()
        {
            ConfigNode chosenpropellant = propellants[fuel_mode];

            ConfigNode[]      assprops            = chosenpropellant.GetNodes("PROPELLANT");
            List <Propellant> list_of_propellants = new List <Propellant>();

            // loop though propellants until we get to the selected one, then set it up
            foreach (ConfigNode prop_node in assprops)
            {
                fuelmode                 = chosenpropellant.GetValue("guiName");
                ispMultiplier            = float.Parse(chosenpropellant.GetValue("ispMultiplier"));
                isLFO                    = bool.Parse(chosenpropellant.GetValue("isLFO"));
                currentpropellant_is_jet = false;
                if (chosenpropellant.HasValue("isJet"))
                {
                    currentpropellant_is_jet = bool.Parse(chosenpropellant.GetValue("isJet"));
                }
                //print (currentpropellant_is_jet);

                Propellant curprop = new Propellant();
                curprop.Load(prop_node);
                if (curprop.drawStackGauge && HighLogic.LoadedSceneIsFlight)
                {
                    curprop.drawStackGauge = false;
                    if (currentpropellant_is_jet)
                    {
                        fuel_gauge.SetMessage("Atmosphere");
                    }
                    else
                    {
                        fuel_gauge.SetMessage(curprop.name);
                        myAttachedEngine.thrustPercentage = 100;
                        part.temperature = 1;
                    }
                    fuel_gauge.SetMsgBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetMsgTextColor(XKCDColors.ElectricLime);
                    fuel_gauge.SetProgressBarColor(XKCDColors.Yellow);
                    fuel_gauge.SetProgressBarBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetValue(0f);
                }
                list_of_propellants.Add(curprop);
            }

            // update the engine with the new propellants
            if (PartResourceLibrary.Instance.GetDefinition(list_of_propellants[0].name) != null)
            {
                myAttachedEngine.propellants.Clear();
                myAttachedEngine.propellants = list_of_propellants;
                myAttachedEngine.SetupPropellant();
            }

            if (HighLogic.LoadedSceneIsFlight)   // you can have any fuel you want in the editor but not in flight
            // should we switch to another propellant because we have none of this one?
            {
                bool next_propellant = false;
                List <Propellant> curEngine_propellants_list = new List <Propellant>();
                curEngine_propellants_list = myAttachedEngine.propellants;
                foreach (Propellant curEngine_propellant in curEngine_propellants_list)
                {
                    List <PartResource> partresources = part.GetConnectedResources(curEngine_propellant.name).ToList();

                    if (partresources.Count == 0 || !PartResourceLibrary.Instance.resourceDefinitions.Contains(list_of_propellants[0].name))
                    {
                        next_propellant = true;
                    }
                }

                // do the switch if needed
                if (next_propellant && fuel_mode != 1)
                {
                    TogglePropellant();
                }
            }
            else
            {
                if (!PartResourceLibrary.Instance.resourceDefinitions.Contains(list_of_propellants[0].name) && fuel_mode != 1)   // Still ignore propellants that don't exist
                {
                    TogglePropellant();
                }
                estimateEditorPerformance(); // update editor estimates
            }
        }
コード例 #11
0
        public void evaluateMaxThrust()
        {
            bool electrothermal_prop = false;
            List<Part> vessel_parts = vessel.parts;
            total_power_output = 0;
            var curEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            ConfigNode chosenpropellant = propellants[fuel_mode];
            ConfigNode[] assprops = chosenpropellant.GetNodes("PROPELLANT");
            List<Propellant> list_of_propellants = new List<Propellant>();
            //bool propellant_is_upgrade = false;

            for (int i = 0; i < assprops.Length; ++i) {
                fuelmode = chosenpropellant.GetValue("guiName");
                ispMultiplier = float.Parse(chosenpropellant.GetValue("ispMultiplier"));
                thrust_efficiency = float.Parse(chosenpropellant.GetValue("efficiency"));
                //propellant_is_upgrade = bool.Parse(chosenpropellant.GetValue("isUpgraded"));
                electrothermal_prop = bool.Parse(chosenpropellant.GetValue("electroThermal"));
                Propellant curprop = new Propellant();
                curprop.Load(assprops[i]);
                if (curprop.drawStackGauge) {
                    curprop.drawStackGauge = false;
                    fuel_gauge.SetMessage(curprop.name);
                    fuel_gauge.SetMsgBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetMsgTextColor(XKCDColors.ElectricLime);
                    fuel_gauge.SetProgressBarColor(XKCDColors.Yellow);
                    fuel_gauge.SetProgressBarBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetValue(0f);
                }
                list_of_propellants.Add(curprop);
            }

            total_power_output = getStableResourceSupply(FNResourceManager.FNRESOURCE_MEGAJOULES);

            final_thrust_store = thrust_efficiency*2000.0f*total_power_output / (initialIsp * ispMultiplier * 9.81f);

            //float thrust_ratio = total_power_output / reference_power;
            //final_thrust_store = initial_thrust * thrust_ratio / ispMultiplier;

            FloatCurve newISP = new FloatCurve ();
            newISP.Add (0, initialIsp * ispMultiplier);
            curEngine.atmosphereCurve = newISP;

            if (PartResourceLibrary.Instance.GetDefinition(list_of_propellants[0].name) != null) {

                curEngine.propellants.Clear();
                curEngine.propellants = list_of_propellants;
                curEngine.SetupPropellant();
            }

            List<PartResource> partresources = new List<PartResource>();
            part.GetConnectedResources(curEngine.propellants[0].id, PartResourceLibrary.Instance.GetDefinition(curEngine.propellants[0].name).resourceFlowMode, partresources);

            //if(!isupgraded) {
            if (partresources.Count == 0 && fuel_mode != 0) {
                if (isThrusterElectrothermal && !electrothermal_prop) {
                    TogglePropellant();
                } else if (!isThrusterElectrothermal) {
                    TogglePropellant();
                }
            }
            //}else{
            //    if(!propellant_is_upgrade) {
                    //TogglePropellant();
               //     }
            //}
        }
コード例 #12
0
        public void evaluateMaxThrust()
        {
            bool        electrothermal_prop = false;
            List <Part> vessel_parts        = vessel.parts;

            total_power_output = 0;
            var        curEngine        = this.part.Modules["ModuleEngines"] as ModuleEngines;
            ConfigNode chosenpropellant = propellants[fuel_mode];

            ConfigNode[]      assprops            = chosenpropellant.GetNodes("PROPELLANT");
            List <Propellant> list_of_propellants = new List <Propellant>();

            //bool propellant_is_upgrade = false;

            for (int i = 0; i < assprops.Length; ++i)
            {
                fuelmode          = chosenpropellant.GetValue("guiName");
                ispMultiplier     = float.Parse(chosenpropellant.GetValue("ispMultiplier"));
                thrust_efficiency = float.Parse(chosenpropellant.GetValue("efficiency"));
                //propellant_is_upgrade = bool.Parse(chosenpropellant.GetValue("isUpgraded"));
                electrothermal_prop = bool.Parse(chosenpropellant.GetValue("electroThermal"));
                Propellant curprop = new Propellant();
                curprop.Load(assprops[i]);
                if (curprop.drawStackGauge)
                {
                    curprop.drawStackGauge = false;
                    fuel_gauge.SetMessage(curprop.name);
                    fuel_gauge.SetMsgBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetMsgTextColor(XKCDColors.ElectricLime);
                    fuel_gauge.SetProgressBarColor(XKCDColors.Yellow);
                    fuel_gauge.SetProgressBarBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetValue(0f);
                }
                list_of_propellants.Add(curprop);
            }

            total_power_output = getStableResourceSupply(FNResourceManager.FNRESOURCE_MEGAJOULES);

            final_thrust_store = thrust_efficiency * 2000.0f * total_power_output / (initialIsp * ispMultiplier * 9.81f);

            //float thrust_ratio = total_power_output / reference_power;
            //final_thrust_store = initial_thrust * thrust_ratio / ispMultiplier;

            FloatCurve newISP = new FloatCurve();

            newISP.Add(0, initialIsp * ispMultiplier);
            curEngine.atmosphereCurve = newISP;

            if (PartResourceLibrary.Instance.GetDefinition(list_of_propellants[0].name) != null)
            {
                curEngine.propellants.Clear();
                curEngine.propellants = list_of_propellants;
                curEngine.SetupPropellant();
            }

            List <PartResource> partresources = new List <PartResource>();

            part.GetConnectedResources(curEngine.propellants[0].id, PartResourceLibrary.Instance.GetDefinition(curEngine.propellants[0].name).resourceFlowMode, partresources);

            //if(!isupgraded) {
            if (partresources.Count == 0 && fuel_mode != 0)
            {
                if (isThrusterElectrothermal && !electrothermal_prop)
                {
                    TogglePropellant();
                }
                else if (!isThrusterElectrothermal)
                {
                    TogglePropellant();
                }
            }
            //}else{
            //    if(!propellant_is_upgrade) {
            //TogglePropellant();
            //     }
            //}
        }
コード例 #13
0
        public void setupPropellants()
        {
            ConfigNode chosenpropellant = propellants[fuel_mode];

            ConfigNode[]      assprops            = chosenpropellant.GetNodes("PROPELLANT");
            List <Propellant> list_of_propellants = new List <Propellant>();

            // loop though propellants until we get to the selected one, then set it up
            for (int i = 0; i < assprops.Length; ++i)
            {
                fuelmode                 = chosenpropellant.GetValue("guiName");
                ispMultiplier            = float.Parse(chosenpropellant.GetValue("ispMultiplier"));
                isLFO                    = bool.Parse(chosenpropellant.GetValue("isLFO"));
                currentpropellant_is_jet = false;
                if (chosenpropellant.HasValue("isJet"))
                {
                    currentpropellant_is_jet = bool.Parse(chosenpropellant.GetValue("isJet"));
                }
                //print (currentpropellant_is_jet);

                Propellant curprop = new Propellant();
                curprop.Load(assprops[i]);
                if (curprop.drawStackGauge)
                {
                    curprop.drawStackGauge = false;
                    if (currentpropellant_is_jet)
                    {
                        fuel_gauge.SetMessage("Atmosphere");
                    }
                    else
                    {
                        fuel_gauge.SetMessage(curprop.name);
                        myAttachedEngine.thrustPercentage = 100;
                        part.temperature = 1;
                    }
                    fuel_gauge.SetMsgBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetMsgTextColor(XKCDColors.ElectricLime);
                    fuel_gauge.SetProgressBarColor(XKCDColors.Yellow);
                    fuel_gauge.SetProgressBarBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetValue(0f);
                }
                list_of_propellants.Add(curprop);
            }
            // update the engine with the new propellants
            if (PartResourceLibrary.Instance.GetDefinition(list_of_propellants[0].name) != null)
            {
                myAttachedEngine.propellants.Clear();
                myAttachedEngine.propellants = list_of_propellants;
                myAttachedEngine.SetupPropellant();
            }

            // should we switch to another propellant because we have none of this one?
            bool next_propellant = false;
            List <Propellant> curEngine_propellants_list = new List <Propellant>();

            curEngine_propellants_list = myAttachedEngine.propellants;
            foreach (Propellant curEngine_propellant in curEngine_propellants_list)
            {
                List <PartResource> partresources = new List <PartResource>();
                part.GetConnectedResources(curEngine_propellant.id, partresources);

                if (partresources.Count == 0 || !PartResourceLibrary.Instance.resourceDefinitions.Contains(list_of_propellants[0].name))
                {
                    next_propellant = true;
                }
            }
            // do the switch if needed
            if (next_propellant && fuel_mode != 1)
            {
                TogglePropellant();
            }
        }
コード例 #14
0
        /// <summary>
        /// Load the engine config
        /// </summary>
        /// <param name="node">The config node to load from</param>
        public void Load(ConfigNode node)
        {
            if (node.name.Equals("MODE"))
            {
                ConfigNode.LoadObjectFromConfig(this, node);

                //load the propellants
                ConfigNode[] propellantNodes = node.GetNodes("PROPELLANT");
                propellants = new List <Propellant>();
                for (int i = 0; i < propellantNodes.Length; i++)
                {
                    Propellant p = new Propellant();
                    p.Load(propellantNodes[i]);
                    propellants.Add(p);
                }

                //load the name of the mode
                if (node.HasValue("name"))
                {
                    name = node.GetValue("name");
                }

                //load the curve for atmosphere ISP or Thrust
                if (node.HasNode("atmosphereISPCurve"))
                {
                    atmosphereISPCurve = new FloatCurve();
                    atmosphereISPCurve.Load(node.GetNode("atmosphereISPCurve"));

                    float tmpMin;
                    atmosphereISPCurve.FindMinMaxValue(out tmpMin, out maxISP);
                }
                else if (node.HasNode("atmosphereThrustCurve"))
                {
                    atmosphereThrustCurve = new FloatCurve();
                    atmosphereThrustCurve.Load(node.GetNode("atmosphereThrustCurve"));
                }
                else
                {
                    atmosphereISPCurve = new FloatCurve();
                    atmosphereISPCurve.Add(0, 0);
                    atmosphereISPCurve.Add(1, 100);
                    maxISP = 100;
                }

                //load the consumption curve
                if (node.HasNode("consumptionCurve"))
                {
                    consumptionCurve = new FloatCurve();
                    consumptionCurve.Load(node.GetNode("consumptionCurve"));
                }

                //load the velocity curve
                if (node.HasNode("velocityCurve"))
                {
                    velocityCurve = new FloatCurve();
                    velocityCurve.Load(node.GetNode("velocityCurve"));
                }

                //wheter the engine needs an atmosphere to work
                if (node.HasValue("needsAtmosphere"))
                {
                    needsAtmosphere = bool.Parse(node.GetValue("needsAtmosphere"));
                }

                //wheter the engine needs oxygen to operate
                if (node.HasValue("needsOxygen"))
                {
                    needsOxygen = bool.Parse(node.GetValue("needsOxygen"));
                }

                //wheter the engine needs to be in water to operate
                if (node.HasValue("needsWater"))
                {
                    needsWater = bool.Parse(node.GetValue("needsWater"));
                }

                //wheter the engine needs to be in water to operate
                if (node.HasValue("maxThrust"))
                {
                    try
                    {
                        maxThrust = float.Parse(node.GetValue("maxThrust"));
                    }
                    catch (Exception e)
                    {
                        maxThrust = 0;
                        Debug.LogError("[LYNX] Cannot load maxThrust for engine: " + e.Message);
                    }
                }

                //wheter the engine needs to be in water to operate
                if (node.HasValue("flameoutThreshold"))
                {
                    try
                    {
                        flameoutThreshold = float.Parse(node.GetValue("flameoutThreshold"));
                    }
                    catch (Exception e)
                    {
                        flameoutThreshold = 0.1f;
                        Debug.LogError("[LYNX] Cannot load flameoutThreshold for engine: " + e.Message);
                    }
                }

                //calculate the fuel flow modifier
                if (atmosphereISPCurve != null)
                {
                    float fuelDensity = 0.0f;
                    for (int i = 0; i < propellants.Count; i++)
                    {
                        fuelDensity += PartResourceLibrary.Instance.resourceDefinitions[propellants[i].name].density;
                    }

                    fuelFlow = (fuelDensity > 0.0f) ? maxThrust / (9.80665f * maxISP * fuelDensity) : 1;
                }
                else
                {
                    fuelFlow = 1.0f;
                }
            }
        }
コード例 #15
0
        public void setupPropellants()
        {
            ConfigNode chosenpropellant = propellants[fuel_mode];
            ConfigNode[] assprops = chosenpropellant.GetNodes("PROPELLANT");
            List<Propellant> list_of_propellants = new List<Propellant>();
            // loop though propellants until we get to the selected one, then set it up
            for (int i = 0; i < assprops.Length; ++i) {
                fuelmode = chosenpropellant.GetValue("guiName");
                ispMultiplier = float.Parse(chosenpropellant.GetValue("ispMultiplier"));
                isLFO = bool.Parse(chosenpropellant.GetValue("isLFO"));
                currentpropellant_is_jet = false;
                if(chosenpropellant.HasValue("isJet")) {
                    currentpropellant_is_jet = bool.Parse(chosenpropellant.GetValue("isJet"));
                }
                //print (currentpropellant_is_jet);

                Propellant curprop = new Propellant();
                curprop.Load(assprops[i]);
                if (curprop.drawStackGauge) {
                    curprop.drawStackGauge = false;
                    if (currentpropellant_is_jet) {
                        fuel_gauge.SetMessage("Atmosphere");
                    }else {
                        fuel_gauge.SetMessage(curprop.name);
                        myAttachedEngine.thrustPercentage = 100;
                        part.temperature = 1;
                    }
                    fuel_gauge.SetMsgBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetMsgTextColor(XKCDColors.ElectricLime);
                    fuel_gauge.SetProgressBarColor(XKCDColors.Yellow);
                    fuel_gauge.SetProgressBarBgColor(XKCDColors.DarkLime);
                    fuel_gauge.SetValue(0f);
                }
                list_of_propellants.Add(curprop);
            }
            // update the engine with the new propellants
            if (PartResourceLibrary.Instance.GetDefinition(list_of_propellants[0].name) != null) {
                myAttachedEngine.propellants.Clear();
                myAttachedEngine.propellants = list_of_propellants;
                myAttachedEngine.SetupPropellant();
            }

            // should we switch to another propellant because we have none of this one?
            bool next_propellant = false;
            List<Propellant> curEngine_propellants_list = new List<Propellant>();
            curEngine_propellants_list = myAttachedEngine.propellants;
            foreach(Propellant curEngine_propellant in curEngine_propellants_list) {
                List<PartResource> partresources = new List<PartResource>();
                part.GetConnectedResources(curEngine_propellant.id, PartResourceLibrary.Instance.GetDefinition(curEngine_propellant.name).resourceFlowMode, partresources);

                if (partresources.Count == 0 || !PartResourceLibrary.Instance.resourceDefinitions.Contains(list_of_propellants[0].name)) {
                    next_propellant = true;
                }
            }
            // do the switch if needed
            if (next_propellant && fuel_mode != 1) {
                TogglePropellant();
            }
        }
コード例 #16
0
ファイル: ModuleRCSFX.cs プロジェクト: KerBell/SESI
 public void LoadPropellants(ConfigNode node)
 {
     propellants.Clear();
     foreach (ConfigNode prop in node.GetNodes("PROPELLANT"))
     {
         Propellant fuel = new Propellant();
         fuel.Load(prop);
         propellants.Add(fuel);
     }
     SetupPropellant();
 }