From 66190e4db7aec60ae89fc56a8f5111c1e4e5da3cd59860e01960f3e730c0c40d Mon Sep 17 00:00:00 2001 From: copecone Date: Tue, 26 May 2026 22:39:23 +0900 Subject: [PATCH] Remove Endscreen Lantern Sound --- Patch/ClassPatch/EndscreenLanternsPatch.cs | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Patch/ClassPatch/EndscreenLanternsPatch.cs diff --git a/Patch/ClassPatch/EndscreenLanternsPatch.cs b/Patch/ClassPatch/EndscreenLanternsPatch.cs new file mode 100644 index 0000000..1bc1bc4 --- /dev/null +++ b/Patch/ClassPatch/EndscreenLanternsPatch.cs @@ -0,0 +1,73 @@ +using System.Diagnostics.CodeAnalysis; +using HarmonyLib; + +namespace ADOFAIRenderer.Patch.ClassPatch +{ + [HarmonyPatch(typeof(EndscreenLanterns))] + // ReSharper disable once InconsistentNaming + public static class EndscreenLanternsPatch + { + [HarmonyPrefix] + [HarmonyPatch("Show")] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool PrefixShow(EndscreenLanterns __instance, ref int __result) + { + if (!RenderMod.IsRendering) return true; + if (__instance != null) + { + __instance.Hide(); + } + __result = 0; // Return 0 lanterns shown + return false; // Skip original Show method + } + + [HarmonyPrefix] + [HarmonyPatch("Hide")] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public static void PrefixHide(EndscreenLanterns __instance) + { + if (__instance == null) return; + + var traverse = Traverse.Create(__instance); + + // Kill lampSequences (private Sequence[] lampSequences) via reflection + var lampSequencesField = traverse.Field("lampSequences"); + var lampSequencesObj = lampSequencesField.GetValue(); + if (lampSequencesObj is System.Array lampSequencesArray) + { + for (var i = 0; i < lampSequencesArray.Length; i++) + { + var item = lampSequencesArray.GetValue(i); + if (item == null) continue; + try + { + var killMethod = item.GetType().GetMethod("Kill", new[] { typeof(bool) }); + killMethod?.Invoke(item, new object[] { false }); + } + catch + { + // Ignore reflection errors + } + lampSequencesArray.SetValue(null, i); + } + } + + // Kill chainSequence (private Sequence chainSequence) via reflection + var chainSequenceField = traverse.Field("chainSequence"); + var chainSequenceObj = chainSequenceField.GetValue(); + if (chainSequenceObj == null) return; + { + try + { + var killMethod = chainSequenceObj.GetType().GetMethod("Kill", new[] { typeof(bool) }); + killMethod?.Invoke(chainSequenceObj, new object[] { false }); + } + catch + { + // Ignore reflection errors + } + chainSequenceField.SetValue(null); + } + } + } +}