Decompiled source of FocusedWalkieTalkieVoices v0.0.1

FocusedWalkieTalkieVoices.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using FocusedWalkieTalkieVoices.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FocusedWalkieTalkieVoices")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6f3942fbb4f4fac0d69c3c6ddd531ed3c9267a62")]
[assembly: AssemblyProduct("FocusedWalkieTalkieVoices")]
[assembly: AssemblyTitle("FocusedWalkieTalkieVoices")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace FocusedWalkieTalkieVoices
{
	[BepInPlugin("dummy.FocusedWalkieTalkieVoices", "dummy.FocusedWalkieTalkieVoices", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("dummy.FocusedWalkieTalkieVoices");

		public static Plugin instance;

		public ConfigEntry<float> focusedWalkieTalkieVolumeMultiplier;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			InitializeConfigValues();
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"FocusedWalkieTalkieVoices loaded");
		}

		private void InitializeConfigValues()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_005b: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			LethalConfigManager.SetModDescription("FocusedWalkieTalkieVoices");
			focusedWalkieTalkieVolumeMultiplier = ((BaseUnityPlugin)instance).Config.Bind<float>("FocusedWalkieTalkieVoices", "Volume Multiplier", 0.2f, "How loud other players are compared to players talking through your walkie-talkie. From 0.0 to 1.0.");
			FloatSliderOptions val = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = 1f;
			FloatSliderOptions val2 = val;
			FloatSliderConfigItem val3 = new FloatSliderConfigItem(focusedWalkieTalkieVolumeMultiplier, val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			focusedWalkieTalkieVolumeMultiplier.SettingChanged += delegate
			{
				StartOfRound.Instance.UpdatePlayerVoiceEffects();
			};
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)(message ?? ""));
		}

		public static void LogError(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogError((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "dummy.FocusedWalkieTalkieVoices";

		public const string PLUGIN_NAME = "FocusedWalkieTalkieVoices";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace FocusedWalkieTalkieVoices.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("UpdatePlayerVoiceEffects")]
		private static void ChangeVolumeWhileWalkieTalkie(PlayerControllerB[] ___allPlayerScripts)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			PlayerControllerB val = ((!GameNetworkManager.Instance.localPlayerController.isPlayerDead || !((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)) ? GameNetworkManager.Instance.localPlayerController : GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript);
			foreach (PlayerControllerB val2 in ___allPlayerScripts)
			{
				if ((!val2.isPlayerControlled && !val2.isPlayerDead) || (Object)(object)val2 == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					continue;
				}
				bool flag = val2.speakingToWalkieTalkie && val.holdingWalkieTalkie && (Object)(object)val2 != (Object)(object)val;
				if (GameNetworkManager.Instance.localPlayerController.isPlayerDead || !flag)
				{
					continue;
				}
				val2.voicePlayerState.Volume = 1f;
				foreach (PlayerControllerB val3 in ___allPlayerScripts)
				{
					if ((val3.isPlayerControlled || val3.isPlayerDead) && !((Object)(object)val3 == (Object)(object)GameNetworkManager.Instance.localPlayerController) && !val3.speakingToWalkieTalkie)
					{
						val3.voicePlayerState.Volume = Plugin.instance.focusedWalkieTalkieVolumeMultiplier.Value;
					}
				}
			}
		}
	}
}