From fb1b5997a69ca7168168be8e1787960a5c90eac2 Mon Sep 17 00:00:00 2001 From: siimav Date: Mon, 17 Jun 2024 18:56:35 +0300 Subject: [PATCH] Forcefully reset RA CommNet when upgrading TS --- Source/RP0/Utilities/KCTUtilities.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/RP0/Utilities/KCTUtilities.cs b/Source/RP0/Utilities/KCTUtilities.cs index 20816dd3eb5..45799d08780 100644 --- a/Source/RP0/Utilities/KCTUtilities.cs +++ b/Source/RP0/Utilities/KCTUtilities.cs @@ -1509,6 +1509,24 @@ public static void SetFacilityLevel(SpaceCenterFacility scf, int level) upgradable.configNode.SetValue("lvl", normLevel); // Note that OnKSCFacilityUpgrading and OnKSCFacilityUpgraded events are not fired through this code path + // Still, we need to let RA know that it needs a reset to account for the finished upgrade. + if (scf == SpaceCenterFacility.TrackingStation) + { + ClobberRACommnet(); + } + } + } + + private static void ClobberRACommnet() + { + var mInf = CommNetScenario.Instance?.GetType().GetMethod("ApplyTSLevelChange", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); + if (mInf != null) + { + mInf.Invoke(CommNetScenario.Instance, []); + } + else + { + RP0Debug.LogError($"Failed to call ApplyTSLevelChange() on RA CommNetScenario"); } } }