From 17416a2f14405201960153bb8b8ad1e0d6e948fc Mon Sep 17 00:00:00 2001 From: siimav Date: Sun, 24 Sep 2023 21:50:07 +0300 Subject: [PATCH] Make sure that LaunchedVessel information is available even when build times are disabled --- Source/RP0/Harmony/EditorLogic.cs | 21 +++++++++++++++++++++ Source/RP0/RP0.csproj | 3 ++- Source/RP0/SpaceCenter/KCTEvents.cs | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 Source/RP0/Harmony/EditorLogic.cs diff --git a/Source/RP0/Harmony/EditorLogic.cs b/Source/RP0/Harmony/EditorLogic.cs new file mode 100644 index 00000000000..5f7e053629b --- /dev/null +++ b/Source/RP0/Harmony/EditorLogic.cs @@ -0,0 +1,21 @@ +using HarmonyLib; + +namespace RP0.Harmony +{ + internal class PatchEditorLogic + { + [HarmonyPatch(typeof(EditorLogic))] + internal class PatchGoForLaunch + { + [HarmonyPrefix] + [HarmonyPatch("goForLaunch")] + 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; + } + } + } +} diff --git a/Source/RP0/RP0.csproj b/Source/RP0/RP0.csproj index e29487205de..8b43004299e 100644 --- a/Source/RP0/RP0.csproj +++ b/Source/RP0/RP0.csproj @@ -58,6 +58,7 @@ + @@ -413,4 +414,4 @@ --> - + \ No newline at end of file diff --git a/Source/RP0/SpaceCenter/KCTEvents.cs b/Source/RP0/SpaceCenter/KCTEvents.cs index 5569cf68bb6..71c94488b09 100644 --- a/Source/RP0/SpaceCenter/KCTEvents.cs +++ b/Source/RP0/SpaceCenter/KCTEvents.cs @@ -262,7 +262,8 @@ public void VesselSituationChange(GameEvents.HostedFromToAction vm is KCTVesselTracker) as KCTVesselTracker; if (dataModule != null && dataModule.Data.FacilityBuiltIn == EditorFacility.VAB && !dataModule.Data.HasStartedReconditioning)