From 6c71efa6b32b422f622f69fb9d3e8cd6be76e5f0 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..e88d2d64f3c 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, new object[0]); + } + else + { + RP0Debug.LogError($"Failed to call ApplyTSLevelChange() on RA CommNetScenario"); } } }