Fix issue where you autopilot to the sun when in DB

This commit is contained in:
Nick J. Connors 2022-02-08 10:44:47 -05:00
parent 701f908798
commit 90cff5bfc2

View File

@ -68,9 +68,12 @@ namespace NewHorizons.Tools
public static bool CheckShipOutersideSolarSystem(PlayerState __instance, ref bool __result) public static bool CheckShipOutersideSolarSystem(PlayerState __instance, ref bool __result)
{ {
if (PlayerState._inBrambleDimension) return false;
Transform sunTransform = Locator.GetSunTransform(); Transform sunTransform = Locator.GetSunTransform();
OWRigidbody shipBody = Locator.GetShipBody(); OWRigidbody shipBody = Locator.GetShipBody();
__result = sunTransform != null && shipBody != null && (sunTransform.position - shipBody.transform.position).sqrMagnitude > Main.FurthestOrbit * Main.FurthestOrbit * 4f; var maxDist2 = Mathf.Max(900000000f, Main.FurthestOrbit * Main.FurthestOrbit * 2f);
__result = sunTransform != null && shipBody != null && (sunTransform.position - shipBody.transform.position).sqrMagnitude > maxDist2;
return false; return false;
} }