using 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 Microsoft.CodeAnalysis; using RadioVolumeAdjust.Patches; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("RadioVolumeAdjust")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+dfed63d06efa6fc8a32e12678d4ab0286f678c0e")] [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.0")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "rusty.RadioVolumeAdjust"; public const string ModName = "RadioVolumeAdjust"; public const string ModVersion = "1.0.0"; private const float Step = 0.1f; public static float RadioVolume = 1f; public static ManualLogSource Log = null; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("rusty.RadioVolumeAdjust").PatchAll(typeof(StartOfRoundPatch)); Log.LogInfo((object)"RadioVolumeAdjust loaded. PageUp / PageDown adjust radio volume (start: 100%)."); } private void Update() { if (Input.GetKeyDown((KeyCode)280)) { Adjust(0.1f); } if (Input.GetKeyDown((KeyCode)281)) { Adjust(-0.1f); } } private static void Adjust(float delta) { float num = Mathf.Clamp(Mathf.Round((RadioVolume + delta) * 10f) / 10f, 0f, 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"); } } } } } 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; } } } } }