Decompiled source of REPO Volume v0.0.1

REPO.Volume/REPO.Volume.dll

Decompiled 4 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("968aef2c-fbf4-48c0-9e34-6cd8df3f024f")]
[assembly: AssemblyFileVersion("1.3.3.7")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.3.3.7")]
namespace REPO.Volume
{
	[BepInPlugin("REPO.Volume.Hurensohn", "REPO.Volume", "1.0.0")]
	public class Volume : BaseUnityPlugin
	{
		internal static ManualLogSource log;

		private const string Version = "1.0.0";

		private const string Name = "REPO.Volume";

		private const string GUID = "REPO.Volume.Hurensohn";

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			log = ((BaseUnityPlugin)this).Logger;
			new Harmony("REPO.Volume.Hurensohn").PatchAll();
			log.LogInfo((object)"REPO.Volume Loaded.");
		}
	}
}
namespace REPO.Volume.Extender
{
	[HarmonyPatch(typeof(PlayerVoiceChat), "Update")]
	internal static class Boost
	{
		private static readonly FieldRef<PlayerVoiceChat, AudioSource> source = AccessTools.FieldRefAccess<PlayerVoiceChat, AudioSource>("audioSource");

		private static readonly FieldRef<AudioLowPassLogic, float> volume = AccessTools.FieldRefAccess<AudioLowPassLogic, float>("Volume");

		[HarmonyPostfix]
		private static void postfix(PlayerVoiceChat __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.lowPassLogic == (Object)null)
			{
				return;
			}
			AudioSource val = source.Invoke(__instance);
			if (!((Object)(object)val == (Object)null))
			{
				float num = volume.Invoke(__instance.lowPassLogic);
				float extra = ((num > 1f) ? num : 1f);
				filter filter2 = ((Component)val).GetComponent<filter>();
				if ((Object)(object)filter2 == (Object)null)
				{
					filter2 = ((Component)val).gameObject.AddComponent<filter>();
				}
				filter2.extra = extra;
			}
		}
	}
	internal class filter : MonoBehaviour
	{
		public float extra = 1f;

		private void OnAudioFilterRead(float[] data, int channels)
		{
			if (data != null && extra != 1f)
			{
				for (int i = 0; i < data.Length; i++)
				{
					data[i] *= extra;
				}
			}
		}
	}
	[HarmonyPatch(typeof(MenuSlider), "Start")]
	internal static class Slider
	{
		private static readonly FieldRef<MenuSlider, int> segments = AccessTools.FieldRefAccess<MenuSlider, int>("settingSegments");

		[HarmonyPrefix]
		private static void prefix(MenuSlider __instance)
		{
			apply(__instance);
		}

		[HarmonyPostfix]
		private static void postfix(MenuSlider __instance)
		{
			apply(__instance);
		}

		internal static void apply(MenuSlider slider)
		{
			if (!((Object)(object)slider == (Object)null) && !((Object)(object)((Component)slider).GetComponent<MenuSliderPlayerMicGain>() == (Object)null))
			{
				slider.startValue = 0;
				slider.endValue = 1000;
				segments.Invoke(slider) = 1000;
			}
		}
	}
	[HarmonyPatch(typeof(MenuSliderPlayerMicGain), "SetSlider")]
	internal static class set
	{
		private static readonly FieldRef<MenuSliderPlayerMicGain, MenuSlider> bar = AccessTools.FieldRefAccess<MenuSliderPlayerMicGain, MenuSlider>("menuSlider");

		private static readonly FieldRef<MenuSliderPlayerMicGain, float> value = AccessTools.FieldRefAccess<MenuSliderPlayerMicGain, float>("currentValue");

		private static readonly FieldRef<MenuSlider, int> current = AccessTools.FieldRefAccess<MenuSlider, int>("currentValue");

		[HarmonyPrefix]
		private static bool prefix(MenuSliderPlayerMicGain __instance, float _value)
		{
			MenuSlider val = bar.Invoke(__instance);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Slider.apply(val);
			float num = Mathf.Clamp(_value, 0f, 5f);
			val.SetBar(num / 5f);
			val.SetBarScaleInstant();
			value.Invoke(__instance) = current.Invoke(val);
			return false;
		}
	}
}