Decompiled source of CoreAssetsPlugin CCM v1.0.4

CoreAssets_CCM.dll

Decompiled 2 months 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 TaleSpire.ContentManagement;
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("CoreAssets_CCM")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nth Dimension")]
[assembly: AssemblyProduct("CoreAssets_CCM")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("CoreAssets_CCM")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.4.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.coreassets.ccm", "Core Assets Plugin", "1.0.4.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CoreAssetsPlugin : BaseUnityPlugin
{
	[HarmonyPatch]
	public class Patch_DbGroupImpl_Add
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("TaleSpire.ContentManagement.AssetDb+DbGroupImpl");
			return AccessTools.Method(type, "Add", (Type[])null, (Type[])null);
		}

		private static void Prefix(object dbEntry)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			try
			{
				Provider._db.Add((DbEntry)dbEntry);
			}
			catch (Exception arg)
			{
				LoggingPlugin.LogWarning($"[Harmony Patch] Error accessing DbEntry properties: {arg}");
			}
		}
	}

	public static class Provider
	{
		[CompilerGenerated]
		private sealed class <GetNewAssets>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ReadOnlyDictionary<string, AssetInfo> existingAssets;

			public Func<Dictionary<string, AssetInfo>, string, IEnumerator> callback;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetNewAssets>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					_callback = callback;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((MonoBehaviour)_self).StartCoroutine(SendCollectedAssetList(existingAssets));
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <SendCollectedAssetList>d__4 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ReadOnlyDictionary<string, AssetInfo> existingAssets;

			private Dictionary<string, AssetInfo> <assets>5__1;

			private List<DbEntry>.Enumerator <>s__2;

			private DbEntry <entry>5__3;

			private string <groupName>5__4;

			private string <id>5__5;

			private Icon <icon>5__6;

			private FetchKey <fetchKey>5__7;

			private Texture2D <tex>5__8;

			private Exception <ex>5__9;

			private Exception <ex2>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SendCollectedAssetList>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num == -3 || num == 3)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<assets>5__1 = null;
				<>s__2 = default(List<DbEntry>.Enumerator);
				<entry>5__3 = null;
				<groupName>5__4 = null;
				<id>5__5 = null;
				<icon>5__6 = default(Icon);
				<tex>5__8 = null;
				<ex>5__9 = null;
				<ex2>5__10 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02de: Unknown result type (might be due to invalid IL or missing references)
				//IL_02eb: 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_02fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0303: Unknown result type (might be due to invalid IL or missing references)
				//IL_0318: Unknown result type (might be due to invalid IL or missing references)
				//IL_031f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0324: Unknown result type (might be due to invalid IL or missing references)
				//IL_0339: Unknown result type (might be due to invalid IL or missing references)
				//IL_0345: Unknown result type (might be due to invalid IL or missing references)
				//IL_035c: Unknown result type (might be due to invalid IL or missing references)
				//IL_036e: Unknown result type (might be due to invalid IL or missing references)
				//IL_037a: Unknown result type (might be due to invalid IL or missing references)
				//IL_038c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0393: Unknown result type (might be due to invalid IL or missing references)
				//IL_0398: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_03db: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0407: Unknown result type (might be due to invalid IL or missing references)
				//IL_0414: Expected O, but got Unknown
				//IL_041c: Unknown result type (might be due to invalid IL or missing references)
				//IL_042f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0434: Unknown result type (might be due to invalid IL or missing references)
				//IL_043a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0528: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Expected O, but got Unknown
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Expected O, but got Unknown
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Invalid comparison between Unknown and I4
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Invalid comparison between Unknown and I4
				//IL_0280: Unknown result type (might be due to invalid IL or missing references)
				//IL_028a: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						LoggingPlugin.LogInfo("Starting Countdown Loop (Counter Is " + _counter + ")");
						goto IL_00aa;
					case 1:
						<>1__state = -1;
						_counter--;
						goto IL_00aa;
					case 2:
						<>1__state = -1;
						<assets>5__1 = new Dictionary<string, AssetInfo>();
						<>s__2 = _db.GetEnumerator();
						<>1__state = -3;
						goto IL_0646;
					case 3:
						{
							<>1__state = -3;
							Dictionary<string, AssetInfo> dictionary = <assets>5__1;
							string key = <id>5__5;
							AssetInfo val = new AssetInfo
							{
								provider = "COREASSETS"
							};
							InternedPackId dataPackId = <entry>5__3.DataPackId;
							val.pack = ((object)(InternedPackId)(ref dataPackId)).ToString();
							val.prefab = <id>5__5;
							val.filename = "Core";
							DbContentKind kind = <entry>5__3.Kind;
							val.kind = ((object)(DbContentKind)(ref kind)).ToString();
							kind = <entry>5__3.Kind;
							val.category = ((object)(DbContentKind)(ref kind)).ToString();
							val.header = "CORE";
							val.name = ToSpaceBasedCamelCase(<entry>5__3.Name);
							val.description = <entry>5__3.Description;
							val.author = "BouncyRock";
							val.groupName = ToSpaceBasedCamelCase(<groupName>5__4);
							dataPackId = <entry>5__3.DataPackId;
							string? text = ((object)(SourceLocalPackId)(ref dataPackId.SourceLocalPackId)).ToString();
							dataPackId = <entry>5__3.DataPackId;
							val.comment = text + "," + ((object)(InternedPackSource)(ref dataPackId.PackSource)).ToString();
							val.tags = string.Join(",", <entry>5__3.Tags);
							val.hasAnimations = false;
							val.hasAudio = false;
							val.hasBlendshapes = false;
							dictionary.Add(key, val);
							try
							{
								<icon>5__6 = default(Icon);
								<fetchKey>5__7 = ContentManager.FetchIcon(ref <entry>5__3.IconAddress, false);
								ContentManager.TryGetIcon(<fetchKey>5__7, ref <icon>5__6);
								<tex>5__8 = <icon>5__6.Sprite.texture;
								LoggingPlugin.LogInfo("Sprite Name = " + ((Object)<icon>5__6.Sprite).name);
								<icon>5__6.Sprite.texture.Apply();
								LoggingPlugin.LogInfo("Texture Name = " + ((Object)<icon>5__6.Sprite.texture).name);
								File.WriteAllBytes(CommonCustomsMenuPlugin.GetCacheFolder() + "Portrait." + <id>5__5 + ".png", ImageConversion.EncodeToPNG(<tex>5__8));
								LoggingPlugin.LogInfo("Writing Specific Portrait File '" + CommonCustomsMenuPlugin.GetCacheFolder() + "Portrait." + <id>5__5 + ".png'");
								<icon>5__6 = default(Icon);
								<tex>5__8 = null;
							}
							catch (Exception ex)
							{
								<ex>5__9 = ex;
								try
								{
									LoggingPlugin.LogWarning("Exception: " + <ex>5__9.Message);
									File.WriteAllBytes(CommonCustomsMenuPlugin.GetCacheFolder() + "Portrait." + <id>5__5 + ".png", _self.defaultIcon);
									LoggingPlugin.LogInfo("Writing Default Portrait File '" + CommonCustomsMenuPlugin.GetCacheFolder() + "Portrait." + <id>5__5 + ".png'");
								}
								catch (Exception ex)
								{
									<ex2>5__10 = ex;
									LoggingPlugin.LogInfo("Exception: " + <ex2>5__10.Message);
									LoggingPlugin.LogInfo("Skipping Portrait File '" + CommonCustomsMenuPlugin.GetCacheFolder() + "Portrait." + <id>5__5 + ".png'");
								}
							}
							goto IL_062f;
						}
						IL_0646:
						if (<>s__2.MoveNext())
						{
							<entry>5__3 = <>s__2.Current;
							if ((int)<entry>5__3.Kind == 4 || (int)<entry>5__3.Kind == 2)
							{
								LoggingPlugin.LogInfo("Adding Asset: Group='" + ToSpaceBasedCamelCase(<entry>5__3.Group.Name) + "' Name='" + ToSpaceBasedCamelCase(<entry>5__3.Name) + "'");
								<groupName>5__4 = <entry>5__3.Group.Name;
								if (<groupName>5__4.ToUpper() == "COMMUNITY")
								{
									<groupName>5__4 = "[MOD.IO]";
								}
								if (<groupName>5__4.ToUpper() == "LOCAL")
								{
									<groupName>5__4 = "[LOCAL]";
								}
								<id>5__5 = GetId(<entry>5__3);
								if (!existingAssets.ContainsKey(<id>5__5))
								{
									_self.notification = "Registering... [Provider: COREASSETS, Group: " + <groupName>5__4 + ", Name: " + <entry>5__3.Name + "]";
									<>2__current = (object)new WaitForEndOfFrame();
									<>1__state = 3;
									return true;
								}
								goto IL_062f;
							}
							goto IL_063e;
						}
						<>m__Finally1();
						<>s__2 = default(List<DbEntry>.Enumerator);
						LoggingPlugin.LogInfo("Posting Asset Results");
						_self.notification = null;
						((MonoBehaviour)_self).StartCoroutine(_callback((from kvp in <assets>5__1
							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), "CoreAssets"));
						return false;
						IL_062f:
						<groupName>5__4 = null;
						<id>5__5 = null;
						goto IL_063e;
						IL_063e:
						<entry>5__3 = null;
						goto IL_0646;
						IL_00aa:
						if (_counter > 0)
						{
							LoggingPlugin.LogInfo("Countdown To Send Asset Info Is " + _counter);
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 1;
							return true;
						}
						LoggingPlugin.LogInfo("Packing Asset Results");
						_self.notification = "Registering... [Provider: COREASSETS]";
						<>2__current = (object)new WaitForEndOfFrame();
						<>1__state = 2;
						return true;
					}
				}
				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__2).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static int _counter = 5;

		public static List<DbEntry> _db = new List<DbEntry>();

		private static Func<Dictionary<string, AssetInfo>, string, IEnumerator> _callback = null;

		[IteratorStateMachine(typeof(<GetNewAssets>d__3))]
		public static IEnumerator GetNewAssets(ReadOnlyDictionary<string, AssetInfo> existingAssets, Func<Dictionary<string, AssetInfo>, string, IEnumerator> callback)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetNewAssets>d__3(0)
			{
				existingAssets = existingAssets,
				callback = callback
			};
		}

		[IteratorStateMachine(typeof(<SendCollectedAssetList>d__4))]
		private static IEnumerator SendCollectedAssetList(ReadOnlyDictionary<string, AssetInfo> existingAssets)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SendCollectedAssetList>d__4(0)
			{
				existingAssets = existingAssets
			};
		}

		public static void SpawnNewAsset(AssetInfo info)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			LoggingPlugin.LogDebug("Spawning " + ((object)info)?.ToString() + " Based On Stored Guid " + info.prefab);
			CommonCustomsMenuPlugin._self.Close();
			try
			{
				DbEntry val = _db.Where((DbEntry entry) => GetId(entry) == info.prefab).First();
				CreatureDataV3 val2 = new CreatureDataV3(ref val.DataAddress);
				CreatureSpawnerBoardTool.SwitchCreatureTool(ref val2, false, false);
			}
			catch (Exception ex)
			{
				LoggingPlugin.LogWarning("Unable to find " + info.prefab + " in core assets database");
				LoggingPlugin.LogWarning("Details: " + ex.Message);
			}
		}

		public static string GetId(DbEntry entry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			InternedPackId dataPackId = entry.DataPackId;
			return (((object)(InternedPackId)(ref dataPackId)).ToString() + ":" + ((object)(InternedContentAddress)(ref entry.DataAddress)).ToString()).Replace(":", "");
		}

		public static string ToSpaceBasedCamelCase(string raw)
		{
			raw = ((raw == null || raw.Trim() == "") ? "content" : raw.ToLower());
			string text = raw.Substring(0, 1).ToUpper();
			if (raw.Length > 1)
			{
				for (int i = 1; i < raw.Length; i++)
				{
					text = ((!(raw.Substring(i - 1, 1) == " ")) ? (text + raw.Substring(i, 1)) : (text + raw.Substring(i, 1).ToUpper()));
				}
			}
			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("Core Assets Plugin"), text, false);
		}
	}

	[CompilerGenerated]
	private sealed class <WarnAboutLogLevel>d__15 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public CoreAssetsPlugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WarnAboutLogLevel>d__15(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 Assets Plugin: Using '" + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + "' diagnostics.\r\nUse 'Info' for better performance", 10f, 0f);
				SystemMessage.DisplayInfoText("Core Assets 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 Assets Plugin";

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

	public const string Version = "1.0.4.0";

	public const string Author = "Lord Ashes";

	public static CoreAssetsPlugin _self;

	private string notification = null;

	public byte[] defaultIcon = ImageConversion.EncodeToPNG(Image.LoadTexture("org.lordashes.plugins.coreassets.ccm.Default.png", (CacheType)999));

	public string cacheFolder = CommonCustomsMenuPlugin.GetCacheFolder();

	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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: 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());
		}
		string text = CommonCustomsMenuPlugin.RegisterProviderV2("COREASSETS", "Core Talespire minis", "1.0.4.0", (Func<ReadOnlyDictionary<string, AssetInfo>, Func<Dictionary<string, AssetInfo>, string, IEnumerator>, IEnumerator>)Provider.GetNewAssets, (Action<AssetInfo>)Provider.SpawnNewAsset);
		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.coreassets.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(<WarnAboutLogLevel>d__15))]
	private IEnumerator WarnAboutLogLevel()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WarnAboutLogLevel>d__15(0)
		{
			<>4__this = this
		};
	}
}