-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates a new option into the vessel recovery dialog that allows queueing up a repair of all failures. Only available for VAB-built vessels while in prelaunch state. This operation is blocking (i.e cannot build another vessel at the same time in that LC) and takes 1/7.5 of rollout time. No additional cost other than what is paid for engineer salary.
- Loading branch information
Showing
14 changed files
with
404 additions
and
65 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using HarmonyLib; | ||
|
||
namespace RP0.Harmony | ||
{ | ||
[HarmonyPatch(typeof(FlightInputHandler))] | ||
internal class PatchFlightInputHandler | ||
{ | ||
/// <summary> | ||
/// Makes sure that throttle stays at 0 when repairs were done and vessel comes off rails. | ||
/// </summary> | ||
[HarmonyPostfix] | ||
[HarmonyPatch("SetLaunchCtrlState")] | ||
internal static void Postfix_SetLaunchCtrlState() | ||
{ | ||
bool b = SpaceCenterManagement.Instance?.DoingVesselRepair ?? false; | ||
if (b) | ||
{ | ||
FlightInputHandler.state.mainThrottle = 0; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace RP0 | ||
{ | ||
public static class TFInterop | ||
{ | ||
private static bool? _isTestFlightInstalled = null; | ||
private static bool? _hasSupportForReset = null; | ||
private static Assembly _assembly; | ||
private static MethodInfo _miGetVesselStatus; | ||
private static MethodInfo _miResetAllFailuresOnVessel; | ||
private static MethodInfo _miResetAllRunTimesOnVessel; | ||
|
||
public static bool IsTestFlightInstalled | ||
{ | ||
get | ||
{ | ||
EnsureReflectionInitialized(); | ||
return _isTestFlightInstalled.Value; | ||
} | ||
} | ||
public static bool HasSupportForReset | ||
{ | ||
get | ||
{ | ||
EnsureReflectionInitialized(); | ||
return _hasSupportForReset.Value; | ||
} | ||
} | ||
|
||
public static bool VesselHasFailedParts(Vessel v) | ||
{ | ||
if (v == null) return false; | ||
|
||
EnsureReflectionInitialized(); | ||
var res = (int)_miGetVesselStatus.Invoke(null, new object[] { v }); | ||
// 0 = OK, 1 = Has failure, -1 = Could not find TestFlight Core on Part | ||
return res > 0; | ||
} | ||
|
||
public static void ResetAllFailures(Vessel v) | ||
{ | ||
if (v == null) return; | ||
|
||
EnsureReflectionInitialized(); | ||
_miResetAllFailuresOnVessel.Invoke(null, new object[] { v }); | ||
_miResetAllRunTimesOnVessel.Invoke(null, new object[] { v }); | ||
} | ||
|
||
private static void EnsureReflectionInitialized() | ||
{ | ||
if (_isTestFlightInstalled.HasValue) return; | ||
|
||
_assembly = AssemblyLoader.loadedAssemblies.FirstOrDefault((AssemblyLoader.LoadedAssembly la) => string.Equals(la.name, "TestFlightCore", StringComparison.OrdinalIgnoreCase))?.assembly; | ||
_isTestFlightInstalled = _assembly != null; | ||
_hasSupportForReset = false; | ||
|
||
if (_isTestFlightInstalled.Value) | ||
{ | ||
var type = _assembly.GetType("TestFlightCore.TestFlightInterface"); | ||
_miGetVesselStatus = type.GetMethod("GetVesselStatus", BindingFlags.Public | BindingFlags.Static); | ||
_miResetAllFailuresOnVessel = type.GetMethod("ResetAllFailuresOnVessel", BindingFlags.Public | BindingFlags.Static); | ||
_miResetAllRunTimesOnVessel = type.GetMethod("ResetAllRunTimesOnVessel", BindingFlags.Public | BindingFlags.Static); | ||
_hasSupportForReset = _miResetAllRunTimesOnVessel != null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.