using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("zabuMod")] [assembly: AssemblyTitle("zabuMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace REPOJP.AutoMuteOn { [BepInPlugin("REPOJP.AutoMuteOn", "AutoMuteOn", "4.0.0")] public sealed class AutoMuteOnPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__16 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string reason; public AutoMuteOnPlugin <>4__this; private float 5__1; private int 5__2; private float 5__3; private int 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 1f; try { 5__1 = Mathf.Clamp(ApplyDelaySeconds.Value, 0f, 10f); } catch { 5__1 = 1f; } if (5__1 > 0f) { <>2__current = (object)new WaitForSeconds(5__1); <>1__state = 1; return true; } <>2__current = null; <>1__state = 2; return true; case 1: <>1__state = -1; goto IL_00d0; case 2: <>1__state = -1; goto IL_00d0; case 3: <>1__state = -1; goto IL_01f5; case 4: { <>1__state = -1; goto IL_01f5; } IL_01f5: 5__4++; break; IL_00d0: 5__2 = 20; 5__3 = 0.5f; try { 5__2 = Mathf.Clamp(ApplyRetryCount.Value, 1, 120); } catch { 5__2 = 20; } try { 5__3 = Mathf.Clamp(ApplyRetryIntervalSeconds.Value, 0.1f, 5f); } catch { 5__3 = 0.5f; } 5__4 = 0; break; } if (5__4 < 5__2 && ModEnabled != null && ModEnabled.Value) { if (!IsReadyForMainProcess()) { <>2__current = (object)new WaitForSeconds(5__3); <>1__state = 3; return true; } if (!TrySetToggleMute(value: true)) { <>2__current = (object)new WaitForSeconds(5__3); <>1__state = 4; return true; } WriteInfo("Auto mute applied reason=" + reason + " retry=" + 5__4); } <>4__this.applyCoroutine = null; 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(); } } public const string PluginGuid = "REPOJP.AutoMuteOn"; public const string PluginName = "AutoMuteOn"; public const string PluginVersion = "4.0.0"; internal static AutoMuteOnPlugin Instance; internal static ManualLogSource Log; internal static ConfigEntry ModEnabled; internal static ConfigEntry ApplyDelaySeconds; internal static ConfigEntry ApplyRetryCount; internal static ConfigEntry ApplyRetryIntervalSeconds; internal static ConfigEntry EnableLog; private Harmony harmony; private Coroutine applyCoroutine; private static FieldInfo toggleMuteField; private void Awake() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Instance = this; try { ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failure: Persist setup\n" + ex)); } ModEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable this mod. このMODを有効化"); ApplyDelaySeconds = ((BaseUnityPlugin)this).Config.Bind("General", "ApplyDelaySeconds", 1f, new ConfigDescription("Delay after level generation before applying toggle mute. レベル生成後にトグルミュートを適用するまでの待機秒数", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); ApplyRetryCount = ((BaseUnityPlugin)this).Config.Bind("General", "ApplyRetryCount", 20, new ConfigDescription("Retry count after level generation. レベル生成後の再試行回数", (AcceptableValueBase)(object)new AcceptableValueRange(1, 120), Array.Empty())); ApplyRetryIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind("General", "ApplyRetryIntervalSeconds", 0.5f, new ConfigDescription("Retry interval seconds after level generation. レベル生成後の再試行間隔秒数", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); EnableLog = ((BaseUnityPlugin)this).Config.Bind("Debug", "EnableLog", true, "Enable log output. ログ出力有効化"); harmony = new Harmony("REPOJP.AutoMuteOn"); harmony.PatchAll(); WriteInfo("Loaded AutoMuteOn v4.0.0 safe mode"); } private void OnDestroy() { if (applyCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(applyCoroutine); applyCoroutine = null; } try { if (harmony != null) { harmony.UnpatchSelf(); harmony = null; } } catch { } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void ScheduleApplyAfterLevelGenerated(string reason) { if (ModEnabled != null && ModEnabled.Value) { if (applyCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(applyCoroutine); applyCoroutine = null; } applyCoroutine = ((MonoBehaviour)this).StartCoroutine(CoApplyAfterLevelGenerated(reason)); } } [IteratorStateMachine(typeof(d__16))] private IEnumerator CoApplyAfterLevelGenerated(string reason) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__16(0) { <>4__this = this, reason = reason }; } private static bool IsReadyForMainProcess() { try { if ((Object)(object)LevelGenerator.Instance == (Object)null) { return false; } if (!LevelGenerator.Instance.Generated) { return false; } } catch { return false; } try { if ((Object)(object)RunManager.instance == (Object)null) { return false; } if ((Object)(object)StatsManager.instance == (Object)null) { return false; } if ((Object)(object)PunManager.instance == (Object)null) { return false; } } catch { return false; } try { if (SemiFunc.RunIsShop()) { return false; } } catch { } try { if (SemiFunc.RunIsLevel() || SemiFunc.RunIsArena() || SemiFunc.RunIsTutorial()) { return true; } } catch { return false; } return false; } private static bool TrySetToggleMute(bool value) { DataDirector val = null; try { val = DataDirector.instance; } catch { val = null; } if ((Object)(object)val == (Object)null) { return false; } FieldInfo fieldInfo = GetToggleMuteField(); if (fieldInfo == null) { WriteWarning("DataDirector.toggleMute field not found"); return false; } try { object value2 = fieldInfo.GetValue(val); bool flag = false; if (value2 is bool) { flag = (bool)value2; } if (flag != value) { fieldInfo.SetValue(val, value); } return true; } catch (Exception ex) { WriteError("Failure: Set toggleMute\n" + ex); return false; } } private static FieldInfo GetToggleMuteField() { if (toggleMuteField != null) { return toggleMuteField; } try { toggleMuteField = AccessTools.Field(typeof(DataDirector), "toggleMute"); } catch { toggleMuteField = null; } return toggleMuteField; } internal static void WriteInfo(string message) { if (Log != null && (EnableLog == null || EnableLog.Value)) { Log.LogInfo((object)message); } } internal static void WriteWarning(string message) { if (Log != null && (EnableLog == null || EnableLog.Value)) { Log.LogWarning((object)message); } } internal static void WriteError(string message) { if (Log != null && (EnableLog == null || EnableLog.Value)) { Log.LogError((object)message); } } } [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] internal static class LevelGenerator_GenerateDone_Patch { private static void Postfix() { try { if ((Object)(object)AutoMuteOnPlugin.Instance != (Object)null) { AutoMuteOnPlugin.Instance.ScheduleApplyAfterLevelGenerated("LevelGenerator.GenerateDone"); } } catch (Exception ex) { AutoMuteOnPlugin.WriteError("Failure: GenerateDone patch\n" + ex); } } } }