Decompiled source of BetterAudioMenu v0.1.2

plugins/com.github.KinTheInfinite.BetterAudioMenu.dll

Decompiled 2 days 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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.KinTheInfinite.BetterAudioMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2")]
[assembly: AssemblyProduct("com.github.KinTheInfinite.BetterAudioMenu")]
[assembly: AssemblyTitle("BetterAudioMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BetterAudioMenu
{
	[BepInPlugin("kintheinfinite.betteraudiomenu", "Kin's Chaotic Trials", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(AudioLevelSlider), "Update")]
		public class SliderPositionPatch
		{
			private static void Postfix(AudioLevels __instance)
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				if (update_delay > 0f)
				{
					return;
				}
				update_delay = 0.05f;
				AudioLevels component = ((Component)((Component)__instance).transform.parent).GetComponent<AudioLevels>();
				float num = 0f;
				foreach (AudioLevelSlider slider in component.sliders)
				{
					num = Mathf.Max(num, ((Component)slider).transform.position.y);
				}
				int num2 = 0;
				float num3 = config_height_difference.Value * ((float)Screen.height / 1080f);
				foreach (AudioLevelSlider slider2 in component.sliders)
				{
					Vector3 position = ((Component)slider2).transform.position;
					position.y = num - (float)num2 * num3;
					((Component)slider2).transform.position = position;
					if (((Component)slider2).gameObject.activeSelf)
					{
						num2++;
					}
				}
				foreach (Character allCharacter in Character.AllCharacters)
				{
					foreach (AudioLevelSlider slider3 in component.sliders)
					{
						if (slider3.player == null || (Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null || ((MonoBehaviourPun)allCharacter).photonView.OwnerActorNr != slider3.player.ActorNumber)
						{
							continue;
						}
						AnimatedMouth componentInChildren = ((Component)allCharacter).GetComponentInChildren<AnimatedMouth>();
						if (!((Object)(object)componentInChildren == (Object)null) && !((Object)(object)componentInChildren.audioSource == (Object)null))
						{
							float[] array = new float[256];
							componentInChildren.audioSource.GetSpectrumData(array, 0, (FFTWindow)0);
							float num4 = AnimatedMouth.MicrophoneLevelMaxDecibels(AnimatedMouth.MicrophoneLevelMax(array));
							num4 += 196f;
							TextMeshProUGUI playerName = slider3.playerName;
							if (num4 > 80f)
							{
								((Graphic)playerName).color = Color.red;
							}
							else if (num4 > 50f)
							{
								((Graphic)playerName).color = Color.yellow;
							}
							else if (num4 > 20f)
							{
								((Graphic)playerName).color = Color.green;
							}
							else
							{
								((Graphic)playerName).color = Color.white;
							}
						}
					}
				}
			}
		}

		private static ConfigEntry<float> config_height_difference;

		public static float update_delay;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			config_height_difference = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HeightDifference", 40f, "Difference in height between sliders.");
			Harmony val = new Harmony("kintheinfinite.betteraudiomenu");
			val.PatchAll(typeof(SliderPositionPatch));
		}

		private void Update()
		{
			update_delay -= Time.deltaTime;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}