Beispiel #1
0
        public void SetTanks()
        {
            tanks.Clear();
            rfTanks.Clear();

            tanksHighlyPressurized = true; // will be set false if any propellant has no highly-pres tank feeding it
            fuelRatio = 1d;

            // iterate through all propellants.
            for (int i = engine.propellants.Count - 1; i >= 0; --i)
            {
                Propellant          p = engine.propellants[i];
                List <PartResource> resources = Utilities.FindResources(engine.part, p);
                double propAmt = 0d, propMax = 0d;
                bool   presTank = false;
                for (int j = resources.Count - 1; j >= 0; --j)
                {
                    PartResource r = resources[j];
                    propAmt += r.amount;
                    propMax += r.maxAmount;

                    Part part = r.part;
                    Tanks.ModuleFuelTanks tank = null;
                    if (!tanks.Contains(part))
                    {
                        tanks.Add(part);
                        for (int k = part.Modules.Count - 1; k >= 0; --k)
                        {
                            PartModule m = part.Modules[k];
                            if (m is Tanks.ModuleFuelTanks)
                            {
                                tank          = m as Tanks.ModuleFuelTanks;
                                rfTanks[part] = tank;
                            }
                        }
                    }
                    else
                    {
                        rfTanks.TryGetValue(part, out tank);
                    }
                    if (tank != null)
                    {
                        // noPresTank will stay true only if no pressurized tank found.
                        bool resourcePres;
                        tank.pressurizedFuels.TryGetValue(r.resourceName, out resourcePres);
                        presTank |= resourcePres || tank.highlyPressurized;
                    }
                }
                tanksHighlyPressurized &= presTank; // i.e. if no tank, set false.

                // set ratio
                fuelRatio = Math.Min(fuelRatio, propAmt / propMax);
            }
        }
        public void SetTanks()
        {
            tanks.Clear();
            rfTanks.Clear();

            tanksHighlyPressurized = true; // will be set false if any propellant has no highly-pres tank feeding it

            // iterate through all propellants.
            for (int i = engine.propellants.Count - 1; i >= 0; --i)
            {
                Propellant p = engine.propellants[i];
                p.UpdateConnectedResources(engine.part);
                bool presTank = false;
                for (int j = p.connectedResources.Count - 1; j >= 0; --j)
                {
                    PartResource          r    = p.connectedResources[j];
                    Part                  part = r.part;
                    Tanks.ModuleFuelTanks tank = null;
                    if (!tanks.Contains(part))
                    {
                        tanks.Add(part);
                        for (int k = part.Modules.Count - 1; k >= 0; --k)
                        {
                            PartModule m = part.Modules[k];
                            if (m is Tanks.ModuleFuelTanks)
                            {
                                tank          = m as Tanks.ModuleFuelTanks;
                                rfTanks[part] = tank;
                            }
                        }
                    }
                    else
                    {
                        rfTanks.TryGetValue(part, out tank);
                    }
                    if (tank != null)
                    {
                        // noPresTank will stay true only if no pressurized tank found.
                        bool resourcePres;
                        tank.pressurizedFuels.TryGetValue(r.resourceName, out resourcePres);
                        presTank |= resourcePres || tank.highlyPressurized;
                    }
                }
                tanksHighlyPressurized &= presTank; // i.e. if no tank, set false.
            }
        }
Beispiel #3
0
        public void Reset()
        {
            ullageSets.Clear();
            tanks.Clear();

            for (int i = partCount - 1; i >= 0; --i)
            {
                Part part = vessel.Parts[i];
                for (int j = part.Modules.Count - 1; j >= 0; --j)
                {
                    PartModule m = part.Modules[j];
                    if (m is Tanks.ModuleFuelTanks)
                    {
                        Tanks.ModuleFuelTanks tank = m as Tanks.ModuleFuelTanks;
                        if (!tanks.Contains(tank))
                        {
                            tanks.Add(tank);
                        }
                    }
                    else if (m is ModuleEnginesRF)
                    {
                        ModuleEnginesRF engine = m as ModuleEnginesRF;

                        if (engine.ullageSet == null) // just in case
                        {
                            engine.ullageSet = new UllageSet(engine);
                        }
                        else
                        {
                            engine.ullageSet.SetTanks();
                            engine.ullageSet.SetModule(this);
                        }

                        ullageSets.Add(engine.ullageSet);
                    }
                }
            }
        }