Fix sun proxy breaking

This commit is contained in:
Nick 2023-08-23 12:05:18 -04:00
parent 13c2b8badc
commit e8d7307bb3
2 changed files with 21 additions and 1 deletions

View File

@ -201,7 +201,8 @@ namespace NewHorizons.Components.Stars
transform.localPosition = Vector3.zero; transform.localPosition = Vector3.zero;
// Some effects use Locator.GetSunTransform so hopefully its fine to change it // Some effects use Locator.GetSunTransform so hopefully its fine to change it
Locator._sunTransform = transform; // Use the root transform of the star because that's the default behaviour, breaks SunProxy is not (potentially others)
Locator._sunTransform = star.transform;
// TODO?: maybe also turn off star controller stuff (mainly proxy light) since idk if that can handle more than 1 being on // TODO?: maybe also turn off star controller stuff (mainly proxy light) since idk if that can handle more than 1 being on
} }

View File

@ -0,0 +1,19 @@
using HarmonyLib;
using NewHorizons.Utility;
namespace NewHorizons.Patches.ProxyPatches
{
[HarmonyPatch(typeof(SunProxy))]
public static class SunProxyPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(SunProxy.Start))]
public static void SunProxy_Start(SunProxy __instance)
{
// We mess with the Locator.GetSunTransform() value to switch it to other relevant stars since it's used for some other effects
// However if it's set to a different star when the SunProxy starts it breaks, so we double check it here
__instance._sunTransform = SearchUtilities.Find("Sun_Body").transform;
__instance._realSunController = __instance._sunTransform.GetComponent<SunController>();
}
}
}