public int ReturnBuildingCosts(SpaceCenterFacility facility)
        {
            switch (facility)
            {
            case SpaceCenterFacility.Administration:
                return(administrationCost);

            case SpaceCenterFacility.AstronautComplex:
                return(astronautComplexCost);

            case SpaceCenterFacility.MissionControl:
                return(missionControlCost);

            case SpaceCenterFacility.ResearchAndDevelopment:
                return(rndCost);

            case SpaceCenterFacility.SpaceplaneHangar:
                return(sphCost);

            case SpaceCenterFacility.TrackingStation:
                return(trackingStationCost);

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                return(vabCost);

            default:
                return(otherFacilityCost);
            }
        }
Example #2
0
        private void UpdateFacilityLevelStats(UpgradeableObject.UpgradeLevel lvl, int lvlIdx)
        {
            // levelText appears to be unused by KSP itself. We can use it to store original level stats.
            // Restoring old values is necessary because those persist between scene changes but some of them are based on current KCT settings.
            if (lvl.levelText == null)
            {
                lvl.levelText            = ScriptableObject.CreateInstance <KSCUpgradeableLevelText>();
                lvl.levelText.facility   = lvl.levelStats.facility;
                lvl.levelText.linePrefix = lvl.levelStats.linePrefix;
                lvl.levelText.textBase   = lvl.levelStats.textBase;
            }
            else
            {
                lvl.levelStats.textBase = lvl.levelText.textBase;
            }

            KCTDebug.Log($"Overriding level stats text for {lvl.levelStats.facility} lvl {lvlIdx}");

            SpaceCenterFacility facilityType = lvl.levelStats.facility;

            if (facilityType == SpaceCenterFacility.VehicleAssemblyBuilding ||
                facilityType == SpaceCenterFacility.SpaceplaneHangar)
            {
                if (PresetManager.Instance.ActivePreset.GeneralSettings.CommonBuildLine &&
                    facilityType == SpaceCenterFacility.SpaceplaneHangar)
                {
                    lvl.levelStats.linePrefix = string.Empty;
                    lvl.levelStats.textBase   = "Upgrade the VAB instead";
                }
                else
                {
                    lvl.levelStats.textBase += $"\n{lvlIdx + 1} build queue{(lvlIdx > 0 ? "s" : string.Empty)}";
                    if (lvlIdx > 0)
                    {
                        lvl.levelStats.textBase += $"\n+{lvlIdx * 25}% build rate";
                    }
                }
            }
            else if (facilityType == SpaceCenterFacility.ResearchAndDevelopment &&
                     lvlIdx > 0)
            {
                lvl.levelStats.textBase += $"\n+{lvlIdx * 25}% research rate";
            }
            else if (facilityType == SpaceCenterFacility.Administration)
            {
                lvl.levelStats.linePrefix = string.Empty;
                lvl.levelStats.textBase   = "This facility is currently unused";
            }
            else if (facilityType == SpaceCenterFacility.AstronautComplex &&
                     lvlIdx > 0)
            {
                lvl.levelStats.textBase += $"\n{lvlIdx * 25}% shorter R&R times";
                lvl.levelStats.textBase += $"\n{lvlIdx * 25}% shorter training times";
            }
            else if (facilityType == SpaceCenterFacility.LaunchPad)
            {
                lvl.levelStats.linePrefix = string.Empty;
                lvl.levelStats.textBase   = "<color=\"red\"><b>Launchpads cannot be upgraded. Build a new launchpad from the KCT Build List tab instead.</b></color>";
            }
        }
Example #3
0
        public static double CalculateBuildTime(double cost, SpaceCenterFacility facilityType, KCT_KSC KSC = null)
        {
            double bp        = CalculateBP(cost, facilityType);
            double rateTotal = KCT_Utilities.GetBothBuildRateSum(KSC ?? KCT_GameStates.ActiveKSC);

            return(bp / rateTotal);
        }
        private int[] getFacilityLevelsVisual(SpaceCenterFacility f)
        {
            switch (f)
            {
            case SpaceCenterFacility.Administration:
                return(customGameVariables.upgradesVisualAdministration);

            case SpaceCenterFacility.AstronautComplex:
                return(customGameVariables.upgradesVisualAstronauts);

            case SpaceCenterFacility.LaunchPad:
                return(customGameVariables.upgradesVisualLaunchPad);

            case SpaceCenterFacility.MissionControl:
                return(customGameVariables.upgradesVisualMission);

            case SpaceCenterFacility.ResearchAndDevelopment:
                return(customGameVariables.upgradesVisualRnD);

            case SpaceCenterFacility.Runway:
                return(customGameVariables.upgradesVisualRunway);

            case SpaceCenterFacility.SpaceplaneHangar:
                return(customGameVariables.upgradesVisualSPH);

            case SpaceCenterFacility.TrackingStation:
                return(customGameVariables.upgradesVisualTracking);

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                return(customGameVariables.upgradesVisualVAB);

            default:
                return(customGameVariables.upgradesVisualTracking);
            }
        }
        private float[] getFacilityUpgradePrices(SpaceCenterFacility f)
        {
            switch (f)
            {
            case SpaceCenterFacility.Administration:
                return(customGameVariables.upgradesAdministration);

            case SpaceCenterFacility.AstronautComplex:
                return(customGameVariables.upgradesAstronauts);

            case SpaceCenterFacility.LaunchPad:
                return(customGameVariables.upgradesLaunchPad);

            case SpaceCenterFacility.MissionControl:
                return(customGameVariables.upgradesMission);

            case SpaceCenterFacility.ResearchAndDevelopment:
                return(customGameVariables.upgradesRnD);

            case SpaceCenterFacility.Runway:
                return(customGameVariables.upgradesRunway);

            case SpaceCenterFacility.SpaceplaneHangar:
                return(customGameVariables.upgradesSPH);

            case SpaceCenterFacility.TrackingStation:
                return(customGameVariables.upgradesTracking);

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                return(customGameVariables.upgradesVAB);

            default:
                return(customGameVariables.upgradesTracking);
            }
        }
Example #6
0
 public FacilityConstructionEventDto(FacilityConstructionEvent fce)
 {
     date     = CareerLog.UTToDate(fce.UT).ToString("o");
     facility = fce.Facility;
     newLevel = fce.NewLevel;
     cost     = fce.Cost;
     state    = fce.State;
 }
Example #7
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary> Calculates the level (1..3) of the facility specified.</summary>
        ///
        /// <param name="facility"> The facility to fetch the level for.</param>
        ///
        /// <returns> The level of the facility. This will be 1..3 where 1 is the initial level on a new
        ///           career game and 3 is fully upgraded.</returns>
        private int FacilityLevel(SpaceCenterFacility facility)
        {
            var level = ScenarioUpgradeableFacilities.GetFacilityLevel(facility); // 0 .. 1
            var count = ScenarioUpgradeableFacilities
                        .GetFacilityLevelCount(facility);                         // max upgrades allowed (usually 2)

            return((int)(level * count) + 1);
        }
Example #8
0
        public KCT_UpgradingBuilding(SpaceCenterFacility type, string facilityID, int newLevel, int oldLevel, string name)
        {
            facilityType = type;
            id           = facilityID;
            upgradeLevel = newLevel;
            currentLevel = oldLevel;
            commonName   = name;

            KCTDebug.Log(string.Format("Upgrade of {0} requested from {1} to {2}", name, oldLevel, newLevel));
        }
Example #9
0
 private int GetKCTUpgradeCounts(SpaceCenterFacility facility)
 {
     try
     {
         return(KerbalConstructionTime.Utilities.GetSpentUpgradesFor(facility));
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
         return(0);
     }
 }
Example #10
0
 private int GetKCTUpgradeCounts(SpaceCenterFacility facility)
 {
     try
     {
         return(FnGetKCTUpgdCounts == null ? 0 : FnGetKCTUpgdCounts(facility));
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
         return(0);
     }
 }
Example #11
0
        public static int BuildingUpgradeLevel(SpaceCenterFacility facility)
        {
            int lvl = 0;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && Settings1.Instance.UseUpgrades)
            {
                lvl = (int)Math.Round((ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility) * ScenarioUpgradeableFacilities.GetFacilityLevel(facility)));
            }
            else
            {
                lvl = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility); //returns 2 for VAB in Sandbox
            }
            return(lvl);
        }
 public static int BuildingUpgradeLevel(SpaceCenterFacility facility)
 {
     int lvl = 0;
     if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && Settings.Instance.UseUpgrades)
     {
         lvl = (int)(2 * ScenarioUpgradeableFacilities.GetFacilityLevel(facility));
     }
     else
     {
         //lvl = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility);
         lvl = 2;
     }
     return lvl;
 }
Example #13
0
        public string MaximumVesselMass()
        {
            SpaceCenterFacility rolloutFacility = (EditorDriver.editorFacility == EditorFacility.VAB) ? SpaceCenterFacility.LaunchPad : SpaceCenterFacility.Runway;
            float maximumVesselMass             = GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(rolloutFacility));

            if (maximumVesselMass < float.MaxValue)
            {
                return(string.Format("{0} t", maximumVesselMass.ToString("F3")));
            }
            else
            {
                return("Unlimited");
            }
        }
Example #14
0
        /// <summary>
        /// Gets the (integer) level of a particular facility
        /// </summary>
        /// <param name="facility">The facility to check</param>
        /// <returns>The level of the facility</returns>
        public static int GetFacilityLevel(SpaceCenterFacility facility)
        {
            int lvl = 0;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                lvl = (int)(ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility) * ScenarioUpgradeableFacilities.GetFacilityLevel(facility));
            }
            else
            {
                lvl = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility); //returns 2 for VAB in Sandbox
            }
            return(lvl);
        }
Example #15
0
        public void AddFacilityConstructionEvent(SpaceCenterFacility facility, int newLevel, double cost, ConstructionState state)
        {
            if (CareerEventScope.ShouldIgnore || !IsEnabled)
            {
                return;
            }

            _facilityConstructions.Add(new FacilityConstructionEvent(KSPUtils.GetUT())
            {
                Facility = facility,
                NewLevel = newLevel,
                Cost     = cost,
                State    = state
            });
        }
Example #16
0
        public static int BuildingUpgradeLevel(SpaceCenterFacility facility)
        {
            int lvl = 0;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && Settings.Instance.UseUpgrades)
            {
                lvl = (int)(2 * ScenarioUpgradeableFacilities.GetFacilityLevel(facility));
            }
            else
            {
                //lvl = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility);
                lvl = 2;
            }
            return(lvl);
        }
Example #17
0
        public void AddFacilityConstructionEvent(SpaceCenterFacility facility, int newLevel, double cost, ConstructionState state)
        {
            if (!IsEnabled)
            {
                return;
            }

            _facilityConstructions.Add(new FacilityConstructionEvent(Planetarium.GetUniversalTime())
            {
                Facility = facility,
                NewLevel = newLevel,
                Cost     = cost,
                State    = state
            });
        }
        public override bool LoadFromConfig(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.LoadFromConfig(configNode);

            // Check on active contracts too
            checkOnActiveContract = configNode.HasValue("checkOnActiveContract") ? checkOnActiveContract : true;

            valid &= ConfigNodeUtil.ParseValue<SpaceCenterFacility>(configNode, "facility", x => facility = x, this);
            valid &= ConfigNodeUtil.ParseValue<int>(configNode, "minLevel", x => minLevel = x, this, 1, x => Validation.Between(x, 1, 3));
            valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxLevel", x => maxLevel = x, this, 3, x => Validation.Between(x, 1, 3));
            valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "minLevel", "maxLevel" }, this);

            return valid;
        }
Example #19
0
        public int GetBuildingCosts()
        {
            int cost = 0;

            for (int i = 0; i < facilities.Count(); i++)
            {
                SpaceCenterFacility facility = facilities.ElementAt(i);
                if (facility == SpaceCenterFacility.LaunchPad || facility == SpaceCenterFacility.Runway)
                {
                    continue;
                }
                int lvl = (int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) * ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility)) + 1;
                cost += lvl * BudgetSettings.instance.ReturnBuildingCosts(facility);
            }
            return(cost);
        }
Example #20
0
        private int GetFacilityLevel(SpaceCenterFacility facility)
        {
            if (ScenarioUpgradeableFacilities.Instance == null || !ScenarioUpgradeableFacilities.Instance.enabled)
            {
                return(int.MaxValue);
            }


            double maxlevel = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility);

            if (maxlevel <= 0)
            {
                maxlevel = 2;                                                                                 // not sure why, but GetFacilityLevelCount return -1 in career
            }
            return((int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) * maxlevel + 1)); // They start counting at 0
        }
Example #21
0
        public FacilityManager()
        {
            InternalListeners.OnBudgetAboutToFire.Add(OnBudgetAboutToFire);
            SpaceCenterFacility[] spaceCentreFacilities = (SpaceCenterFacility[])Enum.GetValues(typeof(SpaceCenterFacility));
            for (int i = 0; i < spaceCentreFacilities.Length; i++)
            {
                SpaceCenterFacility spf = spaceCentreFacilities.ElementAt(i);
                Facilities.Add(new BureaucracyFacility(spf));
            }
            //RB loads super late, well after we're done here, so we need to check if it's installed and set up a BureaucracyFacility for the Observatory.
            ResearchBodiesWrapper rw = new ResearchBodiesWrapper();

            if (rw.RBInstalled())
            {
                Facilities.Add(new BureaucracyFacility("Observatory"));
            }
            Name             = "Construction";
            ThisMonthsBudget = HighLogic.CurrentGame.Parameters.Career.StartingFunds * FundingAllocation;
            Instance         = this;
            Debug.Log("[Bureaucracy]: Facility Manager Ready");
        }
Example #22
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary> Calculates the base maintenance cost for the facility specified.</summary>
        ///
        /// <param name="facility"> The facility to fetch the maintenance cost for.</param>
        ///
        /// <returns> The building costs.</returns>
        private int BaseStructureCost(SpaceCenterFacility facility)
        {
            if (BudgetSettings.Instance == null)
            {
                return(0);
            }

            switch (facility)
            {
            case SpaceCenterFacility.Administration:
                return(BudgetSettings.Instance.structureCostAdministration);

            case SpaceCenterFacility.AstronautComplex:
                return(BudgetSettings.Instance.structureCostAstronautComplex);

            case SpaceCenterFacility.MissionControl:
                return(BudgetSettings.Instance.structureCostMissionControl);

            case SpaceCenterFacility.ResearchAndDevelopment:
                return(BudgetSettings.Instance.structureCostRnD);

            case SpaceCenterFacility.SpaceplaneHangar:
                return(BudgetSettings.Instance.structureCostSph);

            case SpaceCenterFacility.TrackingStation:
                return(BudgetSettings.Instance.structureCostTrackingStation);

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                return(BudgetSettings.Instance.structureCostVab);

            case SpaceCenterFacility.LaunchPad:
            case SpaceCenterFacility.Runway:
                return(0);

            default:
                return(BudgetSettings.Instance.structureCostOtherFacility);
            }
        }
Example #23
0
        private string SetName(SpaceCenterFacility spf)
        {
            switch (spf)
            {
            case SpaceCenterFacility.Administration:
                return("Administration");

            case SpaceCenterFacility.AstronautComplex:
                CanBeClosed = true;
                return("AstronautComplex");

            case SpaceCenterFacility.MissionControl:
                return("MissionControl");

            case SpaceCenterFacility.SpaceplaneHangar:
                CanBeClosed = true;
                return("SpaceplaneHangar");

            case SpaceCenterFacility.TrackingStation:
                return("TrackingStation");

            case SpaceCenterFacility.ResearchAndDevelopment:
                return("ResearchAndDevelopment");

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                CanBeClosed = true;
                return("VehicleAssemblyBuilding");

            case SpaceCenterFacility.Runway:
                return("Runway");

            case SpaceCenterFacility.LaunchPad:
                return("LaunchPad");

            default:
                return("Other Facility");
            }
        }
Example #24
0
        internal void ProcessUpgrade()
        {
            int oldLevel = getMember <int>("level");

            KCTDebug.Log($"Upgrading from level {oldLevel}");

            string facilityID = GetFacilityID();
            SpaceCenterFacility facilityType = GetFacilityType();

            string gate = GetTechGate(facilityID, oldLevel + 1);

            KCTDebug.Log("[KCTT] Gate for " + facilityID + "? " + gate);
            if (!string.IsNullOrEmpty(gate))
            {
                if (ResearchAndDevelopment.GetTechnologyState(gate) != RDTech.State.Available)
                {
                    PopupDialog.SpawnPopupDialog(new MultiOptionDialog("kctUpgradePadConfirm",
                                                                       "Can't upgrade this facility. Requires " + KerbalConstructionTimeData.techNameToTitle[gate] + ".",
                                                                       "Lack Tech to Upgrade",
                                                                       HighLogic.UISkin,
                                                                       new DialogGUIButton("Ok", stub)),
                                                 false,
                                                 HighLogic.UISkin);

                    return;
                }
            }

            KCT_UpgradingBuilding upgrading = new KCT_UpgradingBuilding(facilityType, facilityID, oldLevel + 1, oldLevel, facilityID.Split('/').Last());

            upgrading.isLaunchpad = facilityID.ToLower().Contains("launchpad");
            if (upgrading.isLaunchpad)
            {
                upgrading.launchpadID = KCT_GameStates.ActiveKSC.ActiveLaunchPadID;
                if (upgrading.launchpadID > 0)
                {
                    upgrading.commonName += KCT_GameStates.ActiveKSC.ActiveLPInstance.name;
                }
            }

            if (!upgrading.AlreadyInProgress())
            {
                float cost = getMember <float>("upgradeCost");

                if (Funding.CanAfford(cost))
                {
                    KCT_Utilities.SpendFunds(cost, TransactionReasons.Structures);
                    KCT_GameStates.ActiveKSC.KSCTech.Add(upgrading);
                    upgrading.SetBP(cost);
                    upgrading.cost = cost;

                    try
                    {
                        KCT_Events.onFacilityUpgradeQueued?.Fire(upgrading);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogException(ex);
                    }

                    ScreenMessages.PostScreenMessage("Facility upgrade requested!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    KCTDebug.Log($"Facility {facilityID} upgrade requested to lvl {oldLevel + 1} for {cost} funds, resulting in a BP of {upgrading.BP}");
                }
                else
                {
                    KCTDebug.Log("Couldn't afford to upgrade.");
                    ScreenMessages.PostScreenMessage("Not enough funds to upgrade facility!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                }
            }
            else if (oldLevel + 1 != upgrading.currentLevel)
            {
                ScreenMessages.PostScreenMessage("Facility is already being upgraded!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                KCTDebug.Log($"Facility {facilityID} tried to upgrade to lvl {oldLevel + 1} but already in list!");
            }
        }
Example #25
0
 protected override void OnLoadFromConfig(ConfigNode node)
 {
     facility = ConfigNodeUtil.ParseValue <SpaceCenterFacility>(node, "facility", SpaceCenterFacility.Administration);
     level    = ConfigNodeUtil.ParseValue <int>(node, "level");
 }
Example #26
0
 public override void OnLoad(ConfigNode configNode)
 {
     facility = ConfigNodeUtil.ParseValue <SpaceCenterFacility>(configNode, "facility");
     minLevel = ConfigNodeUtil.ParseValue <int>(configNode, "minLevel");
     maxLevel = ConfigNodeUtil.ParseValue <int>(configNode, "maxLevel");
 }
 public override void OnLoad(ConfigNode configNode)
 {
     facility = ConfigNodeUtil.ParseValue<SpaceCenterFacility>(configNode, "facility");
     minLevel = ConfigNodeUtil.ParseValue<int>(configNode, "minLevel");
     maxLevel = ConfigNodeUtil.ParseValue<int>(configNode, "maxLevel");
 }
Example #28
0
        public static List <UpgradeableFacility> GetFacilityReferencesByType(SpaceCenterFacility facilityType)
        {
            string internalId = ScenarioUpgradeableFacilities.SlashSanitize(facilityType.ToString());

            return(GetFacilityReferencesById(internalId));
        }
Example #29
0
        public override bool LoadFromConfig(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.LoadFromConfig(configNode);

            // Check on active contracts too
            checkOnActiveContract = configNode.HasValue("checkOnActiveContract") ? checkOnActiveContract : true;

            valid &= ConfigNodeUtil.ParseValue <SpaceCenterFacility>(configNode, "facility", x => facility = x, this);
            valid &= ConfigNodeUtil.ParseValue <int>(configNode, "minLevel", x => minLevel = x, this, 1, x => Validation.Between(x, 1, 3));
            valid &= ConfigNodeUtil.ParseValue <int>(configNode, "maxLevel", x => maxLevel = x, this, 3, x => Validation.Between(x, 1, 3));
            valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "minLevel", "maxLevel" }, this);

            return(valid);
        }
Example #30
0
 public static int GetKCTUpgradeCounts(SpaceCenterFacility facility)
 {
     return(KerbalConstructionTime.Utilities.GetSpentUpgradesFor(facility));
 }
Example #31
0
 public static int GetKCTUpgradeCounts(SpaceCenterFacility facility)
 {
     return(KCT_Utilities.SpentUpgradesFor(facility));
 }
 protected override void OnLoadFromConfig(ConfigNode node)
 {
     facility = ConfigNodeUtil.ParseValue<SpaceCenterFacility>(node, "facility", SpaceCenterFacility.Administration);
     level = ConfigNodeUtil.ParseValue<int>(node, "level");
 }
Example #33
0
        public static double CalculateBP(double cost, SpaceCenterFacility facilityType)
        {
            int isAdm = 0, isAC = 0, isLP = 0, isMC = 0, isRD = 0, isRW = 0, isTS = 0, isSPH = 0, isVAB = 0;

            switch (facilityType)
            {
            case SpaceCenterFacility.Administration:
                isAdm = 1;
                break;

            case SpaceCenterFacility.AstronautComplex:
                isAC = 1;
                break;

            case SpaceCenterFacility.LaunchPad:
                isLP = 1;
                break;

            case SpaceCenterFacility.MissionControl:
                isMC = 1;
                break;

            case SpaceCenterFacility.ResearchAndDevelopment:
                isRD = 1;
                break;

            case SpaceCenterFacility.Runway:
                isRW = 1;
                break;

            case SpaceCenterFacility.TrackingStation:
                isTS = 1;
                break;

            case SpaceCenterFacility.SpaceplaneHangar:
                isSPH = 1;
                break;

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                isVAB = 1;
                break;

            default:
                break;
            }
            var variables = new Dictionary <string, string>()
            {
                { "C", cost.ToString() },
                { "O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString() },
                { "Adm", isAdm.ToString() },
                { "AC", isAC.ToString() },
                { "LP", isLP.ToString() },
                { "MC", isMC.ToString() },
                { "RD", isRD.ToString() },
                { "RW", isRW.ToString() },
                { "TS", isTS.ToString() },
                { "SPH", isSPH.ToString() },
                { "VAB", isVAB.ToString() }
            };

            double bp = KCT_MathParsing.GetStandardFormulaValue("KSCUpgrade", variables);

            if (bp <= 0)
            {
                bp = 1;
            }

            return(bp);
        }
        // With the help of NoMoreGrind code by nlight
        private void LoadUpgradesPrices()
        {
            log("Loading new upgrades prices");

            foreach (UpgradeableFacility facility in GameObject.FindObjectsOfType <UpgradeableFacility>())
            {
                SpaceCenterFacility facilityType = (SpaceCenterFacility)Enum.Parse(typeof(SpaceCenterFacility), facility.name);

                float[] prices       = getFacilityUpgradePrices(facilityType);
                int     levels       = getFacilityLevels(facilityType);
                int[]   levelsVisual = getFacilityLevelsVisual(facilityType);

                if (prices == null)
                {
                    log("No upgrades prices set for " + facilityType + ". Skipping");
                    continue;
                }

                if (levels != prices.Length)
                {
                    log("Wrong numbers of upgrade price for " + facility + " expecting " + levels + " and have " + prices.Length + ". Check your configs");
                    continue;
                }

                UpgradeableObject.UpgradeLevel[] upgradeLevels = facility.UpgradeLevels;

                if (facility.UpgradeLevels[facility.FacilityLevel].Spawned)
                {
                    facility.UpgradeLevels[facility.FacilityLevel].Despawn();
                }

                UpgradeableObject.UpgradeLevel[] newUpgradeLevels = new UpgradeableObject.UpgradeLevel[levels];

                for (int i = 0; i < levels; i++)
                {
                    int originalLevel = Math.Min(i, upgradeLevels.Length - 1);

                    UpgradeableObject.UpgradeLevel level = new UpgradeableObject.UpgradeLevel();
                    var sourceLvl = upgradeLevels[originalLevel];

                    level.levelCost        = prices[i];
                    level.levelText        = sourceLvl.levelText;
                    level.levelStats       = sourceLvl.levelStats;
                    level.facilityPrefab   = sourceLvl.facilityPrefab;
                    level.facilityInstance = null;

                    if (levelsVisual.Length == levels)
                    {
                        log(facility.name + " Copying level " + (levelsVisual[i] - 1) + " for level " + (i + 1));
                        //level.facilityPrefab = Instantiate(upgradeLevels[levelsVisual[i] - 1].facilityPrefab);
                        level.facilityPrefab = upgradeLevels[levelsVisual[i] - 1].facilityPrefab;
                    }
                    else
                    {
                        log("Wrong levelsVisual length " + levelsVisual.Length + " for " + facility.name + " expected " + levels);
                    }

                    newUpgradeLevels[i] = level;
                }

                facility.UpgradeLevels = newUpgradeLevels;
                facility.SetupLevels();
                facility.setLevel(facility.FacilityLevel);
            }
            log("New upgrades prices are Loaded");
        }