mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
24 lines
949 B
C#
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;
|
|
}
|
|
}
|
|
}
|