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 Newtonsoft.Json; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CoreAudioProxy_CCM")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Nth Dimension")] [assembly: AssemblyProduct("CoreAudioProxy_CCM")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("CoreAudioProxy_CCM")] [assembly: ComVisible(false)] [assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")] [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; [BepInPlugin("org.lordashes.plugins.coreaudioproxy.ccm", "Core Audio Proxy Plugin", "1.0.0.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 CoreAssetsProxyPlugin : BaseUnityPlugin { public static class Provider { public class Index { public string Name { get; set; } public List Music { get; set; } } public class MusicItem { public string Id { get; set; } public string Name { get; set; } public bool IsDeprecated { get; set; } public string GroupTag { get; set; } public string[] Tags { get; set; } public AssetType Asset { get; set; } } public class AssetType { public string BundleId { get; set; } public string AssetName { get; set; } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string talespireFolder; private string 5__1; private Texture2D 5__2; private byte[] 5__3; private Dictionary 5__4; private string[] <>s__5; private int <>s__6; private string 5__7; private string 5__8; private string 5__9; private Index 5__10; private List.Enumerator <>s__11; private MusicItem 5__12; private AssetInfo 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; <>s__5 = null; 5__7 = null; 5__8 = null; 5__9 = null; 5__10 = null; <>s__11 = default(List.Enumerator); 5__12 = null; 5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; if (!_existingAssets.ContainsKey(5__12.Asset.AssetName)) { AssetInfo val = new AssetInfo(); val.provider = "AUDIO"; val.filename = ("AssetBundle:" + 5__7 + "/Assets/" + 5__12.Asset.BundleId + ":" + 5__12.Asset.AssetName).Replace("\\", "/"); val.pack = 5__12.Asset.BundleId; val.prefab = 5__12.Asset.AssetName; val.name = 5__12.Name; val.kind = "Audio"; val.category = "Audio"; val.header = ((5__12.Asset.BundleId.IndexOf("_amb_") > -1) ? "Ambient" : "Music"); val.groupName = "Core Talespire"; val.description = ((5__12.Asset.BundleId.IndexOf("_amb_") > -1) ? "Ambient Audio" : "Music") + " from Core Talespire"; val.author = "Bouncy Rock"; val.comment = "Core Talespire audio"; val.hasAnimations = false; val.hasAudio = true; val.hasBlendshapes = false; val.tags = "Audio,Core"; 5__13 = val; 5__4.Add(5__13.prefab, 5__13); File.WriteAllBytes(5__1 + "/Portrait." + 5__13.prefab + ".png", 5__3, (CacheType)999); 5__13 = null; } 5__12 = null; goto IL_04c1; } <>1__state = -1; 5__1 = Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/"; 5__2 = Image.LoadTexture("org.lordashes.plugins.coreaudioproxy.ccm.Default.png", (CacheType)999); 5__3 = ImageConversion.EncodeToPNG(5__2); 5__4 = new Dictionary(); talespireFolder += "/Taleweaver"; <>s__5 = Directory.GetDirectories(talespireFolder); <>s__6 = 0; goto IL_0536; IL_04c1: if (<>s__11.MoveNext()) { 5__12 = <>s__11.Current; LoggingPlugin.LogTrace(5__12.Name + " (" + ((5__12.Asset.BundleId.IndexOf("_amb_") > -1) ? "Ambient" : "Music") + ") from " + 5__10.Name); _self.notification = "Registering... [Provider: AUDIO via AUDIOPROXY, Pack: " + 5__10.Name + ", Audio: " + 5__12.Name + "]"; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; } <>m__Finally1(); <>s__11 = default(List.Enumerator); LoggingPlugin.LogTrace(5__10.Name + " from " + 5__8 + ": Processing Completed"); 5__9 = null; 5__10 = null; goto IL_0519; IL_0519: 5__8 = null; 5__7 = null; <>s__6++; goto IL_0536; IL_0536: if (<>s__6 < <>s__5.Length) { 5__7 = <>s__5[<>s__6]; 5__8 = Path.GetFileName(5__7); if (5__8.Length > 23 && 5__8.Substring(8, 1) == "-" && 5__8.Substring(13, 1) == "-" && 5__8.Substring(18, 1) == "-" && 5__8.Substring(23, 1) == "-") { 5__9 = File.ReadAllText(5__7 + "/index.json"); 5__10 = JsonConvert.DeserializeObject(5__9); LoggingPlugin.LogDebug(5__10.Name + " from " + 5__8 + ": Processing"); <>s__11 = 5__10.Music.GetEnumerator(); <>1__state = -3; goto IL_04c1; } goto IL_0519; } <>s__5 = null; _self.notification = null; LoggingPlugin.LogDebug("Sending CCM Registration For " + 5__4.Count + " New Core Audio Assets"); ((MonoBehaviour)_self).StartCoroutine(_callback(5__4, "CoreAudioProxy")); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__11).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ReadOnlyDictionary existingAssets; public Func, string, IEnumerator> callback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; _existingAssets = existingAssets; _callback = callback; <>2__current = ((MonoBehaviour)_self).StartCoroutine(ExtractAudio(Paths.GameRootPath)); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static ReadOnlyDictionary _existingAssets; private static Func, string, IEnumerator> _callback; [IteratorStateMachine(typeof(d__2))] public static IEnumerator GetNewAssets(ReadOnlyDictionary existingAssets, Func, string, IEnumerator> callback) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { existingAssets = existingAssets, callback = callback }; } [IteratorStateMachine(typeof(d__3))] private static IEnumerator ExtractAudio(string talespireFolder) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { talespireFolder = talespireFolder }; } } public static class Utility { public static bool isBoardLoaded() { return SimpleSingletonBehaviour.HasInstance && SingletonStateMBehaviour>.HasInstance && !BoardSessionManager.IsLoading; } public static float ParseFloat(string value) { return float.Parse(value, CultureInfo.InvariantCulture); } public static GameObject FindInHierarchy(GameObject start, string seekName) { List results = new List(); 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 results = new List(); 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 results = new List(); 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 results = new List(); 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 results = new List(); 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(GameObject start, string seekType) { List results = new List(); 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 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 dictionary, string key) { foreach (KeyValuePair 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("Core Audio Proxy Plugin"), text, false); } } [CompilerGenerated] private sealed class d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CoreAssetsProxyPlugin <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } try { DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel(); SystemMessage.DisplayInfoText("Core Audio Proxy Plugin: Using '" + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + "' diagnostics.\r\nUse 'Info' for better performance", 10f, 0f); SystemMessage.DisplayInfoText("Core Audio Proxy Plugin: Use 'Debug' or 'Trace' for\r\ntroubleshooting only.", 10f, 0f); } catch { goto IL_0072; } return false; IL_0072: <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string Name = "Core Audio Proxy Plugin"; public const string Guid = "org.lordashes.plugins.coreaudioproxy.ccm"; public const string Version = "1.0.0.0"; public const string Author = "Lord Ashes"; public static CoreAssetsProxyPlugin _self; private string notification = null; private Rect registrationMessagePos = Rect.zero; private GUIStyle registrationMessageStyle = new GUIStyle(); 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown _self = this; LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind("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()); } string text = CommonCustomsMenuPlugin.RegisterProviderV2("AUDIOPROXY", "Core Talespire minis", "1.0.0.0", (Func, Func, string, IEnumerator>, IEnumerator>)Provider.GetNewAssets, (Action)delegate { throw new Exception("AUDIOPROXY Is Not Intended To Process Selection."); }); string[] array = text.Split(new char[1] { ',' }); registrationMessagePos = new Rect((float)int.Parse(array[0]), (float)int.Parse(array[1]), (float)(Screen.width - int.Parse(array[0])), (float)(Screen.height - int.Parse(array[1]))); registrationMessageStyle.fontSize = int.Parse(array[2]); registrationMessageStyle.fontStyle = (FontStyle)1; registrationMessageStyle.active.textColor = Color.white; registrationMessageStyle.normal.textColor = Color.white; Harmony val = new Harmony("org.lordashes.plugins.coreaudioproxy.ccm"); val.PatchAll(); Utility.PostOnMainPage((BaseUnityPlugin)(object)this); } private void OnGUI() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (notification != null) { GUI.Label(registrationMessagePos, notification, registrationMessageStyle); } } [IteratorStateMachine(typeof(d__12))] private IEnumerator WarnAboutLogLevel() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this }; } }