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 NoiseSuppressionPlus v1.0.1
NoiseSuppressionPlus.dll
Decompiled 3 days agousing System; 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 Dissonance.Audio.Capture; using Dissonance.Config; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NoiseSuppressionPlus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Toggle noise suppression, adjust suppression strength, and cycle mic sensitivity in Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NoiseSuppressionPlus")] [assembly: AssemblyTitle("NoiseSuppressionPlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 NoiseSuppressionPlus { internal class InputActions : LcInputActions { public static InputActions Instance { get; private set; } [InputAction("<Keyboard>/minus", Name = "Toggle Noise Suppression")] public InputAction ToggleNoiseSuppressionKey { get; set; } [InputAction("<Keyboard>/equals", Name = "Cycle Mic Sensitivity")] public InputAction CycleMicrophoneSensitivityKey { get; set; } [InputAction("<Keyboard>/rightBracket", Name = "Increase Suppression Amount")] public InputAction IncreaseSuppressionAmountKey { get; set; } [InputAction("<Keyboard>/leftBracket", Name = "Decrease Suppression Amount")] public InputAction DecreaseSuppressionAmountKey { get; set; } public InputActions() { Instance = this; } } [BepInPlugin("NoiseSuppressionPlus", "NoiseSuppressionPlus", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private InputActions _inputActions; private static VadSensitivityLevels[] _sensitivityLevels; private static int _currentSensitivityIndex; private static bool _logOutput; private unsafe void Awake() { _logOutput = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogOutput", false, "Enable verbose logging to the BepInEx console for diagnosing issues").Value; ConfigEntry<string> val = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "ToggleKey", "<Keyboard>/minus", "Keybind for toggling noise suppression (Unity Input System path)"); ConfigEntry<string> val2 = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "CycleKey", "<Keyboard>/equals", "Keybind for cycling mic sensitivity"); ConfigEntry<string> val3 = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "IncreaseKey", "<Keyboard>/rightBracket", "Keybind for increasing suppression amount"); ConfigEntry<string> val4 = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "DecreaseKey", "<Keyboard>/leftBracket", "Keybind for decreasing suppression amount"); VadSensitivityLevels[] array = new VadSensitivityLevels[4]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); _sensitivityLevels = (VadSensitivityLevels[])(object)array; ConfigEntry<string> savedSensitivity = ((BaseUnityPlugin)this).Config.Bind<string>("Sensitivity", "SensitivityLevel", "MediumSensitivity", (ConfigDescription)null); _currentSensitivityIndex = Array.FindIndex(_sensitivityLevels, (VadSensitivityLevels l) => ((object)(*(VadSensitivityLevels*)(&l))/*cast due to .constrained prefix*/).ToString() == savedSensitivity.Value); if (_currentSensitivityIndex < 0) { _currentSensitivityIndex = 0; } float num = ClampSuppression(SnapToFive(((BaseUnityPlugin)this).Config.Bind<float>("Suppression", "BackgroundSoundRemovalAmount", 65f, (ConfigDescription)null).Value)); VoiceSettings.Instance.BackgroundSoundRemovalAmount = num / 100f; _inputActions = new InputActions(); ApplyKeybindOverride(_inputActions.ToggleNoiseSuppressionKey, val.Value, "<Keyboard>/minus"); ApplyKeybindOverride(_inputActions.CycleMicrophoneSensitivityKey, val2.Value, "<Keyboard>/equals"); ApplyKeybindOverride(_inputActions.IncreaseSuppressionAmountKey, val3.Value, "<Keyboard>/rightBracket"); ApplyKeybindOverride(_inputActions.DecreaseSuppressionAmountKey, val4.Value, "<Keyboard>/leftBracket"); if (_logOutput) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("NoiseSuppressionPlus initialized. Keybinds: Toggle=" + val.Value + " Cycle=" + val2.Value + " Increase=" + val3.Value + " Decrease=" + val4.Value)); } _inputActions.ToggleNoiseSuppressionKey.performed += delegate { if (CanModifyAudio()) { VoiceSettings.Instance.BackgroundSoundRemovalEnabled = !VoiceSettings.Instance.BackgroundSoundRemovalEnabled; ShowNotification("Noise Suppression", VoiceSettings.Instance.BackgroundSoundRemovalEnabled ? "Enabled" : "Disabled", !VoiceSettings.Instance.BackgroundSoundRemovalEnabled); } }; _inputActions.CycleMicrophoneSensitivityKey.performed += delegate { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (CanModifyAudio()) { _currentSensitivityIndex = (_currentSensitivityIndex + 1) % _sensitivityLevels.Length; VadSensitivityLevels val5 = _sensitivityLevels[_currentSensitivityIndex]; VoiceSettings.Instance.VadSensitivity = val5; ShowNotification("Mic Sensitivity", FormatSensitivityName(val5), isWarning: false); } }; _inputActions.IncreaseSuppressionAmountKey.performed += delegate { if (CanModifyAudio()) { float value = VoiceSettings.Instance.BackgroundSoundRemovalAmount * 100f; value = SnapToFive(value); value = ClampSuppression(value + 5f); VoiceSettings.Instance.BackgroundSoundRemovalAmount = value / 100f; ShowNotification("Suppression Amount", $"{value:F0}%", isWarning: false); } }; _inputActions.DecreaseSuppressionAmountKey.performed += delegate { if (CanModifyAudio()) { float value = VoiceSettings.Instance.BackgroundSoundRemovalAmount * 100f; value = SnapToFive(value); value = ClampSuppression(value - 5f); VoiceSettings.Instance.BackgroundSoundRemovalAmount = value / 100f; ShowNotification("Suppression Amount", $"{value:F0}%", isWarning: false); } }; } private void OnDestroy() { VoiceSettings.Instance.BackgroundSoundRemovalEnabled = false; } private static bool CanModifyAudio() { if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null) { return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null; } return false; } private static void ShowNotification(string header, string body, bool isWarning) { if (!((Object)(object)HUDManager.Instance == (Object)null)) { HUDManager.Instance.DisplayTip(header, body, isWarning, false, ""); } } private static void ApplyKeybindOverride(InputAction action, string configValue, string defaultValue) { if (!(configValue == defaultValue)) { InputActionRebindingExtensions.ApplyBindingOverride(action, 0, configValue); } } private static float SnapToFive(float value) { return Mathf.Round(value / 5f) * 5f; } private static float ClampSuppression(float value) { if (value < 10f) { return 10f; } if (value > 100f) { return 100f; } return value; } private unsafe static string FormatSensitivityName(VadSensitivityLevels level) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown return (int)level switch { 0 => "Low", 1 => "Medium", 2 => "High", 3 => "Very High", _ => ((object)(*(VadSensitivityLevels*)(&level))/*cast due to .constrained prefix*/).ToString(), }; } } public static class PluginInfo { public const string PLUGIN_GUID = "NoiseSuppressionPlus"; public const string PLUGIN_NAME = "NoiseSuppressionPlus"; public const string PLUGIN_VERSION = "1.0.0"; } }