From 4b65afe5fd8a00fdc87e8f6f0cffe00d2f2b8d0c Mon Sep 17 00:00:00 2001 From: NathanKell Date: Mon, 9 Oct 2023 01:35:13 -0700 Subject: [PATCH] One more rename: KCTData to SpaceCenterManagement --- Source/RP0/Addons/GameplayTips.cs | 2 +- Source/RP0/CareerLog/CareerLog.cs | 10 +- Source/RP0/Crew/CrewHandler.cs | 6 +- Source/RP0/Crew/TrainingTemplate.cs | 2 +- Source/RP0/Harmony/EditorDriver.cs | 8 +- Source/RP0/Harmony/EditorLogic.cs | 4 +- Source/RP0/Harmony/EditorPartIcon.cs | 4 +- Source/RP0/Harmony/EngineersReport.cs | 18 +-- Source/RP0/Harmony/FundsWidget.cs | 6 +- Source/RP0/Harmony/KSCFacilityContextMenu.cs | 4 +- Source/RP0/Harmony/KSCSwitcher.cs | 4 +- Source/RP0/Harmony/PartListTooltip.cs | 2 +- Source/RP0/Harmony/RDController.cs | 16 +-- Source/RP0/Harmony/RDNode.cs | 8 +- Source/RP0/Harmony/RDTech.cs | 6 +- Source/RP0/Harmony/RealFuels.cs | 10 +- Source/RP0/Harmony/ScienceWidget.cs | 2 +- Source/RP0/Harmony/StrategySystem.cs | 2 +- .../RP0/Leaders/Effects/CurrencyModifier.cs | 2 +- Source/RP0/Leaders/StrategyRP0.cs | 4 +- Source/RP0/Maintenance/MaintenanceHandler.cs | 12 +- Source/RP0/Milestones/MilestoneHandler.cs | 4 +- Source/RP0/Persistence/GUIPosition.cs | 8 +- Source/RP0/Programs/ProgramHandler.cs | 8 +- Source/RP0/RP0.csproj | 2 +- Source/RP0/ScenarioModules/Confidence.cs | 4 +- .../ScenarioModules/UnlockCreditHandler.cs | 6 +- Source/RP0/Settings/SpaceCenterSettings.cs | 2 +- Source/RP0/Singletons/SingletonHost.cs | 2 +- Source/RP0/SpaceCenter/AirlaunchParams.cs | 2 +- Source/RP0/SpaceCenter/AirlaunchTechLevel.cs | 4 +- .../SpaceCenter/LaunchComplex/LCEfficiency.cs | 40 +++---- .../SpaceCenter/LaunchComplex/LCLaunchPad.cs | 12 +- .../LaunchComplex/LCSpaceCenter.cs | 6 +- .../LaunchComplex/LaunchComplex.cs | 16 +-- .../Projects/ConstructionProject.cs | 2 +- .../Projects/FacilityUpgradeProject.cs | 4 +- .../SpaceCenter/Projects/FundTargetProject.cs | 2 +- .../Projects/LCConstructionProject.cs | 2 +- .../RP0/SpaceCenter/Projects/LCOpsProject.cs | 2 +- .../Projects/PadConstructionProject.cs | 4 +- .../SpaceCenter/Projects/ResearchProject.cs | 10 +- .../RP0/SpaceCenter/Projects/VesselProject.cs | 22 ++-- Source/RP0/SpaceCenter/SCMEvents.cs | 32 ++--- ...onTimeData.cs => SpaceCenterManagement.cs} | 4 +- .../RP0/SpaceCenter/VesselBuildValidator.cs | 8 +- Source/RP0/UI/KCT/GUI_Airlaunch.cs | 16 +-- Source/RP0/UI/KCT/GUI_BuildList.cs | 110 +++++++++--------- Source/RP0/UI/KCT/GUI_BuildPlans.cs | 18 +-- Source/RP0/UI/KCT/GUI_ClearLaunch.cs | 8 +- Source/RP0/UI/KCT/GUI_CrewSelect.cs | 42 +++---- Source/RP0/UI/KCT/GUI_DevPartsButton.cs | 2 +- Source/RP0/UI/KCT/GUI_DismantlePad.cs | 4 +- Source/RP0/UI/KCT/GUI_Editor.cs | 98 ++++++++-------- Source/RP0/UI/KCT/GUI_FirstRun.cs | 14 +-- Source/RP0/UI/KCT/GUI_Main.cs | 20 ++-- Source/RP0/UI/KCT/GUI_NewLC.cs | 32 ++--- Source/RP0/UI/KCT/GUI_NewPad.cs | 16 +-- Source/RP0/UI/KCT/GUI_Personnel.cs | 38 +++--- Source/RP0/UI/KCT/GUI_Presets.cs | 6 +- Source/RP0/UI/KCT/GUI_Simulation.cs | 20 ++-- Source/RP0/UI/KCT/GUI_TopRightButtons.cs | 2 +- Source/RP0/UI/KCT/GUI_VesselMerge.cs | 10 +- Source/RP0/UI/MaintenanceGUI.cs | 32 ++--- Source/RP0/UpgradeScripts/v3_0_ACRnD.cs | 63 +--------- Source/RP0/Utilities/Formula.cs | 4 +- Source/RP0/Utilities/KCTUtilities.cs | 104 ++++++++--------- 67 files changed, 474 insertions(+), 525 deletions(-) rename Source/RP0/SpaceCenter/{KerbalConstructionTimeData.cs => SpaceCenterManagement.cs} (99%) diff --git a/Source/RP0/Addons/GameplayTips.cs b/Source/RP0/Addons/GameplayTips.cs index ba54a21d3e0..9843f90b959 100644 --- a/Source/RP0/Addons/GameplayTips.cs +++ b/Source/RP0/Addons/GameplayTips.cs @@ -53,7 +53,7 @@ internal void Start() { var vessel = FlightGlobals.ActiveVessel; if (!_airlaunchTipShown && vessel && - KerbalConstructionTimeData.Instance.IsSimulatedFlight && + SpaceCenterManagement.Instance.IsSimulatedFlight && vessel.GetVesselBuiltAt() == EditorFacility.SPH && vessel.FindPartModuleImplementing() != null) // Does the vessel have a rocket engine? { diff --git a/Source/RP0/CareerLog/CareerLog.cs b/Source/RP0/CareerLog/CareerLog.cs index 5e1378efdbc..57f4af92767 100644 --- a/Source/RP0/CareerLog/CareerLog.cs +++ b/Source/RP0/CareerLog/CareerLog.cs @@ -618,10 +618,10 @@ private void SwitchToNextPeriod() { _prevPeriod.CurrentFunds = Funding.Instance.Funds; _prevPeriod.CurrentSci = ResearchAndDevelopment.Instance.Science; - _prevPeriod.RnDQueueLength = KerbalConstructionTimeData.Instance.TechList.Sum(t => t.scienceCost); - _prevPeriod.NumEngineers = KerbalConstructionTimeData.Instance.TotalEngineers; - _prevPeriod.NumResearchers = KerbalConstructionTimeData.Instance.Researchers; - _prevPeriod.EfficiencyEngineers = KerbalConstructionTimeData.Instance.WeightedAverageEfficiencyEngineers; + _prevPeriod.RnDQueueLength = SpaceCenterManagement.Instance.TechList.Sum(t => t.scienceCost); + _prevPeriod.NumEngineers = SpaceCenterManagement.Instance.TotalEngineers; + _prevPeriod.NumResearchers = SpaceCenterManagement.Instance.Researchers; + _prevPeriod.EfficiencyEngineers = SpaceCenterManagement.Instance.WeightedAverageEfficiencyEngineers; _prevPeriod.ScienceEarned = GetSciPointTotalFromKCT(); _prevPeriod.FundsGainMult = HighLogic.CurrentGame.Parameters.Career.FundsGainMultiplier; _prevPeriod.SubsidySize = MaintenanceHandler.Instance.GetSubsidyAmount(_prevPeriod.StartUT, _prevPeriod.EndUT); @@ -889,7 +889,7 @@ private float GetSciPointTotalFromKCT() try { // KCT returns -1 if the player hasn't earned any sci yet - return Math.Max(0, KerbalConstructionTimeData.Instance.SciPointsTotal); + return Math.Max(0, SpaceCenterManagement.Instance.SciPointsTotal); } catch (Exception ex) { diff --git a/Source/RP0/Crew/CrewHandler.cs b/Source/RP0/Crew/CrewHandler.cs index 4180741d838..a7725407dea 100644 --- a/Source/RP0/Crew/CrewHandler.cs +++ b/Source/RP0/Crew/CrewHandler.cs @@ -227,7 +227,7 @@ public void AddPartCourses(AvailablePart ap) ap.partPrefab.Modules.Contains() || KCTUtils.IsClamp(ap.partPrefab)) return; bool hasTech = !string.IsNullOrEmpty(ap.TechRequired); - bool isKCTExperimentalNode = hasTech && KerbalConstructionTimeData.Instance.TechListHas(ap.TechRequired); + bool isKCTExperimentalNode = hasTech && SpaceCenterManagement.Instance.TechListHas(ap.TechRequired); bool isPartUnlocked = !hasTech || (!isKCTExperimentalNode && ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available); if (!isKCTExperimentalNode && !isPartUnlocked) @@ -288,7 +288,7 @@ public static bool CheckCrewForPart(ProtoCrewMember pcm, string partName, bool i return false; if (!HighLogic.CurrentGame.Parameters.CustomParams().IsTrainingEnabled - || KerbalConstructionTimeData.Instance.IsSimulatedFlight) + || SpaceCenterManagement.Instance.IsSimulatedFlight) return true; // If part doesn't have a training associated with it, abort @@ -1023,7 +1023,7 @@ private IEnumerator EnsureActiveCrewInSimulationRoutine() if (!HighLogic.LoadedSceneIsFlight) yield return null; yield return new WaitForFixedUpdate(); - if (KerbalConstructionTimeData.Instance.IsSimulatedFlight && FlightGlobals.ActiveVessel != null) + if (SpaceCenterManagement.Instance.IsSimulatedFlight && FlightGlobals.ActiveVessel != null) { foreach (ProtoCrewMember pcm in FlightGlobals.ActiveVessel.GetVesselCrew()) { diff --git a/Source/RP0/Crew/TrainingTemplate.cs b/Source/RP0/Crew/TrainingTemplate.cs index 66368718b05..ef3557dc45d 100644 --- a/Source/RP0/Crew/TrainingTemplate.cs +++ b/Source/RP0/Crew/TrainingTemplate.cs @@ -44,7 +44,7 @@ public bool IsUnlocked if (string.IsNullOrEmpty(ap.TechRequired)) return true; - if (!KerbalConstructionTimeData.Instance.TechListHas(ap.TechRequired) && ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available) + if (!SpaceCenterManagement.Instance.TechListHas(ap.TechRequired) && ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available) return true; } diff --git a/Source/RP0/Harmony/EditorDriver.cs b/Source/RP0/Harmony/EditorDriver.cs index 9917ec7a0fd..89998bfc540 100644 --- a/Source/RP0/Harmony/EditorDriver.cs +++ b/Source/RP0/Harmony/EditorDriver.cs @@ -22,14 +22,14 @@ internal static void Prefix_SwitchEditor(EditorFacility facility) private static void FixActiveLC(EditorFacility facility) { var type = facility == EditorFacility.SPH ? LaunchComplexType.Hangar : LaunchComplexType.Pad; - if (KerbalConstructionTimeData.Instance?.ActiveSC.ActiveLC.LCType != type) + if (SpaceCenterManagement.Instance?.ActiveSC.ActiveLC.LCType != type) { - for (int i = 0; i < KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Count; ++i) + for (int i = 0; i < SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Count; ++i) { - var lc = KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes[i]; + var lc = SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes[i]; if (lc.IsOperational && lc.LCType == type) { - KerbalConstructionTimeData.Instance.ActiveSC.SwitchLaunchComplex(i); + SpaceCenterManagement.Instance.ActiveSC.SwitchLaunchComplex(i); return; } } diff --git a/Source/RP0/Harmony/EditorLogic.cs b/Source/RP0/Harmony/EditorLogic.cs index 09364082029..56a3e384fb4 100644 --- a/Source/RP0/Harmony/EditorLogic.cs +++ b/Source/RP0/Harmony/EditorLogic.cs @@ -11,8 +11,8 @@ internal static void Prefix_goForLaunch() { if (PresetManager.Instance.ActivePreset?.GeneralSettings?.Enabled != true) return; - KerbalConstructionTimeData.Instance.LaunchedVessel = new VesselProject(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, EditorLogic.FlagURL, false); - KerbalConstructionTimeData.Instance.LaunchedVessel.LCID = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ID; + SpaceCenterManagement.Instance.LaunchedVessel = new VesselProject(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, EditorLogic.FlagURL, false); + SpaceCenterManagement.Instance.LaunchedVessel.LCID = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ID; } } } diff --git a/Source/RP0/Harmony/EditorPartIcon.cs b/Source/RP0/Harmony/EditorPartIcon.cs index 2d04e5228b5..36ee04390a5 100644 --- a/Source/RP0/Harmony/EditorPartIcon.cs +++ b/Source/RP0/Harmony/EditorPartIcon.cs @@ -13,7 +13,7 @@ internal class PatchEditorPartIcon internal static void PatchUpdate(EditorPartIcon __instance) { // stock's experimental display is broken and we want to replace it anyways, so use its state variables - if (__instance.checkedExperimental || KerbalConstructionTimeData.Instance == null) + if (__instance.checkedExperimental || SpaceCenterManagement.Instance == null) return; AvailablePart part = __instance.AvailPart; @@ -22,7 +22,7 @@ internal static void PatchUpdate(EditorPartIcon __instance) if (btnImage == null || part == null) return; - if (KerbalConstructionTimeData.Instance.TechList.Any(tech => tech.techID == part.TechRequired)) + if (SpaceCenterManagement.Instance.TechList.Any(tech => tech.techID == part.TechRequired)) btnImage.color = __instance.experimentalPartColor; __instance.checkedExperimental = true; diff --git a/Source/RP0/Harmony/EngineersReport.cs b/Source/RP0/Harmony/EngineersReport.cs index a57c16a7bea..8f3ea953953 100644 --- a/Source/RP0/Harmony/EngineersReport.cs +++ b/Source/RP0/Harmony/EngineersReport.cs @@ -155,17 +155,17 @@ internal static bool Prefix_UpdateCratStats(EngineersReport __instance, ShipCons bool resourcesOK = true; if (PresetManager.Instance.ActivePreset.GeneralSettings.Enabled && PresetManager.Instance.ActivePreset.GeneralSettings.BuildTimes) { - totalMass = KerbalConstructionTimeData.Instance.EditorVessel.mass; - craftSize = KerbalConstructionTimeData.Instance.EditorVessel.ShipSize; - vesselHumanRated = KerbalConstructionTimeData.Instance.EditorVessel.humanRated; + totalMass = SpaceCenterManagement.Instance.EditorVessel.mass; + craftSize = SpaceCenterManagement.Instance.EditorVessel.ShipSize; + vesselHumanRated = SpaceCenterManagement.Instance.EditorVessel.humanRated; - resourcesOK = KerbalConstructionTimeData.Instance.EditorVessel.ResourcesOK(KerbalConstructionTimeData.Instance.EditorVessel.LC.Stats); + resourcesOK = SpaceCenterManagement.Instance.EditorVessel.ResourcesOK(SpaceCenterManagement.Instance.EditorVessel.LC.Stats); - massLimit = KerbalConstructionTimeData.Instance.EditorVessel.LC.MassMax; - minMassLimit = KerbalConstructionTimeData.Instance.EditorVessel.LC.MassMin; - maxSize = KerbalConstructionTimeData.Instance.EditorVessel.LC.SizeMax; - lcHumanRated = KerbalConstructionTimeData.Instance.EditorVessel.LC.IsHumanRated; - vesselHumanRated = KerbalConstructionTimeData.Instance.EditorVessel.humanRated; + massLimit = SpaceCenterManagement.Instance.EditorVessel.LC.MassMax; + minMassLimit = SpaceCenterManagement.Instance.EditorVessel.LC.MassMin; + maxSize = SpaceCenterManagement.Instance.EditorVessel.LC.SizeMax; + lcHumanRated = SpaceCenterManagement.Instance.EditorVessel.LC.IsHumanRated; + vesselHumanRated = SpaceCenterManagement.Instance.EditorVessel.humanRated; } else { diff --git a/Source/RP0/Harmony/FundsWidget.cs b/Source/RP0/Harmony/FundsWidget.cs index 3b146846239..f0793781750 100644 --- a/Source/RP0/Harmony/FundsWidget.cs +++ b/Source/RP0/Harmony/FundsWidget.cs @@ -33,9 +33,9 @@ internal static void Postfix_DelayedStart(FundsWidget __instance) private static string GetTooltipText() { return Localizer.Format("#rp0_Widgets_Funds_Tooltip", - LocalizationHandler.FormatValuePositiveNegative(KerbalConstructionTimeData.Instance.GetBudgetDelta(86400d), "N1"), - LocalizationHandler.FormatValuePositiveNegative(KerbalConstructionTimeData.Instance.GetBudgetDelta(86400d * 30d), "N0"), - LocalizationHandler.FormatValuePositiveNegative(KerbalConstructionTimeData.Instance.GetBudgetDelta(86400d * 365.25d), "N0")); + LocalizationHandler.FormatValuePositiveNegative(SpaceCenterManagement.Instance.GetBudgetDelta(86400d), "N1"), + LocalizationHandler.FormatValuePositiveNegative(SpaceCenterManagement.Instance.GetBudgetDelta(86400d * 30d), "N0"), + LocalizationHandler.FormatValuePositiveNegative(SpaceCenterManagement.Instance.GetBudgetDelta(86400d * 365.25d), "N0")); } } } diff --git a/Source/RP0/Harmony/KSCFacilityContextMenu.cs b/Source/RP0/Harmony/KSCFacilityContextMenu.cs index 3cd04c6cda8..d7922163c3f 100644 --- a/Source/RP0/Harmony/KSCFacilityContextMenu.cs +++ b/Source/RP0/Harmony/KSCFacilityContextMenu.cs @@ -74,7 +74,7 @@ internal static bool Prefix_CreateWindowContent(KSCFacilityContextMenu __instanc if (HighLogic.LoadedSceneIsGame) oldCost *= HighLogic.CurrentGame.Parameters.Career.FundsLossMultiplier; var facilityType = GetFacilityType(__instance.host); - double rate = KCTUtilities.GetConstructionRate(0, KerbalConstructionTimeData.Instance.ActiveSC, facilityType); + double rate = KCTUtilities.GetConstructionRate(0, SpaceCenterManagement.Instance.ActiveSC, facilityType); if ((float)__instance.host.Facility.FacilityLevel != __instance.host.Facility.MaxLevel) { @@ -388,7 +388,7 @@ private static void ProcessUpgrade(SpaceCenterBuilding host, bool isUpgrade) cost = -cost; upgrading.cost = cost; - KerbalConstructionTimeData.Instance.ActiveSC.FacilityUpgrades.Add(upgrading); + SpaceCenterManagement.Instance.ActiveSC.FacilityUpgrades.Add(upgrading); try { diff --git a/Source/RP0/Harmony/KSCSwitcher.cs b/Source/RP0/Harmony/KSCSwitcher.cs index 427403b9cf7..1270c001e24 100644 --- a/Source/RP0/Harmony/KSCSwitcher.cs +++ b/Source/RP0/Harmony/KSCSwitcher.cs @@ -19,9 +19,9 @@ internal static bool Prepare() [HarmonyPostfix] internal static void Postfix_SetSite(ConfigNode KSC, bool __result) { - if (__result && KerbalConstructionTimeData.Instance != null) + if (__result && SpaceCenterManagement.Instance != null) { - KerbalConstructionTimeData.Instance.SetActiveKSC(KSC.name); + SpaceCenterManagement.Instance.SetActiveKSC(KSC.name); } } } diff --git a/Source/RP0/Harmony/PartListTooltip.cs b/Source/RP0/Harmony/PartListTooltip.cs index a83ff6f3513..08c3225165d 100644 --- a/Source/RP0/Harmony/PartListTooltip.cs +++ b/Source/RP0/Harmony/PartListTooltip.cs @@ -45,7 +45,7 @@ private static void PatchButtons(PartListTooltip __instance, AvailablePart avail techID = availablePart.TechRequired; eCost = availablePart.entryCost; } - if (KerbalConstructionTimeData.Instance.TechListHas(techID)) + if (SpaceCenterManagement.Instance.TechListHas(techID)) { __instance.buttonPurchaseContainer.SetActive(false); __instance.costPanel.SetActive(true); diff --git a/Source/RP0/Harmony/RDController.cs b/Source/RP0/Harmony/RDController.cs index c57bcb6a162..782e1b505d6 100644 --- a/Source/RP0/Harmony/RDController.cs +++ b/Source/RP0/Harmony/RDController.cs @@ -24,7 +24,7 @@ internal static void Postfix_ShowNodePanel(RDController __instance, RDNode node) string techID = node.tech.techID; bool showCredit = node.tech.state == RDTech.State.Available; int techItemIndex = -1; - bool showProgress = !showCredit && (techItemIndex = KerbalConstructionTimeData.Instance.TechListIndex(techID)) != -1; + bool showProgress = !showCredit && (techItemIndex = SpaceCenterManagement.Instance.TechListIndex(techID)) != -1; showCredit |= showProgress; var type = Database.NodeTypes.ValueOrDefault(node.tech.techID); string extraText = Localizer.Format("#rp0_RnD_NodeType", Localizer.Format("#rp0_RnD_NodeType_" + type.ToStringCached())) + "\n"; @@ -41,12 +41,12 @@ internal static void Postfix_ShowNodePanel(RDController __instance, RDNode node) if (showProgress) { - ResearchProject item = KerbalConstructionTimeData.Instance.TechList[techItemIndex]; + ResearchProject item = SpaceCenterManagement.Instance.TechList[techItemIndex]; double prevTime = 0d; if (KCTSettings.Instance.UseDates) { for (int i = 0; i < techItemIndex; ++i) - prevTime += KerbalConstructionTimeData.Instance.TechList[i].GetTimeLeftEst(prevTime); + prevTime += SpaceCenterManagement.Instance.TechList[i].GetTimeLeftEst(prevTime); } extraText += Localizer.Format(item.BuildRate > 0 ? "#rp0_RnD_Progress" : "#rp0_RnD_ProgressEst", (item.GetFractionComplete() * 100d).ToString("N0"), @@ -58,14 +58,14 @@ internal static void Postfix_ShowNodePanel(RDController __instance, RDNode node) __instance.node_description.text = extraText + __instance.node_description.text; // we could patch RDNodeList...or we could just handle this as a postfix. - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; for (int i = 0; i < __instance.requiresList.scrollList.list.Count; ++i) { // Items are added to this list in order from the parents so these will be in sync. var nodeItem = __instance.requiresList.scrollList.list[i].listItem.GetComponent(); var parent = node.parents[i]; - if (parent.parent.node.state != RDNode.State.RESEARCHED && KerbalConstructionTimeData.Instance.TechListHas(parent.parent.node.tech.techID)) + if (parent.parent.node.state != RDNode.State.RESEARCHED && SpaceCenterManagement.Instance.TechListHas(parent.parent.node.tech.techID)) { nodeItem.node.SetButtonState(RDNode.State.RESEARCHED); nodeItem.node.graphics.SetIconColor(XKCDColors.KSPNotSoGoodOrange); // replaces the white @@ -84,7 +84,7 @@ internal static void Postfix_Start(RDController __instance) [HarmonyPatch("UpdatePanel")] internal static bool Prefix_UpdatePanel(RDController __instance) { - if (KerbalConstructionTimeData.Instance.TechListHas(__instance.node_selected.tech.techID)) + if (SpaceCenterManagement.Instance.TechListHas(__instance.node_selected.tech.techID)) { __instance.node_inPanel.SetButtonState(RDNode.State.RESEARCHED); __instance.node_inPanel.SetIconState(__instance.node_selected.icon); @@ -102,9 +102,9 @@ internal static bool Prefix_UpdatePanel(RDController __instance) [HarmonyPatch("ActionButtonClick")] internal static bool Prefix_ActionButtonClick(RDController __instance) { - if (KerbalConstructionTimeData.Instance.TechListHas(__instance.node_selected.tech.techID)) + if (SpaceCenterManagement.Instance.TechListHas(__instance.node_selected.tech.techID)) { - KCT_GUI.CancelTechNode(KerbalConstructionTimeData.Instance.TechList.FindIndex(t => t.techID == __instance.node_selected.tech.techID)); + KCT_GUI.CancelTechNode(SpaceCenterManagement.Instance.TechList.FindIndex(t => t.techID == __instance.node_selected.tech.techID)); return false; } diff --git a/Source/RP0/Harmony/RDNode.cs b/Source/RP0/Harmony/RDNode.cs index e3c5603bfe3..009bfd72578 100644 --- a/Source/RP0/Harmony/RDNode.cs +++ b/Source/RP0/Harmony/RDNode.cs @@ -23,7 +23,7 @@ internal static bool Prefix_GetTooltipCaption(RDNode __instance, out string __re } CurrencyModifierQueryRP0 cmq = CurrencyModifierQueryRP0.RunQuery(TransactionReasonsRP0.RnDTechResearch, 0d, -__instance.tech.scienceCost, 0d); - if (KerbalConstructionTimeData.Instance?.TechListHas(__instance.tech.techID) == true) + if (SpaceCenterManagement.Instance?.TechListHas(__instance.tech.techID) == true) { __result = cmq.GetCostLineOverride(true, true, false) + "\n" + _ColorGreen + Localizer.GetStringByTag("#rp0_RnD_TechResearching") + ""; } @@ -61,7 +61,7 @@ internal static bool UpdateGraphics(RDNode __instance) if (!PresetManager.Instance.ActivePreset.GeneralSettings.Enabled || !PresetManager.Instance.ActivePreset.GeneralSettings.TechUnlockTimes || !PresetManager.Instance.ActivePreset.GeneralSettings.BuildTimes - || KerbalConstructionTimeData.Instance == null) + || SpaceCenterManagement.Instance == null) return true; if (__instance.tech == null) @@ -74,7 +74,7 @@ internal static bool UpdateGraphics(RDNode __instance) { __instance.SetButtonState(RDNode.State.RESEARCHED); } - else if (KerbalConstructionTimeData.Instance.TechListHas(__instance.tech.techID)) + else if (SpaceCenterManagement.Instance.TechListHas(__instance.tech.techID)) { __instance.SetButtonState(RDNode.State.RESEARCHED); __instance.graphics.SetIconColor(XKCDColors.KSPNotSoGoodOrange); // replaces the white @@ -110,7 +110,7 @@ internal static bool UpdateGraphics(RDNode __instance) else { //allResearched = false; - if (KerbalConstructionTimeData.Instance.TechListHas(parent.parent.node.tech.techID)) + if (SpaceCenterManagement.Instance.TechListHas(parent.parent.node.tech.techID)) { listReasearchedOrQueued.Add(parent); anyResearchedOrQueued = true; diff --git a/Source/RP0/Harmony/RDTech.cs b/Source/RP0/Harmony/RDTech.cs index 6165dd93695..fd5e272877b 100644 --- a/Source/RP0/Harmony/RDTech.cs +++ b/Source/RP0/Harmony/RDTech.cs @@ -14,13 +14,13 @@ internal static bool Prefix_UnlockTech(RDTech __instance, bool updateGameState) || !PresetManager.Instance.ActivePreset.GeneralSettings.BuildTimes) return true; - if (KerbalConstructionTimeData.Instance.TechListHas(__instance.techID)) + if (SpaceCenterManagement.Instance.TechListHas(__instance.techID)) return false; var tech = new ResearchProject(__instance); - KerbalConstructionTimeData.Instance.TechList.Add(tech); - tech.UpdateBuildRate(KerbalConstructionTimeData.Instance.TechList.Count - 1); + SpaceCenterManagement.Instance.TechList.Add(tech); + tech.UpdateBuildRate(SpaceCenterManagement.Instance.TechList.Count - 1); SCMEvents.OnTechQueued.Fire(__instance); diff --git a/Source/RP0/Harmony/RealFuels.cs b/Source/RP0/Harmony/RealFuels.cs index 7de969bc4fb..105767add96 100644 --- a/Source/RP0/Harmony/RealFuels.cs +++ b/Source/RP0/Harmony/RealFuels.cs @@ -48,9 +48,9 @@ internal static void Postfix_DrawSelectButton(RealFuels.ModuleEngineConfigsBase [HarmonyPatch("SetConfiguration", new Type[] { typeof(ConfigNode), typeof(bool) })] internal static void Postfix_SetConfiguration(RealFuels.ModuleEngineConfigsBase __instance, ConfigNode newConfig) { - if (HighLogic.LoadedSceneIsEditor && KerbalConstructionTimeData.Instance != null) + if (HighLogic.LoadedSceneIsEditor && SpaceCenterManagement.Instance != null) { - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } if (HighLogic.LoadedScene != GameScenes.LOADING && __instance.part != null) { @@ -73,9 +73,9 @@ internal class RFMFTPatcher [HarmonyPatch("RaiseTankDefinitionChanged")] internal static void Postfix_RaiseTankDefinitionChanged(RealFuels.Tanks.ModuleFuelTanks __instance) { - if (HighLogic.LoadedSceneIsEditor && KerbalConstructionTimeData.Instance != null) + if (HighLogic.LoadedSceneIsEditor && SpaceCenterManagement.Instance != null) { - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } if (HighLogic.LoadedScene != GameScenes.LOADING && __instance.part != null) { @@ -131,7 +131,7 @@ internal static bool PatchedPurchaseConfig(RealFuels.EntryCostManager __instance techNode = null; if (HighLogic.LoadedSceneIsEditor) - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; return true; } diff --git a/Source/RP0/Harmony/ScienceWidget.cs b/Source/RP0/Harmony/ScienceWidget.cs index 284f31eadb3..988fdd23582 100644 --- a/Source/RP0/Harmony/ScienceWidget.cs +++ b/Source/RP0/Harmony/ScienceWidget.cs @@ -21,7 +21,7 @@ internal static void Postfix_DelayedStart(FundsWidget __instance) private static string GetTooltipText() { - double pts = KerbalConstructionTimeData.Instance.SciPointsTotal; + double pts = SpaceCenterManagement.Instance.SciPointsTotal; if (pts < 0d) pts = 0d; return Localizer.Format("#rp0_Widgets_Science_Tooltip", diff --git a/Source/RP0/Harmony/StrategySystem.cs b/Source/RP0/Harmony/StrategySystem.cs index 6e5f2da5c6c..3d495ab08c9 100644 --- a/Source/RP0/Harmony/StrategySystem.cs +++ b/Source/RP0/Harmony/StrategySystem.cs @@ -168,7 +168,7 @@ internal static void Postfix_LoadStrategies() ProgramHandler.Instance.OnLoadStrategiesComplete(); - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); + SpaceCenterManagement.Instance.RecalculateBuildRates(); } } } \ No newline at end of file diff --git a/Source/RP0/Leaders/Effects/CurrencyModifier.cs b/Source/RP0/Leaders/Effects/CurrencyModifier.cs index 2c5d8deee62..2f534f2eb6d 100644 --- a/Source/RP0/Leaders/Effects/CurrencyModifier.cs +++ b/Source/RP0/Leaders/Effects/CurrencyModifier.cs @@ -83,7 +83,7 @@ protected void OnEffectQuery(CurrencyModifierQuery qry) { var reason = qryRP0.reasonRP0; // Work around a Kerbalism issue: it uses reason None for science transmission - if (reason == TransactionReasonsRP0.None && qry.GetInput(Currency.Science) > 0f && !KerbalConstructionTimeData.IsRefundingScience) + if (reason == TransactionReasonsRP0.None && qry.GetInput(Currency.Science) > 0f && !SpaceCenterManagement.IsRefundingScience) reason = TransactionReasonsRP0.ScienceTransmission; if ((listeningReasons & reason) != 0) qryRP0.Multiply(currency, multToUse); diff --git a/Source/RP0/Leaders/StrategyRP0.cs b/Source/RP0/Leaders/StrategyRP0.cs index c9edb3cd2c8..0e0d0b58494 100644 --- a/Source/RP0/Leaders/StrategyRP0.cs +++ b/Source/RP0/Leaders/StrategyRP0.cs @@ -145,7 +145,7 @@ public void PerformActivate(bool useCurrency) if (!(this is Programs.ProgramStrategy)) { - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); + SpaceCenterManagement.Instance.RecalculateBuildRates(); MaintenanceHandler.Instance?.UpdateUpkeep(); Programs.ProgramHandler.Instance.OnLeaderChange(); // FIXME add setup cost if we add setup costs to leaders @@ -182,7 +182,7 @@ public virtual bool DeactivateOverride() if (!(this is Programs.ProgramStrategy)) { - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); + SpaceCenterManagement.Instance.RecalculateBuildRates(); MaintenanceHandler.Instance?.UpdateUpkeep(); Programs.ProgramHandler.Instance.OnLeaderChange(); CareerLog.Instance?.AddLeaderEvent(Config.Name, false, deactivateRep); diff --git a/Source/RP0/Maintenance/MaintenanceHandler.cs b/Source/RP0/Maintenance/MaintenanceHandler.cs index 5c5d232e380..a2e31553e01 100644 --- a/Source/RP0/Maintenance/MaintenanceHandler.cs +++ b/Source/RP0/Maintenance/MaintenanceHandler.cs @@ -44,7 +44,7 @@ public class MaintenanceHandler : ScenarioModule public MaintenanceGUI.MaintenancePeriod guiSelectedPeriod = MaintenanceGUI.MaintenancePeriod.Day; public readonly Dictionary IntegrationSalaries = new Dictionary(); - public double Researchers => KerbalConstructionTimeData.Instance.Researchers; + public double Researchers => SpaceCenterManagement.Instance.Researchers; private bool _wasWarpingHigh = false; private int _frameCount = 0; @@ -208,9 +208,9 @@ private void UpdateKCTSalaries() { Profiler.BeginSample("RP0Maintenance UpdateKCTSalaries"); IntegrationSalaries.Clear(); - foreach (LCSpaceCenter ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (LCSpaceCenter ksc in SpaceCenterManagement.Instance.KSCs) { - IntegrationSalaries[ksc.KSCName] = KerbalConstructionTimeData.Instance.GetEffectiveIntegrationEngineersForSalary(ksc); + IntegrationSalaries[ksc.KSCName] = SpaceCenterManagement.Instance.GetEffectiveIntegrationEngineersForSalary(ksc); } Profiler.EndSample(); } @@ -339,7 +339,7 @@ public double LCUpkeep(LaunchComplex lc) private double GetFacilityUpgradeRatio(SpaceCenterFacility facility) { - foreach (var fac in KerbalConstructionTimeData.Instance.ActiveSC.FacilityUpgrades) + foreach (var fac in SpaceCenterManagement.Instance.ActiveSC.FacilityUpgrades) if (fac.FacilityType == facility) return fac.progress / fac.BP; @@ -357,7 +357,7 @@ public void UpdateUpkeep() EnsureFacilityLvlCostsLoaded(); LCsCostPerDay = 0d; - foreach (var ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (var ksc in SpaceCenterManagement.Instance.KSCs) { foreach (var lc in ksc.LaunchComplexes) LCsCostPerDay += LCUpkeep(lc); @@ -557,7 +557,7 @@ public void FixedUpdate() } // Finally, update all builds - KerbalConstructionTimeData.Instance.ProgressBuildTime(UTDiff); + SpaceCenterManagement.Instance.ProgressBuildTime(UTDiff); } public void OnDestroy() diff --git a/Source/RP0/Milestones/MilestoneHandler.cs b/Source/RP0/Milestones/MilestoneHandler.cs index 3d67c9c351a..7e2588c68ba 100644 --- a/Source/RP0/Milestones/MilestoneHandler.cs +++ b/Source/RP0/Milestones/MilestoneHandler.cs @@ -195,7 +195,7 @@ private IEnumerator ContractCompleteRoutine(ConfiguredContract cc) AddVesselCrewData(milestone.name, FlightGlobals.ActiveVessel); // Add extra data here if desired - if (!HighLogic.LoadedSceneIsFlight || KerbalConstructionTimeData.Instance.IsSimulatedFlight) + if (!HighLogic.LoadedSceneIsFlight || SpaceCenterManagement.Instance.IsSimulatedFlight) yield break; yield return CaptureScreenshot(milestone, overwrite: false); @@ -204,7 +204,7 @@ private IEnumerator ContractCompleteRoutine(ConfiguredContract cc) private IEnumerator ContractParamCompleteRoutine(ContractConfiguratorParameter ccp) { - if (!HighLogic.LoadedSceneIsFlight || KerbalConstructionTimeData.Instance.IsSimulatedFlight || + if (!HighLogic.LoadedSceneIsFlight || SpaceCenterManagement.Instance.IsSimulatedFlight || !ContractParamToMilestone.TryGetValue(ccp.ID, out Milestone milestone)) { yield break; diff --git a/Source/RP0/Persistence/GUIPosition.cs b/Source/RP0/Persistence/GUIPosition.cs index bda83cc92b8..ce89727c729 100644 --- a/Source/RP0/Persistence/GUIPosition.cs +++ b/Source/RP0/Persistence/GUIPosition.cs @@ -33,8 +33,8 @@ public void Save() try { - buildListPositionSaved = new GUIPosition("buildList", KCT_GUI.BuildListWindowPosition.x, KCT_GUI.BuildListWindowPosition.y, KerbalConstructionTimeData.ShowWindows[0]); - editorPositionSaved = new GUIPosition("editor", KCT_GUI.EditorWindowPosition.x, KCT_GUI.EditorWindowPosition.y, KerbalConstructionTimeData.ShowWindows[1]); + buildListPositionSaved = new GUIPosition("buildList", KCT_GUI.BuildListWindowPosition.x, KCT_GUI.BuildListWindowPosition.y, SpaceCenterManagement.ShowWindows[0]); + editorPositionSaved = new GUIPosition("editor", KCT_GUI.EditorWindowPosition.x, KCT_GUI.EditorWindowPosition.y, SpaceCenterManagement.ShowWindows[1]); editorBuildListPositionSaved = new GUIPosition("editorBuildList", KCT_GUI.EditorBuildListWindowPosition.x, KCT_GUI.EditorBuildListWindowPosition.y, false); ConfigNode cnTemp = ConfigNode.CreateConfigFromObject(this, new ConfigNode()); @@ -60,14 +60,14 @@ public void Load() { KCT_GUI.BuildListWindowPosition.x = buildListPositionSaved.xPos; KCT_GUI.BuildListWindowPosition.y = buildListPositionSaved.yPos; - KerbalConstructionTimeData.ShowWindows[0] = buildListPositionSaved.visible; + SpaceCenterManagement.ShowWindows[0] = buildListPositionSaved.visible; } if (editorPositionSaved != null) { KCT_GUI.EditorWindowPosition.x = editorPositionSaved.xPos; KCT_GUI.EditorWindowPosition.y = editorPositionSaved.yPos; - KerbalConstructionTimeData.ShowWindows[1] = editorPositionSaved.visible; + SpaceCenterManagement.ShowWindows[1] = editorPositionSaved.visible; } if (editorBuildListPositionSaved != null) diff --git a/Source/RP0/Programs/ProgramHandler.cs b/Source/RP0/Programs/ProgramHandler.cs index cfe3ddad27a..8bcd49ae8bc 100644 --- a/Source/RP0/Programs/ProgramHandler.cs +++ b/Source/RP0/Programs/ProgramHandler.cs @@ -319,8 +319,8 @@ public float RepToConfidenceForContract(ConfiguredContract cc, bool isAwarding) private void OnContractAccept(Contract data) { - if (KerbalConstructionTimeData.Instance.StartedProgram) - KerbalConstructionTimeData.Instance.AcceptedContract = true; + if (SpaceCenterManagement.Instance.StartedProgram) + SpaceCenterManagement.Instance.AcceptedContract = true; } private void OnContractComplete(Contract data) @@ -349,7 +349,7 @@ private IEnumerator ContractCompleteRoutine(Contract data) // Handle KCT applicants int applicants = Database.SettingsSC.ContractApplicants.GetApplicantsFromContract(cc.contractType.name); if (applicants > 0) - KerbalConstructionTimeData.Instance.Applicants += applicants; + SpaceCenterManagement.Instance.Applicants += applicants; // Handle Confidence float repToConf = RepToConfidenceForContract(cc, true); @@ -523,7 +523,7 @@ public void ActivateProgram(Program p) ps.SetProgram(activeP); - KerbalConstructionTimeData.Instance.StartedProgram = true; + SpaceCenterManagement.Instance.StartedProgram = true; } public void CompleteProgram(Program p) diff --git a/Source/RP0/RP0.csproj b/Source/RP0/RP0.csproj index ca74b6cf170..7198d1f78e6 100644 --- a/Source/RP0/RP0.csproj +++ b/Source/RP0/RP0.csproj @@ -275,7 +275,7 @@ - + diff --git a/Source/RP0/ScenarioModules/Confidence.cs b/Source/RP0/ScenarioModules/Confidence.cs index 2d19b8f98f5..6ed3eb5bbc0 100644 --- a/Source/RP0/ScenarioModules/Confidence.cs +++ b/Source/RP0/ScenarioModules/Confidence.cs @@ -57,11 +57,11 @@ private void OnCurrenciesModified(CurrencyModifierQuery query) float sciDelta = query.GetInput(Currency.Science); float conf = 0f; // Annoyingly Kerbalism uses TransactionReason.None for science transmission - if (!KerbalConstructionTimeData.IsRefundingScience && sciDelta > 0f + if (!SpaceCenterManagement.IsRefundingScience && sciDelta > 0f && (query.reason == TransactionReasons.ScienceTransmission || query.reason == TransactionReasons.VesselRecovery || query.reason == TransactionReasons.None)) { if (Programs.ProgramHandler.Settings != null) - conf = Programs.ProgramHandler.Settings.scienceToConfidence.Evaluate(System.Math.Max(0f, (float)KerbalConstructionTimeData.Instance.SciPointsTotal)) * sciDelta; + conf = Programs.ProgramHandler.Settings.scienceToConfidence.Evaluate(System.Math.Max(0f, (float)SpaceCenterManagement.Instance.SciPointsTotal)) * sciDelta; else conf = sciDelta * 2f; diff --git a/Source/RP0/ScenarioModules/UnlockCreditHandler.cs b/Source/RP0/ScenarioModules/UnlockCreditHandler.cs index a380f76cd20..f56dcf06ec3 100644 --- a/Source/RP0/ScenarioModules/UnlockCreditHandler.cs +++ b/Source/RP0/ScenarioModules/UnlockCreditHandler.cs @@ -19,7 +19,7 @@ public double CreditForTime(double UT) double sum = 0d; double mult = UT * Database.SettingsSC.salaryResearchers * (1d / (86400d * 365.25d)); - int res = KerbalConstructionTimeData.Instance.Researchers; + int res = SpaceCenterManagement.Instance.Researchers; int totalCounted = 0; foreach (var kvp in Database.SettingsSC.researchersToUnlockCreditSalaryMultipliers) @@ -218,7 +218,7 @@ private void OnPartPurchased(AvailablePart ap) int remainingCost = (int)ProcessCredit(ap.entryCost, ap.TechRequired); ap.SetEntryCost(remainingCost); if(HighLogic.LoadedSceneIsEditor) - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } } @@ -228,7 +228,7 @@ private void OnPartUpgradePurchased(PartUpgradeHandler.Upgrade up) float remainingCost = ProcessCredit(up.entryCost, up.techRequired); up.entryCost = remainingCost; if (HighLogic.LoadedSceneIsEditor) - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } public override void OnLoad(ConfigNode node) diff --git a/Source/RP0/Settings/SpaceCenterSettings.cs b/Source/RP0/Settings/SpaceCenterSettings.cs index c6a7c1dea3d..f4cc45a93b3 100644 --- a/Source/RP0/Settings/SpaceCenterSettings.cs +++ b/Source/RP0/Settings/SpaceCenterSettings.cs @@ -99,7 +99,7 @@ public class SpaceCenterSettings : ConfigNodePersistenceBase public double LCEfficiencyMin => LCEfficiencyUpgradesMin.GetSum(); public double LCEfficiencyMax => LCEfficiencyUpgradesMax.GetSum(); public double ResearcherEfficiency => ResearcherEfficiencyUpgrades.GetMultiplier() - * Formula.GetScienceResearchEfficiencyMult(KerbalConstructionTimeData.Instance.SciPointsTotal); + * Formula.GetScienceResearchEfficiencyMult(SpaceCenterManagement.Instance.SciPointsTotal); public override void Load(ConfigNode node) { diff --git a/Source/RP0/Singletons/SingletonHost.cs b/Source/RP0/Singletons/SingletonHost.cs index d01ec3421c9..e73e1da4232 100644 --- a/Source/RP0/Singletons/SingletonHost.cs +++ b/Source/RP0/Singletons/SingletonHost.cs @@ -78,7 +78,7 @@ public void Awake() public void Start() { - ToolbarControl.RegisterMod(KerbalConstructionTimeData._modId, KerbalConstructionTimeData._modName); + ToolbarControl.RegisterMod(SpaceCenterManagement._modId, SpaceCenterManagement._modName); foreach (var s in _singletons) { diff --git a/Source/RP0/SpaceCenter/AirlaunchParams.cs b/Source/RP0/SpaceCenter/AirlaunchParams.cs index adba0816594..3bbc5218128 100644 --- a/Source/RP0/SpaceCenter/AirlaunchParams.cs +++ b/Source/RP0/SpaceCenter/AirlaunchParams.cs @@ -36,7 +36,7 @@ public AirlaunchParams(AirlaunchParams src) public bool Validate(out string errorMsg) { - AirlaunchTechLevel lvl = KerbalConstructionTimeData.Instance.IsSimulatedFlight ? AirlaunchTechLevel.GetHighestLevelIncludingUnderResearch() : + AirlaunchTechLevel lvl = SpaceCenterManagement.Instance.IsSimulatedFlight ? AirlaunchTechLevel.GetHighestLevelIncludingUnderResearch() : AirlaunchTechLevel.GetCurrentLevel(); if (lvl == null) { diff --git a/Source/RP0/SpaceCenter/AirlaunchTechLevel.cs b/Source/RP0/SpaceCenter/AirlaunchTechLevel.cs index 351e2d82404..4c016af6f6a 100644 --- a/Source/RP0/SpaceCenter/AirlaunchTechLevel.cs +++ b/Source/RP0/SpaceCenter/AirlaunchTechLevel.cs @@ -71,7 +71,7 @@ public bool CanLaunchVessel(VesselProject vessel, out string reason) public bool IsUnlocked => ResearchAndDevelopment.GetTechnologyState(TechRequired) == RDTech.State.Available; - public bool IsUnderResearch => KerbalConstructionTimeData.Instance.TechListHas(TechRequired); + public bool IsUnderResearch => SpaceCenterManagement.Instance.TechListHas(TechRequired); public static bool AnyUnlocked() { @@ -81,7 +81,7 @@ public static bool AnyUnlocked() public static bool AnyUnderResearch() { EnsureLevelsLoaded(); - return _techLevels.Any(tl => KerbalConstructionTimeData.Instance.TechListHas(tl.TechRequired)); + return _techLevels.Any(tl => SpaceCenterManagement.Instance.TechListHas(tl.TechRequired)); } public static AirlaunchTechLevel GetCurrentLevel() diff --git a/Source/RP0/SpaceCenter/LaunchComplex/LCEfficiency.cs b/Source/RP0/SpaceCenter/LaunchComplex/LCEfficiency.cs index c5513817516..2a0cb53b06d 100644 --- a/Source/RP0/SpaceCenter/LaunchComplex/LCEfficiency.cs +++ b/Source/RP0/SpaceCenter/LaunchComplex/LCEfficiency.cs @@ -61,7 +61,7 @@ protected void Relink() continue; } - var lc = KerbalConstructionTimeData.Instance.FindLCFromID(id); + var lc = SpaceCenterManagement.Instance.FindLCFromID(id); if (lc == null) { _lcIDs.RemoveAt(i); @@ -77,7 +77,7 @@ protected void Relink() protected void RefreshCache() { _closenessCache.Clear(); - foreach (LCEfficiency e in KerbalConstructionTimeData.Instance.LCEfficiencies) + foreach (LCEfficiency e in SpaceCenterManagement.Instance.LCEfficiencies) if (e != this) _closenessCache[e] = Formula.GetLCCloseness(_lcStats, e._lcStats); } @@ -94,9 +94,9 @@ public void RemoveLC(LaunchComplex lc) else { // Just in case we get in a bad state - if (KerbalConstructionTimeData.Instance.LCToEfficiency.ContainsKey(lc)) + if (SpaceCenterManagement.Instance.LCToEfficiency.ContainsKey(lc)) { - KerbalConstructionTimeData.Instance.LCToEfficiency.Remove(lc); + SpaceCenterManagement.Instance.LCToEfficiency.Remove(lc); ClearEmpty(); } } @@ -132,7 +132,7 @@ public void IncreaseEfficiency(double increase, bool distribute) if (distribute) { - foreach (var e in KerbalConstructionTimeData.Instance.LCEfficiencies) + foreach (var e in SpaceCenterManagement.Instance.LCEfficiencies) if (e != this) e.ReceiveDistributedEfficiency(this, increase); } @@ -253,7 +253,7 @@ public static LCEfficiency FindClosest(LCData data, out double bestCloseness) bestCloseness = 0d; LCEfficiency bestItem = null; - foreach (var e in KerbalConstructionTimeData.Instance.LCEfficiencies) + foreach (var e in SpaceCenterManagement.Instance.LCEfficiencies) { double closeness = Formula.GetLCCloseness(data, e._lcStats); if (closeness > bestCloseness) @@ -268,7 +268,7 @@ public static LCEfficiency FindClosest(LCData data, out double bestCloseness) public static LCEfficiency GetOrCreateEfficiencyForLC(LaunchComplex lc, bool allowLookup) { LCEfficiency e; - if (allowLookup && KerbalConstructionTimeData.Instance.LCToEfficiency.TryGetValue(lc, out e)) + if (allowLookup && SpaceCenterManagement.Instance.LCToEfficiency.TryGetValue(lc, out e)) return e; e = FindClosest(lc, out double closeness); @@ -283,14 +283,14 @@ public static LCEfficiency GetOrCreateEfficiencyForLC(LaunchComplex lc, bool all } e = new LCEfficiency(lc); // this will put it in the dict - KerbalConstructionTimeData.Instance.LCEfficiencies.Add(e); + SpaceCenterManagement.Instance.LCEfficiencies.Add(e); RefreshAllCaches(); return e; } public static void RelinkAll() { - foreach (var e in KerbalConstructionTimeData.Instance.LCEfficiencies) + foreach (var e in SpaceCenterManagement.Instance.LCEfficiencies) e.Relink(); if (!ClearEmpty()) @@ -299,18 +299,18 @@ public static void RelinkAll() protected static void RefreshAllCaches() { - foreach (var e in KerbalConstructionTimeData.Instance.LCEfficiencies) + foreach (var e in SpaceCenterManagement.Instance.LCEfficiencies) e.RefreshCache(); } public static bool ClearEmpty() { - int oldCount = KerbalConstructionTimeData.Instance.LCEfficiencies.Count; - for (int i = KerbalConstructionTimeData.Instance.LCEfficiencies.Count; i-- > 0;) - if (KerbalConstructionTimeData.Instance.LCEfficiencies[i]._lcs.Count == 0) - KerbalConstructionTimeData.Instance.LCEfficiencies.RemoveAt(i); + int oldCount = SpaceCenterManagement.Instance.LCEfficiencies.Count; + for (int i = SpaceCenterManagement.Instance.LCEfficiencies.Count; i-- > 0;) + if (SpaceCenterManagement.Instance.LCEfficiencies[i]._lcs.Count == 0) + SpaceCenterManagement.Instance.LCEfficiencies.RemoveAt(i); - if (oldCount != KerbalConstructionTimeData.Instance.LCEfficiencies.Count) + if (oldCount != SpaceCenterManagement.Instance.LCEfficiencies.Count) { RefreshAllCaches(); return true; @@ -340,7 +340,7 @@ public static void RecalculateConstants() if (KSP.UI.Screens.MessageSystem.Instance != null) { var sb = StringBuilderCache.Acquire(); - foreach (var kvp in KerbalConstructionTimeData.Instance.LCToEfficiency) + foreach (var kvp in SpaceCenterManagement.Instance.LCToEfficiency) { if (kvp.Value._efficiency < _MinEfficiency) { @@ -353,7 +353,7 @@ public static void RecalculateConstants() $"Due to improved technology the minimum efficiency for launch complexes is now {_MinEfficiency:P1} and the following complexes had efficiency raised to that level:" + lcsModified, KSP.UI.Screens.MessageSystemButton.MessageButtonColor.GREEN, KSP.UI.Screens.MessageSystemButton.ButtonIcons.ACHIEVE)); } - foreach (var e in KerbalConstructionTimeData.Instance.LCEfficiencies) + foreach (var e in SpaceCenterManagement.Instance.LCEfficiencies) if (e._efficiency < _MinEfficiency) e._efficiency = _MinEfficiency; } @@ -371,14 +371,14 @@ public double PostClosenessStartingEfficiency(double closeness) private void added(int idx, LaunchComplex lc) { - if (KerbalConstructionTimeData.Instance.LCToEfficiency.TryGetValue(lc, out var oldEffic)) + if (SpaceCenterManagement.Instance.LCToEfficiency.TryGetValue(lc, out var oldEffic)) { oldEffic._lcs.Remove(lc); if (oldEffic._lcs.Count == 0 && !_ignoreObserve) ClearEmpty(); } - KerbalConstructionTimeData.Instance.LCToEfficiency[lc] = this; + SpaceCenterManagement.Instance.LCToEfficiency[lc] = this; if (_ignoreObserve) return; @@ -388,7 +388,7 @@ private void added(int idx, LaunchComplex lc) private void removed(int idx, LaunchComplex lc) { - KerbalConstructionTimeData.Instance.LCToEfficiency.Remove(lc); + SpaceCenterManagement.Instance.LCToEfficiency.Remove(lc); if (_ignoreObserve) return; diff --git a/Source/RP0/SpaceCenter/LaunchComplex/LCLaunchPad.cs b/Source/RP0/SpaceCenter/LaunchComplex/LCLaunchPad.cs index 69d47179133..725a3e86c87 100644 --- a/Source/RP0/SpaceCenter/LaunchComplex/LCLaunchPad.cs +++ b/Source/RP0/SpaceCenter/LaunchComplex/LCLaunchPad.cs @@ -67,7 +67,7 @@ public LaunchComplex LC { get { - foreach (LCSpaceCenter currentKSC in KerbalConstructionTimeData.Instance.KSCs) + foreach (LCSpaceCenter currentKSC in SpaceCenterManagement.Instance.KSCs) { if (currentKSC.LaunchComplexes.FirstOrDefault(x => x.LaunchPads.Contains(this)) is LaunchComplex currentLC) { @@ -123,12 +123,12 @@ public LCLaunchPad(Guid id, string name, float lvl) level = (int)lvl; isOperational = false; - KerbalConstructionTimeData.Instance.RegisterLP(this); + SpaceCenterManagement.Instance.RegisterLP(this); } public bool Delete(out string failReason) { - foreach (LCSpaceCenter currentKSC in KerbalConstructionTimeData.Instance.KSCs) + foreach (LCSpaceCenter currentKSC in SpaceCenterManagement.Instance.KSCs) { foreach (LaunchComplex currentLC in currentKSC.LaunchComplexes) { @@ -167,12 +167,12 @@ public bool Delete(out string failReason) currentLC.LaunchPads.RemoveAt(idx); - if (currentLC == KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC) + if (currentLC == SpaceCenterManagement.Instance.ActiveSC.ActiveLC) { currentLC.SwitchLaunchPad(0); } - KerbalConstructionTimeData.Instance.UnregsiterLP(this); + SpaceCenterManagement.Instance.UnregsiterLP(this); } } @@ -215,7 +215,7 @@ public void SetActive() try { - int idx = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LaunchPads.IndexOf(this); + int idx = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LaunchPads.IndexOf(this); RP0Debug.Log($"Switching to LaunchPad: {name} lvl: {level} destroyed? {IsDestroyed}. Index {idx}"); //set the level to this level diff --git a/Source/RP0/SpaceCenter/LaunchComplex/LCSpaceCenter.cs b/Source/RP0/SpaceCenter/LaunchComplex/LCSpaceCenter.cs index ebfe156397d..4ee8d8709cf 100644 --- a/Source/RP0/SpaceCenter/LaunchComplex/LCSpaceCenter.cs +++ b/Source/RP0/SpaceCenter/LaunchComplex/LCSpaceCenter.cs @@ -151,9 +151,9 @@ public void SwitchLaunchComplex(int LC_index, bool updateDestrNode = true) if (HighLogic.LoadedSceneIsEditor) { - if (!KerbalConstructionTimeData.EditorShipEditingMode) - KerbalConstructionTimeData.Instance.EditorVessel.LCID = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ID; - KerbalConstructionTimeData.Instance.StartCoroutine(CallbackUtil.DelayedCallback(0.02f, Harmony.PatchEngineersReport.UpdateCraftStats)); + if (!SpaceCenterManagement.EditorShipEditingMode) + SpaceCenterManagement.Instance.EditorVessel.LCID = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ID; + SpaceCenterManagement.Instance.StartCoroutine(CallbackUtil.DelayedCallback(0.02f, Harmony.PatchEngineersReport.UpdateCraftStats)); } LaunchComplexes[LC_index].SwitchLaunchPad(); diff --git a/Source/RP0/SpaceCenter/LaunchComplex/LaunchComplex.cs b/Source/RP0/SpaceCenter/LaunchComplex/LaunchComplex.cs index ea965273d21..9fcd81a54ed 100644 --- a/Source/RP0/SpaceCenter/LaunchComplex/LaunchComplex.cs +++ b/Source/RP0/SpaceCenter/LaunchComplex/LaunchComplex.cs @@ -161,7 +161,7 @@ public LaunchComplex(LCData lcData, LCSpaceCenter ksc) AddListeners(); - KerbalConstructionTimeData.Instance.RegisterLC(this); + SpaceCenterManagement.Instance.RegisterLC(this); } public void Modify(LCData data, Guid modId) @@ -357,16 +357,16 @@ public LCLaunchPad FindFreeLaunchPad() public void Delete() { if (_efficiencySource == null) - KerbalConstructionTimeData.Instance.LCToEfficiency.TryGetValue(this, out _efficiencySource); + SpaceCenterManagement.Instance.LCToEfficiency.TryGetValue(this, out _efficiencySource); if (_efficiencySource != null) _efficiencySource.RemoveLC(this); else LCEfficiency.ClearEmpty(); foreach (var lp in LaunchPads) - KerbalConstructionTimeData.Instance.UnregsiterLP(lp); + SpaceCenterManagement.Instance.UnregsiterLP(lp); - KerbalConstructionTimeData.Instance.UnregisterLC(this); + SpaceCenterManagement.Instance.UnregisterLC(this); int index = KSC.LaunchComplexes.IndexOf(this); KSC.LaunchComplexes.RemoveAt(index); @@ -383,9 +383,9 @@ public void Load(ConfigNode node) { ConfigNode.LoadObjectFromConfig(this, node); - if (KerbalConstructionTimeData.Instance.LoadedSaveVersion < KerbalConstructionTimeData.VERSION) + if (SpaceCenterManagement.Instance.LoadedSaveVersion < SpaceCenterManagement.VERSION) { - if (KerbalConstructionTimeData.Instance.LoadedSaveVersion < 6) + if (SpaceCenterManagement.Instance.LoadedSaveVersion < 6) { var alNode = node.GetNode("Airlaunch_Prep"); if (alNode != null && alNode.nodes.Count > 0) @@ -424,9 +424,9 @@ public void PostLoad(LCSpaceCenter ksc) foreach (var pc in PadConstructions) added(i++, pc); - KerbalConstructionTimeData.Instance.RegisterLC(this); + SpaceCenterManagement.Instance.RegisterLC(this); foreach(var lp in LaunchPads) - KerbalConstructionTimeData.Instance.RegisterLP(lp); + SpaceCenterManagement.Instance.RegisterLP(lp); if (HighLogic.LoadedSceneIsEditor) { diff --git a/Source/RP0/SpaceCenter/Projects/ConstructionProject.cs b/Source/RP0/SpaceCenter/Projects/ConstructionProject.cs index 8602c141447..7964feecd3e 100644 --- a/Source/RP0/SpaceCenter/Projects/ConstructionProject.cs +++ b/Source/RP0/SpaceCenter/Projects/ConstructionProject.cs @@ -46,7 +46,7 @@ public LCSpaceCenter KSC { if (_ksc == null) { - _ksc = KerbalConstructionTimeData.Instance.KSCs.Find(ksc => ksc.Constructions.Contains(this)); + _ksc = SpaceCenterManagement.Instance.KSCs.Find(ksc => ksc.Constructions.Contains(this)); } return _ksc; } diff --git a/Source/RP0/SpaceCenter/Projects/FacilityUpgradeProject.cs b/Source/RP0/SpaceCenter/Projects/FacilityUpgradeProject.cs index 498e40cda0b..fe11b7792cb 100644 --- a/Source/RP0/SpaceCenter/Projects/FacilityUpgradeProject.cs +++ b/Source/RP0/SpaceCenter/Projects/FacilityUpgradeProject.cs @@ -126,7 +126,7 @@ public bool AlreadyInProgress() public static bool AlreadyInProgressByID(string id) { - return KerbalConstructionTimeData.Instance.KSCs.Find(ksc => ksc.FacilityUpgrades.Find(ub => ub.id == id) != null) != null; + return SpaceCenterManagement.Instance.KSCs.Find(ksc => ksc.FacilityUpgrades.Find(ub => ub.id == id) != null) != null; } protected override void ProcessCancel() @@ -148,7 +148,7 @@ protected override void ProcessCancel() protected override void ProcessComplete() { - if (ScenarioUpgradeableFacilities.Instance != null && !KerbalConstructionTimeData.Instance.ErroredDuringOnLoad) + if (ScenarioUpgradeableFacilities.Instance != null && !SpaceCenterManagement.Instance.ErroredDuringOnLoad) { Apply(); diff --git a/Source/RP0/SpaceCenter/Projects/FundTargetProject.cs b/Source/RP0/SpaceCenter/Projects/FundTargetProject.cs index 40481f9a730..5cdd3c8adb4 100644 --- a/Source/RP0/SpaceCenter/Projects/FundTargetProject.cs +++ b/Source/RP0/SpaceCenter/Projects/FundTargetProject.cs @@ -81,7 +81,7 @@ public double GetTimeLeft() { double time = (timeUpper + timeLower) * 0.5d; // This is the post-CMQ delta. - double fundDelta = KerbalConstructionTimeData.Instance.GetBudgetDelta(time); + double fundDelta = SpaceCenterManagement.Instance.GetBudgetDelta(time); double totalFunds = baseFunds + fundDelta; if (totalFunds >= targetFunds) diff --git a/Source/RP0/SpaceCenter/Projects/LCConstructionProject.cs b/Source/RP0/SpaceCenter/Projects/LCConstructionProject.cs index a4cfff71f83..500b60cfe77 100644 --- a/Source/RP0/SpaceCenter/Projects/LCConstructionProject.cs +++ b/Source/RP0/SpaceCenter/Projects/LCConstructionProject.cs @@ -32,7 +32,7 @@ public override void Load(ConfigNode node) protected override void ProcessComplete() { - if (!KerbalConstructionTimeData.Instance.ErroredDuringOnLoad) + if (!SpaceCenterManagement.Instance.ErroredDuringOnLoad) { LaunchComplex lc = KSC.LaunchComplexes.Find(l => l.ID == lcID); lc.IsOperational = true; diff --git a/Source/RP0/SpaceCenter/Projects/LCOpsProject.cs b/Source/RP0/SpaceCenter/Projects/LCOpsProject.cs index e380074cdb6..239f5214d26 100644 --- a/Source/RP0/SpaceCenter/Projects/LCOpsProject.cs +++ b/Source/RP0/SpaceCenter/Projects/LCOpsProject.cs @@ -29,7 +29,7 @@ public LaunchComplex LC { if (_lc == null) { - foreach (var ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (var ksc in SpaceCenterManagement.Instance.KSCs) { foreach (var lc in ksc.LaunchComplexes) { diff --git a/Source/RP0/SpaceCenter/Projects/PadConstructionProject.cs b/Source/RP0/SpaceCenter/Projects/PadConstructionProject.cs index 3c3e09a2ce6..dfb66266b17 100644 --- a/Source/RP0/SpaceCenter/Projects/PadConstructionProject.cs +++ b/Source/RP0/SpaceCenter/Projects/PadConstructionProject.cs @@ -16,7 +16,7 @@ public LaunchComplex LC { if (_lc == null) { - foreach (var ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (var ksc in SpaceCenterManagement.Instance.KSCs) { foreach (var lc in ksc.LaunchComplexes) { @@ -68,7 +68,7 @@ protected override void ProcessCancel() protected override void ProcessComplete() { - if (ScenarioUpgradeableFacilities.Instance != null && !KerbalConstructionTimeData.Instance.ErroredDuringOnLoad) + if (ScenarioUpgradeableFacilities.Instance != null && !SpaceCenterManagement.Instance.ErroredDuringOnLoad) { LCLaunchPad lp = LC.LaunchPads.Find(p => p.id == id); lp.isOperational = true; diff --git a/Source/RP0/SpaceCenter/Projects/ResearchProject.cs b/Source/RP0/SpaceCenter/Projects/ResearchProject.cs index 2658d5c869d..a126871fba6 100644 --- a/Source/RP0/SpaceCenter/Projects/ResearchProject.cs +++ b/Source/RP0/SpaceCenter/Projects/ResearchProject.cs @@ -100,7 +100,7 @@ public double BuildRate { if (_buildRate < 0) { - UpdateBuildRate(Math.Max(KerbalConstructionTimeData.Instance.TechList.IndexOf(this), 0)); + UpdateBuildRate(Math.Max(SpaceCenterManagement.Instance.TechList.IndexOf(this), 0)); } return _buildRate; } @@ -202,7 +202,7 @@ public void EnableTech() public bool IsInList() { - return KerbalConstructionTimeData.Instance.TechListHas(techID); + return SpaceCenterManagement.Instance.TechListHas(techID); } public string GetItemName() => techName; @@ -283,9 +283,9 @@ public double IncrementProgress(double UTDiff) } go.DestroyGameObject(); - KerbalConstructionTimeData.Instance.TechList.Remove(this); + SpaceCenterManagement.Instance.TechList.Remove(this); - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); // this might change other rates + SpaceCenterManagement.Instance.RecalculateBuildRates(); // this might change other rates double portion = toGo / increment; UnlockCreditHandler.Instance.IncrementCreditTime(techID, portion * UTDiff); @@ -298,7 +298,7 @@ public double IncrementProgress(double UTDiff) public string GetBlockingTech() { - var techList = KerbalConstructionTimeData.Instance.TechList; + var techList = SpaceCenterManagement.Instance.TechList; string blockingTech = null; List parentList; diff --git a/Source/RP0/SpaceCenter/Projects/VesselProject.cs b/Source/RP0/SpaceCenter/Projects/VesselProject.cs index e8a80e2a261..72b98583356 100644 --- a/Source/RP0/SpaceCenter/Projects/VesselProject.cs +++ b/Source/RP0/SpaceCenter/Projects/VesselProject.cs @@ -146,7 +146,7 @@ public Guid LCID if (_lcID == Guid.Empty) _lc = null; else - _lc = KerbalConstructionTimeData.Instance.LC(_lcID); + _lc = SpaceCenterManagement.Instance.LC(_lcID); } } @@ -157,7 +157,7 @@ public LaunchComplex LC { if (_lc == null) { - _lc = KerbalConstructionTimeData.Instance.LC(_lcID); + _lc = SpaceCenterManagement.Instance.LC(_lcID); } return _lc; } @@ -237,13 +237,13 @@ public VesselProject(ShipConstruct s, string ls, string flagURL, bool storeConst { Type = ProjectType.SPH; FacilityBuiltIn = EditorFacility.SPH; - LC = KerbalConstructionTimeData.Instance.ActiveSC.Hangar; + LC = SpaceCenterManagement.Instance.ActiveSC.Hangar; } else { Type = ProjectType.VAB; FacilityBuiltIn = EditorFacility.VAB; - LC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; if (_lc.LCType == LaunchComplexType.Hangar) { RP0Debug.LogError($"ERROR: Tried to link vessel {shipName} to LC {_lc.Name} but vessel is type VAB!"); @@ -548,11 +548,11 @@ public void Launch(bool fillFuel = false) { HighLogic.CurrentGame.editorFacility = GetEditorFacility() == EditorFacilities.VAB ? EditorFacility.VAB : EditorFacility.SPH; - LaunchComplex lc = KerbalConstructionTimeData.Instance.FindLCFromID(_lcID); + LaunchComplex lc = SpaceCenterManagement.Instance.FindLCFromID(_lcID); if (lc == null) - lc = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + lc = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; else - KerbalConstructionTimeData.Instance.ActiveSC.SwitchLaunchComplex(KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.IndexOf(lc)); + SpaceCenterManagement.Instance.ActiveSC.SwitchLaunchComplex(SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.IndexOf(lc)); string tempFile = $"{KSPUtil.ApplicationRootPath}saves/{HighLogic.SaveFolder}/Ships/temp.craft"; UpdateRFTanks(); @@ -571,7 +571,7 @@ public void Launch(bool fillFuel = false) } KCTUtilities.CleanupDebris(launchSiteName); - KerbalConstructionTimeData.Instance.AirlaunchParams.KSPVesselId = Guid.Empty; + SpaceCenterManagement.Instance.AirlaunchParams.KSPVesselId = Guid.Empty; FlightDriver.StartWithNewLaunch(tempFile, flag, launchSiteName, new VesselCrewManifest()); } @@ -609,7 +609,7 @@ public bool MeetsFacilityRequirements(List failedReasons) LaunchComplex selectedLC; if (LC == null) { - selectedLC = Type == ProjectType.VAB ? KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC : KerbalConstructionTimeData.Instance.ActiveSC.Hangar; + selectedLC = Type == ProjectType.VAB ? SpaceCenterManagement.Instance.ActiveSC.ActiveLC : SpaceCenterManagement.Instance.ActiveSC.Hangar; } else { @@ -1434,9 +1434,9 @@ public void LinkToLC(LaunchComplex lc) public override void Load(ConfigNode node) { base.Load(node); - if (KerbalConstructionTimeData.Instance.LoadedSaveVersion < KerbalConstructionTimeData.VERSION) + if (SpaceCenterManagement.Instance.LoadedSaveVersion < SpaceCenterManagement.VERSION) { - if (KerbalConstructionTimeData.Instance.LoadedSaveVersion < 7) + if (SpaceCenterManagement.Instance.LoadedSaveVersion < 7) { double intPoints = 0d; node.TryGetValue("integrationPoints", ref intPoints); diff --git a/Source/RP0/SpaceCenter/SCMEvents.cs b/Source/RP0/SpaceCenter/SCMEvents.cs index 2021415d493..017f507f140 100644 --- a/Source/RP0/SpaceCenter/SCMEvents.cs +++ b/Source/RP0/SpaceCenter/SCMEvents.cs @@ -167,7 +167,7 @@ public void FacilityUpgradedEvent(Upgradeables.UpgradeableFacility facility, int if (KCT_GUI.IsPrimarilyDisabled) return; RP0Debug.Log($"Facility {facility.id} upgraded to lvl {lvl}"); - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); + SpaceCenterManagement.Instance.RecalculateBuildRates(); } public void FaciliyRepaired(DestructibleBuilding facility) @@ -175,8 +175,8 @@ public void FaciliyRepaired(DestructibleBuilding facility) if (facility.id.Contains("LaunchPad")) { RP0Debug.Log("LaunchPad was repaired."); - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ActiveLPInstance.RefreshDestructionNode(); - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ActiveLPInstance.CompletelyRepairNode(); + SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ActiveLPInstance.RefreshDestructionNode(); + SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ActiveLPInstance.CompletelyRepairNode(); } } @@ -185,7 +185,7 @@ public void FacilityDestroyed(DestructibleBuilding facility) if (facility.id.Contains("LaunchPad")) { RP0Debug.Log("LaunchPad was damaged."); - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ActiveLPInstance.RefreshDestructionNode(); + SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ActiveLPInstance.RefreshDestructionNode(); } } @@ -200,22 +200,22 @@ private void OnCurrenciesModified(CurrencyModifierQuery query) private void ShipModifiedEvent(ShipConstruct vessel) { - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } private void StageCountChangedEvent(int num) { - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } private void StagingOrderChangedEvent() { - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } private void PartStageabilityChangedEvent(Part p) { - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } public void GameSceneEvent(GameScenes scene) @@ -225,9 +225,9 @@ public void GameSceneEvent(GameScenes scene) if (scene == GameScenes.MAINMENU) { - KerbalConstructionTimeData.Reset(); + SpaceCenterManagement.Reset(); KCTUtilities.DisableSimulationLocks(); - InputLockManager.RemoveControlLock(KerbalConstructionTimeData.KCTLaunchLock); + InputLockManager.RemoveControlLock(SpaceCenterManagement.KCTLaunchLock); if (PresetManager.Instance != null) { @@ -270,7 +270,7 @@ public void VesselSituationChange(GameEvents.HostedFromToAction { _validationResult = ValidationResult.Fail; }), new DialogGUIButton($"Unlock {partCount} part{(partCount > 1? "s":"")} for {Math.Max(0d, -cmq.GetTotal(CurrencyRP0.Funds, true)):N0} and {mode} (spending {spentCredit:N0} unlock credit)", () => @@ -423,7 +423,7 @@ private bool PurchaseConfig(PartModule pm, string tech) if (ret) { if (HighLogic.LoadedSceneIsEditor) - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } return ret; } diff --git a/Source/RP0/UI/KCT/GUI_Airlaunch.cs b/Source/RP0/UI/KCT/GUI_Airlaunch.cs index 4eff8b822fe..1215697208b 100644 --- a/Source/RP0/UI/KCT/GUI_Airlaunch.cs +++ b/Source/RP0/UI/KCT/GUI_Airlaunch.cs @@ -16,7 +16,7 @@ public static partial class KCT_GUI private static void ResetToMax() { - AirlaunchTechLevel lvl = KerbalConstructionTimeData.Instance.IsSimulatedFlight ? AirlaunchTechLevel.GetHighestLevelIncludingUnderResearch() : + AirlaunchTechLevel lvl = SpaceCenterManagement.Instance.IsSimulatedFlight ? AirlaunchTechLevel.GetHighestLevelIncludingUnderResearch() : AirlaunchTechLevel.GetCurrentLevel(); if (lvl != null) { @@ -42,7 +42,7 @@ public static void DrawAirlaunchWindow(int windowID) { if (_airlaunchParams == null) { - _airlaunchParams = new AirlaunchParams(KerbalConstructionTimeData.Instance.AirlaunchParams); + _airlaunchParams = new AirlaunchParams(SpaceCenterManagement.Instance.AirlaunchParams); if (_airlaunchParams.Altitude == 0) ResetToMax(); @@ -143,8 +143,8 @@ private static void HandleLaunch() { try { - bool isSim = KerbalConstructionTimeData.Instance.IsSimulatedFlight; - _airlaunchParams.KCTVesselId = isSim ? FlightGlobals.ActiveVessel.id : KerbalConstructionTimeData.Instance.LaunchedVessel.shipID; + bool isSim = SpaceCenterManagement.Instance.IsSimulatedFlight; + _airlaunchParams.KCTVesselId = isSim ? FlightGlobals.ActiveVessel.id : SpaceCenterManagement.Instance.LaunchedVessel.shipID; bool valid = _airlaunchParams.Validate(out _errorMsg); if (valid) @@ -152,16 +152,16 @@ private static void HandleLaunch() _errorMsg = null; if (isSim) { - var kct = KerbalConstructionTimeData.Instance; + var kct = SpaceCenterManagement.Instance; kct.StartCoroutine(kct.AirlaunchRoutine(_airlaunchParams, _airlaunchParams.KCTVesselId, skipCountdown: true)); ToggleVisibility(false); return; } - KerbalConstructionTimeData.Instance.AirlaunchParams = _airlaunchParams; + SpaceCenterManagement.Instance.AirlaunchParams = _airlaunchParams; _airlaunchParams = null; - VesselProject b = KerbalConstructionTimeData.Instance.LaunchedVessel; + VesselProject b = SpaceCenterManagement.Instance.LaunchedVessel; if (!b.IsCrewable()) { b.Launch(); @@ -169,7 +169,7 @@ private static void HandleLaunch() else { GUIStates.ShowAirlaunch = false; - KerbalConstructionTimeData.ToolbarControl?.SetFalse(); + SpaceCenterManagement.ToolbarControl?.SetFalse(); _centralWindowPosition.height = 1; AssignInitialCrew(); GUIStates.ShowShipRoster = true; diff --git a/Source/RP0/UI/KCT/GUI_BuildList.cs b/Source/RP0/UI/KCT/GUI_BuildList.cs index 59d1a30fa27..e1333cfeecc 100644 --- a/Source/RP0/UI/KCT/GUI_BuildList.cs +++ b/Source/RP0/UI/KCT/GUI_BuildList.cs @@ -199,7 +199,7 @@ public static void DrawBuildListWindow(int windowID) GUILayout.Label(locTxt, _windowSkin.label); GUILayout.Label(DTUtils.GetColonFormattedTimeWithTooltip(buildItem.GetTimeLeft(), txt+locTxt+buildItem.GetItemName())); - if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button(new GUIContent($"Warp to{Environment.NewLine}Complete", $"√ Gain/Loss:\n{KerbalConstructionTimeData.Instance.GetBudgetDelta(buildItem.GetTimeLeft()):N0}"))) + if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button(new GUIContent($"Warp to{Environment.NewLine}Complete", $"√ Gain/Loss:\n{SpaceCenterManagement.Instance.GetBudgetDelta(buildItem.GetTimeLeft()):N0}"))) { KCTWarpController.Create(null); // warp to next item } @@ -212,11 +212,11 @@ public static void DrawBuildListWindow(int windowID) if (KCTSettings.Instance.AutoKACAlarms && KACWrapper.APIReady && buildItem.GetTimeLeft() > 30) //don't check if less than 30 seconds to completion. Might fix errors people are seeing { double UT = Planetarium.GetUniversalTime(); - if (!KCTUtilities.IsApproximatelyEqual(KerbalConstructionTimeData.Instance.KACAlarmUT - UT, buildItem.GetTimeLeft())) + if (!KCTUtilities.IsApproximatelyEqual(SpaceCenterManagement.Instance.KACAlarmUT - UT, buildItem.GetTimeLeft())) { RP0Debug.Log("KAC Alarm being created!"); - KerbalConstructionTimeData.Instance.KACAlarmUT = buildItem.GetTimeLeft() + UT; - KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == KerbalConstructionTimeData.Instance.KACAlarmId); + SpaceCenterManagement.Instance.KACAlarmUT = buildItem.GetTimeLeft() + UT; + KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == SpaceCenterManagement.Instance.KACAlarmId); if (alarm == null) { alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.Name.StartsWith("RP-1: ")); @@ -251,8 +251,8 @@ public static void DrawBuildListWindow(int windowID) } else txt += $"{buildItem.GetItemName()} Complete"; - KerbalConstructionTimeData.Instance.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, txt, KerbalConstructionTimeData.Instance.KACAlarmUT); - RP0Debug.Log($"Alarm created with ID: {KerbalConstructionTimeData.Instance.KACAlarmId}"); + SpaceCenterManagement.Instance.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, txt, SpaceCenterManagement.Instance.KACAlarmUT); + RP0Debug.Log($"Alarm created with ID: {SpaceCenterManagement.Instance.KACAlarmId}"); } } } @@ -294,8 +294,8 @@ public static void DrawBuildListWindow(int windowID) //} bool hasIdleEngineers = false; // This reimplements FreeEngineers for speed, since we also have to check LCs for idle - int engCount = KerbalConstructionTimeData.Instance.ActiveSC.Engineers; - foreach (var lc in KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes) + int engCount = SpaceCenterManagement.Instance.ActiveSC.Engineers; + foreach (var lc in SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes) { if (!lc.IsOperational || lc.Engineers == 0) continue; @@ -311,13 +311,13 @@ public static void DrawBuildListWindow(int windowID) if (!hasIdleEngineers && engCount > 0) hasIdleEngineers = true; - if (GUILayout.Button(new GUIContent("Staff", hasIdleEngineers ? "Some engineers are idle!" : (KerbalConstructionTimeData.Instance.Applicants > 0 ? "Applicants can be hired for free!" : "Hire/fire/reassign staff")), - hasIdleEngineers ? _yellowButton : (KerbalConstructionTimeData.Instance.Applicants > 0 ? _greenButton : GUI.skin.button))) + if (GUILayout.Button(new GUIContent("Staff", hasIdleEngineers ? "Some engineers are idle!" : (SpaceCenterManagement.Instance.Applicants > 0 ? "Applicants can be hired for free!" : "Hire/fire/reassign staff")), + hasIdleEngineers ? _yellowButton : (SpaceCenterManagement.Instance.Applicants > 0 ? _greenButton : GUI.skin.button))) { GUIStates.ShowPersonnelWindow = true; //GUIStates.ShowBuildList = false; //GUIStates.ShowBLPlus = false; - _LCIndex = KerbalConstructionTimeData.Instance.ActiveSC.LCIndex; + _LCIndex = SpaceCenterManagement.Instance.ActiveSC.LCIndex; _currentPersonnelHover = PersonnelButtonHover.None; } if (GUILayout.Button("Plans")) @@ -363,7 +363,7 @@ public static void DrawBuildListWindow(int windowID) private static void RenderConstructionList() { - LCSpaceCenter ksc = KerbalConstructionTimeData.Instance.ActiveSC; + LCSpaceCenter ksc = SpaceCenterManagement.Instance.ActiveSC; GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); @@ -412,7 +412,7 @@ private static void RenderConstructionList() if (!HighLogic.LoadedSceneIsEditor && buildRate > 0d) { - if (GUILayout.Button(new GUIContent("Warp", $"√ Gain/Loss:\n{KerbalConstructionTimeData.Instance.GetBudgetDelta(constr.GetTimeLeft()):N0}"), GUILayout.Width(45))) + if (GUILayout.Button(new GUIContent("Warp", $"√ Gain/Loss:\n{SpaceCenterManagement.Instance.GetBudgetDelta(constr.GetTimeLeft()):N0}"), GUILayout.Width(45))) { KCTWarpController.Create(constr); } @@ -462,7 +462,7 @@ private static void RenderTechList() { _accumulatedTimeBefore = 0d; - PersistentObservableList techList = KerbalConstructionTimeData.Instance.TechList; + PersistentObservableList techList = SpaceCenterManagement.Instance.TechList; GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(_width1 / 2)); @@ -561,7 +561,7 @@ private static void RenderTechList() if (forceRecheck) { forceRecheck = false; - KerbalConstructionTimeData.Instance.UpdateTechTimes(); + SpaceCenterManagement.Instance.UpdateTechTimes(); } string blockingPrereq = t.GetBlockingTech(); @@ -616,7 +616,7 @@ private static int CompareBuildItems(ISpaceCenterProject a, ISpaceCenterProject private static void RenderCombinedList() { double accTime; - foreach (var k in KerbalConstructionTimeData.Instance.KSCs) + foreach (var k in SpaceCenterManagement.Instance.KSCs) { foreach (var l in k.LaunchComplexes) { @@ -639,7 +639,7 @@ private static void RenderCombinedList() } } accTime = 0d; - foreach (var t in KerbalConstructionTimeData.Instance.TechList) + foreach (var t in SpaceCenterManagement.Instance.TechList) { _timeBeforeItem[t] = accTime; accTime += t.GetTimeLeftEst(accTime); @@ -647,8 +647,8 @@ private static void RenderCombinedList() } _allItems.AddRange(Crew.CrewHandler.Instance.TrainingCourses); - if (KerbalConstructionTimeData.Instance.fundTarget.IsValid) - _allItems.Add(KerbalConstructionTimeData.Instance.fundTarget); + if (SpaceCenterManagement.Instance.fundTarget.IsValid) + _allItems.Add(SpaceCenterManagement.Instance.fundTarget); // Precalc times and then sort foreach (var b in _allItems) @@ -740,7 +740,7 @@ private static void RenderCombinedList() _scrollPos2 = GUILayout.BeginScrollView(_scrollPos2, GUILayout.Height(GUI.skin.label.lineHeight * 5)); int idx = 0; - foreach (var lc in KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes) + foreach (var lc in SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes) { foreach (var b in lc.Warehouse) RenderWarehouseRow(b, idx++, true); @@ -833,7 +833,7 @@ private static void DrawTypeIcon(ISpaceCenterProject b) private static void RenderBuildList() { - LaunchComplex activeLC = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LC : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LC : SpaceCenterManagement.Instance.ActiveSC.ActiveLC; RenderBuildlistHeader(); @@ -861,12 +861,12 @@ private static void RenderBuildlistHeader() private static void RenderRollouts() { - LaunchComplex activeLC = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LC : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LC : SpaceCenterManagement.Instance.ActiveSC.ActiveLC; foreach (ReconRolloutProject reconditioning in activeLC.Recon_Rollout.FindAll(r => r.RRType == ReconRolloutProject.RolloutReconType.Reconditioning)) { GUILayout.BeginHorizontal(); double tLeft = reconditioning.GetTimeLeft(); - if (!HighLogic.LoadedSceneIsEditor && reconditioning.GetBuildRate() > 0 && GUILayout.Button(new GUIContent("Warp To", $"√ Gain/Loss:\n{KerbalConstructionTimeData.Instance.GetBudgetDelta(tLeft):N0}"), GUILayout.Width((_butW + 4) * 3))) + if (!HighLogic.LoadedSceneIsEditor && reconditioning.GetBuildRate() > 0 && GUILayout.Button(new GUIContent("Warp To", $"√ Gain/Loss:\n{SpaceCenterManagement.Instance.GetBudgetDelta(tLeft):N0}"), GUILayout.Width((_butW + 4) * 3))) { KCTWarpController.Create(reconditioning); } @@ -888,7 +888,7 @@ private static void RenderVesselsBeingBuilt(LaunchComplex lc) if (HighLogic.LoadedSceneIsEditor) GUILayout.Label("No vessels integrating!"); else - GUILayout.Label($"No vessels integrating! Go to the {(KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad ? "VAB" : "SPH")} to add more."); + GUILayout.Label($"No vessels integrating! Go to the {(SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad ? "VAB" : "SPH")} to add more."); } bool recalc = false; for (int i = 0; i < lc.BuildList.Count; i++) @@ -973,7 +973,7 @@ private static void RenderVesselsBeingBuilt(LaunchComplex lc) private static void RenderWarehouse() { - LaunchComplex activeLC = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LC : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LC : SpaceCenterManagement.Instance.ActiveSC.ActiveLC; bool isPad = activeLC.LCType == LaunchComplexType.Pad; GUILayout.Label("__________________________________________________"); GUILayout.BeginHorizontal(); @@ -1008,7 +1008,7 @@ private static void RenderWarehouseRow(VesselProject b, int listIdx, bool isComb LaunchComplex vesselLC = b.LC; - bool isPad = vesselLC != KerbalConstructionTimeData.Instance.ActiveSC.Hangar; + bool isPad = vesselLC != SpaceCenterManagement.Instance.ActiveSC.Hangar; string launchSite = b.launchSite; if (launchSite == "LaunchPad" && isPad) @@ -1257,7 +1257,7 @@ private static void RenderWarehouseRow(VesselProject b, int listIdx, bool isComb } else { - KerbalConstructionTimeData.Instance.LaunchedVessel = b; + SpaceCenterManagement.Instance.LaunchedVessel = b; if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, pad.launchSiteName).Count == 0) { GUIStates.ShowBLPlus = false; @@ -1267,7 +1267,7 @@ private static void RenderWarehouseRow(VesselProject b, int listIdx, bool isComb { GUIStates.ShowBuildList = false; - KerbalConstructionTimeData.ToolbarControl?.SetFalse(); + SpaceCenterManagement.ToolbarControl?.SetFalse(); _centralWindowPosition.height = 1; AssignInitialCrew(); @@ -1341,7 +1341,7 @@ private static void RenderWarehouseRow(VesselProject b, int listIdx, bool isComb else { GUIStates.ShowBLPlus = false; - KerbalConstructionTimeData.Instance.LaunchedVessel = b; + SpaceCenterManagement.Instance.LaunchedVessel = b; if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "Runway").Count == 0) { @@ -1357,7 +1357,7 @@ private static void RenderWarehouseRow(VesselProject b, int listIdx, bool isComb else { GUIStates.ShowBuildList = false; - KerbalConstructionTimeData.ToolbarControl?.SetFalse(); + SpaceCenterManagement.ToolbarControl?.SetFalse(); _centralWindowPosition.height = 1; AssignInitialCrew(); GUIStates.ShowShipRoster = true; @@ -1384,14 +1384,14 @@ private static void RenderWarehouseRow(VesselProject b, int listIdx, bool isComb private static void RenderLaunchComplexControls() { - LaunchComplex activeLC = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LC : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LC : SpaceCenterManagement.Instance.ActiveSC.ActiveLC; GUILayout.BeginHorizontal(); // Don't allow switching in edit mode - int lcCount = KerbalConstructionTimeData.EditorShipEditingMode ? 1 : KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexCount; + int lcCount = SpaceCenterManagement.EditorShipEditingMode ? 1 : SpaceCenterManagement.Instance.ActiveSC.LaunchComplexCount; if (lcCount > 1 && GUILayout.Button("<<", GUILayout.ExpandWidth(false))) { - KerbalConstructionTimeData.Instance.ActiveSC.SwitchToPrevLaunchComplex(); + SpaceCenterManagement.Instance.ActiveSC.SwitchToPrevLaunchComplex(); } GUILayout.FlexibleSpace(); string lcText = $"{activeLC.Name} ({activeLC.SupportedMassAsPrettyText})"; @@ -1441,14 +1441,14 @@ private static void RenderLaunchComplexControls() GUILayout.FlexibleSpace(); if (lcCount > 1 && GUILayout.Button(">>", GUILayout.ExpandWidth(false))) { - KerbalConstructionTimeData.Instance.ActiveSC.SwitchToNextLaunchComplex(); + SpaceCenterManagement.Instance.ActiveSC.SwitchToNextLaunchComplex(); } GUILayout.EndHorizontal(); } private static void RenderLaunchPadControls() { - LaunchComplex activeLC = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LC : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LC : SpaceCenterManagement.Instance.ActiveSC.ActiveLC; GUILayout.BeginHorizontal(); bool oldRushing = activeLC.IsRushing; @@ -1544,48 +1544,48 @@ public static void CancelTechNode(int index, bool initialCancel = true) { if (initialCancel) { - KerbalConstructionTimeData.TechListIgnoreUpdates = true; + SpaceCenterManagement.TechListIgnoreUpdates = true; KCTUtilities.RemoveResearchedPartsFromExperimental(); } - if (KerbalConstructionTimeData.Instance.TechList.Count > index) + if (SpaceCenterManagement.Instance.TechList.Count > index) { - ResearchProject node = KerbalConstructionTimeData.Instance.TechList[index]; + ResearchProject node = SpaceCenterManagement.Instance.TechList[index]; RP0Debug.Log($"Cancelling tech: {node.techName}"); // cancel children - for (int i = 0; i < KerbalConstructionTimeData.Instance.TechList.Count; i++) + for (int i = 0; i < SpaceCenterManagement.Instance.TechList.Count; i++) { - List parentList = Database.TechNameToParents[KerbalConstructionTimeData.Instance.TechList[i].techID]; + List parentList = Database.TechNameToParents[SpaceCenterManagement.Instance.TechList[i].techID]; if (parentList.Contains(node.techID)) { CancelTechNode(i, false); // recheck list in case multiple levels of children were deleted. i = -1; - index = KerbalConstructionTimeData.Instance.TechList.FindIndex(t => t.techID == node.techID); + index = SpaceCenterManagement.Instance.TechList.FindIndex(t => t.techID == node.techID); } } if (KSPUtils.CurrentGameHasScience()) { - bool valBef = KerbalConstructionTimeData.IsRefundingScience; - KerbalConstructionTimeData.IsRefundingScience = true; + bool valBef = SpaceCenterManagement.IsRefundingScience; + SpaceCenterManagement.IsRefundingScience = true; try { ResearchAndDevelopment.Instance.AddScience(node.scienceCost, TransactionReasons.RnDTechResearch); } finally { - KerbalConstructionTimeData.IsRefundingScience = valBef; + SpaceCenterManagement.IsRefundingScience = valBef; } } - KerbalConstructionTimeData.Instance.TechList.RemoveAt(index); + SpaceCenterManagement.Instance.TechList.RemoveAt(index); Crew.CrewHandler.Instance?.OnTechCanceled(node.techID); if (initialCancel) // do this only once { - KerbalConstructionTimeData.Instance.TechListUpdated(); - KerbalConstructionTimeData.TechListIgnoreUpdates = false; + SpaceCenterManagement.Instance.TechListUpdated(); + SpaceCenterManagement.TechListIgnoreUpdates = false; KCTUtilities.AddResearchedPartsToExperimental(); } } @@ -1593,9 +1593,9 @@ public static void CancelTechNode(int index, bool initialCancel = true) public static void CancelConstruction(int index) { - if (KerbalConstructionTimeData.Instance.ActiveSC.Constructions.Count > index) + if (SpaceCenterManagement.Instance.ActiveSC.Constructions.Count > index) { - ConstructionProject item = KerbalConstructionTimeData.Instance.ActiveSC.Constructions[index]; + ConstructionProject item = SpaceCenterManagement.Instance.ActiveSC.Constructions[index]; RP0Debug.Log($"Cancelling construction: {item.GetItemName()}"); item.Cancel(); } @@ -1606,7 +1606,7 @@ private static void DrawBLPlusWindow(int windowID) Rect parentPos = HighLogic.LoadedSceneIsEditor ? EditorBuildListWindowPosition : BuildListWindowPosition; _blPlusPosition.yMin = parentPos.yMin; _blPlusPosition.height = 225; - VesselProject b = KCTUtilities.FindVPByID(KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC, _selectedVesselId); + VesselProject b = KCTUtilities.FindVPByID(SpaceCenterManagement.Instance.ActiveSC.ActiveLC, _selectedVesselId); GUILayout.BeginVertical(); string launchSite = b.launchSite; @@ -1659,10 +1659,10 @@ private static void DrawBLPlusWindow(int windowID) EditorWindowPosition.height = 1; string tempFile = $"{KSPUtil.ApplicationRootPath}saves/{HighLogic.SaveFolder}/Ships/temp.craft"; b.UpdateNodeAndSave(tempFile); - KerbalConstructionTimeData.Instance.EditedVessel = b; + SpaceCenterManagement.Instance.EditedVessel = b; GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); - KerbalConstructionTimeData.EditorShipEditingMode = true; - KerbalConstructionTimeData.Instance.MergingAvailable = b.IsFinished; + SpaceCenterManagement.EditorShipEditingMode = true; + SpaceCenterManagement.Instance.MergingAvailable = b.IsFinished; InputLockManager.SetControlLock(ControlTypes.EDITOR_EXIT, "KCTEditExit"); InputLockManager.SetControlLock(ControlTypes.EDITOR_NEW, "KCTEditNew"); @@ -1703,7 +1703,7 @@ private static void DrawBLPlusWindow(int windowID) GUIStates.ShowBLPlus = false; } - if (!b.IsFinished && b.BuildRate > 0 && GUILayout.Button(new GUIContent("Warp To", $"√ Gain/Loss:\n{KerbalConstructionTimeData.Instance.GetBudgetDelta(b.GetTimeLeft()):N0}"))) + if (!b.IsFinished && b.BuildRate > 0 && GUILayout.Button(new GUIContent("Warp To", $"√ Gain/Loss:\n{SpaceCenterManagement.Instance.GetBudgetDelta(b.GetTimeLeft()):N0}"))) { KCTWarpController.Create(b); GUIStates.ShowBLPlus = false; @@ -1736,7 +1736,7 @@ private static void DrawBLPlusWindow(int windowID) public static void DrawLaunchSiteChooser(int windowID) { - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; GUILayout.BeginVertical(); _launchSiteScrollView = GUILayout.BeginScrollView(_launchSiteScrollView, GUILayout.Height((float)Math.Min(Screen.height * 0.75, 25 * _launchSites.Count + 10))); diff --git a/Source/RP0/UI/KCT/GUI_BuildPlans.cs b/Source/RP0/UI/KCT/GUI_BuildPlans.cs index b2f0db72007..5bfeb49845f 100644 --- a/Source/RP0/UI/KCT/GUI_BuildPlans.cs +++ b/Source/RP0/UI/KCT/GUI_BuildPlans.cs @@ -78,13 +78,13 @@ private static void DrawBuildPlansWindow(int id) GUILayout.EndHorizontal(); _buildPlansScrollPos = GUILayout.BeginScrollView(_buildPlansScrollPos, GUILayout.Height(250)); - if (KerbalConstructionTimeData.Instance.BuildPlans.Count == 0) + if (SpaceCenterManagement.Instance.BuildPlans.Count == 0) { GUILayout.Label("No vessels in plans."); } - for (int i = 0; i < KerbalConstructionTimeData.Instance.BuildPlans.Count; i++) + for (int i = 0; i < SpaceCenterManagement.Instance.BuildPlans.Count; i++) { - VesselProject b = KerbalConstructionTimeData.Instance.BuildPlans.Values[i]; + VesselProject b = SpaceCenterManagement.Instance.BuildPlans.Values[i]; if (!b.AllPartsValid) continue; GUILayout.BeginHorizontal(); @@ -112,7 +112,7 @@ private static void DrawBuildPlansWindow(int id) } else { - KCTUtilities.TryAddVesselToBuildList(b.CreateCopy(), skipPartChecks: true, KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC); + KCTUtilities.TryAddVesselToBuildList(b.CreateCopy(), skipPartChecks: true, SpaceCenterManagement.Instance.ActiveSC.ActiveLC); } } } @@ -161,15 +161,15 @@ public static void AddVesselToPlansList(string launchSite) public static void AddVesselToPlansList(VesselProject vp) { ScreenMessage message; - if (KerbalConstructionTimeData.Instance.BuildPlans.ContainsKey(vp.shipName)) + if (SpaceCenterManagement.Instance.BuildPlans.ContainsKey(vp.shipName)) { - KerbalConstructionTimeData.Instance.BuildPlans.Remove(vp.shipName); + SpaceCenterManagement.Instance.BuildPlans.Remove(vp.shipName); message = new ScreenMessage($"Replacing previous plan for {vp.shipName} in the Plans list.", 4f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(message); } - KerbalConstructionTimeData.Instance.BuildPlans.Add(vp.shipName, vp); + SpaceCenterManagement.Instance.BuildPlans.Add(vp.shipName, vp); - RP0Debug.Log($"Added {vp.shipName} to plans list at KSC {KerbalConstructionTimeData.Instance.ActiveSC.KSCName}. Cost: {vp.cost}"); + RP0Debug.Log($"Added {vp.shipName} to plans list at KSC {SpaceCenterManagement.Instance.ActiveSC.KSCName}. Cost: {vp.cost}"); RP0Debug.Log($"Launch site is {vp.launchSite}"); string text = $"Added {vp.shipName} to plans list."; message = new ScreenMessage(text, 4f, ScreenMessageStyle.UPPER_CENTER); @@ -178,7 +178,7 @@ public static void AddVesselToPlansList(VesselProject vp) private static void RemoveVesselFromPlans() { - KerbalConstructionTimeData.Instance.BuildPlans.RemoveAt(_planToDelete); + SpaceCenterManagement.Instance.BuildPlans.RemoveAt(_planToDelete); } } } diff --git a/Source/RP0/UI/KCT/GUI_ClearLaunch.cs b/Source/RP0/UI/KCT/GUI_ClearLaunch.cs index 01cb8b906c0..7328d255e1b 100644 --- a/Source/RP0/UI/KCT/GUI_ClearLaunch.cs +++ b/Source/RP0/UI/KCT/GUI_ClearLaunch.cs @@ -12,7 +12,7 @@ public static void DrawClearLaunch(int windowID) { GUIStates.ShowClearLaunch = false; - List list = ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, KerbalConstructionTimeData.Instance.LaunchedVessel.launchSite); + List list = ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, SpaceCenterManagement.Instance.LaunchedVessel.launchSite); foreach (ProtoVessel pv in list) ShipConstruction.RecoverVesselFromFlight(pv, HighLogic.CurrentGame.flightState); @@ -22,9 +22,9 @@ public static void DrawClearLaunch(int windowID) } else { - if (!KerbalConstructionTimeData.Instance.LaunchedVessel.IsCrewable()) + if (!SpaceCenterManagement.Instance.LaunchedVessel.IsCrewable()) { - KerbalConstructionTimeData.Instance.LaunchedVessel.Launch(); + SpaceCenterManagement.Instance.LaunchedVessel.Launch(); } else { @@ -37,7 +37,7 @@ public static void DrawClearLaunch(int windowID) if (GUILayout.Button("Cancel")) { - KerbalConstructionTimeData.Instance.LaunchedVessel = new VesselProject(); + SpaceCenterManagement.Instance.LaunchedVessel = new VesselProject(); GUIStates.ShowClearLaunch = false; GUIStates.ShowAirlaunch = false; GUIStates.ShowBuildList = true; diff --git a/Source/RP0/UI/KCT/GUI_CrewSelect.cs b/Source/RP0/UI/KCT/GUI_CrewSelect.cs index a63d8186f2d..5160d76074f 100644 --- a/Source/RP0/UI/KCT/GUI_CrewSelect.cs +++ b/Source/RP0/UI/KCT/GUI_CrewSelect.cs @@ -38,7 +38,7 @@ internal enum SortBy { Name, Type, Level }; public static void DrawShipRoster(int windowID) { // This window can stay alive during scene transition - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; GUILayout.BeginVertical(GUILayout.ExpandHeight(true), GUILayout.MaxHeight(Screen.height / 2)); @@ -85,11 +85,11 @@ public static void DrawShipRoster(int windowID) Part p = _parts[j]; if (p.CrewCapacity == 0) continue; - List launchedCrew = KerbalConstructionTimeData.Instance.LaunchedCrew[j]?.CrewList; + List launchedCrew = SpaceCenterManagement.Instance.LaunchedCrew[j]?.CrewList; if (launchedCrew == null) { launchedCrew = new List(); - KerbalConstructionTimeData.Instance.LaunchedCrew.Add(new PartCrewAssignment(p.craftID, launchedCrew)); + SpaceCenterManagement.Instance.LaunchedCrew.Add(new PartCrewAssignment(p.craftID, launchedCrew)); } @@ -207,7 +207,7 @@ public static void DrawShipRoster(int windowID) { CheckTanksAndLaunch(false); } - if (KerbalConstructionTimeData.Instance.LaunchedVessel.IsValid && !KerbalConstructionTimeData.Instance.LaunchedVessel.AreTanksFull()) + if (SpaceCenterManagement.Instance.LaunchedVessel.IsValid && !SpaceCenterManagement.Instance.LaunchedVessel.AreTanksFull()) { if (GUILayout.Button("Fill Tanks & Launch")) { @@ -219,8 +219,8 @@ public static void DrawShipRoster(int windowID) { GUIStates.ShowShipRoster = false; GUIStates.ShowBuildList = true; - KerbalConstructionTimeData.Instance.LaunchedVessel = new VesselProject(); - KerbalConstructionTimeData.Instance.LaunchedCrew.Clear(); + SpaceCenterManagement.Instance.LaunchedVessel = new VesselProject(); + SpaceCenterManagement.Instance.LaunchedCrew.Clear(); _crewListWindowPosition.height = 1; _availableCrew = null; _possibleCrewForParts.Clear(); @@ -235,7 +235,7 @@ public static void DrawShipRoster(int windowID) private static void RemoveAllCrewFromPods() { - foreach (PartCrewAssignment cp in KerbalConstructionTimeData.Instance.LaunchedCrew) + foreach (PartCrewAssignment cp in SpaceCenterManagement.Instance.LaunchedCrew) { cp.CrewList.Clear(); } @@ -264,7 +264,7 @@ private static bool FillAllPodsWithCrew() for (int i = 0; i < p.CrewCapacity; i++) { - if (KerbalConstructionTimeData.Instance.LaunchedCrew[j].CrewList.Count <= i) + if (SpaceCenterManagement.Instance.LaunchedCrew[j].CrewList.Count <= i) { if (_possibleCrewForPart.Count > 0) { @@ -273,14 +273,14 @@ private static bool FillAllPodsWithCrew() ProtoCrewMember crewMember = _possibleCrewForPart[index]; if (crewMember != null) { - KerbalConstructionTimeData.Instance.LaunchedCrew[j].CrewList.Add(new CrewMemberAssignment(crewMember)); + SpaceCenterManagement.Instance.LaunchedCrew[j].CrewList.Add(new CrewMemberAssignment(crewMember)); _possibleCrewForPart.RemoveAt(index); _availableCrew.Remove(crewMember); _possibleCrewForParts.Remove(crewMember); } } } - else if (KerbalConstructionTimeData.Instance.LaunchedCrew[j].CrewList[i].PCM == null) + else if (SpaceCenterManagement.Instance.LaunchedCrew[j].CrewList[i].PCM == null) { if (_possibleCrewForPart.Count > 0) { @@ -289,7 +289,7 @@ private static bool FillAllPodsWithCrew() ProtoCrewMember crewMember = _possibleCrewForPart[index]; if (crewMember != null) { - KerbalConstructionTimeData.Instance.LaunchedCrew[j].CrewList[i] = new CrewMemberAssignment(crewMember); + SpaceCenterManagement.Instance.LaunchedCrew[j].CrewList[i] = new CrewMemberAssignment(crewMember); _possibleCrewForPart.RemoveAt(index); _availableCrew.Remove(crewMember); _possibleCrewForParts.Remove(crewMember); @@ -413,7 +413,7 @@ public static void DrawCrewSelect(int windowID) if (clickedNautButton) { - List activeCrew = KerbalConstructionTimeData.Instance.LaunchedCrew[_partIndexToCrew].CrewList; + List activeCrew = SpaceCenterManagement.Instance.LaunchedCrew[_partIndexToCrew].CrewList; if (activeCrew.Count > _indexToCrew) { activeCrew.Insert(_indexToCrew, new CrewMemberAssignment(crew)); @@ -429,7 +429,7 @@ public static void DrawCrewSelect(int windowID) activeCrew.Insert(_indexToCrew, new CrewMemberAssignment(crew)); } _rosterForCrewSelect.Remove(crew); - KerbalConstructionTimeData.Instance.LaunchedCrew[_partIndexToCrew].CrewList = activeCrew; + SpaceCenterManagement.Instance.LaunchedCrew[_partIndexToCrew].CrewList = activeCrew; GUIStates.ShowCrewSelect = false; GUIStates.ShowShipRoster = true; _crewListWindowPosition.height = 1; @@ -551,15 +551,15 @@ private static int GetFirstCrewableIndex(List ship) public static void AssignInitialCrew() { RefreshInventoryAvailability(); - KerbalConstructionTimeData.Instance.LaunchedCrew.Clear(); - _pseudoParts = KerbalConstructionTimeData.Instance.LaunchedVessel.GetPseudoParts(); + SpaceCenterManagement.Instance.LaunchedCrew.Clear(); + _pseudoParts = SpaceCenterManagement.Instance.LaunchedVessel.GetPseudoParts(); _parts.Clear(); foreach (PseudoPart pp in _pseudoParts) { Part p = KCTUtilities.GetAvailablePartByName(pp.Name).partPrefab; p.craftID = pp.Uid; _parts.Add(p); - KerbalConstructionTimeData.Instance.LaunchedCrew.Add(new PartCrewAssignment(pp.Uid, new List())); + SpaceCenterManagement.Instance.LaunchedCrew.Add(new PartCrewAssignment(pp.Uid, new List())); } //get all available crew from the roster and then fill all crewable parts with 'nauts that finished proficiency and mission training @@ -569,7 +569,7 @@ public static void AssignInitialCrew() // then obviously we had crew trained. if (!anyFound) { - KerbalConstructionTimeData.Instance.StartCoroutine(CallbackUtil.DelayedCallback(0.001f, ShowUntrainedTip)); + SpaceCenterManagement.Instance.StartCoroutine(CallbackUtil.DelayedCallback(0.001f, ShowUntrainedTip)); } } @@ -603,7 +603,7 @@ private static List GetAvailableCrew() bool available = true; if (crewMember.rosterStatus == ProtoCrewMember.RosterStatus.Available && !crewMember.inactive) { - foreach (PartCrewAssignment cP in KerbalConstructionTimeData.Instance.LaunchedCrew) + foreach (PartCrewAssignment cP in SpaceCenterManagement.Instance.LaunchedCrew) { if (cP.CrewList.Any(c => c?.PCM == crewMember)) { @@ -623,7 +623,7 @@ private static List GetAvailableCrew() bool available = true; if (crewMember.rosterStatus == ProtoCrewMember.RosterStatus.Available && !crewMember.inactive) { - foreach (PartCrewAssignment cP in KerbalConstructionTimeData.Instance.LaunchedCrew) + foreach (PartCrewAssignment cP in SpaceCenterManagement.Instance.LaunchedCrew) { if (cP.CrewList.Any(c => c?.PCM == crewMember)) { @@ -643,7 +643,7 @@ private static List GetAvailableCrew() private static void CheckTanksAndLaunch(bool fillTanks) { - foreach (PartCrewAssignment crewedPart in KerbalConstructionTimeData.Instance.LaunchedCrew) + foreach (PartCrewAssignment crewedPart in SpaceCenterManagement.Instance.LaunchedCrew) { foreach (CrewMemberAssignment assign in crewedPart.CrewList) { @@ -662,7 +662,7 @@ private static void CheckTanksAndLaunch(bool fillTanks) } KCTSettings.Instance.RandomizeCrew = AssignRandomCrew; - KerbalConstructionTimeData.Instance.LaunchedVessel.Launch(fillTanks); + SpaceCenterManagement.Instance.LaunchedVessel.Launch(fillTanks); GUIStates.ShowShipRoster = false; _crewListWindowPosition.height = 1; diff --git a/Source/RP0/UI/KCT/GUI_DevPartsButton.cs b/Source/RP0/UI/KCT/GUI_DevPartsButton.cs index 1d15420da39..63593c0f174 100644 --- a/Source/RP0/UI/KCT/GUI_DevPartsButton.cs +++ b/Source/RP0/UI/KCT/GUI_DevPartsButton.cs @@ -24,7 +24,7 @@ public override void Init() protected override void OnClick() { - KerbalConstructionTimeData.Instance.ExperimentalPartsEnabled = IsOn; + SpaceCenterManagement.Instance.ExperimentalPartsEnabled = IsOn; if (IsOn) { diff --git a/Source/RP0/UI/KCT/GUI_DismantlePad.cs b/Source/RP0/UI/KCT/GUI_DismantlePad.cs index a6b72ee079c..9c2b24cecbe 100644 --- a/Source/RP0/UI/KCT/GUI_DismantlePad.cs +++ b/Source/RP0/UI/KCT/GUI_DismantlePad.cs @@ -7,7 +7,7 @@ public static partial class KCT_GUI { public static void DrawDismantlePadWindow(int windowID) { - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; bool isLC = GUIStates.ShowDismantleLC; GUILayout.BeginVertical(); GUILayout.Label("Are you sure you want to dismantle the currently selected " + @@ -38,7 +38,7 @@ public static void DrawDismantlePadWindow(int windowID) private static void TryDismantleLCorPad(bool isLC) { - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; if (isLC) { if (activeLC.LCType == LaunchComplexType.Hangar) diff --git a/Source/RP0/UI/KCT/GUI_Editor.cs b/Source/RP0/UI/KCT/GUI_Editor.cs index 0c4e3627b53..cad55bc3e1c 100644 --- a/Source/RP0/UI/KCT/GUI_Editor.cs +++ b/Source/RP0/UI/KCT/GUI_Editor.cs @@ -32,7 +32,7 @@ public static void DrawEditorGUI(int windowID) EditorWindowPosition.height = 1; } GUILayout.BeginVertical(); - if (!KerbalConstructionTimeData.EditorShipEditingMode) + if (!SpaceCenterManagement.EditorShipEditingMode) { RenderBuildMode(); } @@ -51,19 +51,19 @@ public static void DrawEditorGUI(int windowID) private static void RenderBuildMode() { - double buildPoints = KerbalConstructionTimeData.Instance.EditorVessel.buildPoints; - double bpLeaderEffect = KerbalConstructionTimeData.Instance.EditorVessel.LeaderEffect; - double effic = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.Efficiency; - double rateWithCurEngis = KCTUtilities.GetBuildRate(KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC, KerbalConstructionTimeData.Instance.EditorVessel.mass, KerbalConstructionTimeData.Instance.EditorVessel.buildPoints, KerbalConstructionTimeData.Instance.EditorVessel.humanRated, 0) + double buildPoints = SpaceCenterManagement.Instance.EditorVessel.buildPoints; + double bpLeaderEffect = SpaceCenterManagement.Instance.EditorVessel.LeaderEffect; + double effic = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.Efficiency; + double rateWithCurEngis = KCTUtilities.GetBuildRate(SpaceCenterManagement.Instance.ActiveSC.ActiveLC, SpaceCenterManagement.Instance.EditorVessel.mass, SpaceCenterManagement.Instance.EditorVessel.buildPoints, SpaceCenterManagement.Instance.EditorVessel.humanRated, 0) * effic - * KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.StrategyRateMultiplier; + * SpaceCenterManagement.Instance.ActiveSC.ActiveLC.StrategyRateMultiplier; RenderBuildRateInputRow(buildPoints, rateWithCurEngis); if (KSP.UI.Screens.DebugToolbar.DebugScreenSpawner.Instance?.screen?.isShown ?? false) { GUILayout.Label($"BP Cost: {buildPoints:N0}"); - GUILayout.Label($"EC: {KerbalConstructionTimeData.Instance.EditorVessel.effectiveCost:N0}"); + GUILayout.Label($"EC: {SpaceCenterManagement.Instance.EditorVessel.effectiveCost:N0}"); } if (double.TryParse(BuildRateForDisplay, out double bR)) @@ -71,13 +71,13 @@ private static void RenderBuildMode() double buildTime = bR > 0d ? (effic >= LCEfficiency.MaxEfficiency ? buildPoints / (bR * bpLeaderEffect) - : KerbalConstructionTimeData.Instance.EditorVessel.CalculateTimeLeftForBuildRate(buildPoints, bR / effic, effic, out _)) + : SpaceCenterManagement.Instance.EditorVessel.CalculateTimeLeftForBuildRate(buildPoints, bR / effic, effic, out _)) : 0d; GUILayout.Label($"Integration Time: {(bR > 0 ? KSPUtil.PrintDateDeltaCompact(buildTime, true, false) : "infinity")} at {effic:P0}"); - if (KerbalConstructionTimeData.EditorRolloutBP > 0) + if (SpaceCenterManagement.EditorRolloutBP > 0) { - GUILayout.Label($"Rollout Time: {(bR > 0 ? KSPUtil.PrintDateDeltaCompact(KerbalConstructionTimeData.EditorRolloutBP / bR, true, false) : "infinity")} at {effic:P0}"); + GUILayout.Label($"Rollout Time: {(bR > 0 ? KSPUtil.PrintDateDeltaCompact(SpaceCenterManagement.EditorRolloutBP / bR, true, false) : "infinity")} at {effic:P0}"); } } else @@ -85,45 +85,45 @@ private static void RenderBuildMode() GUILayout.Label("Invalid Integration Rate"); } - if (EditorDriver.editorFacility == EditorFacility.SPH || (KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad && KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.IsHumanRated && !KerbalConstructionTimeData.Instance.EditorVessel.humanRated)) + if (EditorDriver.editorFacility == EditorFacility.SPH || (SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad && SpaceCenterManagement.Instance.ActiveSC.ActiveLC.IsHumanRated && !SpaceCenterManagement.Instance.EditorVessel.humanRated)) { GUILayout.BeginHorizontal(); GUILayout.Label("Engineer Cap:"); - GUILayout.Label((EditorDriver.editorFacility == EditorFacility.SPH ? KerbalConstructionTimeData.Instance.ActiveSC.Hangar : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC).MaxEngineersFor(KerbalConstructionTimeData.Instance.EditorVessel).ToString(), GetLabelRightAlignStyle()); + GUILayout.Label((EditorDriver.editorFacility == EditorFacility.SPH ? SpaceCenterManagement.Instance.ActiveSC.Hangar : SpaceCenterManagement.Instance.ActiveSC.ActiveLC).MaxEngineersFor(SpaceCenterManagement.Instance.EditorVessel).ToString(), GetLabelRightAlignStyle()); GUILayout.EndHorizontal(); } if (bR > 0d && rateWithCurEngis > 0d) { - double effectiveEngCount = bR / rateWithCurEngis * KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.Engineers; + double effectiveEngCount = bR / rateWithCurEngis * SpaceCenterManagement.Instance.ActiveSC.ActiveLC.Engineers; double salaryPerDayAboveIdle = Database.SettingsSC.salaryEngineers * (1d / 365.25d) * (1d - Database.SettingsSC.IdleSalaryMult); double cost = buildPoints / bR / 86400d * effectiveEngCount * salaryPerDayAboveIdle; GUILayout.Label(new GUIContent($"Net Salary: √{-CurrencyUtils.Funds(TransactionReasonsRP0.SalaryEngineers, -cost):N1}", "The extra salary paid above the idle rate for these engineers")); } - if (KerbalConstructionTimeData.EditorRolloutCost > 0) - GUILayout.Label($"Rollout Cost: √{-CurrencyUtils.Funds(TransactionReasonsRP0.RocketRollout, -KerbalConstructionTimeData.EditorRolloutCost):N1}"); + if (SpaceCenterManagement.EditorRolloutCost > 0) + GUILayout.Label($"Rollout Cost: √{-CurrencyUtils.Funds(TransactionReasonsRP0.RocketRollout, -SpaceCenterManagement.EditorRolloutCost):N1}"); bool showCredit = false; - if (KerbalConstructionTimeData.EditorUnlockCosts > 0) + if (SpaceCenterManagement.EditorUnlockCosts > 0) { showCredit = true; - GUILayout.Label($"Unlock Cost: √{-CurrencyUtils.Funds(TransactionReasonsRP0.PartOrUpgradeUnlock, -KerbalConstructionTimeData.EditorUnlockCosts):N1}"); + GUILayout.Label($"Unlock Cost: √{-CurrencyUtils.Funds(TransactionReasonsRP0.PartOrUpgradeUnlock, -SpaceCenterManagement.EditorUnlockCosts):N1}"); } - if (KerbalConstructionTimeData.EditorToolingCosts > 0) + if (SpaceCenterManagement.EditorToolingCosts > 0) { showCredit = true; - GUILayout.Label($"Tooling Cost: √{-CurrencyUtils.Funds(TransactionReasonsRP0.ToolingPurchase, -KerbalConstructionTimeData.EditorToolingCosts):N1}"); + GUILayout.Label($"Tooling Cost: √{-CurrencyUtils.Funds(TransactionReasonsRP0.ToolingPurchase, -SpaceCenterManagement.EditorToolingCosts):N1}"); } if (showCredit) GUILayout.Label($"Unlock Credit: √{UnlockCreditHandler.Instance.TotalCredit:N1}"); - if (KerbalConstructionTimeData.EditorRequiredTechs.Count > 0) + if (SpaceCenterManagement.EditorRequiredTechs.Count > 0) { string techLabel = string.Empty; - foreach (string techId in KerbalConstructionTimeData.EditorRequiredTechs) + foreach (string techId in SpaceCenterManagement.EditorRequiredTechs) { string techName = ResearchAndDevelopment.GetTechnologyTitle(techId); @@ -135,7 +135,7 @@ private static void RenderBuildMode() GUILayout.Label(techLabel); } - if (KerbalConstructionTimeData.Instance.EditorVessel.humanRated && !KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.IsHumanRated) + if (SpaceCenterManagement.Instance.EditorVessel.humanRated && !SpaceCenterManagement.Instance.ActiveSC.ActiveLC.IsHumanRated) { GUILayout.Label("WARNING: Cannot integrate vessel!"); GUILayout.Label("Select a human-rated Launch Complex."); @@ -151,7 +151,7 @@ private static void RenderBuildMode() if (!KCTSettings.Instance.OverrideLaunchButton && GUILayout.Button("Integrate")) { KCTUtilities.TryAddVesselToBuildList(); - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } GUILayout.EndHorizontal(); if (GUILayout.Button("Show/Hide Management")) @@ -177,9 +177,9 @@ private static void ShowBuildVesselFirstDialog() private static void RenderEditorLaunchComplexControls() { - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; bool rightLC = (EditorDriver.editorFacility == EditorFacility.SPH) == (activeLC.LCType == LaunchComplexType.Hangar); - int lcCount = KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexCountPad; + int lcCount = SpaceCenterManagement.Instance.ActiveSC.LaunchComplexCountPad; GUILayout.BeginHorizontal(); if (rightLC) @@ -188,7 +188,7 @@ private static void RenderEditorLaunchComplexControls() { if (lcCount > 1 && !GUIStates.ShowModifyLC && GUILayout.Button("<<", GUILayout.ExpandWidth(false))) { - KerbalConstructionTimeData.Instance.ActiveSC.SwitchToPrevLaunchComplex(); + SpaceCenterManagement.Instance.ActiveSC.SwitchToPrevLaunchComplex(); BuildRateForDisplay = null; } } @@ -201,7 +201,7 @@ private static void RenderEditorLaunchComplexControls() { if (lcCount > 1 && !GUIStates.ShowModifyLC && GUILayout.Button(">>", GUILayout.ExpandWidth(false))) { - KerbalConstructionTimeData.Instance.ActiveSC.SwitchToNextLaunchComplex(); + SpaceCenterManagement.Instance.ActiveSC.SwitchToNextLaunchComplex(); BuildRateForDisplay = null; } } @@ -213,19 +213,19 @@ private static void RenderEditorLaunchComplexControls() if (lcCount > 0) { if (GUILayout.Button(_gcSwitchToLC)) - KerbalConstructionTimeData.Instance.ActiveSC.SwitchToNextLaunchComplex(); + SpaceCenterManagement.Instance.ActiveSC.SwitchToNextLaunchComplex(); } else { - GUILayout.Label(KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Count > 1 ? _gcNoLCAvailableSomeConstructing : _gcNoLCAvailable, GetLabelCenterAlignStyle()); + GUILayout.Label(SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Count > 1 ? _gcNoLCAvailableSomeConstructing : _gcNoLCAvailable, GetLabelCenterAlignStyle()); } } else { - if (KerbalConstructionTimeData.Instance.ActiveSC.Hangar.IsOperational) + if (SpaceCenterManagement.Instance.ActiveSC.Hangar.IsOperational) { if (GUILayout.Button(_gcSwitchToHangar)) - KerbalConstructionTimeData.Instance.ActiveSC.SwitchLaunchComplex(KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.IndexOf(KerbalConstructionTimeData.Instance.ActiveSC.Hangar)); + SpaceCenterManagement.Instance.ActiveSC.SwitchLaunchComplex(SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.IndexOf(SpaceCenterManagement.Instance.ActiveSC.Hangar)); } else { @@ -244,7 +244,7 @@ private static void RenderEditorLaunchComplexControls() } else { - SetFieldsFromVessel(KerbalConstructionTimeData.Instance.EditorVessel); + SetFieldsFromVessel(SpaceCenterManagement.Instance.EditorVessel); _wasShowBuildList = GUIStates.ShowBuildList; GUIStates.ShowNewLC = true; @@ -292,7 +292,7 @@ private static void RenderEditorLaunchComplexControls() } else { - SetFieldsFromVesselKeepOld(KerbalConstructionTimeData.Instance.EditorVessel, activeLC); + SetFieldsFromVesselKeepOld(SpaceCenterManagement.Instance.EditorVessel, activeLC); _wasShowBuildList = GUIStates.ShowBuildList; GUIStates.ShowModifyLC = true; @@ -309,15 +309,15 @@ private static void RenderEditorLaunchComplexControls() private static void RenderEditMode() { - VesselProject editedVessel = KerbalConstructionTimeData.Instance.EditedVessel; - double fullVesselBP = KerbalConstructionTimeData.Instance.EditorVessel.buildPoints; - double bpLeaderEffect = KerbalConstructionTimeData.Instance.EditorVessel.LeaderEffect; + VesselProject editedVessel = SpaceCenterManagement.Instance.EditedVessel; + double fullVesselBP = SpaceCenterManagement.Instance.EditorVessel.buildPoints; + double bpLeaderEffect = SpaceCenterManagement.Instance.EditorVessel.LeaderEffect; double effic = editedVessel.LC.Efficiency; KCTUtilities.GetShipEditProgress(editedVessel, out double newProgressBP, out double originalCompletionPercent, out double newCompletionPercent); GUILayout.Label($"Original: {Math.Max(0, originalCompletionPercent):P2}"); GUILayout.Label($"Edited: {newCompletionPercent:P2}"); - double rateWithCurEngis = KCTUtilities.GetBuildRate(editedVessel.LC, KerbalConstructionTimeData.Instance.EditorVessel.mass, KerbalConstructionTimeData.Instance.EditorVessel.buildPoints, KerbalConstructionTimeData.Instance.EditorVessel.humanRated, 0) + double rateWithCurEngis = KCTUtilities.GetBuildRate(editedVessel.LC, SpaceCenterManagement.Instance.EditorVessel.mass, SpaceCenterManagement.Instance.EditorVessel.buildPoints, SpaceCenterManagement.Instance.EditorVessel.humanRated, 0) * effic * editedVessel.LC.StrategyRateMultiplier; RenderBuildRateInputRow(fullVesselBP, rateWithCurEngis); @@ -344,9 +344,9 @@ private static void RenderEditMode() idx == -1 ? "Time left takes efficiency increase into account based on assuming vessel will be placed at head of integration list" : "Time left takes efficiency increase into account based on vessel's current place in the integration list")); - if (KerbalConstructionTimeData.EditorRolloutBP > 0) + if (SpaceCenterManagement.EditorRolloutBP > 0) { - GUILayout.Label($"Rollout Time: {DTUtils.GetFormattedTime(KerbalConstructionTimeData.EditorRolloutBP / (bR / effic * rolloutEff) , 0, false)} at {rolloutEff:P0}"); + GUILayout.Label($"Rollout Time: {DTUtils.GetFormattedTime(SpaceCenterManagement.EditorRolloutBP / (bR / effic * rolloutEff) , 0, false)} at {rolloutEff:P0}"); } } else @@ -355,10 +355,10 @@ private static void RenderEditMode() } GUILayout.BeginHorizontal(); - if (EditorDriver.editorFacility == EditorFacility.SPH || (KerbalConstructionTimeData.Instance.EditorVessel.LC.IsHumanRated && !KerbalConstructionTimeData.Instance.EditorVessel.humanRated)) + if (EditorDriver.editorFacility == EditorFacility.SPH || (SpaceCenterManagement.Instance.EditorVessel.LC.IsHumanRated && !SpaceCenterManagement.Instance.EditorVessel.humanRated)) { GUILayout.Label("Engineer Cap:"); - GUILayout.Label(KerbalConstructionTimeData.Instance.EditorVessel.LC.MaxEngineersFor(KerbalConstructionTimeData.Instance.EditorVessel).ToString(), GetLabelRightAlignStyle()); + GUILayout.Label(SpaceCenterManagement.Instance.EditorVessel.LC.MaxEngineersFor(SpaceCenterManagement.Instance.EditorVessel).ToString(), GetLabelRightAlignStyle()); } else { @@ -374,7 +374,7 @@ private static void RenderEditMode() if (GUILayout.Button("Cancel Edits")) { RP0Debug.Log("Edits cancelled."); - KerbalConstructionTimeData.ClearVesselEditMode(); + SpaceCenterManagement.ClearVesselEditMode(); HighLogic.LoadScene(GameScenes.SPACECENTER); } @@ -387,12 +387,12 @@ private static void RenderEditMode() EditorLogic.fetch.Lock(true, true, true, "KCTGUILock"); GUIStates.ShowSimConfig = true; - KerbalConstructionTimeData.Instance.LaunchedVessel = new VesselProject(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, EditorLogic.FlagURL, true); - KerbalConstructionTimeData.Instance.LaunchedVessel.LCID = editedVessel.LC.ID; // should already be correct, but just in case. + SpaceCenterManagement.Instance.LaunchedVessel = new VesselProject(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, EditorLogic.FlagURL, true); + SpaceCenterManagement.Instance.LaunchedVessel.LCID = editedVessel.LC.ID; // should already be correct, but just in case. } GUILayout.EndHorizontal(); - if (!KerbalConstructionTimeData.Instance.EditorVessel.AreTanksFull() && + if (!SpaceCenterManagement.Instance.EditorVessel.AreTanksFull() && GUILayout.Button("Fill Tanks")) { foreach (Part p in EditorLogic.fetch.ship.parts) @@ -446,10 +446,10 @@ private static void RenderBuildRateInputRow(double buildPoints, double rateWithC if (GUILayout.Button(_gcMaxBuildRate, GUILayout.ExpandWidth(false))) { - var ship = KerbalConstructionTimeData.Instance.EditorVessel; - var deltaToMaxEngineers = int.MaxValue - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.Engineers; - bR = KCTUtilities.GetBuildRate(KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC, ship.mass, buildPoints, ship.humanRated, deltaToMaxEngineers) - * KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.Efficiency * KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.StrategyRateMultiplier; + var ship = SpaceCenterManagement.Instance.EditorVessel; + var deltaToMaxEngineers = int.MaxValue - SpaceCenterManagement.Instance.ActiveSC.ActiveLC.Engineers; + bR = KCTUtilities.GetBuildRate(SpaceCenterManagement.Instance.ActiveSC.ActiveLC, ship.mass, buildPoints, ship.humanRated, deltaToMaxEngineers) + * SpaceCenterManagement.Instance.ActiveSC.ActiveLC.Efficiency * SpaceCenterManagement.Instance.ActiveSC.ActiveLC.StrategyRateMultiplier; BuildRateForDisplay = bR.ToString(); } diff --git a/Source/RP0/UI/KCT/GUI_FirstRun.cs b/Source/RP0/UI/KCT/GUI_FirstRun.cs index 32e1c4ea55c..e6cff1992f2 100644 --- a/Source/RP0/UI/KCT/GUI_FirstRun.cs +++ b/Source/RP0/UI/KCT/GUI_FirstRun.cs @@ -12,7 +12,7 @@ public static partial class KCT_GUI public static void DrawFirstRun(int windowID) { - if (IsPrimarilyDisabled || KerbalConstructionTimeData.Instance.DontShowFirstRunAgain) + if (IsPrimarilyDisabled || SpaceCenterManagement.Instance.DontShowFirstRunAgain) { GUIStates.ShowFirstRun = false; return; @@ -37,7 +37,7 @@ public static void DrawFirstRun(int windowID) } GUILayout.Label(""); - if (!KerbalConstructionTimeData.Instance.StartedProgram) + if (!SpaceCenterManagement.Instance.StartedProgram) { GUILayout.Label($"{step++}) Choose your starting Programs."); GUILayout.Label("These provide you with funds over time, and allow you to select relevant contracts in Mission Control. Go to the Admin Building to select them. Note that if you're selecting a crewed program like X-Planes, you'll need to hire some nauts!"); @@ -48,7 +48,7 @@ public static void DrawFirstRun(int windowID) GUILayout.Label(""); } - if (!KerbalConstructionTimeData.Instance.AcceptedContract) + if (!SpaceCenterManagement.Instance.AcceptedContract) { GUILayout.Label($"{step++}) Accept a Contract."); GUILayout.Label("With a Program selected, you now have access to the Contracts associated with that Program. Programs have some number of optional and some number of required contracts. Optional contracts aren't necessary to complete the program, but award Confidence."); @@ -59,7 +59,7 @@ public static void DrawFirstRun(int windowID) GUILayout.Label(""); } - if (!KerbalConstructionTimeData.Instance.StarterLCBuilding) + if (!SpaceCenterManagement.Instance.StarterLCBuilding) { GUILayout.Label($"{step++}) Build a starting Launch Complex."); GUILayout.Label("With a contract accepted, now it's time to create and integrate a vessel to complete it. If it's a rocket, you'll need a launch complex to launch it. Go to the VAB and make your rocket, then click New the Integration Info (was KCT) window. The LC properties will be set to support that vessel. Once you have LCs built you can also modify them the same way, either a simple Upgrade or a bigger Reconstruction. Reconstructions remove support for any vessel but the current, but lead to lower maintenance over time."); @@ -70,9 +70,9 @@ public static void DrawFirstRun(int windowID) GUILayout.Label(""); } - if (!KerbalConstructionTimeData.Instance.HiredStarterApplicants) + if (!SpaceCenterManagement.Instance.HiredStarterApplicants) { - GUILayout.Label($"{step++}) Assign your {KerbalConstructionTimeData.Instance.Applicants} starting Applicants"); + GUILayout.Label($"{step++}) Assign your {SpaceCenterManagement.Instance.Applicants} starting Applicants"); if (GUILayout.Button($"Go to Staffing", HighLogic.Skin.button)) { GUIStates.ShowPersonnelWindow = true; @@ -85,7 +85,7 @@ public static void DrawFirstRun(int windowID) { if (_dontShowFirstRunAgain) { - KerbalConstructionTimeData.Instance.DontShowFirstRunAgain = true; + SpaceCenterManagement.Instance.DontShowFirstRunAgain = true; } GUIStates.ShowFirstRun = false; } diff --git a/Source/RP0/UI/KCT/GUI_Main.cs b/Source/RP0/UI/KCT/GUI_Main.cs index 76a1405260f..e2fcb77b583 100644 --- a/Source/RP0/UI/KCT/GUI_Main.cs +++ b/Source/RP0/UI/KCT/GUI_Main.cs @@ -38,7 +38,7 @@ public static void SetGUIPositions() _windowSkin = GUI.skin; GUI.skin = _windowSkin; - if (_validScenes.Contains(HighLogic.LoadedScene) && KerbalConstructionTimeData.Instance != null) + if (_validScenes.Contains(HighLogic.LoadedScene) && SpaceCenterManagement.Instance != null) { if (GUIStates.ShowSettings) _presetPosition = DrawWindowWithTooltipSupport(_presetPosition, "DrawPresetWindow", "Settings", DrawPresetWindow); @@ -120,13 +120,13 @@ public static void SetGUIPositions() { if (!_isKSCLocked) { - InputLockManager.SetControlLock(ControlTypes.KSC_FACILITIES, KerbalConstructionTimeData.KCTKSCLock); + InputLockManager.SetControlLock(ControlTypes.KSC_FACILITIES, SpaceCenterManagement.KCTKSCLock); _isKSCLocked = true; } } else if (_isKSCLocked) { - InputLockManager.RemoveControlLock(KerbalConstructionTimeData.KCTKSCLock); + InputLockManager.RemoveControlLock(SpaceCenterManagement.KCTKSCLock); _isKSCLocked = false; } @@ -150,11 +150,11 @@ public static void ToggleVisibility(bool isVisible) GUIStates.ShowBLPlus = false; ResetBLWindow(); - if (KerbalConstructionTimeData.Instance.IsSimulatedFlight && (AirlaunchTechLevel.AnyUnlocked() || AirlaunchTechLevel.AnyUnderResearch())) + if (SpaceCenterManagement.Instance.IsSimulatedFlight && (AirlaunchTechLevel.AnyUnlocked() || AirlaunchTechLevel.AnyUnderResearch())) { GUIStates.ShowAirlaunch = isVisible; } - if (KerbalConstructionTimeData.Instance.IsSimulatedFlight) + if (SpaceCenterManagement.Instance.IsSimulatedFlight) { GUIStates.ShowSimulationGUI = isVisible; _simulationWindowPosition.height = 1; @@ -166,7 +166,7 @@ public static void ToggleVisibility(bool isVisible) GUIStates.ShowEditorGUI = isVisible; if (!isVisible) GUIStates.ShowBuildList = false; - KerbalConstructionTimeData.ShowWindows[1] = isVisible; + SpaceCenterManagement.ShowWindows[1] = isVisible; } else if ((HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) && !IsPrimarilyDisabled) { @@ -175,7 +175,7 @@ public static void ToggleVisibility(bool isVisible) GUIStates.ShowBuildPlansWindow = false; GUIStates.ShowBLPlus = false; ResetBLWindow(); - KerbalConstructionTimeData.ShowWindows[0] = isVisible; + SpaceCenterManagement.ShowWindows[0] = isVisible; } RefreshToolbarState(); @@ -185,11 +185,11 @@ private static void RefreshToolbarState() { if (GUIStates.IsMainGuiVisible) { - KerbalConstructionTimeData.ToolbarControl.SetTrue(false); + SpaceCenterManagement.ToolbarControl.SetTrue(false); } else { - KerbalConstructionTimeData.ToolbarControl.SetFalse(false); + SpaceCenterManagement.ToolbarControl.SetFalse(false); } } @@ -202,7 +202,7 @@ public static void RestorePrevUIState() if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.EDITOR) { int idx = HighLogic.LoadedScene == GameScenes.SPACECENTER ? 0 : 1; - KerbalConstructionTimeData.ShowWindows[idx] = GUIStates.IsMainGuiVisible; + SpaceCenterManagement.ShowWindows[idx] = GUIStates.IsMainGuiVisible; } RefreshToolbarState(); diff --git a/Source/RP0/UI/KCT/GUI_NewLC.cs b/Source/RP0/UI/KCT/GUI_NewLC.cs index 20ed9e03543..8b2e84433d4 100644 --- a/Source/RP0/UI/KCT/GUI_NewLC.cs +++ b/Source/RP0/UI/KCT/GUI_NewLC.cs @@ -51,7 +51,7 @@ private static void SetResources() private static void SetFieldsFromStartingLCData(LCData old) { _newLCData.SetFrom(old); - _newLCData.Name = _newName = $"Launch Complex {(KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Count)}"; + _newLCData.Name = _newName = $"Launch Complex {(SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Count)}"; SetStrings(); SetResources(); } @@ -75,7 +75,7 @@ private static void SetFieldsFromVessel(VesselProject vp, LaunchComplex lc = nul if (vp.mass < 1f) // special case _newLCData.massMax = 1f; - _newLCData.Name = _newName = $"Launch Complex {(KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Count)}"; + _newLCData.Name = _newName = $"Launch Complex {(SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Count)}"; _newLCData.massOrig = _newLCData.massMax; _newLCData.lcType = LaunchComplexType.Pad; } @@ -201,7 +201,7 @@ private static void GetAllResourceKeys() public static void DrawNewLCWindow(int windowID) { - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; double oldVABCost = 0, oldPadCost = 0, oldResCost = 0, lpMult = 1; bool isModify = GUIStates.ShowModifyLC; @@ -289,7 +289,7 @@ public static void DrawNewLCWindow(int windowID) } if (!isHangar) { - bool isMinBad = HighLogic.LoadedSceneIsEditor && KerbalConstructionTimeData.Instance.EditorVessel.mass < minTonnage; + bool isMinBad = HighLogic.LoadedSceneIsEditor && SpaceCenterManagement.Instance.EditorVessel.mass < minTonnage; GUILayout.BeginHorizontal(); if (isMinBad) GUILayout.Label("Minimum tonnage:", GetLabelStyleYellow()); @@ -497,7 +497,7 @@ public static void DrawNewLCWindow(int windowID) GUILayout.BeginHorizontal(); if (GUILayout.Button(isModify ? "Renovate" : "Build") && ValidateLCCreationParameters(_newLCData.Name, _newLCData.GetPadFracLevel(), _newLCData.massMax, _newLCData.sizeMax, isModify ? activeLC : null)) { - if (HighLogic.LoadedSceneIsEditor && !KerbalConstructionTimeData.Instance.EditorVessel.MeetsFacilityRequirements(_newLCData, null)) + if (HighLogic.LoadedSceneIsEditor && !SpaceCenterManagement.Instance.EditorVessel.MeetsFacilityRequirements(_newLCData, null)) { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("LCModifyVesselConfirm", @@ -524,7 +524,7 @@ public static void DrawNewLCWindow(int windowID) //} if (isModify && !isHangar && GUILayout.Button(_cleanButtonContent)) { - SetFieldsFromVessel(KerbalConstructionTimeData.Instance.EditorVessel, activeLC); + SetFieldsFromVessel(SpaceCenterManagement.Instance.EditorVessel, activeLC); } if (isModify && GUILayout.Button(_existingButtonContent)) { @@ -552,7 +552,7 @@ public static void DrawNewLCWindow(int windowID) private static void ProcessNewLC(bool isModify, double curPadCost, double totalCost, double oldTotalCost) { - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; if (isModify && ModifyFailure(out string failedVessels)) { @@ -568,7 +568,7 @@ private static void ProcessNewLC(bool isModify, double curPadCost, double totalC else { - KerbalConstructionTimeData.Instance.StarterLCBuilding |= !isModify; + SpaceCenterManagement.Instance.StarterLCBuilding |= !isModify; if (!KSPUtils.CurrentGameIsCareer()) { @@ -576,7 +576,7 @@ private static void ProcessNewLC(bool isModify, double curPadCost, double totalC if (isModify) activeLC.Modify(_newLCData, Guid.NewGuid()); else - KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Add(new LaunchComplex(_newLCData, KerbalConstructionTimeData.Instance.ActiveSC)); + SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Add(new LaunchComplex(_newLCData, SpaceCenterManagement.Instance.ActiveSC)); } else { @@ -587,7 +587,7 @@ private static void ProcessNewLC(bool isModify, double curPadCost, double totalC { lc = activeLC; KCTUtilities.ChangeEngineers(lc, -engineers); - KerbalConstructionTimeData.Instance.ActiveSC.SwitchToPrevLaunchComplex(); + SpaceCenterManagement.Instance.ActiveSC.SwitchToPrevLaunchComplex(); // We have to update any ongoing pad constructions too foreach (var pc in lc.PadConstructions) @@ -600,9 +600,9 @@ private static void ProcessNewLC(bool isModify, double curPadCost, double totalC } else { - lc = new LaunchComplex(_newLCData, KerbalConstructionTimeData.Instance.ActiveSC); + lc = new LaunchComplex(_newLCData, SpaceCenterManagement.Instance.ActiveSC); lc.IsOperational = false; - KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Add(lc); + SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Add(lc); } var modData = new LCData(); @@ -619,7 +619,7 @@ private static void ProcessNewLC(bool isModify, double curPadCost, double totalC lcConstr.SetBP(totalCost, oldTotalCost); if (_assignEngOnComplete) lcConstr.engineersToReadd = engineers; - KerbalConstructionTimeData.Instance.ActiveSC.LCConstructions.Add(lcConstr); + SpaceCenterManagement.Instance.ActiveSC.LCConstructions.Add(lcConstr); try { @@ -766,7 +766,7 @@ public static void DrawLCResourcesWindow(int windowID) private static bool ModifyFailure(out string failedVessels) { failedVessels = string.Empty; - LaunchComplex activeLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex activeLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; foreach (var vp in activeLC.BuildList) { if (!vp.MeetsFacilityRequirements(_newLCData, null)) @@ -816,9 +816,9 @@ private static bool ValidateLCCreationParameters(string newName, float fractiona return false; } - for (int i = 0; i < KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes.Count; i++) + for (int i = 0; i < SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes.Count; i++) { - var lp = KerbalConstructionTimeData.Instance.ActiveSC.LaunchComplexes[i]; + var lp = SpaceCenterManagement.Instance.ActiveSC.LaunchComplexes[i]; if (string.Equals(lp.Name, newName, StringComparison.OrdinalIgnoreCase)) { ScreenMessages.PostScreenMessage("Another launch complex with the same name already exists"); diff --git a/Source/RP0/UI/KCT/GUI_NewPad.cs b/Source/RP0/UI/KCT/GUI_NewPad.cs index 42ba3118005..649b65a8701 100644 --- a/Source/RP0/UI/KCT/GUI_NewPad.cs +++ b/Source/RP0/UI/KCT/GUI_NewPad.cs @@ -10,7 +10,7 @@ public static partial class KCT_GUI public static void DrawNewPadWindow(int windowID) { - LaunchComplex curLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex curLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); @@ -73,7 +73,7 @@ public static void DrawNewPadWindow(int windowID) if (!KSPUtils.CurrentGameIsCareer()) { RP0Debug.Log("Building new launchpad!"); - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LaunchPads.Add(new LCLaunchPad(id, _newName, fractionalPadLvl) + SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LaunchPads.Add(new LCLaunchPad(id, _newName, fractionalPadLvl) { isOperational = true }); @@ -82,7 +82,7 @@ public static void DrawNewPadWindow(int windowID) { RP0Debug.Log("Building new launchpad!"); var lp = new LCLaunchPad(id, _newName, fractionalPadLvl); - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LaunchPads.Add(lp); + SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LaunchPads.Add(lp); var padConstr = new PadConstructionProject { @@ -91,7 +91,7 @@ public static void DrawNewPadWindow(int windowID) name = _newName }; padConstr.SetBP(curPadCost, 0d); - KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.PadConstructions.Add(padConstr); + SpaceCenterManagement.Instance.ActiveSC.ActiveLC.PadConstructions.Add(padConstr); try { @@ -136,13 +136,13 @@ public static void DrawRenameWindow(int windowID) } case RenameType.Pad: { - LCLaunchPad lp = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ActiveLPInstance; + LCLaunchPad lp = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ActiveLPInstance; lp.Rename(_newName); break; } case RenameType.LaunchComplex: { - LaunchComplex lc = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex lc = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; lc.Rename(_newName); break; } @@ -171,9 +171,9 @@ private static bool ValidatePadCreationParameters() return false; } - for (int i = 0; i < KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LaunchPads.Count; i++) + for (int i = 0; i < SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LaunchPads.Count; i++) { - var lp = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LaunchPads[i]; + var lp = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LaunchPads[i]; if (string.Equals(lp.name, _newName, StringComparison.OrdinalIgnoreCase)) { ScreenMessages.PostScreenMessage("Another launchpad with the same name already exists"); diff --git a/Source/RP0/UI/KCT/GUI_Personnel.cs b/Source/RP0/UI/KCT/GUI_Personnel.cs index 9f2c213efc9..9ea3a7c745b 100644 --- a/Source/RP0/UI/KCT/GUI_Personnel.cs +++ b/Source/RP0/UI/KCT/GUI_Personnel.cs @@ -41,13 +41,13 @@ private static void DrawPersonnelWindow(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label("Applicants:", GUILayout.Width(120)); - GUILayout.Label(KerbalConstructionTimeData.Instance.Applicants.ToString("N0"), GetLabelRightAlignStyle()); + GUILayout.Label(SpaceCenterManagement.Instance.Applicants.ToString("N0"), GetLabelRightAlignStyle()); GUILayout.EndHorizontal(); double salaryE = -CurrencyUtils.Funds(TransactionReasonsRP0.SalaryEngineers, -MaintenanceHandler.Instance.IntegrationSalaryPerDay * 365.25d); GUILayout.BeginHorizontal(); GUILayout.Label("Total Engineers:", GUILayout.Width(120)); - GUILayout.Label(KerbalConstructionTimeData.Instance.TotalEngineers.ToString("N0"), GetLabelRightAlignStyle(), GUILayout.Width(60)); + GUILayout.Label(SpaceCenterManagement.Instance.TotalEngineers.ToString("N0"), GetLabelRightAlignStyle(), GUILayout.Width(60)); GUILayout.Label("Salary and Facilities:", GetLabelRightAlignStyle(), GUILayout.Width(150)); GUILayout.Label($"√{salaryE:N0}", GetLabelRightAlignStyle()); GUILayout.EndHorizontal(); @@ -55,7 +55,7 @@ private static void DrawPersonnelWindow(int windowID) double salaryR = -CurrencyUtils.Funds(TransactionReasonsRP0.SalaryResearchers, -MaintenanceHandler.Instance.ResearchSalaryPerDay * 365.25d); GUILayout.BeginHorizontal(); GUILayout.Label("Total Researchers:", GUILayout.Width(120)); - GUILayout.Label(KerbalConstructionTimeData.Instance.Researchers.ToString("N0"), GetLabelRightAlignStyle(), GUILayout.Width(60)); + GUILayout.Label(SpaceCenterManagement.Instance.Researchers.ToString("N0"), GetLabelRightAlignStyle(), GUILayout.Width(60)); GUILayout.Label("Salary and Facilities:", GetLabelRightAlignStyle(), GUILayout.Width(150)); GUILayout.Label($"√{salaryR:N0}", GetLabelRightAlignStyle()); GUILayout.EndHorizontal(); @@ -80,7 +80,7 @@ private static void DrawPersonnelWindow(int windowID) if (GUILayout.Button("Close")) { GUIStates.ShowPersonnelWindow = false; - _LCIndex = KerbalConstructionTimeData.Instance.ActiveSC.LCIndex; // reset to current active LC + _LCIndex = SpaceCenterManagement.Instance.ActiveSC.LCIndex; // reset to current active LC } GUILayout.EndVertical(); if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2)) @@ -89,7 +89,7 @@ private static void DrawPersonnelWindow(int windowID) private static void RenderEngineersSection(bool isCostCacheInvalid) { - LCSpaceCenter KSC = KerbalConstructionTimeData.Instance.ActiveSC; + LCSpaceCenter KSC = SpaceCenterManagement.Instance.ActiveSC; LaunchComplex currentLC = KSC.LaunchComplexes[_LCIndex]; GUILayout.BeginHorizontal(); @@ -242,7 +242,7 @@ private static void RenderResearchersSection(bool isCostCacheInvalid) GUILayout.BeginHorizontal(); GUILayout.Label("Researchers:", GUILayout.Width(90)); - GUILayout.Label(KerbalConstructionTimeData.Instance.Researchers.ToString("N0"), GetLabelRightAlignStyle()); + GUILayout.Label(SpaceCenterManagement.Instance.Researchers.ToString("N0"), GetLabelRightAlignStyle()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); @@ -291,9 +291,9 @@ private static void RenderResearchersSection(bool isCostCacheInvalid) GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - if (KerbalConstructionTimeData.Instance.TechList.Count > 0) + if (SpaceCenterManagement.Instance.TechList.Count > 0) { - ResearchProject t = KerbalConstructionTimeData.Instance.TechList[0]; + ResearchProject t = SpaceCenterManagement.Instance.TechList[0]; GUILayout.Label($"Current Research: {t.techName}"); double techRate = Formula.GetResearchRate(t.scienceCost, 0, delta) * efficiency * t.YearBasedRateMult; double timeLeft = (t.scienceCost - t.progress) / techRate; @@ -315,7 +315,7 @@ private static void RenderHireFire(bool research, out int fireAmount, out int hi string title = research ? "Researchers" : "Engineers"; GUILayout.Label($"Hire/Fire {title}:"); - fireAmount = research ? KerbalConstructionTimeData.Instance.Researchers : KerbalConstructionTimeData.Instance.ActiveSC.UnassignedEngineers; + fireAmount = research ? SpaceCenterManagement.Instance.Researchers : SpaceCenterManagement.Instance.ActiveSC.UnassignedEngineers; int workers = _buyModifier; if (workers == int.MaxValue) workers = fireAmount; @@ -327,11 +327,11 @@ private static void RenderHireFire(bool research, out int fireAmount, out int hi if (research) { KCTUtilities.ChangeResearchers(-workers); - KerbalConstructionTimeData.Instance.UpdateTechTimes(); + SpaceCenterManagement.Instance.UpdateTechTimes(); } else { - LCSpaceCenter ksc = KerbalConstructionTimeData.Instance.ActiveSC; + LCSpaceCenter ksc = SpaceCenterManagement.Instance.ActiveSC; KCTUtilities.ChangeEngineers(ksc, -workers); ksc.RecalculateBuildRates(false); } @@ -348,7 +348,7 @@ private static void RenderHireFire(bool research, out int fireAmount, out int hi double modifiedHireCost = -CurrencyUtils.Funds(research ? TransactionReasonsRP0.HiringResearchers : TransactionReasonsRP0.HiringEngineers, -Database.SettingsSC.HireCost); workers = _buyModifier; if (workers == int.MaxValue) - workers = Math.Max(_buyModifierMultsPersonnel[0], KerbalConstructionTimeData.Instance.Applicants + (int)(Funding.Instance.Funds / modifiedHireCost)); + workers = Math.Max(_buyModifierMultsPersonnel[0], SpaceCenterManagement.Instance.Applicants + (int)(Funding.Instance.Funds / modifiedHireCost)); if (research) { @@ -356,10 +356,10 @@ private static void RenderHireFire(bool research, out int fireAmount, out int hi if (maxRes < 0) maxRes = int.MaxValue; - workers = Math.Max(0, Math.Min(workers, maxRes - KerbalConstructionTimeData.Instance.Researchers)); + workers = Math.Max(0, Math.Min(workers, maxRes - SpaceCenterManagement.Instance.Researchers)); } - double workersToHire = Math.Max(0, workers - KerbalConstructionTimeData.Instance.Applicants); + double workersToHire = Math.Max(0, workers - SpaceCenterManagement.Instance.Applicants); _fundsCost = modifiedHireCost * workersToHire; // Show the result for whatever you're asking for, even if you can't afford it. hireAmount = workers; // Math.Min(workers, (int)(Funding.Instance.Funds / Database.SettingsSC.HireCost) + KerbalConstructionTimeData.Instance.UnassignedPersonnel); @@ -373,17 +373,17 @@ private static void RenderHireFire(bool research, out int fireAmount, out int hi if (research) { KCTUtilities.ChangeResearchers(workers); - KerbalConstructionTimeData.Instance.UpdateTechTimes(); + SpaceCenterManagement.Instance.UpdateTechTimes(); } else { - LCSpaceCenter ksc = KerbalConstructionTimeData.Instance.ActiveSC; + LCSpaceCenter ksc = SpaceCenterManagement.Instance.ActiveSC; KCTUtilities.ChangeEngineers(ksc, workers); ksc.RecalculateBuildRates(false); } - KerbalConstructionTimeData.Instance.Applicants = Math.Max(0, KerbalConstructionTimeData.Instance.Applicants - workers); - if (KerbalConstructionTimeData.Instance.Applicants == 0) - KerbalConstructionTimeData.Instance.HiredStarterApplicants = true; + SpaceCenterManagement.Instance.Applicants = Math.Max(0, SpaceCenterManagement.Instance.Applicants - workers); + if (SpaceCenterManagement.Instance.Applicants == 0) + SpaceCenterManagement.Instance.HiredStarterApplicants = true; _fundsCost = int.MinValue; } diff --git a/Source/RP0/UI/KCT/GUI_Presets.cs b/Source/RP0/UI/KCT/GUI_Presets.cs index 21d96cc7a9d..43719a4b4ae 100644 --- a/Source/RP0/UI/KCT/GUI_Presets.cs +++ b/Source/RP0/UI/KCT/GUI_Presets.cs @@ -136,9 +136,9 @@ public static void DrawPresetWindow(int windowID) GUIStates.ShowBuildList = true; RefreshToolbarState(); } - if (!PresetManager.Instance.ActivePreset.GeneralSettings.Enabled) InputLockManager.RemoveControlLock(KerbalConstructionTimeData.KCTKSCLock); + if (!PresetManager.Instance.ActivePreset.GeneralSettings.Enabled) InputLockManager.RemoveControlLock(SpaceCenterManagement.KCTKSCLock); - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); + SpaceCenterManagement.Instance.RecalculateBuildRates(); ResetFormulaRateHolders(); Harmony.PatchKSCFacilityContextMenu.AreTextsUpdated = false; @@ -154,7 +154,7 @@ public static void DrawPresetWindow(int windowID) RefreshToolbarState(); } - KerbalConstructionTimeData.Instance.RecalculateBuildRates(); + SpaceCenterManagement.Instance.RecalculateBuildRates(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); diff --git a/Source/RP0/UI/KCT/GUI_Simulation.cs b/Source/RP0/UI/KCT/GUI_Simulation.cs index 433d28819dd..c207d2ba200 100644 --- a/Source/RP0/UI/KCT/GUI_Simulation.cs +++ b/Source/RP0/UI/KCT/GUI_Simulation.cs @@ -23,7 +23,7 @@ public static void DrawSimulationWindow(int windowID) GUIStates.ShowSimulationGUI = false; KCTUtilities.EnableSimulationLocks(); FlightDriver.RevertToLaunch(); - KerbalConstructionTimeData.Instance.SimulationParams.Reset(); + SpaceCenterManagement.Instance.SimulationParams.Reset(); _centralWindowPosition.height = 1; } @@ -50,11 +50,11 @@ public static void DrawSimulationWindow(int windowID) public static void DrawSimulationConfigure(int windowID) { - SimulationParams simParams = KerbalConstructionTimeData.Instance.SimulationParams; + SimulationParams simParams = SpaceCenterManagement.Instance.SimulationParams; GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Body: "); - if (simParams == null) simParams = KerbalConstructionTimeData.Instance.SimulationParams = new SimulationParams(); + if (simParams == null) simParams = SpaceCenterManagement.Instance.SimulationParams = new SimulationParams(); if (simParams.SimulationBody == null) { simParams.SimulationBody = Planetarium.fetch.Home; @@ -144,7 +144,7 @@ public static void DrawBodyChooser(int windowID) { if (GUILayout.Button(body.bodyName)) { - KerbalConstructionTimeData.Instance.SimulationParams.SimulationBody = body; + SpaceCenterManagement.Instance.SimulationParams.SimulationBody = body; GUIStates.ShowSimBodyChooser = false; GUIStates.ShowSimConfig = true; _centralWindowPosition.height = 1; @@ -159,7 +159,7 @@ public static void DrawBodyChooser(int windowID) private static void StartSim(SimulationParams simParams) { - if (KerbalConstructionTimeData.Instance.IsSimulatedFlight) + if (SpaceCenterManagement.Instance.IsSimulatedFlight) { string msg = "Current save already appears to be a simulation. Starting a simulation inside a simulation isn't allowed."; PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "simErrorPopup", "Simulation error", msg, "Understood", false, HighLogic.UISkin).HideGUIsWhilePopup(); @@ -234,9 +234,9 @@ private static void StartSim(SimulationParams simParams) // Create the LaunchedVessel fresh instead of cloning the EditorVessel, since it's possible that the player // may have changed the vessel slightly since the last time the coroutine updated the EditorVessell. - KerbalConstructionTimeData.Instance.LaunchedVessel = new VesselProject(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, EditorLogic.FlagURL, true); + SpaceCenterManagement.Instance.LaunchedVessel = new VesselProject(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, EditorLogic.FlagURL, true); // Just in case, let's set the LCID - KerbalConstructionTimeData.Instance.LaunchedVessel.LCID = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LCID : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ID; + SpaceCenterManagement.Instance.LaunchedVessel.LCID = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LCID : SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ID; VesselCrewManifest manifest = KSP.UI.CrewAssignmentDialog.Instance.GetManifest(); if (manifest == null) @@ -244,11 +244,11 @@ private static void StartSim(SimulationParams simParams) manifest = HighLogic.CurrentGame.CrewRoster.DefaultCrewForVessel(EditorLogic.fetch.ship.SaveShip(), null, true); } EditorLogic.fetch.ship.SaveShip().Save(tempFile); - KerbalConstructionTimeData.Instance.IsSimulatedFlight = true; + SpaceCenterManagement.Instance.IsSimulatedFlight = true; string launchSiteName = EditorLogic.fetch.launchSiteName; - if (launchSiteName == "LaunchPad" && KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad) + if (launchSiteName == "LaunchPad" && SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad) { - launchSiteName = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.ActiveLPInstance.launchSiteName; + launchSiteName = SpaceCenterManagement.Instance.ActiveSC.ActiveLC.ActiveLPInstance.launchSiteName; } FlightDriver.StartWithNewLaunch(tempFile, EditorLogic.FlagURL, launchSiteName, manifest); } diff --git a/Source/RP0/UI/KCT/GUI_TopRightButtons.cs b/Source/RP0/UI/KCT/GUI_TopRightButtons.cs index c555343a140..6f5b3661061 100644 --- a/Source/RP0/UI/KCT/GUI_TopRightButtons.cs +++ b/Source/RP0/UI/KCT/GUI_TopRightButtons.cs @@ -50,7 +50,7 @@ internal void Start() OnHovTexturePath = "GameData/RP-1/PluginData/Icons/KCT_dev_parts_on", TooltipDefaultText = "Show Experimental parts", TooltipOnText = "Hide Experimental parts", - IsOn = KerbalConstructionTimeData.Instance.ExperimentalPartsEnabled + IsOn = SpaceCenterManagement.Instance.ExperimentalPartsEnabled }; btn.Init(); _buttons.Add(btn); diff --git a/Source/RP0/UI/KCT/GUI_VesselMerge.cs b/Source/RP0/UI/KCT/GUI_VesselMerge.cs index 5058ae77054..991d425ae29 100644 --- a/Source/RP0/UI/KCT/GUI_VesselMerge.cs +++ b/Source/RP0/UI/KCT/GUI_VesselMerge.cs @@ -9,12 +9,12 @@ public static partial class KCT_GUI private static void RenderMergeSection(VesselProject ship) { - if (!_showMergeSelectionList && KerbalConstructionTimeData.Instance.MergingAvailable && GUILayout.Button("Merge Built Vessel")) + if (!_showMergeSelectionList && SpaceCenterManagement.Instance.MergingAvailable && GUILayout.Button("Merge Built Vessel")) { _showMergeSelectionList = true; } - if (_showMergeSelectionList && KerbalConstructionTimeData.Instance.MergingAvailable) + if (_showMergeSelectionList && SpaceCenterManagement.Instance.MergingAvailable) { if (GUILayout.Button("Hide Merge Selection")) { @@ -26,16 +26,16 @@ private static void RenderMergeSection(VesselProject ship) _activeLCMergeScroll = GUILayout.BeginScrollView(_activeLCMergeScroll, GUILayout.Height(5 * 26 + 5), GUILayout.MaxHeight(1 * Screen.height / 4)); - LaunchComplex lc = KerbalConstructionTimeData.EditorShipEditingMode ? KerbalConstructionTimeData.Instance.EditedVessel.LC : KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + LaunchComplex lc = SpaceCenterManagement.EditorShipEditingMode ? SpaceCenterManagement.Instance.EditedVessel.LC : SpaceCenterManagement.Instance.ActiveSC.ActiveLC; foreach (VesselProject vessel in lc.Warehouse) { - if (vessel.shipID != ship.shipID && !KerbalConstructionTimeData.Instance.MergedVessels.Exists(x => x.shipID == vessel.shipID) && GUILayout.Button(vessel.shipName)) + if (vessel.shipID != ship.shipID && !SpaceCenterManagement.Instance.MergedVessels.Exists(x => x.shipID == vessel.shipID) && GUILayout.Button(vessel.shipName)) { vessel.RecalculateFromNode(); ShipConstruct mergedShip = vessel.CreateShipConstructAndRelease(); EditorLogic.fetch.SpawnConstruct(mergedShip); - KerbalConstructionTimeData.Instance.MergedVessels.Add(vessel); + SpaceCenterManagement.Instance.MergedVessels.Add(vessel); } } GUILayout.EndScrollView(); diff --git a/Source/RP0/UI/MaintenanceGUI.cs b/Source/RP0/UI/MaintenanceGUI.cs index 43eab83c69c..6c50b7ac582 100644 --- a/Source/RP0/UI/MaintenanceGUI.cs +++ b/Source/RP0/UI/MaintenanceGUI.cs @@ -83,7 +83,7 @@ private void RenderPeriodSelector() public void RenderSummaryTab() { - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; double totalCost = 0d; @@ -185,7 +185,7 @@ public void RenderSummaryTab() double rolloutCost = 0d; try { - rolloutCost = KerbalConstructionTimeData.Instance.GetRolloutCostOverTime(PeriodFactor * 86400d); + rolloutCost = SpaceCenterManagement.Instance.GetRolloutCostOverTime(PeriodFactor * 86400d); GUILayout.Label("Rollout/Airlaunch Prep", HighLogic.Skin.label, GUILayout.Width(160)); GUILayout.Label(FormatCost(rolloutCost), RightLabel, GUILayout.Width(160)); } @@ -196,7 +196,7 @@ public void RenderSummaryTab() GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - double constrMaterials = KerbalConstructionTimeData.Instance.GetConstructionCostOverTime(PeriodFactor * 86400d); + double constrMaterials = SpaceCenterManagement.Instance.GetConstructionCostOverTime(PeriodFactor * 86400d); GUILayout.Label("Constructions", HighLogic.Skin.label, GUILayout.Width(160)); GUILayout.Label(FormatCost(constrMaterials), RightLabel, GUILayout.Width(160)); if (GUILayout.Button(_infoBtnContent, InfoButton)) @@ -226,9 +226,9 @@ public void RenderSummaryTab() GUILayout.Label("Unlock Credit", HighLogic.Skin.label, GUILayout.Width(160)); double unlockCredit = 0d; double accumTime = 0d; - for (int i = 0; i < KerbalConstructionTimeData.Instance.TechList.Count && accumTime < utDelta; ++i) + for (int i = 0; i < SpaceCenterManagement.Instance.TechList.Count && accumTime < utDelta; ++i) { - var tech = KerbalConstructionTimeData.Instance.TechList[i]; + var tech = SpaceCenterManagement.Instance.TechList[i]; double buildTime = tech.BuildRate > 0d ? tech.TimeLeft : tech.GetTimeLeftEst(accumTime); double timeLeft = utDelta - accumTime; if (buildTime > timeLeft) @@ -288,7 +288,7 @@ private void ConfirmWarpDialog() { UIHolder.Instance.ShowWindow(); InputLockManager.RemoveControlLock("warptofunds"); - KerbalConstructionTimeData.Instance.fundTarget.Clear(); + SpaceCenterManagement.Instance.fundTarget.Clear(); })), false, HighLogic.UISkin); return; } @@ -305,7 +305,7 @@ private void ConfirmWarpDialog() new DialogGUIButton("Understood", () => { UIHolder.Instance.ShowWindow(); InputLockManager.RemoveControlLock("warptofunds"); - KerbalConstructionTimeData.Instance.fundTarget.Clear(); + SpaceCenterManagement.Instance.fundTarget.Clear(); })), false, HighLogic.UISkin); } else @@ -313,21 +313,21 @@ private void ConfirmWarpDialog() var options = new DialogGUIBase[] { new DialogGUIButton("Yes, Warp", () => { - KerbalConstructionTimeData.Instance.fundTarget.Clear(); + SpaceCenterManagement.Instance.fundTarget.Clear(); KCTWarpController.Create(target); UIHolder.Instance.ShowWindow(); InputLockManager.RemoveControlLock("warptofunds"); }), new DialogGUIButton("Add Warp Target", () => { - KerbalConstructionTimeData.Instance.fundTarget = target; + SpaceCenterManagement.Instance.fundTarget = target; target.SetAutoWarp(false); UIHolder.Instance.ShowWindow(); InputLockManager.RemoveControlLock("warptofunds"); }), new DialogGUIButton("Cancel", () => { - KerbalConstructionTimeData.Instance.fundTarget.Clear(); + SpaceCenterManagement.Instance.fundTarget.Clear(); UIHolder.Instance.ShowWindow(); InputLockManager.RemoveControlLock("warptofunds"); }) @@ -340,7 +340,7 @@ private void ConfirmWarpDialog() public void RenderFacilitiesTab() { - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; GUILayout.BeginHorizontal(); @@ -350,7 +350,7 @@ public void RenderFacilitiesTab() GUILayout.EndHorizontal(); double grandTotal = 0d; - foreach (var ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (var ksc in SpaceCenterManagement.Instance.KSCs) { string site = LocalizeSiteName(ksc.KSCName); GUILayout.BeginHorizontal(); @@ -414,7 +414,7 @@ public void RenderFacilitiesTab() public void RenderIntegrationTab() { - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; GUILayout.BeginHorizontal(); @@ -462,7 +462,7 @@ public void RenderIntegrationTab() public void RenderConstructionTab() { - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; double totalCost = 0d; @@ -472,7 +472,7 @@ public void RenderConstructionTab() GUILayout.Label(")", HighLogic.Skin.label); GUILayout.EndHorizontal(); - foreach (var ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (var ksc in SpaceCenterManagement.Instance.KSCs) { string site = LocalizeSiteName(ksc.KSCName); if (ksc.Constructions.Count == 0) @@ -481,7 +481,7 @@ public void RenderConstructionTab() GUILayout.BeginHorizontal(); try { - double cost = KerbalConstructionTimeData.Instance.GetConstructionCostOverTime(PeriodFactor * 86400d, ksc); + double cost = SpaceCenterManagement.Instance.GetConstructionCostOverTime(PeriodFactor * 86400d, ksc); totalCost += cost; GUILayout.Label(site, HighLogic.Skin.label, GUILayout.Width(160)); GUILayout.Label(FormatCost(cost), RightLabel, GUILayout.Width(160)); diff --git a/Source/RP0/UpgradeScripts/v3_0_ACRnD.cs b/Source/RP0/UpgradeScripts/v3_0_ACRnD.cs index 3de808f6ff1..b75d9c522d9 100644 --- a/Source/RP0/UpgradeScripts/v3_0_ACRnD.cs +++ b/Source/RP0/UpgradeScripts/v3_0_ACRnD.cs @@ -138,74 +138,23 @@ public override void OnUpgrade(ConfigNode node, LoadContext loadContext, ConfigN [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO")] public class v3_0_KCTSCM : UpgradeScript { - public override string Name { get => "RP-1 Astronaut Complex and RnD Construction Upgrader"; } - public override string Description { get => "Updates AC and RnD building levels in constructions"; } + public override string Name { get => "RP-1 KCT Upgrader"; } + public override string Description { get => "Updates main scenario module for RP-1"; } public override Version EarliestCompatibleVersion { get => new Version(2, 0, 0); } protected static Version _targetVersion = new Version(3, 0, 0); public override Version TargetVersion => _targetVersion; public override TestResult OnTest(ConfigNode node, LoadContext loadContext, ref string nodeName) { - foreach (ConfigNode n in node.nodes) - { - nodeName = n.GetValue("id"); - if (nodeName == "SpaceCenter/AstronautComplex" || nodeName == "SpaceCenter/ResearchAndDevelopment") - return TestResult.Upgradeable; - } - return TestResult.Pass; + return node.GetValue("name") == "KerbalConstructionTimeData" ? TestResult.Upgradeable : TestResult.Pass; } public override void OnUpgrade(ConfigNode node, LoadContext loadContext, ConfigNode parentNode) { - for (int i = node.nodes.Count; i-- > 0;) + if(node.GetValue("name") == "KerbalConstructionTimeData") { - var n = node.nodes[i]; - string name = n.GetValue("id"); - - // Nuke RnD upgrades - if (name == "SpaceCenter/ResearchAndDevelopment") - { - node.nodes.nodes.RemoveAt(i); - continue; - } - - // Handle AC upgrades - if (name != "SpaceCenter/AstronautComplex") - continue; - - int oldCur = 0; - int oldUp = 0; - double oldSpentCost = 0d; - n.TryGetValue("currentLevel", ref oldCur); - n.TryGetValue("upgradeLevel", ref oldUp); - n.TryGetValue("spentCost", ref oldSpentCost); - - int newCur = 0; - int newUp = 0; - switch (oldUp) - { - case 1: - newCur = 2; - newUp = 3; - break; - - case 2: - newCur = 3; - newUp = 4; - break; - } - // We rejigger BP and total cost. Ignore fundsloss parameter here - double cost = Database.FacilityLevelCosts[SpaceCenterFacility.AstronautComplex][newUp]; - double oldCost = Database.FacilityLevelCosts[SpaceCenterFacility.AstronautComplex].SumThrough(newUp - 1); - double bp = Formula.GetConstructionBP(cost, oldCost, SpaceCenterFacility.AstronautComplex); - double oldBP = 0d; - n.TryGetValue("BP", ref oldBP); - n.SetValue("BP", Math.Min(bp, oldBP)); - n.SetValue("cost", cost.ToString("N0")); - n.SetValue("currentLevel", newCur); - n.SetValue("upgradeLevel", newUp); - - RP0Debug.Log($"UpgradePipeline context {loadContext} updated KCT Admin Building upgrade to target level {newUp} (was {oldUp})"); + node.SetValue("name", "SpaceCenterManagement"); + RP0Debug.Log($"UpgradePipeline context {loadContext} updated KCTData to be SpaceCenterManagement"); } } } diff --git a/Source/RP0/Utilities/Formula.cs b/Source/RP0/Utilities/Formula.cs index 103f08eb745..13776f18f18 100644 --- a/Source/RP0/Utilities/Formula.cs +++ b/Source/RP0/Utilities/Formula.cs @@ -57,7 +57,7 @@ public static double GetConstructionBuildRate(int index, LCSpaceCenter KSC, Spac public static double GetResearchRate(double ScienceValue, int index, int upgradeDelta) { - int Personnel = KerbalConstructionTimeData.Instance.Researchers + upgradeDelta; + int Personnel = SpaceCenterManagement.Instance.Researchers + upgradeDelta; if (index > 0) return 0d; @@ -88,7 +88,7 @@ public static double GetRolloutCost(VesselProject vessel) LaunchComplex vLC = vessel.LC; if (vLC == null) - vLC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + vLC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; double multHR = 1d; if (vLC.IsHumanRated) diff --git a/Source/RP0/Utilities/KCTUtilities.cs b/Source/RP0/Utilities/KCTUtilities.cs index 271582bf447..4cc3ff41da3 100644 --- a/Source/RP0/Utilities/KCTUtilities.cs +++ b/Source/RP0/Utilities/KCTUtilities.cs @@ -366,10 +366,10 @@ public static double AddFunds(double toAdd, TransactionReasonsRP0 reason) public static void ProcessSciPointTotalChange(float changeDelta) { // Earned point totals shouldn't decrease. This would only make sense when done through the cheat menu. - if (changeDelta <= 0f || KerbalConstructionTimeData.IsRefundingScience) return; + if (changeDelta <= 0f || SpaceCenterManagement.IsRefundingScience) return; - KerbalConstructionTimeData.Instance.SciPointsTotal += changeDelta; - RP0Debug.Log("Total sci points earned is now: " + KerbalConstructionTimeData.Instance.SciPointsTotal); + SpaceCenterManagement.Instance.SciPointsTotal += changeDelta; + RP0Debug.Log("Total sci points earned is now: " + SpaceCenterManagement.Instance.SciPointsTotal); } public static void TryAddVesselToBuildList() => TryAddVesselToBuildList(EditorLogic.fetch.launchSiteName); @@ -383,12 +383,12 @@ public static void TryAddVesselToBuildList(string launchSite) ProjectType type = EditorLogic.fetch.ship.shipFacility == EditorFacility.VAB ? ProjectType.VAB : ProjectType.SPH; - if ((type == ProjectType.VAB) != (KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad)) + if ((type == ProjectType.VAB) != (SpaceCenterManagement.Instance.ActiveSC.ActiveLC.LCType == LaunchComplexType.Pad)) { string dialogStr; if (type == ProjectType.VAB) { - if (KerbalConstructionTimeData.Instance.ActiveSC.IsAnyLCOperational) + if (SpaceCenterManagement.Instance.ActiveSC.IsAnyLCOperational) dialogStr = $"a launch complex. Please switch to a launch complex and try again."; else dialogStr = $"a launch complex. You must build a launch complex (or wait for a launch complex to finish building or renovating) before you can integrate this vessel."; @@ -396,7 +396,7 @@ public static void TryAddVesselToBuildList(string launchSite) } else { - if (KerbalConstructionTimeData.Instance.ActiveSC.Hangar.IsOperational) + if (SpaceCenterManagement.Instance.ActiveSC.Hangar.IsOperational) dialogStr = $"the Hangar. Please switch to the Hangar as active launch complex and try again."; else dialogStr = $"the Hangar. You must wait for the Hangar to finish renovating before you can integrate this vessel."; @@ -452,7 +452,7 @@ public static void AddVesselToBuildList(VesselProject vp, bool spendFunds) } else { - RP0Debug.LogError($"Error! Tried to add {vp.shipName} to build list but couldn't find LC! KSC {KerbalConstructionTimeData.Instance.ActiveSC.KSCName} and active LC {KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC}"); + RP0Debug.LogError($"Error! Tried to add {vp.shipName} to build list but couldn't find LC! KSC {SpaceCenterManagement.Instance.ActiveSC.KSCName} and active LC {SpaceCenterManagement.Instance.ActiveSC.ActiveLC}"); return; } @@ -465,7 +465,7 @@ public static void AddVesselToBuildList(VesselProject vp, bool spendFunds) Debug.LogException(ex); } - RP0Debug.Log($"Added {vp.shipName} to build list at {lc.Name} at {KerbalConstructionTimeData.Instance.ActiveSC.KSCName}. Cost: {vp.cost}."); + RP0Debug.Log($"Added {vp.shipName} to build list at {lc.Name} at {SpaceCenterManagement.Instance.ActiveSC.KSCName}. Cost: {vp.cost}."); RP0Debug.Log("Launch site is " + vp.launchSite); string text = $"Added {vp.shipName} to integration list at {lc.Name}."; var message = new ScreenMessage(text, 4f, ScreenMessageStyle.UPPER_CENTER); @@ -489,7 +489,7 @@ public static void TrySaveShipEdits(VesselProject editableShip) }; double usedShipsCost = editableShip.GetTotalCost(); - foreach (VesselProject v in KerbalConstructionTimeData.Instance.MergedVessels) + foreach (VesselProject v in SpaceCenterManagement.Instance.MergedVessels) { usedShipsCost += v.GetTotalCost(); v.RemoveFromBuildList(out _); @@ -535,7 +535,7 @@ private static void SaveShipEdits(double oldCost, VesselProject editableShip, Ve GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); - KerbalConstructionTimeData.ClearVesselEditMode(); + SpaceCenterManagement.ClearVesselEditMode(); RP0Debug.Log("Edits saved."); @@ -547,7 +547,7 @@ public static void GetShipEditProgress(VesselProject ship, out double newProgres double origTotalBP; double oldProgressBP; - if (KerbalConstructionTimeData.Instance.MergedVessels.Count == 0) + if (SpaceCenterManagement.Instance.MergedVessels.Count == 0) { origTotalBP = ship.buildPoints; oldProgressBP = ship.IsFinished ? origTotalBP : ship.progress; @@ -555,7 +555,7 @@ public static void GetShipEditProgress(VesselProject ship, out double newProgres else { double totalEffectiveCost = ship.effectiveCost; - foreach (VesselProject v in KerbalConstructionTimeData.Instance.MergedVessels) + foreach (VesselProject v in SpaceCenterManagement.Instance.MergedVessels) { totalEffectiveCost += v.effectiveCost; } @@ -564,7 +564,7 @@ public static void GetShipEditProgress(VesselProject ship, out double newProgres oldProgressBP *= (1 - Database.SettingsSC.MergingTimePenalty); } - double newTotalBP = KerbalConstructionTimeData.Instance.EditorVessel.buildPoints; + double newTotalBP = SpaceCenterManagement.Instance.EditorVessel.buildPoints; double totalBPDiff = Math.Abs(newTotalBP - origTotalBP); newProgressBP = Math.Max(0, oldProgressBP - (1.1 * totalBPDiff)); originalCompletionPercent = oldProgressBP / origTotalBP; @@ -598,7 +598,7 @@ public static void UnlockExperimentalParts(List availableParts) EditorPartList.Instance?.Refresh(); EditorPartList.Instance?.Refresh(EditorPartList.State.PartsList); if (HighLogic.LoadedSceneIsEditor) - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); } @@ -640,7 +640,7 @@ public static void RemoveResearchedPartsFromExperimental() public static bool PartIsUnlockedButNotPurchased(AvailablePart ap) { bool nodeIsInList = ResearchAndDevelopment.Instance.protoTechNodes.TryGetValue(ap.TechRequired, out ProtoTechNode ptn); - if (!nodeIsInList) return KerbalConstructionTimeData.Instance.TechListHas(ap.TechRequired); + if (!nodeIsInList) return SpaceCenterManagement.Instance.TechListHas(ap.TechRequired); bool nodeIsUnlocked = ptn.state == RDTech.State.Available; bool partNotPurchased = !ptn.partsPurchased.Contains(ap); @@ -699,10 +699,10 @@ private static void _checkTime(in ISpaceCenterProject item, ref double shortestT public static ISpaceCenterProject GetNextThingToFinish() { ISpaceCenterProject thing = null; - if (KerbalConstructionTimeData.Instance.ActiveSC == null) + if (SpaceCenterManagement.Instance.ActiveSC == null) return null; double shortestTime = double.PositiveInfinity; - foreach (LCSpaceCenter KSC in KerbalConstructionTimeData.Instance.KSCs) + foreach (LCSpaceCenter KSC in SpaceCenterManagement.Instance.KSCs) { foreach (LaunchComplex LC in KSC.LaunchComplexes) { @@ -716,15 +716,15 @@ public static ISpaceCenterProject GetNextThingToFinish() foreach (ISpaceCenterProject ub in KSC.Constructions) _checkTime(ub, ref shortestTime, ref thing); } - foreach (ResearchProject tech in KerbalConstructionTimeData.Instance.TechList) + foreach (ResearchProject tech in SpaceCenterManagement.Instance.TechList) { if (tech.GetBlockingTech() == null) // Ignore items that are blocked _checkTime(tech, ref shortestTime, ref thing); } foreach (ISpaceCenterProject course in Crew.CrewHandler.Instance.TrainingCourses) _checkTime(course, ref shortestTime, ref thing); - if (KerbalConstructionTimeData.Instance.fundTarget.IsValid) - _checkTime(KerbalConstructionTimeData.Instance.fundTarget, ref shortestTime, ref thing); + if (SpaceCenterManagement.Instance.fundTarget.IsValid) + _checkTime(SpaceCenterManagement.Instance.fundTarget, ref shortestTime, ref thing); return thing; } @@ -732,7 +732,7 @@ public static ISpaceCenterProject GetNextThingToFinish() public static void DisableModFunctionality() { DisableSimulationLocks(); - InputLockManager.RemoveControlLock(KerbalConstructionTimeData.KCTLaunchLock); + InputLockManager.RemoveControlLock(SpaceCenterManagement.KCTLaunchLock); KCT_GUI.HideAll(); } @@ -788,7 +788,7 @@ public static bool IsApproximatelyEqual(double d1, double d2, double error = 0.0 public static bool ReconditioningActive(LaunchComplex LC, string launchSite = "LaunchPad") { - if (LC == null) LC = KerbalConstructionTimeData.Instance.ActiveSC.ActiveLC; + if (LC == null) LC = SpaceCenterManagement.Instance.ActiveSC.ActiveLC; return LC.GetReconditioning(launchSite) is ReconRolloutProject; } @@ -802,7 +802,7 @@ public static VesselProject FindVPByID(LaunchComplex hintLC, Guid id) return b; } - foreach (LCSpaceCenter ksc in KerbalConstructionTimeData.Instance.KSCs) + foreach (LCSpaceCenter ksc in SpaceCenterManagement.Instance.KSCs) { if (FindVPByID(id, ksc) is VesselProject vp) return vp; @@ -930,35 +930,35 @@ public static bool RecoverActiveVesselToStorage(ProjectType listType) RP0Debug.Log("Attempting to recover active vessel to storage. listType: " + listType); GamePersistence.SaveGame("KCT_Backup", HighLogic.SaveFolder, SaveMode.OVERWRITE); - KerbalConstructionTimeData.Instance.RecoveredVessel = new VesselProject(FlightGlobals.ActiveVessel, listType); + SpaceCenterManagement.Instance.RecoveredVessel = new VesselProject(FlightGlobals.ActiveVessel, listType); KCTVesselData vData = FlightGlobals.ActiveVessel.GetKCTVesselData(); - KerbalConstructionTimeData.Instance.RecoveredVessel.KCTPersistentID = vData?.VesselID; - KerbalConstructionTimeData.Instance.RecoveredVessel.FacilityBuiltIn = vData?.FacilityBuiltIn ?? EditorFacility.None; - KerbalConstructionTimeData.Instance.RecoveredVessel.LCID = vData?.LCID ?? Guid.Empty; - KerbalConstructionTimeData.Instance.RecoveredVessel.LandedAt = FlightGlobals.ActiveVessel.landedAt; + SpaceCenterManagement.Instance.RecoveredVessel.KCTPersistentID = vData?.VesselID; + SpaceCenterManagement.Instance.RecoveredVessel.FacilityBuiltIn = vData?.FacilityBuiltIn ?? EditorFacility.None; + SpaceCenterManagement.Instance.RecoveredVessel.LCID = vData?.LCID ?? Guid.Empty; + SpaceCenterManagement.Instance.RecoveredVessel.LandedAt = FlightGlobals.ActiveVessel.landedAt; //KCT_GameStates.recoveredVessel.type = listType; if (listType == ProjectType.SPH) - KerbalConstructionTimeData.Instance.RecoveredVessel.launchSite = "Runway"; + SpaceCenterManagement.Instance.RecoveredVessel.launchSite = "Runway"; else - KerbalConstructionTimeData.Instance.RecoveredVessel.launchSite = "LaunchPad"; + SpaceCenterManagement.Instance.RecoveredVessel.launchSite = "LaunchPad"; //check for symmetry parts and remove those references if they can't be found - KerbalConstructionTimeData.Instance.RecoveredVessel.RemoveMissingSymmetry(); + SpaceCenterManagement.Instance.RecoveredVessel.RemoveMissingSymmetry(); // debug, save to a file - KerbalConstructionTimeData.Instance.RecoveredVessel.UpdateNodeAndSave("KCTVesselSave", false); + SpaceCenterManagement.Instance.RecoveredVessel.UpdateNodeAndSave("KCTVesselSave", false); //test if we can actually convert it - var test = KerbalConstructionTimeData.Instance.RecoveredVessel.CreateShipConstructAndRelease(); + var test = SpaceCenterManagement.Instance.RecoveredVessel.CreateShipConstructAndRelease(); if (test != null) ShipConstruction.CreateBackup(test); RP0Debug.Log("Load test reported success = " + (test == null ? "false" : "true")); if (test == null) { - KerbalConstructionTimeData.Instance.RecoveredVessel = new VesselProject(); + SpaceCenterManagement.Instance.RecoveredVessel = new VesselProject(); return false; } @@ -974,7 +974,7 @@ public static bool RecoverActiveVesselToStorage(ProjectType listType) { RP0Debug.LogError("Error while recovering craft into inventory."); RP0Debug.LogError("error: " + ex); - KerbalConstructionTimeData.Instance.RecoveredVessel = new VesselProject(); + SpaceCenterManagement.Instance.RecoveredVessel = new VesselProject(); ShipConstruction.ClearBackups(); return false; } @@ -995,7 +995,7 @@ public static void HandleEditorButton() if (KCTSettings.Instance.OverrideLaunchButton) { - if (KerbalConstructionTimeData.EditorShipEditingMode) + if (SpaceCenterManagement.EditorShipEditingMode) { // Prevent switching between VAB and SPH in edit mode. // Bad things will happen if the edits are saved in another mode than the initial one. @@ -1015,14 +1015,14 @@ public static void HandleEditorButton() } EditorLogic.fetch.launchBtn.onClick.RemoveAllListeners(); - EditorLogic.fetch.launchBtn.onClick.AddListener(() => { KerbalConstructionTimeData.ShowLaunchAlert(null); }); + EditorLogic.fetch.launchBtn.onClick.AddListener(() => { SpaceCenterManagement.ShowLaunchAlert(null); }); - if (KerbalConstructionTimeData.Instance == null) + if (SpaceCenterManagement.Instance == null) return; - if (!KerbalConstructionTimeData.Instance.IsLaunchSiteControllerDisabled) + if (!SpaceCenterManagement.Instance.IsLaunchSiteControllerDisabled) { - KerbalConstructionTimeData.Instance.IsLaunchSiteControllerDisabled = true; + SpaceCenterManagement.Instance.IsLaunchSiteControllerDisabled = true; UILaunchsiteController controller = UnityEngine.Object.FindObjectOfType(); if (controller == null) { @@ -1035,12 +1035,12 @@ public static void HandleEditorButton() } } } - else if(KerbalConstructionTimeData.Instance != null) + else if(SpaceCenterManagement.Instance != null) { - InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, KerbalConstructionTimeData.KCTLaunchLock); - if (!KerbalConstructionTimeData.Instance.IsLaunchSiteControllerDisabled) + InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, SpaceCenterManagement.KCTLaunchLock); + if (!SpaceCenterManagement.Instance.IsLaunchSiteControllerDisabled) { - KerbalConstructionTimeData.Instance.IsLaunchSiteControllerDisabled = true; + SpaceCenterManagement.Instance.IsLaunchSiteControllerDisabled = true; RP0Debug.Log("Attempting to disable launchsite specific buttons"); UILaunchsiteController controller = UnityEngine.Object.FindObjectOfType(); if (controller != null) @@ -1053,7 +1053,7 @@ public static void HandleEditorButton() private static void OnEditorSwitch() { - KerbalConstructionTimeData.Instance.StartCoroutine(PostEditorSwitch()); + SpaceCenterManagement.Instance.StartCoroutine(PostEditorSwitch()); } private static System.Collections.IEnumerator PostEditorSwitch() @@ -1064,7 +1064,7 @@ private static System.Collections.IEnumerator PostEditorSwitch() if (EditorDriver.fetch == null) yield break; - KerbalConstructionTimeData.Instance.IsEditorRecalcuationRequired = true; + SpaceCenterManagement.Instance.IsEditorRecalcuationRequired = true; } /// @@ -1500,7 +1500,7 @@ public static void ChangeEngineers(LCSpaceCenter ksc, int delta) public static void ChangeResearchers(int delta) { - KerbalConstructionTimeData.Instance.Researchers += delta; + SpaceCenterManagement.Instance.Researchers += delta; SCMEvents.OnPersonnelChange.Fire(); MaintenanceHandler.Instance.ScheduleMaintenanceUpdate(); } @@ -1510,7 +1510,7 @@ public static void ChangeResearchers(int delta) public static double ScienceForNextApplicants() { - int applicantsCur = ApplicantPacketsForScience(Math.Max(0d, KerbalConstructionTimeData.Instance.SciPointsTotal)); + int applicantsCur = ApplicantPacketsForScience(Math.Max(0d, SpaceCenterManagement.Instance.SciPointsTotal)); return Math.Pow(5d * (applicantsCur + 1d), 1d / ApplicantsPow); } @@ -1582,22 +1582,22 @@ public static bool IsVesselKCTRecovering(ProtoVessel v) if (!PresetManager.Instance.ActivePreset.GeneralSettings.Enabled) return false; - if (KerbalConstructionTimeData.Instance.IsSimulatedFlight) + if (SpaceCenterManagement.Instance.IsSimulatedFlight) return false; if (v.vesselRef.isEVA) return false; // Is also called at the start of the flight scene when recovering clamps & debris - if (KerbalConstructionTimeData.Instance.RecoveredVessel?.IsValid != true) + if (SpaceCenterManagement.Instance.RecoveredVessel?.IsValid != true) { RP0Debug.Log("Recovered vessel is null!"); return false; } - if (v.vesselName != KerbalConstructionTimeData.Instance.RecoveredVessel.shipName) + if (v.vesselName != SpaceCenterManagement.Instance.RecoveredVessel.shipName) { - RP0Debug.Log($"Recovered vessel '{v.vesselName}' and '{KerbalConstructionTimeData.Instance.RecoveredVessel.shipName}' do not match "); + RP0Debug.Log($"Recovered vessel '{v.vesselName}' and '{SpaceCenterManagement.Instance.RecoveredVessel.shipName}' do not match "); return false; }