Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KeepOpenMicOnDeath v1.0.0
REPOmorescreams.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("REPOmorescreams")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("REPOmorescreams")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("19061d09-6376-4345-8920-243b02125e76")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.yourname.keepopenmic.repo", "Keep Open Mic on Death (REPO)", "1.0.0")] public class KeepOpenMicOnDeath_REPO : BaseUnityPlugin { [CompilerGenerated] private sealed class <KeepMicOpen>d__4 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public object player; public KeepOpenMicOnDeath_REPO <>4__this; private object <voiceChat>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <KeepMicOpen>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <voiceChat>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <voiceChat>5__1 = player.GetType().GetField("voiceChat", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(player); if (<voiceChat>5__1 != null && unmuteVoiceMethod != null) { unmuteVoiceMethod.Invoke(<voiceChat>5__1, null); } <>2__current = (object)new WaitForSeconds(10f); <>1__state = 1; return true; case 1: <>1__state = -1; if (<voiceChat>5__1 != null && muteVoiceMethod != null) { muteVoiceMethod.Invoke(<voiceChat>5__1, null); Debug.Log((object)"Mic closed after 10 seconds."); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static MethodInfo muteVoiceMethod; private static MethodInfo unmuteVoiceMethod; public static KeepOpenMicOnDeath_REPO Instance; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Instance = this; Harmony val = new Harmony("com.yourname.keepopenmic.repo"); val.PatchAll(); Type type = AccessTools.TypeByName("PlayerVoiceChat"); if (type != null) { muteVoiceMethod = AccessTools.Method(type, "Mute", (Type[])null, (Type[])null); unmuteVoiceMethod = AccessTools.Method(type, "Unmute", (Type[])null, (Type[])null); } } [IteratorStateMachine(typeof(<KeepMicOpen>d__4))] public IEnumerator KeepMicOpen(object player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <KeepMicOpen>d__4(0) { <>4__this = this, player = player }; } } [HarmonyPatch(typeof(PlayerHealth), "Hurt")] internal class Patch_PlayerHealth_Hurt { private static void Postfix(PlayerHealth __instance, int damage, bool savingGrace, int enemyIndex) { object obj = ((object)__instance).GetType().GetField("health", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance); if (obj is int) { int num = (int)obj; if (num <= 0) { ((MonoBehaviour)KeepOpenMicOnDeath_REPO.Instance).StartCoroutine(KeepOpenMicOnDeath_REPO.Instance.KeepMicOpen(__instance)); } } } }