Fix issues in Intervention (null vessel blackhole, missing null check in detail orb fix)

This commit is contained in:
Nick 2023-08-24 12:20:10 -04:00
parent f1292cbfe9
commit b0eac14fe3
2 changed files with 15 additions and 5 deletions

View File

@ -374,7 +374,7 @@ namespace NewHorizons.Builder.Props
else if (component is NomaiInterfaceOrb orb) else if (component is NomaiInterfaceOrb orb)
{ {
// detect planet gravity // detect planet gravity
var gravityVolume = planetGO.GetAttachedOWRigidbody().GetAttachedGravityVolume(); var gravityVolume = planetGO.GetAttachedOWRigidbody()?.GetAttachedGravityVolume();
orb.GetComponent<ConstantForceDetector>()._detectableFields = gravityVolume ? new ForceVolume[] { gravityVolume } : new ForceVolume[] { }; orb.GetComponent<ConstantForceDetector>()._detectableFields = gravityVolume ? new ForceVolume[] { gravityVolume } : new ForceVolume[] { };
} }

View File

@ -29,12 +29,22 @@ namespace NewHorizons.Patches.WarpPatches
[HarmonyPatch(nameof(VesselWarpController.CheckSystemActivation))] [HarmonyPatch(nameof(VesselWarpController.CheckSystemActivation))]
public static void VesselWarpController_CheckSystemActivation(VesselWarpController __instance) public static void VesselWarpController_CheckSystemActivation(VesselWarpController __instance)
{ {
if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") // Base method only manages the state of the source warp platform blackhole if the EyeStateManager isn't null
// However we place the vessel into other systems, so we want to handle the state in those locations as well
// For some reason the blackhole can also just be null in which case we ignore all this. Happens in Intervention 1.0.3
if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" && __instance._sourceWarpPlatform._blackHole != null)
{ {
if (!__instance._sourceWarpPlatform.IsBlackHoleOpen() && __instance._hasPower && __instance._warpPlatformPowerSlot.IsActivated() && __instance._targetWarpPlatform != null) var isBlackHoleOpen = __instance._sourceWarpPlatform.IsBlackHoleOpen();
__instance._sourceWarpPlatform.OpenBlackHole(__instance._targetWarpPlatform, true); var shouldBlackHoleBeOpen = __instance._hasPower && __instance._warpPlatformPowerSlot.IsActivated() && __instance._targetWarpPlatform != null;
else if (__instance._sourceWarpPlatform.IsBlackHoleOpen() && (!__instance._hasPower || !__instance._warpPlatformPowerSlot.IsActivated()))
if (isBlackHoleOpen && !shouldBlackHoleBeOpen)
{
__instance._sourceWarpPlatform.CloseBlackHole(); __instance._sourceWarpPlatform.CloseBlackHole();
}
else if (!isBlackHoleOpen && shouldBlackHoleBeOpen)
{
__instance._sourceWarpPlatform.OpenBlackHole(__instance._targetWarpPlatform, true);
}
} }
} }