Please disclose if your mod was created primarily 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 ToggleDeafen v1.1.1
ToggleDeafen.dll
Decompiled 2 years agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Dissonance; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using ToggleDeafen.Patches; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ToggleDeafen")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ToggleDeafen")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("de514037-3a9e-41af-98aa-fa75eaea9e6a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ToggleDeafen { public class Confige { public static ConfigEntry<bool> allowDeafenInTerminal; public static void Load() { allowDeafenInTerminal = ToggleDeafenBase.config.Bind<bool>("General", "Allow Deafen In Terminal", false, "Will you be able to use the toggle deafen hotkey while in the terminal or while typing in chat?"); } } public static class PluginInfo { public const string PLUGIN_GUID = "ToggleDeafen"; public const string PLUGIN_NAME = "ToggleDeafen"; public const string PLUGIN_VERSION = "1.0.0.0"; } [BepInPlugin("I0N.ToggleDeafen", "ToggleDeafen", "1.0.0.0")] public class ToggleDeafenBase : BaseUnityPlugin { private const string modGUID = "I0N.ToggleDeafen"; private const string modName = "ToggleDeafen"; private const string modVersion = "1.0.0.0"; public static ConfigFile config = new ConfigFile("BepInEx\\config\\ToggleDeafen.cfg", true); private readonly Harmony harmony = new Harmony("I0N.ToggleDeafen"); public static AssetBundle bundle; private static ToggleDeafenBase Instance; internal static ManualLogSource mls; private void Awake() { Instance = this; mls = Logger.CreateLogSource("ToggleDeafen"); Confige.Load(); bundle = QuickLoadAssetBundle("toggledeafen.assets"); harmony.PatchAll(Assembly.GetExecutingAssembly()); harmony.PatchAll(typeof(VoiceChatPatch)); } public static AssetBundle QuickLoadAssetBundle(string assetBundleName) { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetBundleName); return AssetBundle.LoadFromFile(text); } } [HarmonyPatch(typeof(HUDManager), "Awake")] internal class HUDPatch { [HarmonyPostfix] private static void Postfix() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) ToggleDeafenManager instance = ToggleDeafenManager.instance; instance.DeafenedImagePrefab = ToggleDeafenBase.bundle.LoadAsset<GameObject>("assets/image.prefab"); Transform transform = new GameObject("ToggleDeafenUI").transform; transform.SetParent(HUDManager.Instance.HUDContainer.transform.parent, false); instance.DeafenedImage = Object.Instantiate<GameObject>(instance.DeafenedImagePrefab, Vector3.zero, Quaternion.identity); instance.DeafenedImage.transform.SetParent(transform, false); instance.DeafenedImage.transform.localPosition = new Vector3(-390f, -230f, 6.5f); instance.DeafenedImage.SetActive(false); } } [HarmonyPatch(typeof(IngamePlayerSettings), "Awake")] internal class PlayerSettingsPatch { internal static ManualLogSource mls; [HarmonyPostfix] private static void Postfix(ref IngamePlayerSettings __instance) { ToggleDeafenManager toggleDeafenManager = null; if (!((Component)__instance).gameObject.TryGetComponent<ToggleDeafenManager>(ref toggleDeafenManager)) { ToggleDeafenManager toggleDeafenManager2 = ((Component)__instance).gameObject.AddComponent<ToggleDeafenManager>(); toggleDeafenManager2.playerSettings = __instance; } } public void Awake() { mls = Logger.CreateLogSource("Whateva"); mls.LogInfo((object)"It's alive!"); } } public class ToggleDeafenInputActions : LcInputActions { public static ToggleDeafenInputActions Instance = new ToggleDeafenInputActions(); [InputAction(/*Could not decode attribute arguments.*/)] public InputAction ToggleDeafenKey { get; set; } } public class ToggleDeafenManager : MonoBehaviour { public IngamePlayerSettings playerSettings; public GameObject DeafenedImagePrefab; public GameObject DeafenedImage; public bool Deafened; public static ToggleDeafenManager instance; internal static ManualLogSource mls; public void Awake() { instance = this; ToggleDeafenInputActions.Instance.ToggleDeafenKey.performed += OnToggleDeafenKeyPressed; mls = Logger.CreateLogSource("Manager"); mls.LogInfo((object)"Manager awakens!"); } public void OnDestroy() { ToggleDeafenInputActions.Instance.ToggleDeafenKey.performed -= OnToggleDeafenKeyPressed; } private void OnToggleDeafenKeyPressed(CallbackContext ctx) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown if (!((CallbackContext)(ref ctx)).performed || !Object.op_Implicit((Object)(object)playerSettings) || !Object.op_Implicit((Object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.voiceChatModule) || !Application.isFocused) { return; } if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance)) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (Object.op_Implicit((Object)localPlayerController) && !Confige.allowDeafenInTerminal.Value && (localPlayerController.inTerminalMenu || localPlayerController.isTypingChat)) { return; } } Deafened = !Deafened; IngamePlayerSettings.Instance.settings.micEnabled = !instance.Deafened; IngamePlayerSettings.Instance.SetMicrophoneEnabled(); } public void Update() { if ((Object)(object)DeafenedImage != (Object)null && Object.op_Implicit((Object)(object)playerSettings)) { DeafenedImage.SetActive(Deafened); } } } } namespace ToggleDeafen.Patches { [HarmonyPatch(typeof(DissonanceComms), "Update")] internal class VoiceChatPatch { [HarmonyPostfix] public static void PostFix(ref DissonanceComms __instance) { ToggleDeafenManager instance = ToggleDeafenManager.instance; if (instance.Deafened) { __instance.RemoteVoiceVolume = 0f; IngamePlayerSettings.Instance.settings.micEnabled = false; } else { __instance.RemoteVoiceVolume = 1f; instance.Deafened = false; } } } }