Decompiled source of AudioPlugin CCM v1.0.3

AudioPlugin_CCM.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Bounce.Singletons;
using HarmonyLib;
using ModdingTales;
using UnityEngine;
using UnityEngine.Networking;

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

[BepInPlugin("org.lordashes.plugins.audio.ccm", "Audio Plugin", "1.0.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AudioPlugin : BaseUnityPlugin
{
	public static class Provider
	{
		public static IEnumerator GetAudioAssets(ReadOnlyDictionary<string, AssetInfo> existingAssets, Func<Dictionary<string, AssetInfo>, IEnumerator> callback)
		{
			LoggingPlugin.LogInfo("Loading Icons");
			byte[] iconStop = ImageConversion.EncodeToPNG(Image.LoadTexture("org.lordashes.plugins.audio.ccm.Stop.png", (CacheType)999));
			byte[] iconVolUp = ImageConversion.EncodeToPNG(Image.LoadTexture("org.lordashes.plugins.audio.ccm.VolumeUp.png", (CacheType)999));
			byte[] iconVolDown = ImageConversion.EncodeToPNG(Image.LoadTexture("org.lordashes.plugins.audio.ccm.VolumeDown.png", (CacheType)999));
			byte[] iconLoop = ImageConversion.EncodeToPNG(Image.LoadTexture("org.lordashes.plugins.audio.ccm.Loop.png", (CacheType)999));
			byte[] imageBytes = ImageConversion.EncodeToPNG(Image.LoadTexture("Kind.Audio.png", (CacheType)999));
			LoggingPlugin.LogInfo("Collecting audio files");
			string[] audioFiles = (from file in File.Catalog(false)
				where "|.MP3|.WAV|.OGG|.WWW|".Contains(file.Substring(file.Length - 4).ToUpper())
				select file).ToArray();
			LoggingPlugin.LogInfo("Found " + audioFiles.Length + " Potential Audio Assets. Aware Of " + existingAssets.Count + " Registered Assets.");
			Dictionary<string, AssetInfo> assets = new Dictionary<string, AssetInfo>();
			bool addedAmbientControl = false;
			bool addedMusicControl = false;
			LoggingPlugin.LogInfo("Building Audio Files Items");
			string[] array = audioFiles;
			foreach (string audioFile in array)
			{
				yield return (object)new WaitForEndOfFrame();
				string audioSource = File.Find(audioFile, (CacheType)999).ElementAt(0);
				string prefab = Path.GetFileNameWithoutExtension(audioFile);
				string group = Path.GetFileNameWithoutExtension(Path.GetDirectoryName(audioFile));
				string kind = Path.GetFileNameWithoutExtension(Path.GetDirectoryName(Path.GetDirectoryName(audioFile)));
				string pack2 = audioSource.Substring(Paths.PluginPath.Length + 1);
				pack2 = pack2.Substring(0, pack2.IndexOf("/", 1));
				if (kind.ToUpper() == "AUDIO")
				{
					kind = group;
					group = "General";
				}
				LoggingPlugin.LogTrace("Found Asset (Kind: Audio, Category: " + kind + ", Header: Audio, Group: " + group + ", Pack: " + pack2 + ", Name: " + insertSpaces(prefab) + ", Prefab: " + prefab + ", File: " + audioSource + ")");
				if (!existingAssets.ContainsKey(prefab) && !assets.ContainsKey(prefab))
				{
					_self.notification = "Registering... [Provider: AUDIO, Pack: " + group + ", Item: " + prefab + "]";
					if (kind.ToUpper() == "AMBIENT" && !addedAmbientControl)
					{
						addedAmbientControl = true;
						assets.Add("[Audio.Ambient.Stop]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Ambient",
							groupName = "[Control Ambient]",
							name = "Stop Ambient",
							prefab = ".STOP.Ambient",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..STOP.Ambient.png", iconStop, (CacheType)999);
						assets.Add("[Audio.Ambient.VolumeUp]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Ambient",
							groupName = "[Control Ambient]",
							name = "Volume Up",
							prefab = ".VOL.Ambient.Up",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..VOL.Ambient.Up.png", iconVolUp, (CacheType)999);
						assets.Add("[Audio.Ambient.VolumeDown]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Ambient",
							groupName = "[Control Ambient]",
							name = "Volume Down",
							prefab = ".VOL.Ambient.Down",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..VOL.Ambient.Down.png", iconVolDown, (CacheType)999);
						assets.Add("[Audio.Ambient.Loop]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Ambient",
							groupName = "[Control Ambient]",
							name = "Toggle Loop",
							prefab = ".LOOP.Ambient",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..LOOP.Ambient.png", iconLoop, (CacheType)999);
					}
					if (kind.ToUpper() == "MUSIC" && !addedMusicControl)
					{
						addedMusicControl = true;
						assets.Add("[Audio.Music.Stop]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Music",
							groupName = "[Control Music]",
							name = "Stop Music",
							prefab = ".STOP.Music",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..STOP.Music.png", iconStop, (CacheType)999);
						assets.Add("[Audio.Music.VolumeUp]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Music",
							groupName = "[Control Music]",
							name = "Volume Up",
							prefab = ".VOL.Music.Up",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..VOL.Music.Up.png", iconVolUp, (CacheType)999);
						assets.Add("[Audio.Music.VolumeDown]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Music",
							groupName = "[Control Music]",
							name = "Volume Down",
							prefab = ".VOL.Music.Down",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..VOL.Music.Down.png", iconVolDown, (CacheType)999);
						assets.Add("[Audio.Music.Loop]", new AssetInfo
						{
							provider = "AUDIO",
							pack = "AudioPlugin",
							kind = "Audio",
							category = "Audio",
							header = "Music",
							groupName = "[Control Music]",
							name = "Toggle Loop",
							prefab = ".LOOP.Music",
							filename = ""
						});
						File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait..LOOP.Music.png", iconLoop, (CacheType)999);
					}
					assets.Add(prefab, new AssetInfo
					{
						provider = "AUDIO",
						pack = pack2,
						kind = "Audio",
						category = "Audio",
						header = kind,
						groupName = group,
						name = insertSpaces(prefab),
						prefab = prefab.Replace(" ", ""),
						filename = (audioFile.ToUpper().EndsWith(".WWW") ? File.ReadAllText(audioFile, (CacheType)999) : ("File:///" + audioSource))
					});
					File.WriteAllBytes(Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/Portrait." + prefab.Replace(" ", "") + ".png", imageBytes, (CacheType)999);
				}
			}
			_self.notification = null;
			((MonoBehaviour)_self).StartCoroutine(callback((from kvp in assets
				orderby kvp.Value.header, kvp.Value.category, kvp.Value.name
				select kvp).ToDictionary((KeyValuePair<string, AssetInfo> kvp) => kvp.Key, (KeyValuePair<string, AssetInfo> kvp) => kvp.Value)));
		}

		public static void AudioRequest(AssetInfo assetInfo)
		{
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			if (Utility.isBoardLoaded())
			{
				LoggingPlugin.LogInfo("Requesting Audio '" + assetInfo.prefab + "'");
				if (assetInfo.prefab.StartsWith(".VOL."))
				{
					if (assetInfo.prefab.EndsWith("Up"))
					{
						if (assetInfo.header.ToUpper() == "AMBIENT")
						{
							LoggingPlugin.LogInfo("Increasing Ambient Volume");
							if (_self.volumeAmbient.Value <= 0.9f)
							{
								ConfigEntry<float> volumeAmbient = _self.volumeAmbient;
								volumeAmbient.Value += 0.1f;
							}
						}
						else
						{
							LoggingPlugin.LogInfo("Increasing Music Volume");
							if (_self.volumeMusic.Value <= 0.9f)
							{
								ConfigEntry<float> volumeMusic = _self.volumeMusic;
								volumeMusic.Value += 0.1f;
							}
						}
					}
					else if (assetInfo.prefab.EndsWith("Down"))
					{
						if (assetInfo.header.ToUpper() == "AMBIENT")
						{
							LoggingPlugin.LogInfo("Decreasing Ambient Volume");
							if (_self.volumeAmbient.Value >= 0.1f)
							{
								ConfigEntry<float> volumeAmbient2 = _self.volumeAmbient;
								volumeAmbient2.Value -= 0.1f;
							}
						}
						else
						{
							LoggingPlugin.LogInfo("Decreasing Music Volume");
							if (_self.volumeMusic.Value >= 0.1f)
							{
								ConfigEntry<float> volumeMusic2 = _self.volumeMusic;
								volumeMusic2.Value -= 0.1f;
							}
						}
					}
					SystemMessage.DisplayInfoText("Ambient Volume: " + Math.Max(0, Math.Min(100, (int)(100.0 * ((double)_self.volumeAmbient.Value + 0.01)))) + "%\r\nMusic Volume: " + Math.Max(0, Math.Min(100, (int)(100.0 * ((double)_self.volumeMusic.Value + 0.01)))) + "%", 2.5f, 0f);
					((BaseUnityPlugin)CommonCustomsMenuPlugin._self).Config.Save();
					GameObject val = GameObject.Find("AudioSpeaker.Ambient");
					if ((Object)(object)val == (Object)null)
					{
						LoggingPlugin.LogInfo("Audio Plugin: Creating Audio Speaker");
						val = new GameObject();
						((Object)val).name = "AudioSpeaker.Ambient";
						val.AddComponent<AudioSource>();
					}
					AudioSource component = val.GetComponent<AudioSource>();
					component.volume = _self.volumeAmbient.Value;
					val = GameObject.Find("AudioSpeaker.Music");
					if ((Object)(object)val == (Object)null)
					{
						LoggingPlugin.LogInfo("Audio Plugin: Creating Audio Speaker");
						val = new GameObject();
						((Object)val).name = "AudioSpeaker.Music";
						val.AddComponent<AudioSource>();
					}
					component = val.GetComponent<AudioSource>();
					component.volume = _self.volumeMusic.Value;
				}
				else if (assetInfo.prefab.StartsWith(".LOOP."))
				{
					if (assetInfo.header.ToUpper() == "AMBIENT")
					{
						_self.loopAmbient.Value = !_self.loopAmbient.Value;
					}
					else
					{
						_self.loopMusic.Value = !_self.loopMusic.Value;
					}
					SystemMessage.DisplayInfoText("Ambient Loop: " + (_self.loopAmbient.Value ? "Yes" : "No") + "\r\nMusic Loop: " + (_self.loopMusic.Value ? "Yes" : "No"), 2.5f, 0f);
					((BaseUnityPlugin)CommonCustomsMenuPlugin._self).Config.Save();
				}
				else if (!SafeCalls.InvokeWithSuccessBool("LordAshes.AssetDataPlugin, AssetDataPlugin", "SetInfo", new object[4] { "SPEAKERS", "org.lordashes.plugins.audio.ccm.audio", assetInfo.prefab, false }, (object)null))
				{
					LoggingPlugin.LogInfo("Distribution Failed. Playing Audio '" + assetInfo.prefab + "' Locally");
					RemoteAudioRequest("Add", "SPEAKERS", "org.lordashes.plugins.audio.ccm.audio", "", assetInfo.prefab);
				}
			}
			else
			{
				SystemMessage.DisplayInfoText("Audio Can Only Be Played\r\nWhen A Board Is Loaded", 2.5f, 0f);
			}
		}

		public static IEnumerator PlayAudio(string audio, string type)
		{
			LoggingPlugin.LogInfo("Audio Plugin: Audio URL = '" + audio + "' For 'AudioSpeaker." + type + "'");
			LoggingPlugin.LogInfo("Audio Plugin: Getting Audio Speaker");
			GameObject speaker = GameObject.Find("AudioSpeaker." + type);
			if ((Object)(object)speaker == (Object)null)
			{
				LoggingPlugin.LogInfo("Audio Plugin: Creating Audio Speaker");
				speaker = new GameObject();
				((Object)speaker).name = "AudioSpeaker." + type;
				speaker.AddComponent<AudioSource>();
			}
			LoggingPlugin.LogInfo("Audio Plugin: Creating Audio Speaker Source");
			AudioSource player = speaker.GetComponent<AudioSource>();
			player.volume = ((type.ToUpper() == "AMBIENT") ? _self.volumeAmbient.Value : _self.volumeMusic.Value);
			player.loop = ((type.ToUpper() == "AMBIENT") ? _self.loopAmbient.Value : _self.loopMusic.Value);
			if (audio != "" || audio.StartsWith("#STOP."))
			{
				LoggingPlugin.LogInfo("Audio Plugin: Starting Audio '" + audio + "' Request");
				UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(audio, (AudioType)0);
				try
				{
					yield return www.SendWebRequest();
					if ((int)www.result == 2)
					{
						LoggingPlugin.LogWarning("Audio Plugin: Failure To Request '" + audio + "'");
						LoggingPlugin.LogWarning(www.error);
						yield break;
					}
					Debug.Log((object)("Audio Plugin: Loading Audio '" + audio + "'"));
					player.clip = DownloadHandlerAudioClip.GetContent(www);
					Debug.Log((object)("Audio Plugin: Playing Audio '" + audio + "'"));
					player.Play();
				}
				finally
				{
					((IDisposable)www)?.Dispose();
				}
			}
			else
			{
				Debug.Log((object)"Audio Plugin: Stopping Audio");
				player.Stop();
			}
		}

		private static string insertSpaces(string camelCase)
		{
			string text = camelCase.Substring(0, 1);
			for (int i = 1; i < camelCase.Length; i++)
			{
				if (camelCase.Substring(i - 1, 1) == camelCase.Substring(i - 1, 1).ToLower() && camelCase.Substring(i, 1) == camelCase.Substring(i - 1, 1).ToUpper() && camelCase.Substring(i, 1).ToLower() != camelCase.Substring(i - 1, 1).ToUpper())
				{
					text += " ";
				}
				text += camelCase.Substring(i, 1);
			}
			return text;
		}
	}

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

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

		public static GameObject FindInHierarchy(GameObject start, string seekName)
		{
			List<GameObject> results = new List<GameObject>();
			bool done = false;
			Traverse(start.transform, seekName, null, single: true, ref results, ref done);
			return (results.Count > 0) ? results.ElementAt(0) : null;
		}

		public static GameObject FindInHierarchyViaPartialName(GameObject start, string seekName)
		{
			List<GameObject> results = new List<GameObject>();
			bool done = false;
			Traverse(start.transform, seekName, null, single: true, ref results, ref done, partial: true);
			return (results.Count > 0) ? results.ElementAt(0) : null;
		}

		public static GameObject[] FindAllInHierarchy(GameObject start, string seekName)
		{
			List<GameObject> results = new List<GameObject>();
			bool done = false;
			Traverse(start.transform, seekName, null, single: false, ref results, ref done);
			return results.ToArray();
		}

		public static GameObject[] FindAllInHierarchyViaPartialName(GameObject start, string seekName)
		{
			List<GameObject> results = new List<GameObject>();
			bool done = false;
			Traverse(start.transform, seekName, null, single: false, ref results, ref done, partial: true);
			return results.ToArray();
		}

		public static GameObject FindWithComponentInHierarchy(GameObject start, string seekType)
		{
			List<GameObject> results = new List<GameObject>();
			bool done = false;
			Traverse(start.transform, null, seekType, single: true, ref results, ref done);
			return (results.Count > 0) ? results.ElementAt(0) : null;
		}

		public static GameObject[] FindAllWithComponentInHierarchy<T>(GameObject start, string seekType)
		{
			List<GameObject> results = new List<GameObject>();
			bool done = false;
			Traverse(start.transform, null, seekType, single: false, ref results, ref done);
			return results.ToArray();
		}

		public static void Traverse(Transform root, string seekName, string seekType, bool single, ref List<GameObject> results, ref bool done, bool partial = false)
		{
			try
			{
				if ((seekName == null || seekName == ((Object)((Component)root).gameObject).name || (partial && ((Object)((Component)root).gameObject).name.Contains(seekName))) && (seekType == null || (Object)(object)((Component)root).GetComponent(seekType) != (Object)null))
				{
					LoggingPlugin.LogTrace("Matched '" + ((Object)((Component)root).gameObject).name + "'");
					results.Add(((Component)root).gameObject);
					if (single)
					{
						done = true;
						return;
					}
				}
				foreach (Transform item in ExtensionMethods.Children(root))
				{
					if (!done)
					{
						Traverse(item, seekName, seekType, single, ref results, ref done, partial);
					}
				}
			}
			catch
			{
			}
		}

		public static object LookUp(in Dictionary<string, object> dictionary, string key)
		{
			foreach (KeyValuePair<string, object> item in dictionary)
			{
				if (item.Key.ToUpper() == key.ToUpper())
				{
					return item.Value;
				}
			}
			return null;
		}

		public static void PostOnMainPage(BaseUnityPlugin plugin)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s");
			ModdingUtils.Initialize(plugin, new ManualLogSource("Audio Plugin"), text, false);
		}
	}

	public const string Name = "Audio Plugin";

	public const string Guid = "org.lordashes.plugins.audio.ccm";

	public const string Version = "1.0.3.0";

	public const string Author = "Lord Ashes";

	public static AudioPlugin _self;

	private string notification = null;

	private ConfigEntry<float> volumeAmbient;

	private ConfigEntry<float> volumeMusic;

	private ConfigEntry<bool> loopAmbient;

	private ConfigEntry<bool> loopMusic;

	private void Awake()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Invalid comparison between Unknown and I4
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Expected O, but got Unknown
		_self = this;
		LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
		string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
		DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
		Debug.Log((object)(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")"));
		if ((int)LoggingPlugin.GetLogLevel() >= 4)
		{
			((MonoBehaviour)this).StartCoroutine(WarnAboutLogLevel());
		}
		volumeAmbient = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Ambient Volume (0-1)", 1f, (ConfigDescription)null);
		volumeMusic = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Music Volume (0-1)", 1f, (ConfigDescription)null);
		loopAmbient = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Loop Ambient", true, (ConfigDescription)null);
		loopMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Loop Music", true, (ConfigDescription)null);
		CommonCustomsMenuPlugin.RegisterProvider("AUDIO", "Ambient and music audio", (Func<ReadOnlyDictionary<string, AssetInfo>, Func<Dictionary<string, AssetInfo>, IEnumerator>, IEnumerator>)Provider.GetAudioAssets, (Action<AssetInfo>)delegate(AssetInfo selectedAsset)
		{
			Provider.AudioRequest(selectedAsset);
		});
		SafeCalls.Invoke("LordAshes.AssetDataPlugin, AssetDataPlugin", "SubscribeViaReflection", new object[3]
		{
			"org.lordashes.plugins.audio.ccm.audio",
			((object)this).GetType().AssemblyQualifiedName,
			"RemoteAudioRequest"
		}, (object)null);
		Harmony val = new Harmony("org.lordashes.plugins.audio.ccm");
		val.PatchAll();
		Utility.PostOnMainPage((BaseUnityPlugin)(object)this);
	}

	private void OnGUI()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (notification != null)
		{
			GUI.Label(new Rect(10f, 1030f, 1900f, 30f), notification);
		}
	}

	private IEnumerator WarnAboutLogLevel()
	{
		while (true)
		{
			try
			{
				DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
				SystemMessage.DisplayInfoText("Audio Plugin: Using '" + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + "' diagnostics.\r\nUse 'Info' for better performance", 10f, 0f);
				SystemMessage.DisplayInfoText("Audio Plugin: Use 'Debug' or 'Trace' for\r\ntroubleshooting only.", 10f, 0f);
				break;
			}
			catch
			{
			}
			yield return (object)new WaitForSeconds(1f);
		}
	}

	public static void RemoteAudioRequest(object action, object source, object key, object previous, object current)
	{
		LoggingPlugin.LogInfo("Remote Audio Request For '" + current?.ToString() + "'");
		try
		{
			AssetInfo val = (from info in CommonCustomsMenuPlugin.GetAssets()
				where info.prefab == current.ToString()
				select info).FirstOrDefault();
			LoggingPlugin.LogInfo("Remote Audio Request For URL '" + val.filename + "' From '" + val.header + "'");
			((MonoBehaviour)_self).StartCoroutine(Provider.PlayAudio(val.filename, val.header));
		}
		catch
		{
		}
	}
}