From b7f436b7833ad071863367fb12760e16c4a975a5 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 25 Aug 2022 20:05:17 -0700 Subject: [PATCH 1/5] REMOVE proxy body patches (vanillafix does it) --- NewHorizons/Patches/ProxyBodyPatches.cs | 122 ------------------------ 1 file changed, 122 deletions(-) delete mode 100644 NewHorizons/Patches/ProxyBodyPatches.cs diff --git a/NewHorizons/Patches/ProxyBodyPatches.cs b/NewHorizons/Patches/ProxyBodyPatches.cs deleted file mode 100644 index 804c6682..00000000 --- a/NewHorizons/Patches/ProxyBodyPatches.cs +++ /dev/null @@ -1,122 +0,0 @@ -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(); - 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; - } - } -} From d64ab19b498fa37e2e16df716dc8db8a5559dad5 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 25 Aug 2022 20:06:20 -0700 Subject: [PATCH 2/5] add dependency --- NewHorizons/manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 98464e2b..79681373 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -6,6 +6,7 @@ "uniqueName": "xen.NewHorizons", "version": "1.4.4", "owmlVersion": "2.6.0", + "dependencies": [ "JohnCorby.VanillaFix" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ], "pathsToPreserve": [ "planets", "systems", "translations" ] } From 7db456f8711fd2795bbcb04dc391d286d53c726c Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 25 Aug 2022 20:09:59 -0700 Subject: [PATCH 3/5] Revert "REMOVE proxy body patches (vanillafix does it)" This reverts commit b7f436b7833ad071863367fb12760e16c4a975a5. --- NewHorizons/Patches/ProxyBodyPatches.cs | 122 ++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 NewHorizons/Patches/ProxyBodyPatches.cs diff --git a/NewHorizons/Patches/ProxyBodyPatches.cs b/NewHorizons/Patches/ProxyBodyPatches.cs new file mode 100644 index 00000000..804c6682 --- /dev/null +++ b/NewHorizons/Patches/ProxyBodyPatches.cs @@ -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(); + 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; + } + } +} From fe13757d8758c03045965f120a2567a5863fb41c Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 25 Aug 2022 20:10:27 -0700 Subject: [PATCH 4/5] okay just remove the ones fixed by vanillafix lol --- NewHorizons/Patches/ProxyBodyPatches.cs | 43 ------------------------- 1 file changed, 43 deletions(-) diff --git a/NewHorizons/Patches/ProxyBodyPatches.cs b/NewHorizons/Patches/ProxyBodyPatches.cs index 804c6682..af5a391f 100644 --- a/NewHorizons/Patches/ProxyBodyPatches.cs +++ b/NewHorizons/Patches/ProxyBodyPatches.cs @@ -9,49 +9,6 @@ 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)] From be23815c90d224809801a66c77d271bb024bb6da Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 25 Aug 2022 20:23:10 -0700 Subject: [PATCH 5/5] ALSO remove the OWCollider --- NewHorizons/Builder/Body/ProxyBuilder.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 077a4f8f..29edfc26 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -161,10 +161,8 @@ namespace NewHorizons.Builder.Body } // Remove all collisions if there are any - foreach (var col in newProxy.GetComponentsInChildren()) - { - GameObject.Destroy(col); - } + foreach (var col in newProxy.GetComponentsInChildren()) GameObject.Destroy(col); + foreach (var col in newProxy.GetComponentsInChildren()) GameObject.Destroy(col); foreach (var renderer in newProxy.GetComponentsInChildren()) {