From 6fc600553798d3896e3174501b503557f665102e Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 28 Jun 2023 16:42:08 -0400 Subject: [PATCH] Vio fixed Dreamworld fog --- .../DreamworldControllerPatches.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 NewHorizons/Patches/EchoesOfTheEyePatches/DreamworldControllerPatches.cs diff --git a/NewHorizons/Patches/EchoesOfTheEyePatches/DreamworldControllerPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/DreamworldControllerPatches.cs new file mode 100644 index 00000000..4119fd0a --- /dev/null +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/DreamworldControllerPatches.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using System.Collections.Generic; +using System.Reflection.Emit; +using UnityEngine; + +namespace NewHorizons.Patches.EchoesOfTheEyePatches +{ + [HarmonyPatch(typeof(DreamWorldController))] + public static class DreamworldControllerPatches + { + [HarmonyTranspiler] + [HarmonyPatch(nameof(DreamWorldController.FixedUpdate))] + [HarmonyPatch(nameof(DreamWorldController.SpawnInDreamWorld))] + public static IEnumerable DreamWorldController_SpawnInDreamworld(IEnumerable instructions) + { + // Thank you vio very cool! + // For some reason in Patch 13 they made it so the planetary fog controller is disabled in the Dreamworld + // This broke Hazy Dreams + return new CodeMatcher(instructions).MatchForward(false, + new CodeMatch(OpCodes.Ldarg_0), + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DreamWorldController), nameof(DreamWorldController._playerCamera))), + new CodeMatch(OpCodes.Callvirt, AccessTools.Property(typeof(OWCamera), nameof(OWCamera.planetaryFog)).GetGetMethod()), + new CodeMatch(OpCodes.Ldc_I4_0), + new CodeMatch(OpCodes.Callvirt, AccessTools.Property(typeof(Behaviour), nameof(Behaviour.enabled)).GetSetMethod()) + ) + .Repeat(matcher => matcher.RemoveInstructions(5)) + .InstructionEnumeration(); + } + } +}