Skip to content

Commit

Permalink
Make sure that LaunchedVessel information is available even when buil…
Browse files Browse the repository at this point in the history
…d times are disabled
  • Loading branch information
siimav committed Sep 24, 2023
1 parent 3be3276 commit 17416a2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
21 changes: 21 additions & 0 deletions Source/RP0/Harmony/EditorLogic.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
3 changes: 2 additions & 1 deletion Source/RP0/RP0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Compile Include="Crew\TrainingCourse.cs" />
<Compile Include="Crew\TrainingTemplate.cs" />
<Compile Include="Harmony\CrewTransfer.cs" />
<Compile Include="Harmony\EditorLogic.cs" />
<Compile Include="Harmony\KerbalEVA.cs" />
<Compile Include="Settings\CrewSettings.cs" />
<Compile Include="Crew\TrainingDatabase.cs" />
Expand Down Expand Up @@ -413,4 +414,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
3 changes: 2 additions & 1 deletion Source/RP0/SpaceCenter/KCTEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ public void VesselSituationChange(GameEvents.HostedFromToAction<Vessel, Vessel.S
{
if (ev.from == Vessel.Situations.PRELAUNCH && ev.host == FlightGlobals.ActiveVessel)
{
if (PresetManager.Instance.ActivePreset.GeneralSettings.Enabled)
KCT_Preset_General settings = PresetManager.Instance.ActivePreset.GeneralSettings;
if (settings.Enabled && settings.BuildTimes)
{
var dataModule = FlightGlobals.ActiveVessel.vesselModules.Find(vm => vm is KCTVesselTracker) as KCTVesselTracker;
if (dataModule != null && dataModule.Data.FacilityBuiltIn == EditorFacility.VAB && !dataModule.Data.HasStartedReconditioning)
Expand Down

0 comments on commit 17416a2

Please sign in to comment.