SHA256
Remove Endscreen Lantern Sound
This commit is contained in:
1 parent
15f7cd23d2
commit
66190e4db7
1 file changed
+73
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user