Inheritance: IConfigNode
Exemplo n.º 1
0
        partial void UpdateTankTypeRF(TankDefinition def)
        {
            // Get pressurization
            highlyPressurized = def.highlyPressurized;

            if (isDatabaseLoad)
            {
                UpdateEngineIgnitor(def);
            }
        }
Exemplo n.º 2
0
        partial void UpdateTankTypeRF(TankDefinition def)
        {
            // Get pressurization
            highlyPressurized = def.highlyPressurized;
            numberOfMLILayers = def.numberOfMLILayers;

            if (def.maxMLILayers >= 0f)
            {
                maxMLILayers = def.maxMLILayers;
            }
            else
            {
                maxMLILayers = (int)Fields[nameof(maxMLILayers)].originalValue;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                if (maxMLILayers > 0)
                {
                    Fields[nameof(_numberOfAddedMLILayers)].guiActiveEditor = true;
                    ((UI_FloatRange)Fields[nameof(_numberOfAddedMLILayers)].uiControlEditor).maxValue = maxMLILayers;
                    _numberOfAddedMLILayers = Math.Min(_numberOfAddedMLILayers, maxMLILayers);
                }
                else
                {
                    Fields[nameof(_numberOfAddedMLILayers)].guiActiveEditor = false;
                    _numberOfAddedMLILayers = 0;
                }
            }

            if (def.minUtilization > 0f)
            {
                minUtilization = def.minUtilization;
            }
            else
            {
                minUtilization = (float)Fields[nameof(minUtilization)].originalValue;
            }

            if (def.maxUtilization > 0f)
            {
                maxUtilization = def.maxUtilization;
            }
            else
            {
                maxUtilization = (float)Fields[nameof(maxUtilization)].originalValue;
            }

            InitUtilization();

            if (isDatabaseLoad)
            {
                UpdateEngineIgnitor(def);
            }
        }
Exemplo n.º 3
0
        private void UpdateEngineIgnitor(TankDefinition def)
        {
            // collect pressurized propellants for EngineIgnitor
            // XXX Dirty hack until engine ignitor is fixed
            fuelList.Clear();               //XXX
            fuelList.AddRange(tankList);    //XXX

            pressurizedFuels.Clear();
            for (int i = 0; i < tankList.Count; i++)
            {
                FuelTank f = tankList[i];
                pressurizedFuels[f.name] = def.highlyPressurized || f.note.ToLower().Contains("pressurized");
            }
        }
 partial void UpdateTankTypeRF(TankDefinition def);
Exemplo n.º 5
0
        private void UpdateTankType(bool initializeAmounts = true)
        {
            if (oldType == type || type == null)
            {
                return;
            }

            // Copy the tank list from the tank definitiion
            TankDefinition def;

            if (!MFSSettings.tankDefinitions.Contains(type))
            {
                Debug.LogError("Unable to find tank definition for type \"" + type + "\" reverting.");
                type = oldType;
                return;
            }
            def = MFSSettings.tankDefinitions[type];
            if (!def.canHave)
            {
                type = oldType;
                if (!string.IsNullOrEmpty(oldType)) // we have an old type
                {
                    def = MFSSettings.tankDefinitions[type];
                    if (def.canHave)
                    {
                        return; // go back to old type
                    }
                }
                // else find one that does work
                if (typesAvailable != null)
                {
                    for (int i = 0; i < typesAvailable.Length; i++)
                    {
                        string         tn     = typesAvailable[i];
                        TankDefinition newDef = MFSSettings.tankDefinitions.Contains(tn) ? MFSSettings.tankDefinitions[tn] : null;
                        if (newDef != null && newDef.canHave)
                        {
                            def  = newDef;
                            type = newDef.name;
                            break;
                        }
                    }
                }
                if (type == oldType) // if we didn't find a new one
                {
                    Debug.LogError("Unable to find a type that is tech-available for part " + part.name);
                    return;
                }
            }

            oldType = type;

            // Build the new tank list.
            tankList = new FuelTankList();
            for (int i = 0; i < def.tankList.Count; i++)
            {
                FuelTank tank = def.tankList[i];
                // Pull the override from the list of overrides
                ConfigNode overNode = MFSSettings.GetOverrideList(part).FirstOrDefault(n => n.GetValue("name") == tank.name);

                tankList.Add(tank.CreateCopy(this, overNode, initializeAmounts));
            }
            tankList.TechAmounts(); // update for current techs

            // Destroy any managed resources that are not in the new type.
            HashSet <string> managed     = MFSSettings.managedResources[part.name];             // if this throws, we have some big fish to fry
            bool             needsMesage = false;

            for (int i = part.Resources.Count - 1; i >= 0; --i)
            {
                PartResource partResource = part.Resources[i];
                string       resname      = partResource.resourceName;
                if (!managed.Contains(resname) || tankList.Contains(resname) || unmanagedResources.ContainsKey(resname))
                {
                    continue;
                }
                part.Resources.Remove(partResource.info.id);
                part.SimulationResources.Remove(partResource.info.id);
                needsMesage = true;
            }
            if (needsMesage)
            {
                RaiseResourceListChanged();
            }
            if (!basemassOverride)
            {
                ParseBaseMass(def.basemass);
            }
            if (!baseCostOverride)
            {
                ParseBaseCost(def.baseCost);
            }


            if (!isDatabaseLoad)
            {
                // being called in the SpaceCenter scene is assumed to be a database reload
                //FIXME is this really needed?

                massDirty = true;
            }

            UpdateTankTypeRF(def);
            UpdateTestFlight();
        }
Exemplo n.º 6
0
        private void UpdateEngineIgnitor(TankDefinition def)
        {
            // collect pressurized propellants for EngineIgnitor
            // XXX Dirty hack until engine ignitor is fixed
            fuelList.Clear ();				//XXX
            fuelList.AddRange (tankList);	//XXX

            pressurizedFuels.Clear ();
            for (int i = 0; i < tankList.Count; i++) {
                FuelTank f = tankList[i];
                pressurizedFuels[f.name] = def.highlyPressurized || f.note.ToLower ().Contains ("pressurized");
            }
        }
partial         void UpdateTankTypeRF(TankDefinition def)
        {
            // Get pressurization
            highlyPressurized = def.highlyPressurized;

            if (isDatabaseLoad)
                UpdateEngineIgnitor(def);
        }
partial         void UpdateTankTypeRF(TankDefinition def);