Decompiled source of AudioPlugin v5.0.0

AudioPlugin.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Media;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using Bounce.TaleSpire.AssetManagement;
using Bounce.Unmanaged;
using Bounce.UnsafeViews;
using DataModel;
using HarmonyLib;
using TMPro;
using TaleSpire.Atmosphere;
using TaleSpire.ContentManagement;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AudioPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nth Dimension")]
[assembly: AssemblyProduct("AudioPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("AudioPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("5.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("5.0.0.0")]
namespace LordAshes;

[BepInPlugin("org.pluginmasters.plugins.audio", "Audio Plug-In", "5.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AudioPlugin : BaseUnityPlugin
{
	public class MyCustomMusicContentProvider : IContentProvider, IProvidesMusicDataContent, IProvidesAudioClipContent
	{
		public static NativeHashMap<ContentGuid, (InternedContentAddress address, UnsafeView<MusicDataV0> data, string name)> Music;

		public MyCustomMusicContentProvider()
		{
			if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)"Audio Plug-In: Initializing Custom Music Content Provider");
			}
			if (customAudioSources == null)
			{
				return;
			}
			if (diagnostics >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Audio Plug-In: Categories = " + customAudioSources.Count()));
			}
			if (customAudioSources.Count() > 0)
			{
				if (diagnostics >= DiagnosticLevel.debug)
				{
					Debug.Log((object)("Audio Plug-In: Ambient = " + customAudioSources[(MusicKind)1].Count()));
				}
				if (diagnostics >= DiagnosticLevel.debug)
				{
					Debug.Log((object)("Audio Plug-In: Music = " + customAudioSources[(MusicKind)0].Count()));
				}
			}
			if (customAudioSources != null && customAudioSources.Count > 0 && (customAudioSources[(MusicKind)1].Count() > 0 || customAudioSources[(MusicKind)0].Count() > 0))
			{
				BuildSongReferences();
			}
		}

		public static void BuildSongReferences()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)"Audio Plug-In: Building Audio References");
			}
			Music = new NativeHashMap<ContentGuid, (InternedContentAddress, UnsafeView<MusicDataV0>, string)>(128, (Allocator)4);
			NGuid val = default(NGuid);
			NGuid.TryParse(Utility.GuidFromString("org.pluginmasters.plugins.audio").ToString(), ref val);
			SemiInternedPackId val2 = default(SemiInternedPackId);
			((SemiInternedPackId)(ref val2))..ctor(new SourceLocalPackId(val.Data));
			InternedPackSource val3 = (InternedPackSource)typeof(InternedPackSource).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[1] { typeof(PackSourceKind) }, null).Invoke(new object[1] { (object)(PackSourceKind)3 });
			InternedPackId val4 = default(InternedPackId);
			((InternedPackId)(ref val4))..ctor(val3, val2.SourceLocalPackId, default(MD5));
			using MD5 mD = MD5.Create();
			Builder<MusicDataV0> val7 = default(Builder<MusicDataV0>);
			ContentGuid val8 = default(ContentGuid);
			foreach (MusicKind value in Enum.GetValues(typeof(MusicKind)))
			{
				for (int i = 0; i < customAudioSources[value].Count(); i++)
				{
					string text = customAudioSources[value][i].Substring(customAudioSources[value][i].Replace("\\", "/").LastIndexOf("/") + 1);
					NGuid val6 = (text.EndsWith("►") ? new NGuid(mD.ComputeHash(Encoding.Default.GetBytes(customAudioSources[value][i]))) : new NGuid(mD.ComputeHash(Encoding.Default.GetBytes(text))));
					ref MusicDataV0 reference = ref Builder<MusicDataV0>.Create((Allocator)4, ref val7);
					((ContentGuid)(ref val8))..ctor(val6);
					ContentAddress val9 = ContentAddress.CreateFromParts((PackSourceKind)3, MemoryExtensions.AsSpan(""), val2.SourceLocalPackId, val8);
					MusicDataV0.Construct<MusicDataV0>(val8, ref val7, ref reference, val9, customAudioSources[value][i], "", Array.Empty<string>(), value);
					Root<MusicDataV0> val10 = val7.Complete((Allocator)4);
					UnsafeView<MusicDataV0> item = UnsafeViewExtensions.TakeView<MusicDataV0>(ref val10);
					Music.TryAdd(item.Value.Id, (new InternedContentAddress(val4, item.Value.Address.ContentRef), item, customAudioSources[value][i]));
				}
			}
		}

		public void FetchAudioClip(Destination contentDestination, in InternedContentAddress contentAddress)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			ProcessAudioClipLoad(Music, contentDestination, in contentAddress);
		}

		public void FetchMusicData(Destination contentDestination, in InternedContentAddress contentAddress)
		{
			//IL_000c: 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)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			(InternedContentAddress, UnsafeView<MusicDataV0>, string) tuple = default((InternedContentAddress, UnsafeView<MusicDataV0>, string));
			if (Music.TryGetValue(((ContentRef)(ref contentAddress.ContentRef)).AsContentId, ref tuple))
			{
				ContentManager.TryDeliverContent(contentDestination, ref tuple.Item2);
			}
			else
			{
				ContentManager.TryDeliverFailure(contentDestination, (ContentLoadFailureReason)5);
			}
		}

		void IProvidesMusicDataContent.FetchMusicData(Destination contentDestination, in InternedContentAddress contentAddress)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			FetchMusicData(contentDestination, in contentAddress);
		}

		void IProvidesAudioClipContent.FetchAudioClip(Destination contentDestination, in InternedContentAddress contentAddress)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			FetchAudioClip(contentDestination, in contentAddress);
		}
	}

	[HarmonyPatch(typeof(InternalPackManager), "OnInstanceSetup")]
	public class OnSetupPatches
	{
		private static void Postfix()
		{
			ContentManager.RegisterContentProvider((ContentProviderKind)100, customMusicProvider);
		}
	}

	[HarmonyPatch(typeof(ContentManager), "ProviderKindToPackSourceKind")]
	public class PatchProviderLookup
	{
		private static bool Prefix(ref PackSourceKind __result, ContentProviderKind providerKind)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected I4, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			switch ((int)providerKind)
			{
			case 0:
				__result = (PackSourceKind)1;
				break;
			case 1:
				__result = (PackSourceKind)2;
				break;
			case 2:
				__result = (PackSourceKind)5;
				break;
			case 3:
				__result = (PackSourceKind)6;
				break;
			case 4:
				__result = (PackSourceKind)4;
				break;
			case 5:
				__result = (PackSourceKind)7;
				break;
			default:
				if ((int)providerKind == 100)
				{
					__result = (PackSourceKind)3;
				}
				break;
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(UI_MusicSelectionDropdown), "OnEnable")]
	public class OnEnablePatches
	{
		private static void Postfix(ref TMP_Dropdown ____dropdown, MusicKind ____type, ref List<InternedContentAddress> ____trackList)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			ProcessDropdownCreation(ref ____dropdown, ____type, ref ____trackList);
		}
	}

	[HarmonyPatch(typeof(UI_MusicSelectionDropdown), "SelectIndex")]
	public class OnSelectIndex
	{
		private static bool Prefix(int index, ref TMP_Dropdown ____dropdown, MusicKind ____type, ref List<InternedContentAddress> ____trackList)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return ProcessDropdownSelection(index, ref ____dropdown, ____type, ref ____trackList);
		}
	}

	[HarmonyPatch(typeof(AtmosphereReferenceData), "SetAtmosphereData")]
	public class PatchReferenceData
	{
		private static void Postfix(AtmosphereReferenceData __instance, in AtmosphereData data)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			(InternedContentAddress, UnsafeView<MusicDataV0>, string) tuple = default((InternedContentAddress, UnsafeView<MusicDataV0>, string));
			if (MyCustomMusicContentProvider.Music.TryGetValue(data.music, ref tuple))
			{
				__instance.Music = tuple.Item1;
			}
			(InternedContentAddress, UnsafeView<MusicDataV0>, string) tuple2 = default((InternedContentAddress, UnsafeView<MusicDataV0>, string));
			if (MyCustomMusicContentProvider.Music.TryGetValue(data.ambientMusic, ref tuple2))
			{
				__instance.AmbientMusic = tuple2.Item1;
			}
		}
	}

	private class AudioLibrary
	{
		public Dictionary<string, string> audioReferences { get; set; }
	}

	public static class Utility
	{
		public static bool isBoardLoaded()
		{
			return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
		}

		public static Guid GuidFromString(string input)
		{
			using MD5 mD = MD5.Create();
			byte[] b = mD.ComputeHash(Encoding.Default.GetBytes(input));
			return new Guid(b);
		}

		public static GameObject GetBaseLoader(CreatureGuid cid)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CreatureBoardAsset val = null;
				CreaturePresenter.TryGetAsset(cid, ref val);
				if ((Object)(object)val != (Object)null)
				{
					Transform match = null;
					Traverse(((Component)val).transform, "BaseLoader", 0, 10, ref match);
					if ((Object)(object)match != (Object)null)
					{
						Debug.Log((object)("Audio Plug-In: Base Loader '" + ((Object)match.GetChild(0)).name + "' Found"));
						return ((Component)match.GetChild(0)).gameObject;
					}
					Debug.LogWarning((object)"Audio Plug-In: Could Not Find Base Loader");
					return null;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		public static GameObject GetAssetLoader(CreatureGuid cid)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CreatureBoardAsset val = null;
				CreaturePresenter.TryGetAsset(cid, ref val);
				if ((Object)(object)val != (Object)null)
				{
					Transform match = null;
					Traverse(((Component)val).transform, "AssetLoader", 0, 10, ref match);
					if ((Object)(object)match != (Object)null)
					{
						Debug.Log((object)("Audio Plug-In: Asset Loader '" + ((Object)match.GetChild(0)).name + "' Found"));
						return ((Component)match.GetChild(0)).gameObject;
					}
					Debug.LogWarning((object)"Audio Plug-In: Could Not Find Asset Loader");
					return null;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		public static void Traverse(Transform root, string seek, int depth, int depthMax, ref Transform match)
		{
			try
			{
				if ((Object)(object)match != (Object)null)
				{
					return;
				}
				if (((Object)root).name == seek)
				{
					match = root;
					return;
				}
				foreach (Transform item in ExtensionMethods.Children(root))
				{
					if (depth < depthMax)
					{
						Traverse(item, seek, depth + 1, depthMax, ref match);
					}
				}
			}
			catch
			{
			}
		}

		public static float ParseFloat(string value)
		{
			return float.Parse(value, CultureInfo.InvariantCulture);
		}

		public static string GetCreatureName(string nameBlock)
		{
			if (nameBlock == null)
			{
				return "(Unknown)";
			}
			if (!nameBlock.Contains("<size=0>"))
			{
				return nameBlock;
			}
			return nameBlock.Substring(0, nameBlock.IndexOf("<size=0>")).Trim();
		}

		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nPlugin Masters' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}
	}

	public enum DiagnosticLevel
	{
		none,
		error,
		warning,
		info,
		debug,
		ultra
	}

	public enum CoreAudioInclusionSettings
	{
		first,
		alphabetical,
		last
	}

	public enum MissingContentAudioSettings
	{
		silence,
		warning
	}

	public static IContentProvider customMusicProvider = (IContentProvider)(object)new MyCustomMusicContentProvider();

	public const string Name = "Audio Plug-In";

	public const string Guid = "org.pluginmasters.plugins.audio";

	public const string Version = "5.0.0";

	public const string Author = "Plugin Masters";

	private static Dictionary<string, string> virtualWWWFiles = new Dictionary<string, string>();

	private static Dictionary<MusicKind, string> currentFolder = new Dictionary<MusicKind, string>();

	private static Dictionary<MusicKind, List<string>> customAudioSources = new Dictionary<MusicKind, List<string>>();

	private static Dictionary<MusicKind, SortedDictionary<string, InternedContentAddress>> coreAudioSources = new Dictionary<MusicKind, SortedDictionary<string, InternedContentAddress>>();

	private static AudioPlugin _self = null;

	public static DiagnosticLevel diagnostics { get; set; } = DiagnosticLevel.debug;


	public static ConfigEntry<CoreAudioInclusionSettings> coreInclusionSettings { get; set; }

	public static ConfigEntry<MissingContentAudioSettings> missingContentAudio { get; set; }

	public static ConfigEntry<bool> autoLibrarySync { get; set; }

	private static string corePath { get; set; }

	private static string modIoPath { get; set; }

	private void Awake()
	{
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Expected O, but got Unknown
		_self = this;
		diagnostics = ((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", DiagnosticLevel.info, (ConfigDescription)null).Value;
		coreInclusionSettings = ((BaseUnityPlugin)this).Config.Bind<CoreAudioInclusionSettings>("Settings", "Core Audio Placement", CoreAudioInclusionSettings.alphabetical, (ConfigDescription)null);
		autoLibrarySync = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Auto Sync GMs Library References", true, (ConfigDescription)null);
		missingContentAudio = ((BaseUnityPlugin)this).Config.Bind<MissingContentAudioSettings>("Settings", "What To Play When Requested Audio Is Missing", MissingContentAudioSettings.warning, (ConfigDescription)null);
		corePath = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Virtual Core Path", "*/Core", (ConfigDescription)null).Value.ToString();
		modIoPath = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Virtual Mod.Io Pack Location", Paths.PluginPath + "/.AudioCache/CustomData/Audio/*/ModIo", (ConfigDescription)null).Value.ToString();
		Debug.Log((object)("Audio Plug-In: Active. (Diagnostic Mode = " + diagnostics.ToString() + ", Audio Library Sync = " + autoLibrarySync.Value + ")"));
		foreach (MusicKind value in Enum.GetValues(typeof(MusicKind)))
		{
			MusicKind key = value;
			Directory.CreateDirectory((Paths.PluginPath + "/.AudioCache/CustomData/Audio/*/ModIo").Replace("*", ((object)(MusicKind)(ref key)).ToString()));
			currentFolder.Add(key, ((object)(MusicKind)(ref key)).ToString());
			coreAudioSources.Add(key, new SortedDictionary<string, InternedContentAddress>());
		}
		AssetDataPlugin.Subscribe("org.pluginmasters.plugins.audio", (Action<DatumChange>)AudioRequestHandler);
		Harmony val = new Harmony("org.pluginmasters.plugins.audio");
		val.PatchAll();
		GetAllCustomSongs(ref customAudioSources);
		Utility.PostOnMainPage(((object)this).GetType());
	}

	private void AudioRequestHandler(DatumChange change)
	{
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"Audio Plug-In: Remote Request");
		if (change.value.ToString().ToUpper().StartsWith("RELOAD"))
		{
			if (customMusicProvider != null)
			{
				if (diagnostics >= DiagnosticLevel.debug)
				{
					Debug.Log((object)"Audio Plug-In: Library Reload Requested");
				}
				GetAllCustomSongs(ref customAudioSources);
			}
			else if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)"Audio Plug-In: Library Reload Requested With No CustomMusic Provider Instance");
			}
			return;
		}
		if (diagnostics >= DiagnosticLevel.debug)
		{
			Debug.Log((object)"Audio Plug-In: Remote Play Request");
		}
		AtmosphereManager instance = SimpleSingletonBehaviour<AtmosphereManager>.Instance;
		foreach (MusicKind value2 in Enum.GetValues(typeof(MusicKind)))
		{
			for (int i = 0; i < coreAudioSources[value2].Count(); i++)
			{
				if (coreAudioSources[value2].ElementAt(i).Key.Contains("/" + change.value.ToString()))
				{
					Debug.Log((object)"Audio Plug-In: Found Requested Audio In Core Audio Files");
					InternedContentAddress value = coreAudioSources[value2].ElementAt(i).Value;
					instance.TryPlayMusic(ref value, value2);
					return;
				}
			}
		}
		NativeKeyValueArrays<ContentGuid, (InternedContentAddress, UnsafeView<MusicDataV0>, string)> keyValueArrays = MyCustomMusicContentProvider.Music.GetKeyValueArrays((Allocator)3);
		try
		{
			NativeArray<(InternedContentAddress, UnsafeView<MusicDataV0>, string)> values = keyValueArrays.Values;
			Enumerator<(InternedContentAddress, UnsafeView<MusicDataV0>, string)> enumerator2 = values.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					(InternedContentAddress, UnsafeView<MusicDataV0>, string) current = enumerator2.Current;
					if (current.Item3.Contains("/" + change.value.ToString()))
					{
						Debug.Log((object)"Audio Plug-In: Found Requested Audio In Custom Audio Files");
						instance.TryPlayMusic(ref current.Item1, current.Item2.Value.Kind);
						break;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
		}
		finally
		{
			((IDisposable)keyValueArrays).Dispose();
		}
	}

	public void GetAllCustomSongs(ref Dictionary<MusicKind, List<string>> customAudioSources)
	{
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_046e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_059b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0600: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
		customAudioSources.Clear();
		string text = (File.Exists("ModIo.json") ? File.Find("ModIo.json", (CacheType)999)[0] : null);
		if (text != null)
		{
			ModIoAudio.GetSubscribedAudioModsContent(ModIoAudio.GetSubscribedAudioModsList(text), modIoPath);
		}
		if (diagnostics >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)("Audio Plug-In: Ambient Library =\r\n" + string.Join("\r\n", from a in File.Find("/Audio/Ambient/", (CacheType)1)
				where ".ACC|.MP3|.OGG|.WAV|.WWW".Contains(Path.GetExtension(a).ToUpper())
				select a)));
			Debug.Log((object)("Audio Plug-In: Music Library =\r\n" + string.Join("\r\n", from a in File.Find("/Audio/Music/", (CacheType)1)
				where ".ACC|.MP3|.OGG|.WAV|.WWW".Contains(Path.GetExtension(a).ToUpper())
				select a)));
		}
		customAudioSources.Add((MusicKind)1, (from a in File.Find("/Audio/Ambient/", (CacheType)1)
			where ".ACC|.MP3|.OGG|.WAV|.WWW".Contains(Path.GetExtension(a).ToUpper())
			select a).ToList());
		customAudioSources.Add((MusicKind)0, (from a in File.Find("/Audio/Music/", (CacheType)1)
			where ".ACC|.MP3|.OGG|.WAV|.WWW".Contains(Path.GetExtension(a).ToUpper())
			select a).ToList());
		foreach (MusicKind value in Enum.GetValues(typeof(MusicKind)))
		{
			int num = customAudioSources[value].Count();
			for (int i = 0; i < num; i++)
			{
				customAudioSources[value][i] = customAudioSources[value][i].Replace("\\", "/").Substring(customAudioSources[value][i].IndexOf("/Audio/") + "/Audio/".Length);
				customAudioSources[value][i] = customAudioSources[value][i].Substring(0, customAudioSources[value][i].Replace("\\", "/").LastIndexOf("/")) + "/" + Path.GetFileNameWithoutExtension(customAudioSources[value][i]) + "♫";
				string[] array = customAudioSources[value][i].Substring(0, customAudioSources[value][i].Replace("\\", "/").LastIndexOf("/")).Split('/');
				string text2 = array[0];
				for (int j = 1; j < array.Length; j++)
				{
					if (!customAudioSources[value].Contains(text2 + "/[" + array[j] + "]►"))
					{
						customAudioSources[value].Add(text2 + "/[" + array[j] + "]►");
					}
					if (!customAudioSources[value].Contains(text2 + "/" + array[j] + "/[Back]►"))
					{
						customAudioSources[value].Add(text2 + "/" + array[j] + "/[Back]►");
					}
					text2 = text2 + "/" + array[j];
				}
			}
		}
		KeyValuePair<MusicKind, string>[] array2 = new KeyValuePair<MusicKind, string>[2]
		{
			new KeyValuePair<MusicKind, string>((MusicKind)1, corePath.Replace("*/", "Ambient/")),
			new KeyValuePair<MusicKind, string>((MusicKind)0, corePath.Replace("*/", "Music/"))
		};
		for (int k = 0; k < array2.Length; k++)
		{
			KeyValuePair<MusicKind, string> keyValuePair = array2[k];
			string[] array3 = keyValuePair.Value.Replace("\\", "/").Split("/");
			string text3 = array3[0];
			for (int l = 1; l < array3.Length; l++)
			{
				if (!customAudioSources[keyValuePair.Key].Contains(text3 + "/[" + array3[l] + "]►"))
				{
					customAudioSources[keyValuePair.Key].Add(text3 + "/[" + array3[l] + "]►");
				}
				if (!customAudioSources[keyValuePair.Key].Contains(text3 + "/" + array3[l] + "/[Back]►"))
				{
					customAudioSources[keyValuePair.Key].Add(text3 + "/" + array3[l] + "/[Back]►");
				}
				text3 = text3 + "/" + array3[l];
			}
		}
		if (diagnostics >= DiagnosticLevel.debug)
		{
			foreach (MusicKind value2 in Enum.GetValues(typeof(MusicKind)))
			{
				MusicKind key2 = value2;
				for (int m = 0; m < customAudioSources[key2].Count(); m++)
				{
					Debug.Log((object)("Audio Plug-In: Adding Audio File. Type '" + ((object)(MusicKind)(ref key2)).ToString() + "', Location '" + customAudioSources[key2][m] + "'"));
				}
			}
		}
		if (customMusicProvider != null)
		{
			MyCustomMusicContentProvider.BuildSongReferences();
		}
	}

	public static void ProcessDropdownCreation(ref TMP_Dropdown ____dropdown, MusicKind ____type, ref List<InternedContentAddress> ____trackList)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Invalid comparison between Unknown and I4
		//IL_0208: 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_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0493: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_059d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0761: Unknown result type (might be due to invalid IL or missing references)
		//IL_0763: Invalid comparison between Unknown and I4
		//IL_055b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_0584: Unknown result type (might be due to invalid IL or missing references)
		//IL_0524: Unknown result type (might be due to invalid IL or missing references)
		//IL_0540: Unknown result type (might be due to invalid IL or missing references)
		//IL_040b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_077c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0781: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0766: Unknown result type (might be due to invalid IL or missing references)
		//IL_076b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0774: Unknown result type (might be due to invalid IL or missing references)
		//IL_078f: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: 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_067d: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0816: Unknown result type (might be due to invalid IL or missing references)
		//IL_081b: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08da: Expected O, but got Unknown
		if (diagnostics >= DiagnosticLevel.info)
		{
			Debug.Log((object)"Audio Plug-In: Building Audio Options");
		}
		AtmosphereReferenceData currentReferenceData = AtmosphereManager.GetCurrentReferenceData();
		NativeKeyValueArrays<ContentGuid, (InternedContentAddress, UnsafeView<MusicDataV0>, string)> keyValueArrays = MyCustomMusicContentProvider.Music.GetKeyValueArrays((Allocator)3);
		try
		{
			List<string> list = new List<string>();
			NativeArray<ContentGuid> val = default(NativeArray<ContentGuid>);
			NativeArray<(InternedContentAddress, UnsafeView<MusicDataV0>, string)> val2 = default(NativeArray<(InternedContentAddress, UnsafeView<MusicDataV0>, string)>);
			NativeCollectionExtensionMethods.Deconstruct<ContentGuid, (InternedContentAddress, UnsafeView<MusicDataV0>, string)>(keyValueArrays, ref val, ref val2);
			SortedDictionary<string, InternedContentAddress> sortedDictionary = new SortedDictionary<string, InternedContentAddress>();
			SortedDictionary<string, ContentGuid> source = new SortedDictionary<string, ContentGuid>();
			if (coreAudioSources[____type].Count() == 0)
			{
				if (diagnostics >= DiagnosticLevel.debug)
				{
					Debug.Log((object)("Audio Plug-In: Storing " + (____dropdown.options.Count() - 1) + " Core " + ((object)(MusicKind)(ref ____type)).ToString() + " Audio Options"));
				}
				for (int i = 1; i < ____dropdown.options.Count(); i++)
				{
					if (diagnostics >= DiagnosticLevel.ultra)
					{
						Debug.Log((object)("Audio Plug-In: Storing Item '" + ____dropdown.options[i].text + "'"));
					}
					coreAudioSources[____type].Add(____dropdown.options[i].text, ____trackList[i - 1]);
				}
			}
			if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)"Audio Plug-In: Clear Audio Options");
			}
			____trackList.Clear();
			____dropdown.ClearOptions();
			if ((int)____type == 1)
			{
				____dropdown.AddOptions(new List<string> { "Default" });
			}
			else
			{
				____dropdown.AddOptions(new List<string> { "Silence" });
			}
			if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)("Audio Plug-In: Adding Custom Links (" + (val.Length > 0) + ") For " + currentFolder[____type]));
			}
			if (val.Length > 0)
			{
				for (int j = 0; j < val.Length; j++)
				{
					(InternedContentAddress, UnsafeView<MusicDataV0>, string) tuple = val2[j];
					if (diagnostics >= DiagnosticLevel.ultra)
					{
						Debug.Log((object)("Audio Plug-In: Checks For '" + tuple.Item3 + "'': '" + ((object)(MusicKind)(ref tuple.Item2.Value.Kind)).ToString() + "' vs '" + ((object)(MusicKind)(ref ____type)).ToString() + "' | '" + tuple.Item3.Substring(0, tuple.Item3.Replace("\\", "/").LastIndexOf("/")) + "' vs '" + currentFolder[____type] + "' | " + tuple.Item3.EndsWith("►")));
					}
					if (tuple.Item2.Value.Kind == ____type && tuple.Item3.Substring(0, tuple.Item3.Replace("\\", "/").LastIndexOf("/")) == currentFolder[____type] && tuple.Item3.EndsWith("►"))
					{
						if (diagnostics >= DiagnosticLevel.ultra)
						{
							Debug.Log((object)("Audio Plug-In: Adding Link '" + tuple.Item3 + "' For " + currentFolder[____type]));
						}
						sortedDictionary.Add(tuple.Item3.Substring(tuple.Item3.Replace("\\", "/").LastIndexOf("/") + 1), tuple.Item1);
					}
				}
			}
			if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)("Audio Plug-In: Adding Core Audio Options (" + (currentFolder[____type] == corePath.Replace("*/", ((object)(MusicKind)(ref ____type)).ToString() + "/")) + ")  For " + currentFolder[____type]));
			}
			string text = ((coreInclusionSettings.Value == CoreAudioInclusionSettings.first) ? "♪" : "");
			if (currentFolder[____type] == corePath.Replace("*/", ((object)(MusicKind)(ref ____type)).ToString() + "/"))
			{
				for (int k = 0; k < coreAudioSources[____type].Keys.Count(); k++)
				{
					if (diagnostics >= DiagnosticLevel.ultra)
					{
						Debug.Log((object)("Audio Plug-In: Adding Core Item '" + coreAudioSources[____type].Keys.ElementAt(k) + "' For " + currentFolder[____type]));
					}
					sortedDictionary.Add(text + coreAudioSources[____type].Keys.ElementAt(k), coreAudioSources[____type].Values.ElementAt(k));
				}
			}
			if (diagnostics >= DiagnosticLevel.debug)
			{
				Debug.Log((object)("Audio Plug-In: Adding Custom Audio Options (" + (val.Length > 0) + ")"));
			}
			if (val.Length > 0)
			{
				text = ((coreInclusionSettings.Value == CoreAudioInclusionSettings.last) ? "♪" : "");
				for (int l = 0; l < val.Length; l++)
				{
					(InternedContentAddress, UnsafeView<MusicDataV0>, string) tuple2 = val2[l];
					if (tuple2.Item2.Value.Kind == ____type && tuple2.Item3.Substring(0, tuple2.Item3.Replace("\\", "/").LastIndexOf("/")) == currentFolder[____type] && tuple2.Item3.EndsWith("♫"))
					{
						if (diagnostics >= DiagnosticLevel.ultra)
						{
							Debug.Log((object)("Audio Plug-In: Adding Custom Item '" + tuple2.Item3 + "' For " + currentFolder[____type]));
						}
						sortedDictionary.Add(text + tuple2.Item3.Substring(tuple2.Item3.Replace("\\", "/").LastIndexOf("/") + 1), tuple2.Item1);
					}
				}
			}
			if (diagnostics >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)"Audio Plug-In: Getting Atmosphere Selection");
			}
			InternedContentAddress val3;
			ContentGuid asContentId;
			if ((int)____type != 1)
			{
				val3 = currentReferenceData.Music;
				asContentId = ((ContentRef)(ref val3.ContentRef)).AsContentId;
			}
			else
			{
				val3 = currentReferenceData.AmbientMusic;
				asContentId = ((ContentRef)(ref val3.ContentRef)).AsContentId;
			}
			ContentGuid val4 = asContentId;
			if (diagnostics >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Audio Plug-In: Atmosphere Selection Is " + Convert.ToString(val4)));
			}
			int num = 0;
			if (((object)(ContentGuid)(ref val4)).ToString() != "00000000-0000-0000-0000-000000000000")
			{
				try
				{
					if (diagnostics >= DiagnosticLevel.ultra)
					{
						Debug.Log((object)"Audio Plug-In: Seeking Dropdown Selected Item");
					}
					for (int m = 0; m < sortedDictionary.Count(); m++)
					{
						if (source.ElementAt(m).Value == val4)
						{
							num = m;
							if (diagnostics >= DiagnosticLevel.ultra)
							{
								Debug.Log((object)("Audio Plug-In: Current Dropdown Selection Is " + num));
							}
						}
					}
					if (num == -1)
					{
						string text2 = "/Audio/" + ((missingContentAudio.Value == MissingContentAudioSettings.silence) ? "Silence.mp3" : "Warning.mp3");
						text2 = "file:/" + File.Find(text2, (CacheType)999).ElementAt(0);
						Debug.LogWarning((object)("Audio Plug-In: Trying To Play Fallback Audio " + text2));
						SoundPlayer val5 = new SoundPlayer();
						try
						{
							val5.SoundLocation = text2;
							val5.Load();
							val5.Play();
						}
						finally
						{
							((IDisposable)val5)?.Dispose();
						}
						num = 0;
					}
				}
				catch (Exception)
				{
				}
			}
			else if (diagnostics >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Audio Plug-In: Atmosohere Has No Selection Made For " + ((object)(MusicKind)(ref ____type)).ToString()));
			}
			____trackList.AddRange(sortedDictionary.Values.ToList());
			____dropdown.AddOptions(sortedDictionary.Keys.ToList());
			if (diagnostics >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Audio Plug-In: Applying Current Dropdown Selection Of " + num));
			}
			____dropdown.SetValueWithoutNotify(num);
		}
		finally
		{
			((IDisposable)keyValueArrays).Dispose();
		}
	}

	public static bool ProcessDropdownSelection(int index, ref TMP_Dropdown ____dropdown, MusicKind ____type, ref List<InternedContentAddress> ____trackList)
	{
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: 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_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		if (diagnostics >= DiagnosticLevel.info)
		{
			Debug.Log((object)("Audio Plug-In: Selected '" + ____dropdown.options[index].text + "'"));
		}
		if (!____dropdown.options[index].text.EndsWith("►"))
		{
			return true;
		}
		if (____dropdown.options[index].text == "[Back]►")
		{
			currentFolder[____type] = currentFolder[____type].Substring(0, currentFolder[____type].LastIndexOf("/"));
		}
		else
		{
			currentFolder[____type] = currentFolder[____type] + "/" + ____dropdown.options[index].text.Substring(1, ____dropdown.options[index].text.Length - 3);
		}
		currentFolder[____type] = currentFolder[____type].Replace("\\", "/");
		if (diagnostics >= DiagnosticLevel.debug)
		{
			Debug.Log((object)("Audio Plug-In: Current Folder Is '" + currentFolder[____type] + "'"));
		}
		ProcessDropdownCreation(ref ____dropdown, ____type, ref ____trackList);
		return false;
	}

	public static void ProcessAudioClipLoad(NativeHashMap<ContentGuid, (InternedContentAddress address, UnsafeView<MusicDataV0> data, string name)> Music, Destination contentDestination, in InternedContentAddress contentAddress)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Invalid comparison between Unknown and I4
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Invalid comparison between Unknown and I4
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		(InternedContentAddress, UnsafeView<MusicDataV0>, string) tuple = default((InternedContentAddress, UnsafeView<MusicDataV0>, string));
		if (Music.TryGetValue(((ContentRef)(ref contentAddress.ContentRef)).AsContentId, ref tuple))
		{
			if (diagnostics >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)(((object)(MusicKind)(ref tuple.Item2.Value.Kind)).ToString() + ": " + ((String)(ref tuple.Item2.Value.Name)).GetString() + ": " + ((String)(ref tuple.Item2.Value.Description)).GetString() + ": " + ((Packed)(ref tuple.Item2.Value.Address)).ToUri()));
			}
			string text = ((String)(ref tuple.Item2.Value.Name)).GetString().Replace("♫", "").Replace("♪", "")
				.Replace("\\", "/");
			if (text.Contains("/GM/"))
			{
				text = text.Substring(text.IndexOf("/GM/") + 4);
			}
			text = File.Find("/Audio/" + text, (CacheType)999).ElementAt(0);
			if (Path.GetExtension(text).ToUpper() == ".WWW")
			{
				text = ((!virtualWWWFiles.ContainsKey(Path.GetFileNameWithoutExtension(text))) ? File.ReadAllText(text, (CacheType)999) : virtualWWWFiles[Path.GetFileNameWithoutExtension(text)]);
			}
			if (!text.ToUpper().StartsWith("HTTP"))
			{
				text = "file:/" + text;
			}
			string text2 = "Loading";
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)0);
			try
			{
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				if ((int)audioClip.result == 1)
				{
					AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
					ContentManager.TryDeliverContent(contentDestination, content);
					text2 = "Success";
				}
				else
				{
					text2 = audioClip.error;
				}
			}
			finally
			{
				((IDisposable)audioClip)?.Dispose();
			}
			if (!(text2 != "Success"))
			{
				return;
			}
			Debug.LogWarning((object)("Audio Plug-In: Failure To Load Clip '" + text + "'"));
			Debug.LogWarning((object)("Audio Plug-In: " + text2));
			try
			{
				text = "/Audio/" + ((missingContentAudio.Value == MissingContentAudioSettings.silence) ? "Silence.mp3" : "Warning.mp3");
				text = "file:/" + File.Find(text, (CacheType)999).ElementAt(0);
				Debug.LogWarning((object)("Audio Plug-In: Trying To Play Fallback Audio " + text));
				UnityWebRequest audioClip2 = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)0);
				try
				{
					audioClip2.SendWebRequest();
					while (!audioClip2.isDone)
					{
					}
					if ((int)audioClip2.result == 1)
					{
						AudioClip content2 = DownloadHandlerAudioClip.GetContent(audioClip2);
						ContentManager.TryDeliverContent(contentDestination, content2);
					}
					return;
				}
				finally
				{
					((IDisposable)audioClip2)?.Dispose();
				}
			}
			catch
			{
				return;
			}
		}
		ContentGuid asContentId = ((ContentRef)(ref contentAddress.ContentRef)).AsContentId;
		Debug.LogWarning((object)("Audio Plug-In: Requested Item Address " + ((object)(ContentGuid)(ref asContentId)).ToString() + " Not Registered."));
		ContentManager.TryDeliverFailure(contentDestination, (ContentLoadFailureReason)5);
	}
}

ModIoAudio.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Newtonsoft.Json;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ModIoAudio")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModIoAudio")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("624a9ff8-711b-4ad8-942b-1ea5e21f3f49")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LordAshes;

public class ModIoAudio
{
	public class Download
	{
		public string binary_url { get; set; } = "";

	}

	public class ModFile
	{
		public string filename { get; set; } = "";


		public string songfilename { get; set; } = "";


		public Download download { get; set; } = new Download();

	}

	public class Mod
	{
		public ulong id { get; set; } = 0uL;


		public ulong game_id { get; set; } = 0uL;


		public string summary { get; set; } = "";


		public string description { get; set; } = "";


		public string kind { get; set; } = "Music";


		public string name { get; set; } = "";


		public string name_id { get; set; } = "";


		public string pack { get; set; } = "";


		public ModFile modFile { get; set; } = new ModFile();


		public Guid guid { get; set; } = Guid.Empty;

	}

	public class Mods
	{
		public List<Mod> data { get; set; } = new List<Mod>();


		public int result_count { get; set; } = 0;


		public int result_offset { get; set; } = 0;


		public int result_limit { get; set; } = 0;


		public int result_total { get; set; } = 0;

	}

	public static string api = "https://g-6518.modapi.io/v1";

	public static ulong game_id = 6518uL;

	public static Mods GetAudioModsList(string api_key = null, string oauth2file = "OAuth2.txt")
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		Mods mods = new Mods();
		HttpClient val = new HttpClient();
		try
		{
			bool flag = false;
			int num = 0;
			while (!flag)
			{
				val.DefaultRequestHeaders.Accept.Clear();
				val.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
				string text = "";
				if (api_key == null)
				{
					val.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", File.ReadAllText(oauth2file));
					text = api + "/games/" + game_id + "/mods";
				}
				else
				{
					text = api + "/games/" + game_id + "/mods?api_key=" + api_key;
				}
				Task<string> stringAsync = val.GetStringAsync(text + "&_offset=" + num);
				stringAsync.Wait();
				Mods mods2 = JsonConvert.DeserializeObject<Mods>(stringAsync.Result);
				if (mods2.result_count == 0)
				{
					flag = true;
					continue;
				}
				mods.data.AddRange(mods2.data);
				num += 100;
			}
		}
		finally
		{
			((IDisposable)val)?.Dispose();
		}
		mods.result_offset = 0;
		mods.result_count = mods.data.Count();
		mods.result_limit = mods.data.Count();
		mods.result_total = mods.data.Count();
		return mods;
	}

	public static Mods GetSubscribedAudioModsList(string oauth2file = "OAuth2.txt")
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		Mods mods = new Mods();
		HttpClient val = new HttpClient();
		try
		{
			bool flag = false;
			int num = 0;
			while (!flag)
			{
				val.DefaultRequestHeaders.Accept.Clear();
				val.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", File.ReadAllText(oauth2file));
				val.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
				Task<string> stringAsync = val.GetStringAsync(api + "/me/subscribed?_offset=" + num);
				stringAsync.Wait();
				Mods mods2 = JsonConvert.DeserializeObject<Mods>(stringAsync.Result);
				if (mods2.result_count == 0)
				{
					flag = true;
					continue;
				}
				foreach (Mod datum in mods2.data)
				{
					if (datum.game_id == game_id)
					{
						mods.data.Add(datum);
					}
				}
				num += 100;
			}
		}
		finally
		{
			((IDisposable)val)?.Dispose();
		}
		mods.result_offset = 0;
		mods.result_count = mods.data.Count();
		mods.result_limit = mods.data.Count();
		mods.result_total = mods.data.Count();
		return mods;
	}

	public static Mod GetAudioModInfo(string id, string api_key = null, string oauth2file = "OAuth2.txt")
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		Mods mods = new Mods();
		HttpClient val = new HttpClient();
		try
		{
			val.DefaultRequestHeaders.Accept.Clear();
			val.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
			string text = "";
			if (api_key == null)
			{
				val.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", File.ReadAllText(oauth2file));
				text = api + "/games/" + game_id + "/mods/" + id;
			}
			else
			{
				text = api + "/games/" + game_id + "/mods/" + id + "?api_key=" + api_key;
			}
			Task<string> stringAsync = val.GetStringAsync(text);
			stringAsync.Wait();
			return JsonConvert.DeserializeObject<Mod>(stringAsync.Result);
		}
		finally
		{
			((IDisposable)val)?.Dispose();
		}
	}

	public static void GetSubscribedAudioModsContent(Mods mods, string relativePath)
	{
		Mods mods2 = new Mods();
		foreach (Mod datum in mods.data)
		{
			if (!Directory.Exists(relativePath.Replace("/*/", "/Ambient/") + "/" + datum.name) && !Directory.Exists(relativePath.Replace("/*/", "/Music/") + "/" + datum.name))
			{
				if (!Directory.Exists(relativePath.Replace("/*/", "/Ambient/") + "/" + datum.name))
				{
					Directory.CreateDirectory(relativePath.Replace("/*/", "/Ambient/") + "/" + datum.name);
				}
				if (!Directory.Exists(relativePath.Replace("/*/", "/Music/") + "/" + datum.name))
				{
					Directory.CreateDirectory(relativePath.Replace("/*/", "/Music/") + "/" + datum.name);
				}
				DownloadModIoPackContent(datum.modFile.download.binary_url, relativePath + "/" + datum.name + "/");
			}
		}
	}

	public static string GetModDownloadURL(Guid guid, string api_key = null)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		ulong num = ulong.Parse(guid.ToString().Substring(guid.ToString().Length - 12));
		HttpClient val = new HttpClient();
		try
		{
			val.DefaultRequestHeaders.Accept.Clear();
			val.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
			string text = "";
			if (api_key == null)
			{
				val.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", File.ReadAllText("OAuth2.txt"));
				text = api + "/games/" + game_id + "/mods/" + num;
			}
			else
			{
				text = api + "/games/" + game_id + "/mods/" + num + "?api_key=" + api_key;
			}
			Task<string> stringAsync = val.GetStringAsync(text);
			stringAsync.Wait();
			Mod mod = JsonConvert.DeserializeObject<Mod>(stringAsync.Result);
			return mod.modFile.download.binary_url;
		}
		finally
		{
			((IDisposable)val)?.Dispose();
		}
	}

	public static void DownloadModIoPackContent(string URL, string destination)
	{
		using WebClient webClient = new WebClient();
		webClient.DownloadFile(URL, "./pack.zip");
		using (ZipArchive zipArchive = ZipFile.OpenRead("./pack.zip"))
		{
			foreach (ZipArchiveEntry entry in zipArchive.Entries)
			{
				string destinationFileName = destination.Replace("/*/", "/" + entry.ToString().Substring(0, entry.ToString().IndexOf("/")) + "/") + "/" + entry.ToString().Substring(entry.ToString().IndexOf("/") + 1);
				entry.ExtractToFile(destinationFileName);
			}
		}
		File.Delete("./pack.zip");
	}
}