new-horizons/NewHorizons/Patches/PlayerStatePatches.cs
JohnCorby 656ff16305 Revert "Reformat"
This reverts commit 7c0ba5597720f963432d8379a236e74f3508d077.
2022-05-22 18:41:34 -07:00

24 lines
949 B
C#

using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class PlayerStatePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerState), nameof(PlayerState.CheckShipOutsideSolarSystem))]
public static bool PlayerState_CheckShipOutsideSolarSystem(PlayerState __instance, ref bool __result)
{
if (PlayerState._inBrambleDimension) return false;
// Stop the game from trying to recall your ship when you're visiting far away planets
Transform sunTransform = Locator.GetSunTransform();
OWRigidbody shipBody = Locator.GetShipBody();
var maxDist2 = Mathf.Max(900000000f, Main.FurthestOrbit * Main.FurthestOrbit * 2f);
__result = sunTransform != null && shipBody != null && (sunTransform.position - shipBody.transform.position).sqrMagnitude > maxDist2;
return false;
}
}
}