Skip to content

Commit

Permalink
One more rename: KCTData to SpaceCenterManagement
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Oct 9, 2023
1 parent 4cd2300 commit 4b65afe
Show file tree
Hide file tree
Showing 67 changed files with 474 additions and 525 deletions.
2 changes: 1 addition & 1 deletion Source/RP0/Addons/GameplayTips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleEngineConfigs>() != null) // Does the vessel have a rocket engine?
{
Expand Down
10 changes: 5 additions & 5 deletions Source/RP0/CareerLog/CareerLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/RP0/Crew/CrewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void AddPartCourses(AvailablePart ap)
ap.partPrefab.Modules.Contains<KerbalSeat>() || 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)
Expand Down Expand Up @@ -288,7 +288,7 @@ public static bool CheckCrewForPart(ProtoCrewMember pcm, string partName, bool i
return false;

if (!HighLogic.CurrentGame.Parameters.CustomParams<RP0Settings>().IsTrainingEnabled
|| KerbalConstructionTimeData.Instance.IsSimulatedFlight)
|| SpaceCenterManagement.Instance.IsSimulatedFlight)
return true;

// If part doesn't have a training associated with it, abort
Expand Down Expand Up @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion Source/RP0/Crew/TrainingTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions Source/RP0/Harmony/EditorDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/RP0/Harmony/EditorLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
4 changes: 2 additions & 2 deletions Source/RP0/Harmony/EditorPartIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions Source/RP0/Harmony/EngineersReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions Source/RP0/Harmony/FundsWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
}
4 changes: 2 additions & 2 deletions Source/RP0/Harmony/KSCFacilityContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions Source/RP0/Harmony/KSCSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/RP0/Harmony/PartListTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions Source/RP0/Harmony/RDController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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"),
Expand All @@ -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<RDNodeListItem>();
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
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions Source/RP0/Harmony/RDNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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") + "</color>";
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Source/RP0/Harmony/RDTech.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading

0 comments on commit 4b65afe

Please sign in to comment.