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 RadioVolumeAdjust v1.0.4
BepInEx/plugins/RadioVolumeAdjust.dll
Decompiled a month agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using RadioVolumeAdjust.Patches; 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("RadioVolumeAdjust")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7797a374f4c3a62ae8856cd535229a2a48536f8d")] [assembly: AssemblyProduct("RadioVolumeAdjust")] [assembly: AssemblyTitle("RadioVolumeAdjust")] [assembly: AssemblyVersion("1.0.0.0")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 RadioVolumeAdjust { [BepInPlugin("rusty.RadioVolumeAdjust", "RadioVolumeAdjust", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGuid = "rusty.RadioVolumeAdjust"; public const string ModName = "RadioVolumeAdjust"; public const string ModVersion = "1.0.4"; private const float Step = 0.1f; private const float MinVolume = 0.1f; public static float RadioVolume = 1f; public static ManualLogSource Log = null; public static RadioKeybinds Keys = null; private void Awake() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Keys = new RadioKeybinds(); Keys.VolumeUp.performed += delegate { Adjust(0.1f); }; Keys.VolumeDown.performed += delegate { Adjust(-0.1f); }; new Harmony("rusty.RadioVolumeAdjust").PatchAll(typeof(StartOfRoundPatch)); Log.LogInfo((object)"RadioVolumeAdjust loaded. PageUp / PageDown adjust radio volume (start: 100%)."); } private static void Adjust(float delta) { float num = Mathf.Clamp(Mathf.Round((RadioVolume + delta) * 10f) / 10f, 0.1f, 1f); if (!Mathf.Approximately(num, RadioVolume)) { RadioVolume = num; int num2 = Mathf.RoundToInt(RadioVolume * 100f); Log.LogInfo((object)$"Radio volume: {num2}%"); if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("Radio volume", $"{num2}%", false, false, "LC_Tip1"); } } } } public class RadioKeybinds : LcInputActions { [InputAction("<Keyboard>/pageUp", Name = "Radio volume +")] public InputAction VolumeUp { get; set; } [InputAction("<Keyboard>/pageDown", Name = "Radio volume -")] public InputAction VolumeDown { get; set; } } } namespace RadioVolumeAdjust.Patches { [HarmonyPatch(typeof(StartOfRound), "UpdatePlayerVoiceEffects")] internal static class StartOfRoundPatch { [HarmonyPostfix] private static void Postfix() { GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.localPlayerController == (Object)null) { return; } PlayerControllerB val = ((instance.localPlayerController.isPlayerDead && (Object)(object)instance.localPlayerController.spectatedPlayerScript != (Object)null) ? instance.localPlayerController.spectatedPlayerScript : instance.localPlayerController); float radioVolume = Plugin.RadioVolume; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((val2.isPlayerControlled || val2.isPlayerDead) && !((Object)(object)val2 == (Object)(object)instance.localPlayerController) && !val2.isPlayerDead && val2.voicePlayerState != null && !((Object)(object)val2.currentVoiceChatIngameSettings == (Object)null) && val2.currentVoiceChatIngameSettings._playerState != null && !((Object)(object)val2.currentVoiceChatAudioSource == (Object)null) && val2.speakingToWalkieTalkie && val.holdingWalkieTalkie && (Object)(object)val2 != (Object)(object)val) { float num = (instance.localPlayerController.isPlayerDead ? 0.8f : 1f); val2.voicePlayerState.Volume = num * radioVolume; } } } } }