mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Revert "REMOVE proxy body patches (vanillafix does it)"
This reverts commit b7f436b7833ad071863367fb12760e16c4a975a5.
This commit is contained in:
parent
d64ab19b49
commit
7db456f871
122
NewHorizons/Patches/ProxyBodyPatches.cs
Normal file
122
NewHorizons/Patches/ProxyBodyPatches.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class ProxyBodyPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.Awake))]
|
||||
public static void ProxyBody_Awake(ProxyBody __instance)
|
||||
{
|
||||
// Mobius rly used the wrong event name
|
||||
GlobalMessenger.AddListener("EnterMapView", __instance.OnEnterMapView);
|
||||
GlobalMessenger.AddListener("ExitMapView", __instance.OnExitMapView);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.OnDestroy))]
|
||||
public static void ProxyBody_OnDestroy(ProxyBody __instance)
|
||||
{
|
||||
GlobalMessenger.RemoveListener("EnterMapView", __instance.OnEnterMapView);
|
||||
GlobalMessenger.RemoveListener("ExitMapView", __instance.OnExitMapView);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.OnEnterMapView))]
|
||||
public static void ProxyBody_OnEnterMapView(ProxyBody __instance)
|
||||
{
|
||||
// Set this to false before the method sets the rendering to false so it matches
|
||||
__instance._outOfRange = false;
|
||||
}
|
||||
|
||||
// Mobius why doesn't ProxyOrbiter inherit from ProxyBody
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyOrbiter), nameof(ProxyOrbiter.Awake))]
|
||||
public static void ProxyOrbiter_Awake(ProxyOrbiter __instance)
|
||||
{
|
||||
// Mobius rly used the wrong event name
|
||||
GlobalMessenger.AddListener("EnterMapView", __instance.OnEnterMapView);
|
||||
GlobalMessenger.AddListener("ExitMapView", __instance.OnExitMapView);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyOrbiter), nameof(ProxyOrbiter.OnDestroy))]
|
||||
public static void ProxyOrbiter_OnDestroy(ProxyOrbiter __instance)
|
||||
{
|
||||
GlobalMessenger.RemoveListener("EnterMapView", __instance.OnEnterMapView);
|
||||
GlobalMessenger.RemoveListener("ExitMapView", __instance.OnExitMapView);
|
||||
}
|
||||
|
||||
[HarmonyReversePatch]
|
||||
[HarmonyPatch(typeof(ProxyPlanet), nameof(ProxyPlanet.Initialize))]
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void ProxyPlanet_Initialize(ProxyPlanet instance) { }
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyBrittleHollow), nameof(ProxyBrittleHollow.Initialize))]
|
||||
public static bool ProxyBrittleHollow_Initialize(ProxyBrittleHollow __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProxyPlanet_Initialize(__instance);
|
||||
__instance._moon.SetOriginalBodies(Locator.GetAstroObject(AstroObject.Name.VolcanicMoon).transform, Locator.GetAstroObject(AstroObject.Name.BrittleHollow).transform);
|
||||
if (!__instance._fragmentsResolved) __instance.ResolveFragments();
|
||||
__instance._blackHoleMaterial = new Material(__instance._blackHoleRenderer.sharedMaterial);
|
||||
__instance._blackHoleRenderer.sharedMaterial = __instance._blackHoleMaterial;
|
||||
}
|
||||
catch (NullReferenceException ex)
|
||||
{
|
||||
__instance.PrintInitializeFailMessage(ex);
|
||||
UnityEngine.Object.Destroy(__instance._moon.gameObject);
|
||||
UnityEngine.Object.Destroy(__instance.gameObject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyTimberHearth), nameof(ProxyTimberHearth.Initialize))]
|
||||
public static bool ProxyTimberHearth_Initialize(ProxyTimberHearth __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProxyPlanet_Initialize(__instance);
|
||||
__instance._moon.SetOriginalBodies(Locator.GetAstroObject(AstroObject.Name.TimberMoon).transform, Locator.GetAstroObject(AstroObject.Name.TimberHearth).transform);
|
||||
}
|
||||
catch (NullReferenceException ex)
|
||||
{
|
||||
__instance.PrintInitializeFailMessage(ex);
|
||||
UnityEngine.Object.Destroy(__instance._moon.gameObject);
|
||||
UnityEngine.Object.Destroy(__instance.gameObject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyAshTwin), nameof(ProxyAshTwin.Initialize))]
|
||||
public static bool ProxyAshTwin_Initialize(ProxyAshTwin __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProxyPlanet_Initialize(__instance);
|
||||
__instance._realSandTransform = Locator.GetAstroObject(AstroObject.Name.TowerTwin).GetSandLevelController().transform;
|
||||
SandFunnelController sandFunnelController = SearchUtilities.Find("SandFunnel_Body", false)?.GetComponent<SandFunnelController>();
|
||||
if (sandFunnelController != null)
|
||||
{
|
||||
__instance._realSandColumnRoot = sandFunnelController.scaleRoot;
|
||||
__instance._realSandColumnRenderObject = sandFunnelController.sandGeoObjects[0];
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException ex)
|
||||
{
|
||||
__instance.PrintInitializeFailMessage(ex);
|
||||
UnityEngine.Object.Destroy(__instance.gameObject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user