コード例 #1
0
        public void SetupPropellant()
        {
            switch (type)
            {
            case ModuleType.MODULEENGINES:
                mE.SetupPropellant();
                break;

            case ModuleType.MODULEENGINESFX:
                mEFX.SetupPropellant();
                break;

            default:
                throw new InvalidProgramException();
            }
        }
コード例 #2
0
        private void setupPropellants()
        {
            List <Propellant> list_of_propellants = new List <Propellant>();
            Propellant        new_propellant      = _current_propellant.Propellant;

            if (new_propellant.drawStackGauge)
            {
                new_propellant.drawStackGauge = false;
                fuel_gauge.SetMessage(_current_propellant.PropellantGUIName);
                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(new_propellant);

            if (!list_of_propellants.Exists(prop => PartResourceLibrary.Instance.GetDefinition(prop.name) == null))
            {
                _attached_engine.propellants.Clear();
                _attached_engine.propellants = list_of_propellants;
                _attached_engine.SetupPropellant();
            }
            else
            {
                if (_rep < _propellants.Count)
                {
                    _rep++;
                    togglePropellants();
                    return;
                }
            }

            if (HighLogic.LoadedSceneIsFlight)
            { // you can have any fuel you want in the editor but not in flight
                List <PartResource> totalpartresources = list_of_propellants.SelectMany(prop => part.GetConnectedResources(prop.name)).ToList();
                if (!list_of_propellants.All(prop => totalpartresources.Select(pr => pr.resourceName).Contains(prop.name)) && _rep < _propellants.Count)
                {
                    _rep++;
                    togglePropellants();
                    return;
                }
            }
            _rep = 0;
        }
コード例 #3
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 = 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();
            }
        }