Decompiled source of AudioController v1.0.0

AudioController.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AudioController")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AudioController")]
[assembly: AssemblyTitle("AudioController")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 AudioController
{
	[BepInPlugin("com.maxgamertyper1.audiocontroller", "Audio Controller", "1.0.0")]
	public class AudioController : BaseUnityPlugin
	{
		public static string CustomSongsPath = Path.Combine(Paths.ConfigPath, "CustomSongs");

		internal static ConfigFile config;

		internal static ConfigEntry<bool> OverrideOtherSongs;

		internal static ConfigEntry<bool> LoadCustomSongs;

		private void Log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}

		private void Awake()
		{
			Log("Plugin AudioController is loaded!");
			DoPatching();
			CharacterSelectHandler_online.clientSideMods_you_can_increment_this_to_enable_matchmaking_for_your_mods__please_dont_use_it_to_cheat_thats_really_cringe_especially_if_its_desyncing_others___you_didnt_even_win_on_your_opponents_screen___I_cannot_imagine_a_sadder_existence++;
			if (!Directory.Exists(CustomSongsPath))
			{
				Directory.CreateDirectory(CustomSongsPath);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Created custom folder at: " + CustomSongsPath));
			}
			config = ((BaseUnityPlugin)this).Config;
			OverrideOtherSongs = config.Bind<bool>("Songs", "Override Vanilla Songs", false, "Determines if Custom Songs will override the vanilla songs, removes the vanilla songs");
			LoadCustomSongs = config.Bind<bool>("Songs", "Load Custom Songs", true, "Determines if Custom Songs will be loaded");
			if (LoadCustomSongs.Value)
			{
				SongLoader.CustomSongsToSongs();
			}
		}

		private void DoPatching()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony harmony = new Harmony("com.maxgamertyper1.audiocontroller");
			Patch(harmony, typeof(AudioManager), "OnMatchStarted", "OnMatchStartedPrefix", prefix: true, transpiler: false);
			Patch(harmony, typeof(AudioSource), "Play", "OnSongStartPlaying", prefix: false, transpiler: false);
		}

		private void OnDestroy()
		{
			Log("Bye Bye From AudioController");
		}

		public static Stream GetResourceStream(string path)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream("AudioController." + path);
		}

		public static Texture2D GetTextureFromPng(string path)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			using Stream stream = GetResourceStream(path);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			byte[] array = memoryStream.ToArray();
			Texture2D val = new Texture2D(400, 400, (TextureFormat)4, false);
			((Object)val).name = path;
			ImageConversion.LoadImage(val, array);
			return val;
		}

		private void Update()
		{
			try
			{
				AudioSource musicPlayer = AudioManager.Get().musicPlayer;
				if (!musicPlayer.isPlaying && (Object)(object)musicPlayer.clip != (Object)null && !Patches.IsPaused)
				{
					Patches.NextButtonClicked();
				}
			}
			catch
			{
			}
		}

		private void Patch(Harmony harmony, Type OriginalClass, string OriginalMethod, string PatchMethod, bool prefix, bool transpiler)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(OriginalClass, OriginalMethod, (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), PatchMethod, (Type[])null, (Type[])null);
			if (prefix)
			{
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else if (transpiler)
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			Log("Patched " + OriginalMethod + " in " + OriginalClass.ToString());
		}
	}
	public class SongLoader : MonoBehaviour
	{
		public static void CustomSongsToSongs()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			GameObject val = new GameObject("MP3Loader", new Type[1] { typeof(SongLoader) });
			SongLoader component = val.GetComponent<SongLoader>();
			string[] files = Directory.GetFiles(AudioController.CustomSongsPath);
			string[] array = files;
			foreach (string text in array)
			{
				if (text.Contains("mp3"))
				{
					Debug.Log((object)("Attempting Conversion of " + text + " to AudioClip"));
					((MonoBehaviour)component).StartCoroutine(component.LoadMP3("file://" + text));
				}
			}
		}

		private IEnumerator LoadMP3(string filePath)
		{
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(filePath, (AudioType)13);
			yield return www.SendWebRequest();
			if (www.isNetworkError || www.isHttpError)
			{
				Debug.LogError((object)("Error loading MP3: " + www.error));
				yield break;
			}
			AudioClip newaudio = DownloadHandlerAudioClip.GetContent(www);
			string actualfile = (((Object)newaudio).name = filePath.Replace(AudioController.CustomSongsPath + "\\", "").Replace("file://", "file:"));
			Patches.CustomSongs.Add(newaudio);
			Debug.Log((object)(actualfile + " Loaded Successfully!"));
		}
	}
	public class Patches
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__31_0;

			public static UnityAction <>9__31_1;

			public static UnityAction <>9__31_2;

			public static UnityAction <>9__31_3;

			public static UnityAction <>9__31_4;

			public static UnityAction <>9__31_5;

			public static UnityAction <>9__31_6;

			public static UnityAction<float> <>9__31_7;

			internal void <CreateUIElements>b__31_0()
			{
				SwitchButtonClicked();
			}

			internal void <CreateUIElements>b__31_1()
			{
				PrevButtonClicked();
			}

			internal void <CreateUIElements>b__31_2()
			{
				NextButtonClicked();
			}

			internal void <CreateUIElements>b__31_3()
			{
				PauseButtonClicked();
			}

			internal void <CreateUIElements>b__31_4()
			{
				VolumeButtonClicked();
			}

			internal void <CreateUIElements>b__31_5()
			{
				ShuffleButtonClicked();
			}

			internal void <CreateUIElements>b__31_6()
			{
				LoopButtonClicked();
			}

			internal void <CreateUIElements>b__31_7(float val)
			{
				SliderChanged(val);
			}
		}

		public static AudioManager AudioManager;

		public static bool CurrentlyPaused = true;

		public static bool SliderActive = false;

		public static GameObject SliderObject;

		public static TextMeshProUGUI SongText;

		public static TextMeshProUGUI VolumeText;

		public static TextMeshProUGUI ShuffleText;

		public static Image PauseButtonImage;

		public static Image ShuffleButtonImage;

		public static bool? ShuffleButtonState;

		public static List<AudioClip> CustomSongs = new List<AudioClip>();

		public static bool HasLoadedSongs = false;

		public static int CurrentIndex = 0;

		public static List<int> SongQueue = null;

		public static List<int> PrevSongQueue = null;

		public static bool Looping = true;

		public static TextMeshProUGUI LoopText;

		public static bool IsPaused = false;

		public static bool IsOpened = true;

		public static void ChangeIndex()
		{
			Song[] array = ((AudioManager.test_songs != null && AudioManager.test_songs.Length != 0) ? AudioManager.test_songs : AudioManager.songs);
			if (CurrentIndex <= 0)
			{
				CurrentIndex += array.Length;
			}
			CurrentIndex %= array.Length;
			AudioManager.currentSongIndex = CurrentIndex;
		}

		public static void LoopButtonClicked()
		{
			Looping = !Looping;
			AudioManager.musicPlayer.loop = Looping;
			((TMP_Text)LoopText).text = (Looping ? "True" : "False");
		}

		public static void SwitchButtonClicked()
		{
			IsOpened = !IsOpened;
			((Component)((TMP_Text)VolumeText).transform.parent).gameObject.SetActive(IsOpened);
		}

		public static void NextButtonClicked()
		{
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			AudioManager.musicPlayer.loop = false;
			AudioManager.introMusicPlayer.loop = false;
			if (!CurrentlyPaused)
			{
				PauseButtonClicked();
			}
			if (!ShuffleButtonState.HasValue)
			{
				CurrentIndex++;
				ChangeIndex();
				AudioManager.StartMusic(AudioManager.currentSongIndex);
			}
			else if (ShuffleButtonState.GetValueOrDefault())
			{
				int index = Random.Range(0, SongQueue.Count);
				int currentIndex = SongQueue[index];
				SongQueue.RemoveAt(index);
				PrevSongQueue.Insert(0, CurrentIndex);
				CurrentIndex = currentIndex;
				ChangeIndex();
				AudioManager.StartMusic(AudioManager.currentSongIndex);
				if (SongQueue.Count == 0)
				{
					SongQueue = Enumerable.Range(0, AudioManager.songs.Length).ToList();
				}
				if (PrevSongQueue.Count >= AudioManager.songs.Length * 4)
				{
					PrevSongQueue.RemoveAt(PrevSongQueue.Count - 1);
				}
			}
			else
			{
				int num = Random.Range(0, AudioManager.songs.Length);
				Song val = AudioManager.songs[num];
				PrevSongQueue.Insert(0, num);
				CurrentIndex = num;
				ChangeIndex();
				AudioManager.StartMusic(AudioManager.currentSongIndex);
				if (PrevSongQueue.Count >= AudioManager.songs.Length * 4)
				{
					PrevSongQueue.RemoveAt(PrevSongQueue.Count - 1);
				}
			}
		}

		public static void PrevButtonClicked()
		{
			if (!CurrentlyPaused)
			{
				PauseButtonClicked();
			}
			if (!ShuffleButtonState.HasValue)
			{
				CurrentIndex--;
				ChangeIndex();
				AudioManager.StartMusic(AudioManager.currentSongIndex);
				return;
			}
			if (ShuffleButtonState.GetValueOrDefault())
			{
				try
				{
					int currentIndex = PrevSongQueue[0];
					PrevSongQueue.RemoveAt(0);
					SongQueue.Insert(0, CurrentIndex);
					CurrentIndex = currentIndex;
					ChangeIndex();
					AudioManager.StartMusic(AudioManager.currentSongIndex);
					if (PrevSongQueue.Count == 0)
					{
						CurrentIndex--;
						ChangeIndex();
						AudioManager.StartMusic(AudioManager.currentSongIndex);
					}
					if (SongQueue.Count >= AudioManager.songs.Length)
					{
						SongQueue.RemoveAt(SongQueue.Count - 1);
					}
					return;
				}
				catch (Exception)
				{
					Debug.LogWarning((object)"No More Previous Song Data");
					return;
				}
			}
			try
			{
				int currentIndex2 = PrevSongQueue[0];
				PrevSongQueue.RemoveAt(0);
				CurrentIndex = currentIndex2;
				ChangeIndex();
				AudioManager.StartMusic(AudioManager.currentSongIndex);
			}
			catch (Exception)
			{
				Debug.LogWarning((object)"No More Previous Song Data");
			}
		}

		public static void VolumeButtonClicked()
		{
			if (SliderActive)
			{
				SliderObject.SetActive(false);
				((Component)VolumeText).gameObject.SetActive(false);
			}
			else
			{
				SliderObject.SetActive(true);
				((Component)VolumeText).gameObject.SetActive(true);
				int num;
				try
				{
					num = AudioManager.settings.MusicVolume;
				}
				catch (Exception)
				{
					num = 10;
				}
				SliderObject.GetComponent<Slider>().value = num;
			}
			SliderActive = !SliderActive;
		}

		public static void SliderChanged(float value)
		{
			AudioManager.settings.MusicVolume = (int)value;
			AudioManager.currentMusicVolume = (((int)value == 0) ? 0f : AudioManager.currentMusicVolume);
			AudioManager.UpdateMusicMasterVolume();
			((TMP_Text)VolumeText).text = value.ToString();
		}

		public static void PauseButtonClicked()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			IsPaused = !IsPaused;
			if (CurrentlyPaused)
			{
				AudioManager.PauseMusic();
				Texture2D textureFromPng = AudioController.GetTextureFromPng("play.png");
				Sprite val = Sprite.Create(textureFromPng, new Rect(0f, 0f, (float)((Texture)textureFromPng).width, (float)((Texture)textureFromPng).height), new Vector2(0.5f, 0.5f));
				((Object)val).name = "play.png";
				PauseButtonImage.sprite = val;
			}
			else
			{
				AudioManager.UnPauseMusic();
				Texture2D textureFromPng2 = AudioController.GetTextureFromPng("pause.png");
				Sprite val2 = Sprite.Create(textureFromPng2, new Rect(0f, 0f, (float)((Texture)textureFromPng2).width, (float)((Texture)textureFromPng2).height), new Vector2(0.5f, 0.5f));
				((Object)val2).name = "pause.png";
				PauseButtonImage.sprite = val2;
			}
			CurrentlyPaused = !CurrentlyPaused;
		}

		public static void ShuffleButtonClicked()
		{
			Debug.Log((object)"Changing Shuffle");
			if (PrevSongQueue == null)
			{
				PrevSongQueue = new List<int>();
			}
			if (!ShuffleButtonState.HasValue)
			{
				ShuffleButtonState = true;
				((TMP_Text)ShuffleText).text = "Queue";
				if (SongQueue == null)
				{
					SongQueue = Enumerable.Range(0, AudioManager.songs.Length).ToList();
				}
			}
			else if (ShuffleButtonState.GetValueOrDefault())
			{
				((TMP_Text)ShuffleText).text = "Random";
				ShuffleButtonState = false;
			}
			else
			{
				((TMP_Text)ShuffleText).text = "None";
				ShuffleButtonState = null;
			}
			CurrentlyPaused = !CurrentlyPaused;
		}

		public static GameObject CreateGameObject(string name, Vector3 localposition, List<Type> extratypes)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (extratypes == null)
			{
				extratypes = new List<Type>();
			}
			if (!extratypes.Contains(typeof(RectTransform)))
			{
				extratypes.Add(typeof(RectTransform));
			}
			GameObject val = new GameObject(name, extratypes.ToArray());
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localPosition = localposition;
			return val;
		}

		public static void AddImageInformation(GameObject gameObject, Vector2 SizeDelta, Vector3 LocalScale, string imagepath)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = gameObject.GetComponent<RectTransform>();
			component.sizeDelta = SizeDelta;
			((Transform)component).localScale = LocalScale;
			Image component2 = gameObject.GetComponent<Image>();
			Texture2D textureFromPng = AudioController.GetTextureFromPng(imagepath);
			Sprite val = Sprite.Create(textureFromPng, new Rect(0f, 0f, (float)((Texture)textureFromPng).width, (float)((Texture)textureFromPng).height), new Vector2(0.5f, 0.5f));
			((Object)val).name = imagepath;
			component2.sprite = val;
		}

		public static TextMeshProUGUI AddTextInformation(GameObject gameObject, Vector3 SizeDelta, string text)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = gameObject.GetComponent<RectTransform>();
			component.sizeDelta = Vector2.op_Implicit(SizeDelta);
			TextMeshProUGUI component2 = gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).fontStyle = (FontStyles)1;
			((TMP_Text)component2).font = LocalizedText.localizationTable.GetFont(Settings.Get().Language, false);
			((TMP_Text)component2).text = text;
			((TMP_Text)component2).fontSize = 32f;
			((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
			return component2;
		}

		public static void CreateUIElements()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Expected O, but got Unknown
			//IL_09ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_0a3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a45: Expected O, but got Unknown
			//IL_0a6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad5: Expected O, but got Unknown
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b16: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b85: Expected O, but got Unknown
			//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0beb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Expected O, but got Unknown
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Expected O, but got Unknown
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Expected O, but got Unknown
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Expected O, but got Unknown
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_079d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_080a: Unknown result type (might be due to invalid IL or missing references)
			//IL_084f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0917: Unknown result type (might be due to invalid IL or missing references)
			//IL_091e: Expected O, but got Unknown
			//IL_0945: Unknown result type (might be due to invalid IL or missing references)
			//IL_094a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Expected O, but got Unknown
			GameObject val2 = new GameObject("AudioControllerCanvas", new Type[2]
			{
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			});
			Canvas component = val2.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			((Object)((Component)component).gameObject).name = "AudioControllerCanvas";
			GameObject val3 = CreateGameObject("RadioFolder", new Vector3(-810f, -390f, 0f), null);
			((Transform)val3.GetComponent<RectTransform>()).SetParent(((Component)component).transform, false);
			GameObject val4 = CreateGameObject("RadioBackground", new Vector3(156f, 31f, 0f), new List<Type>(2)
			{
				typeof(CanvasRenderer),
				typeof(Image)
			});
			((Transform)val4.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val4, new Vector2(700f, 200f), Vector3.one, "slider.png");
			((Graphic)val4.GetComponent<Image>()).color = new Color(1f, 1f, 1f, 0.5f);
			GameObject val5 = CreateGameObject("SwitchButton", new Vector3(-560f, -330f, 0f), new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val5.GetComponent<RectTransform>()).SetParent(((Component)component).transform, false);
			AddImageInformation(val5, new Vector2(60f, 20f), Vector3.one, "slider.png");
			Button component2 = val5.GetComponent<Button>();
			ButtonClickedEvent onClick = component2.onClick;
			object obj = <>c.<>9__31_0;
			if (obj == null)
			{
				UnityAction val6 = delegate
				{
					SwitchButtonClicked();
				};
				<>c.<>9__31_0 = val6;
				obj = (object)val6;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			GameObject val7 = CreateGameObject("PrevButton", Vector3.zero, new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val7.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val7, new Vector2(100f, 100f), new Vector3(0.75f, 0.75f, 0.75f), "prev.png");
			Button component3 = val7.GetComponent<Button>();
			ButtonClickedEvent onClick2 = component3.onClick;
			object obj2 = <>c.<>9__31_1;
			if (obj2 == null)
			{
				UnityAction val8 = delegate
				{
					PrevButtonClicked();
				};
				<>c.<>9__31_1 = val8;
				obj2 = (object)val8;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			GameObject val9 = CreateGameObject("NextButton", new Vector3(200f, 0f, 0f), new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val9.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val9, new Vector2(100f, 100f), new Vector3(0.75f, 0.75f, 0.75f), "next.png");
			Button component4 = val9.GetComponent<Button>();
			ButtonClickedEvent onClick3 = component4.onClick;
			object obj3 = <>c.<>9__31_2;
			if (obj3 == null)
			{
				UnityAction val10 = delegate
				{
					NextButtonClicked();
				};
				<>c.<>9__31_2 = val10;
				obj3 = (object)val10;
			}
			((UnityEvent)onClick3).AddListener((UnityAction)obj3);
			GameObject val11 = CreateGameObject("PauseButton", new Vector3(100f, 0f, 0f), new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val11.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val11, new Vector2(100f, 100f), Vector3.one, "pause.png");
			Button component5 = val11.GetComponent<Button>();
			ButtonClickedEvent onClick4 = component5.onClick;
			object obj4 = <>c.<>9__31_3;
			if (obj4 == null)
			{
				UnityAction val12 = delegate
				{
					PauseButtonClicked();
				};
				<>c.<>9__31_3 = val12;
				obj4 = (object)val12;
			}
			((UnityEvent)onClick4).AddListener((UnityAction)obj4);
			PauseButtonImage = val11.GetComponent<Image>();
			GameObject val13 = CreateGameObject("VolumeButton", new Vector3(-100f, 0f, 0f), new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val13.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val13, new Vector2(100f, 100f), Vector3.one, "volumeicon.png");
			Button component6 = val13.GetComponent<Button>();
			ButtonClickedEvent onClick5 = component6.onClick;
			object obj5 = <>c.<>9__31_4;
			if (obj5 == null)
			{
				UnityAction val14 = delegate
				{
					VolumeButtonClicked();
				};
				<>c.<>9__31_4 = val14;
				obj5 = (object)val14;
			}
			((UnityEvent)onClick5).AddListener((UnityAction)obj5);
			GameObject val15 = CreateGameObject("ShuffleButton", new Vector3(300f, 0f, 0f), new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val15.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val15, new Vector2(100f, 100f), Vector3.one, "shuffle.png");
			Button component7 = val15.GetComponent<Button>();
			ButtonClickedEvent onClick6 = component7.onClick;
			object obj6 = <>c.<>9__31_5;
			if (obj6 == null)
			{
				UnityAction val16 = delegate
				{
					ShuffleButtonClicked();
				};
				<>c.<>9__31_5 = val16;
				obj6 = (object)val16;
			}
			((UnityEvent)onClick6).AddListener((UnityAction)obj6);
			ShuffleButtonImage = val15.GetComponent<Image>();
			GameObject val17 = CreateGameObject("LoopButton", new Vector3(410f, 0f, 0f), new List<Type>(new <>z__ReadOnlyArray<Type>(new Type[3]
			{
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			})));
			((Transform)val17.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddImageInformation(val17, new Vector2(100f, 100f), Vector3.one, "loop.png");
			Button component8 = val17.GetComponent<Button>();
			ButtonClickedEvent onClick7 = component8.onClick;
			object obj7 = <>c.<>9__31_6;
			if (obj7 == null)
			{
				UnityAction val18 = delegate
				{
					LoopButtonClicked();
				};
				<>c.<>9__31_6 = val18;
				obj7 = (object)val18;
			}
			((UnityEvent)onClick7).AddListener((UnityAction)obj7);
			val17.transform.localScale = Vector2.op_Implicit(new Vector2(0.9f, 0.9f));
			GameObject val19 = CreateGameObject("PlayingText", new Vector3(150f, 95f, 0f), new List<Type>(new <>z__ReadOnlySingleElementList<Type>(typeof(TextMeshProUGUI))));
			((Transform)val19.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			AddTextInformation(val19, new Vector3(350f, 50f, 0f), "Currently Playing: ");
			GameObject val20 = CreateGameObject("ShuffleText", new Vector3(300f, -50f, 0f), new List<Type>(new <>z__ReadOnlySingleElementList<Type>(typeof(TextMeshProUGUI))));
			((Transform)val20.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			ShuffleText = AddTextInformation(val20, new Vector3(350f, 50f, 0f), "None");
			GameObject val21 = CreateGameObject("LoopText", new Vector3(410f, -50f, 0f), new List<Type>(new <>z__ReadOnlySingleElementList<Type>(typeof(TextMeshProUGUI))));
			((Transform)val21.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			LoopText = AddTextInformation(val21, new Vector3(350f, 50f, 0f), "True");
			GameObject val22 = CreateGameObject("SongText", new Vector3(150f, 57f, 0f), new List<Type>(new <>z__ReadOnlySingleElementList<Type>(typeof(TextMeshProUGUI))));
			((Transform)val22.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			SongText = AddTextInformation(val22, new Vector3(600f, 50f, 0f), "<Song Playing>");
			((TMP_Text)SongText).overflowMode = (TextOverflowModes)1;
			GameObject val23 = CreateGameObject("VolumeText", new Vector3(-100f, 375f, 0f), new List<Type>(new <>z__ReadOnlySingleElementList<Type>(typeof(TextMeshProUGUI))));
			((Transform)val23.GetComponent<RectTransform>()).SetParent(val3.transform, false);
			VolumeText = AddTextInformation(val23, new Vector3(350f, 50f, 0f), "10");
			val23.SetActive(false);
			GameObject val24 = new GameObject("VolumeSlider", new Type[3]
			{
				typeof(RectTransform),
				typeof(Slider),
				typeof(Image)
			});
			val24.transform.SetParent(val3.transform, false);
			SliderObject = val24;
			AddImageInformation(val24, new Vector2(300f, 30f), Vector3.one, "sliderback.png");
			Slider component9 = val24.GetComponent<Slider>();
			component9.minValue = 0f;
			component9.maxValue = 20f;
			int num;
			try
			{
				num = AudioManager.settings.MusicVolume;
			}
			catch (Exception)
			{
				num = 10;
			}
			component9.value = num;
			component9.wholeNumbers = true;
			RectTransform component10 = val24.GetComponent<RectTransform>();
			((Transform)component10).localPosition = new Vector3(-100f, 200f, 0f);
			((Transform)component10).rotation = Quaternion.Euler(0f, 0f, 90f);
			((UnityEvent<float>)(object)component9.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
			{
				SliderChanged(val);
			});
			val24.SetActive(false);
			GameObject val25 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) });
			val25.transform.SetParent(val24.transform, false);
			RectTransform component11 = val25.GetComponent<RectTransform>();
			component11.anchorMin = new Vector2(0f, 0.25f);
			component11.anchorMax = new Vector2(1f, 0.75f);
			Vector2 val26 = default(Vector2);
			((Vector2)(ref val26))..ctor(1f, 0f);
			component11.offsetMax = val26;
			component11.offsetMin = val26;
			GameObject val27 = new GameObject("Fill", new Type[1] { typeof(Image) });
			val27.transform.SetParent(val25.transform, false);
			AddImageInformation(val27, new Vector2(-20f, 0f), Vector3.one, "slider.png");
			RectTransform component12 = val27.GetComponent<RectTransform>();
			component12.anchorMin = Vector2.zero;
			component12.anchorMax = Vector2.one;
			component12.offsetMin = new Vector2(10f, 0f);
			component12.offsetMax = new Vector2(-10f, 0f);
			component9.fillRect = component12;
			GameObject val28 = new GameObject("Handle", new Type[1] { typeof(Image) });
			val28.transform.SetParent(val24.transform, false);
			Image component13 = val28.GetComponent<Image>();
			((Graphic)component13).color = Color32.op_Implicit(new Color32((byte)4, (byte)65, (byte)107, byte.MaxValue));
			RectTransform component14 = val28.GetComponent<RectTransform>();
			component14.sizeDelta = new Vector2(10f, 20f);
			component14.anchorMin = new Vector2(0.5f, 0.5f);
			component14.anchorMax = new Vector2(0.5f, 0.5f);
			component14.pivot = new Vector2(0.5f, 0.5f);
			((Selectable)component9).targetGraphic = (Graphic)(object)component13;
			component9.handleRect = component14;
			val3.transform.localScale = Vector2.op_Implicit(new Vector2(0.6f, 0.6f));
		}

		private static AudioClip GenerateQuietClip(float duration, float frequency, float amplitude)
		{
			int num = 44100;
			int num2 = Mathf.FloorToInt(duration * (float)num);
			float[] array = new float[num2];
			for (int i = 0; i < num2; i++)
			{
				float num3 = (float)i / (float)num;
				array[i] = amplitude * Mathf.Sin((float)Math.PI * 2f * frequency * num3);
			}
			AudioClip val = AudioClip.Create("QuietSound", num2, 1, num, false);
			val.SetData(array, 0);
			return val;
		}

		public static void OnMatchStartedPrefix(ref AudioManager __instance)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			CreateUIElements();
			AudioManager = AudioManager.Get();
			if (HasLoadedSongs)
			{
				return;
			}
			if (AudioController.OverrideOtherSongs.Value && AudioController.LoadCustomSongs.Value)
			{
				AudioManager.songs = Array.Empty<Song>();
			}
			List<Song> list = new List<Song>(AudioManager.songs);
			foreach (AudioClip customSong in CustomSongs)
			{
				Song item = default(Song);
				item.name = ((Object)customSong).name;
				item.songLoop = customSong;
				item.intro = GenerateQuietClip(0.1f, 100f, 1E-10f);
				item.pitch = 1f;
				list.Add(item);
			}
			AudioManager.songs = list.ToArray();
			HasLoadedSongs = true;
		}

		public static void OnSongStartPlaying(ref AudioSource __instance)
		{
			AudioManager val = AudioManager.Get();
			val.musicPlayer.loop = Looping;
			try
			{
				((TMP_Text)SongText).text = val.songs[val.currentSongIndex].name;
			}
			catch
			{
				Debug.Log((object)"Couldn't change text");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "AudioController";

		public const string PLUGIN_NAME = "AudioController";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			return !_moveNextCalled && (_moveNextCalled = true);
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		return (!EqualityComparer<T>.Default.Equals(_item, (T)value)) ? (-1) : 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return (!EqualityComparer<T>.Default.Equals(_item, item)) ? (-1) : 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}