Move mods to Depricated folder.

This commit is contained in:
NotAKidoS 2023-07-26 11:30:19 -05:00
parent e61f119f32
commit 5d1cb2ebec
70 changed files with 44 additions and 119 deletions

View file

@ -1,11 +1,14 @@
using ABI_RC.Core.Base;
using MelonLoader;
using System.Reflection;
using HarmonyLib;
namespace NAK.MuteSFX;
public class MuteSFX : MelonMod
{
#region Mod Settings
internal static MelonLogger.Instance Logger;
internal const string SettingsCategory = nameof(MuteSFX);
@ -15,21 +18,39 @@ public class MuteSFX : MelonMod
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
Category.CreateEntry("Enabled", true, description: "Toggle MuteSFX entirely.");
#endregion
#region Melon Initialization
public override void OnInitializeMelon()
{
Logger = LoggerInstance;
HarmonyInstance.Patch(
typeof(Audio).GetMethod(nameof(Audio.SetMicrophoneActive)),
postfix: new HarmonyLib.HarmonyMethod(typeof(MuteSFX).GetMethod(nameof(OnSetMicrophoneActive_Postfix), BindingFlags.NonPublic | BindingFlags.Static))
typeof(AudioManagement).GetMethod(nameof(AudioManagement.SetMicrophoneActive)),
postfix: new HarmonyMethod(typeof(MuteSFX).GetMethod(nameof(OnSetMicrophoneActive_Postfix), BindingFlags.NonPublic | BindingFlags.Static))
);
AudioModuleManager.SetupDefaultAudioClips();
}
private static void OnSetMicrophoneActive_Postfix(bool muted)
#endregion
#region Patched Methods
private static void OnSetMicrophoneActive_Postfix(bool active)
{
if (EntryEnabled.Value)
AudioModuleManager.PlayAudioModule(muted ? AudioModuleManager.sfx_mute : AudioModuleManager.sfx_unmute);
try
{
if (EntryEnabled.Value)
AudioModuleManager.PlayAudioModule(active ? AudioModuleManager.sfx_unmute : AudioModuleManager.sfx_mute);
}
catch (Exception e)
{
Logger.Error($"Error during the patched method {nameof(OnSetMicrophoneActive_Postfix)}");
Logger.Error(e);
}
}
#endregion
}