Decompiled source of BetterVoiceRange v1.1.0

BetterVoiceRange.dll

Decompiled 2 weeks ago
using 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 HarmonyLib;
using Microsoft.CodeAnalysis;

[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("BetterVoiceRange")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+68fa89fb81041052aed6aa3934980ac9aa80e123")]
[assembly: AssemblyProduct("BetterVoiceRange")]
[assembly: AssemblyTitle("BetterVoiceRange")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BetterVoiceRange
{
	[BepInPlugin("BetterVoiceRange", "BetterVoiceRange", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		private static ConfigEntry<float> lowPassFallOffMultiplier;

		private static ConfigEntry<float> lowPassVolumeMultiplier;

		private static FieldInfo inLobbyMixerField;

		private static FieldInfo lowPassLogicField;

		private static FieldInfo falloffMultiplierField;

		private static FieldInfo volumeMultiplierField;

		private void Awake()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			lowPassFallOffMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "LowPassFallOffMultiplier", 1f, new ConfigDescription("This is the important value. It's the multiplier applied to voice volume over distance through walls. The higher it is, the greater the voice range. Original game value: 0.8.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			lowPassVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "LowPassVolumeMultiplier", 0.5f, new ConfigDescription("Multiplier applied to the voice volume when behind walls. Original game value: 0.5.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			Type typeFromHandle = typeof(PlayerVoiceChat);
			inLobbyMixerField = typeFromHandle.GetField("inLobbyMixer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			lowPassLogicField = typeFromHandle.GetField("lowPassLogic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Type typeFromHandle2 = typeof(AudioLowPassLogic);
			falloffMultiplierField = typeFromHandle2.GetField("FalloffMultiplier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			volumeMultiplierField = typeFromHandle2.GetField("VolumeMultiplier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Harmony val = new Harmony("BetterVoiceRange");
			val.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(PlayerVoiceChat), "Update")]
		[HarmonyPostfix]
		private static void Update(PlayerVoiceChat __instance)
		{
			if (!(bool)inLobbyMixerField?.GetValue(__instance))
			{
				object? obj = lowPassLogicField?.GetValue(__instance);
				AudioLowPassLogic obj2 = (AudioLowPassLogic)((obj is AudioLowPassLogic) ? obj : null);
				falloffMultiplierField.SetValue(obj2, lowPassFallOffMultiplier.Value);
				volumeMultiplierField.SetValue(obj2, lowPassVolumeMultiplier.Value);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BetterVoiceRange";

		public const string PLUGIN_NAME = "BetterVoiceRange";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}