Decompiled source of Empress Spawn Browser v1.6.0

EmpressSpawnBrowser.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e712dbbbff05c3c7bc9711cdb5b1ddae89a2bea5")]
[assembly: AssemblyProduct("EmpressSpawnBrowser")]
[assembly: AssemblyTitle("EmpressSpawnBrowser")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.SpawnBrowser
{
	[BepInPlugin("Empress.SpawnBrowser", "Spawn Browser", "2.5.2")]
	public class SpawnBrowser : BaseUnityPlugin
	{
		[HarmonyPatch]
		private static class Patch_CameraAim_Update
		{
			private static MethodBase TargetMethod()
			{
				return FindTypeBySimpleName("CameraAim")?.GetMethod("Update", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? null;
			}

			private static bool Prefix()
			{
				return !UIActive;
			}
		}

		[HarmonyPatch]
		private static class Patch_EnemyOnScreen_GetOnScreen
		{
			private static MethodBase TargetMethod()
			{
				Type type = FindTypeBySimpleName("EnemyOnScreen");
				if (type == null)
				{
					return null;
				}
				MethodInfo methodInfo = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo mi) => mi.Name == "GetOnScreen" && mi.GetParameters().Length == 1);
				return methodInfo ?? null;
			}

			private static void Finalizer(Exception __exception, ref bool __result)
			{
				if (__exception is KeyNotFoundException)
				{
					__result = false;
				}
				else if (__exception != null)
				{
					throw __exception;
				}
			}
		}

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

			private object <>2__current;

			public SpawnBrowser <>4__this;

			private int <enemyCount>5__1;

			private int <valCount>5__2;

			private int <itemCount>5__3;

			private Type <dirType>5__4;

			private Object <inst>5__5;

			private HashSet<string> <set>5__6;

			private string[] <>s__7;

			private int <>s__8;

			private string <fName>5__9;

			private FieldInfo <fi>5__10;

			private IEnumerable <listObj>5__11;

			private IEnumerator <>s__12;

			private object <soObj>5__13;

			private ScriptableObject <so>5__14;

			private string <trimmed>5__15;

			private string <key>5__16;

			private Exception <ex>5__17;

			private Type <rmType>5__18;

			private object <rm>5__19;

			private FieldInfo <levelsFi>5__20;

			private IEnumerable <levels>5__21;

			private HashSet<string> <set>5__22;

			private IEnumerator <>s__23;

			private object <lvl>5__24;

			private Type <lType>5__25;

			private IEnumerable <presets>5__26;

			private IEnumerator <>s__27;

			private object <preset>5__28;

			private Type <pType>5__29;

			private string[] <>s__30;

			private int <>s__31;

			private string <listName>5__32;

			private FieldInfo <fi>5__33;

			private IEnumerable <listObj>5__34;

			private IEnumerator <>s__35;

			private object <pref>5__36;

			private Type <prefType>5__37;

			private bool <isValid>5__38;

			private string <name>5__39;

			private string <trimmed>5__40;

			private string <key>5__41;

			private Exception <ex>5__42;

			private HashSet<string> <set>5__43;

			private Type <shopType>5__44;

			private object <shop>5__45;

			private string[] <>s__46;

			private int <>s__47;

			private string <listField>5__48;

			private FieldInfo <fi>5__49;

			private IEnumerable <en>5__50;

			private IEnumerator <>s__51;

			private object <entry>5__52;

			private Type <statsType>5__53;

			private object <stats>5__54;

			private FieldInfo <dictFi>5__55;

			private object <dictObj>5__56;

			private IDictionary <dict>5__57;

			private IDictionaryEnumerator <>s__58;

			private DictionaryEntry <de>5__59;

			private string[] <>s__60;

			private int <>s__61;

			private string <alt>5__62;

			private Type <t>5__63;

			private object <inst>5__64;

			private string[] <>s__65;

			private int <>s__66;

			private string <lf>5__67;

			private FieldInfo <fi>5__68;

			private IEnumerable <en>5__69;

			private IEnumerator <>s__70;

			private object <entry>5__71;

			private Exception <ex>5__72;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<dirType>5__4 = null;
				<inst>5__5 = null;
				<set>5__6 = null;
				<>s__7 = null;
				<fName>5__9 = null;
				<fi>5__10 = null;
				<listObj>5__11 = null;
				<>s__12 = null;
				<soObj>5__13 = null;
				<so>5__14 = null;
				<trimmed>5__15 = null;
				<key>5__16 = null;
				<ex>5__17 = null;
				<rmType>5__18 = null;
				<rm>5__19 = null;
				<levelsFi>5__20 = null;
				<levels>5__21 = null;
				<set>5__22 = null;
				<>s__23 = null;
				<lvl>5__24 = null;
				<lType>5__25 = null;
				<presets>5__26 = null;
				<>s__27 = null;
				<preset>5__28 = null;
				<pType>5__29 = null;
				<>s__30 = null;
				<listName>5__32 = null;
				<fi>5__33 = null;
				<listObj>5__34 = null;
				<>s__35 = null;
				<pref>5__36 = null;
				<prefType>5__37 = null;
				<name>5__39 = null;
				<trimmed>5__40 = null;
				<key>5__41 = null;
				<ex>5__42 = null;
				<set>5__43 = null;
				<shopType>5__44 = null;
				<shop>5__45 = null;
				<>s__46 = null;
				<listField>5__48 = null;
				<fi>5__49 = null;
				<en>5__50 = null;
				<>s__51 = null;
				<entry>5__52 = null;
				<statsType>5__53 = null;
				<stats>5__54 = null;
				<dictFi>5__55 = null;
				<dictObj>5__56 = null;
				<dict>5__57 = null;
				<>s__58 = null;
				<de>5__59 = default(DictionaryEntry);
				<>s__60 = null;
				<alt>5__62 = null;
				<t>5__63 = null;
				<inst>5__64 = null;
				<>s__65 = null;
				<lf>5__67 = null;
				<fi>5__68 = null;
				<en>5__69 = null;
				<>s__70 = null;
				<entry>5__71 = null;
				<ex>5__72 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this._discovering = true;
					<>4__this._discovered = false;
					<>4__this._enemyNames.Clear();
					<>4__this._valuableNames.Clear();
					<>4__this._itemNames.Clear();
					<>4__this._enemyByKey.Clear();
					<>4__this._valuableByKey.Clear();
					<>4__this._itemByKey.Clear();
					<enemyCount>5__1 = 0;
					try
					{
						<dirType>5__4 = FindTypeBySimpleName("EnemyDirector");
						<inst>5__5 = Object.FindObjectOfType(<dirType>5__4);
						if (<inst>5__5 != (Object)null)
						{
							<set>5__6 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
							<>s__7 = new string[3] { "enemiesDifficulty1", "enemiesDifficulty2", "enemiesDifficulty3" };
							for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++)
							{
								<fName>5__9 = <>s__7[<>s__8];
								<fi>5__10 = <dirType>5__4.GetField(<fName>5__9, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
								<listObj>5__11 = <fi>5__10?.GetValue(<inst>5__5) as IEnumerable;
								if (<listObj>5__11 != null)
								{
									<>s__12 = <listObj>5__11.GetEnumerator();
									try
									{
										while (<>s__12.MoveNext())
										{
											<soObj>5__13 = <>s__12.Current;
											ref ScriptableObject reference = ref <so>5__14;
											object obj = <soObj>5__13;
											reference = (ScriptableObject)((obj is ScriptableObject) ? obj : null);
											if (!Object.op_Implicit((Object)(object)<so>5__14))
											{
												continue;
											}
											<trimmed>5__15 = RxEnemyTrim.Replace(((Object)<so>5__14).name ?? "", "").Trim();
											if (!string.IsNullOrEmpty(<trimmed>5__15))
											{
												<key>5__16 = <trimmed>5__15.ToLowerInvariant();
												if (!<>4__this._enemyByKey.ContainsKey(<key>5__16))
												{
													<>4__this._enemyByKey[<key>5__16] = <so>5__14;
												}
												<set>5__6.Add(<trimmed>5__15);
												<so>5__14 = null;
												<trimmed>5__15 = null;
												<key>5__16 = null;
												<soObj>5__13 = null;
											}
										}
									}
									finally
									{
										if (<>s__12 is IDisposable disposable7)
										{
											disposable7.Dispose();
										}
									}
									<>s__12 = null;
									<fi>5__10 = null;
									<listObj>5__11 = null;
									<fName>5__9 = null;
								}
							}
							<>s__7 = null;
							<>4__this._enemyNames.AddRange(<set>5__6.OrderBy<string, string>((string x) => x, StringComparer.OrdinalIgnoreCase));
							<enemyCount>5__1 = <>4__this._enemyNames.Count;
							<set>5__6 = null;
						}
						<dirType>5__4 = null;
						<inst>5__5 = null;
					}
					catch (Exception ex)
					{
						<ex>5__17 = ex;
						Logger.LogWarning((object)("Enemy discovery failed: " + <ex>5__17.Message));
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<valCount>5__2 = 0;
					try
					{
						<rmType>5__18 = FindTypeBySimpleName("RunManager");
						<rm>5__19 = <rmType>5__18?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
						<levelsFi>5__20 = <rmType>5__18?.GetField("levels", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						<levels>5__21 = <levelsFi>5__20?.GetValue(<rm>5__19) as IEnumerable;
						<set>5__22 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
						if (<levels>5__21 != null)
						{
							<>s__23 = <levels>5__21.GetEnumerator();
							try
							{
								while (<>s__23.MoveNext())
								{
									<lvl>5__24 = <>s__23.Current;
									<lType>5__25 = <lvl>5__24.GetType();
									<presets>5__26 = <lType>5__25.GetField("ValuablePresets", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(<lvl>5__24) as IEnumerable;
									if (<presets>5__26 == null)
									{
										continue;
									}
									<>s__27 = <presets>5__26.GetEnumerator();
									try
									{
										while (<>s__27.MoveNext())
										{
											<preset>5__28 = <>s__27.Current;
											<pType>5__29 = <preset>5__28.GetType();
											<>s__30 = new string[7] { "tiny", "small", "medium", "big", "wide", "tall", "veryTall" };
											for (<>s__31 = 0; <>s__31 < <>s__30.Length; <>s__31++)
											{
												<listName>5__32 = <>s__30[<>s__31];
												<fi>5__33 = <pType>5__29.GetField(<listName>5__32, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
												<listObj>5__34 = <fi>5__33?.GetValue(<preset>5__28) as IEnumerable;
												if (<listObj>5__34 != null)
												{
													<>s__35 = <listObj>5__34.GetEnumerator();
													try
													{
														while (<>s__35.MoveNext())
														{
															<pref>5__36 = <>s__35.Current;
															if (<pref>5__36 == null)
															{
																continue;
															}
															<prefType>5__37 = <pref>5__36.GetType();
															<isValid>5__38 = InvokeBool(<prefType>5__37.GetMethod("IsValid", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), <pref>5__36);
															if (!<isValid>5__38)
															{
																continue;
															}
															<name>5__39 = GetString(<prefType>5__37.GetProperty("PrefabName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), <pref>5__36);
															if (string.IsNullOrWhiteSpace(<name>5__39))
															{
																continue;
															}
															<trimmed>5__40 = RxValuableTrim.Replace(<name>5__39, "").Trim();
															if (!string.IsNullOrEmpty(<trimmed>5__40))
															{
																<key>5__41 = <trimmed>5__40.ToLowerInvariant();
																if (!<>4__this._valuableByKey.ContainsKey(<key>5__41))
																{
																	<>4__this._valuableByKey[<key>5__41] = <pref>5__36;
																}
																<set>5__22.Add(<trimmed>5__40);
																<prefType>5__37 = null;
																<name>5__39 = null;
																<trimmed>5__40 = null;
																<key>5__41 = null;
																<pref>5__36 = null;
															}
														}
													}
													finally
													{
														if (<>s__35 is IDisposable disposable4)
														{
															disposable4.Dispose();
														}
													}
													<>s__35 = null;
													<fi>5__33 = null;
													<listObj>5__34 = null;
													<listName>5__32 = null;
												}
											}
											<>s__30 = null;
											<pType>5__29 = null;
											<preset>5__28 = null;
										}
									}
									finally
									{
										if (<>s__27 is IDisposable disposable5)
										{
											disposable5.Dispose();
										}
									}
									<>s__27 = null;
									<lType>5__25 = null;
									<presets>5__26 = null;
									<lvl>5__24 = null;
								}
							}
							finally
							{
								if (<>s__23 is IDisposable disposable6)
								{
									disposable6.Dispose();
								}
							}
							<>s__23 = null;
						}
						<>4__this._valuableNames.AddRange(<set>5__22.OrderBy<string, string>((string x) => x, StringComparer.OrdinalIgnoreCase));
						<valCount>5__2 = <>4__this._valuableNames.Count;
						<rmType>5__18 = null;
						<rm>5__19 = null;
						<levelsFi>5__20 = null;
						<levels>5__21 = null;
						<set>5__22 = null;
					}
					catch (Exception ex)
					{
						<ex>5__42 = ex;
						Logger.LogWarning((object)("Valuable discovery failed: " + <ex>5__42.Message));
					}
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<itemCount>5__3 = 0;
					try
					{
						<set>5__43 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
						<shopType>5__44 = FindTypeBySimpleName("ShopManager");
						<shop>5__45 = <shopType>5__44?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
						if (<shop>5__45 != null)
						{
							<>s__46 = new string[3] { "potentialItems", "potentialItemConsumables", "potentialItemUpgrades" };
							for (<>s__47 = 0; <>s__47 < <>s__46.Length; <>s__47++)
							{
								<listField>5__48 = <>s__46[<>s__47];
								<fi>5__49 = <shopType>5__44.GetField(<listField>5__48, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
								<en>5__50 = <fi>5__49?.GetValue(<shop>5__45) as IEnumerable;
								if (<en>5__50 != null)
								{
									<>s__51 = <en>5__50.GetEnumerator();
									try
									{
										while (<>s__51.MoveNext())
										{
											<entry>5__52 = <>s__51.Current;
											<>4__this.AddItemEntry(<entry>5__52, <set>5__43);
											<entry>5__52 = null;
										}
									}
									finally
									{
										if (<>s__51 is IDisposable disposable)
										{
											disposable.Dispose();
										}
									}
									<>s__51 = null;
									<fi>5__49 = null;
									<en>5__50 = null;
									<listField>5__48 = null;
								}
							}
							<>s__46 = null;
						}
						if (<set>5__43.Count == 0)
						{
							<statsType>5__53 = FindTypeBySimpleName("StatsManager");
							<stats>5__54 = <statsType>5__53?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
							<dictFi>5__55 = <statsType>5__53?.GetField("itemDictionary", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							<dictObj>5__56 = <dictFi>5__55?.GetValue(<stats>5__54);
							<dict>5__57 = <dictObj>5__56 as IDictionary;
							if (<dict>5__57 != null)
							{
								<>s__58 = <dict>5__57.GetEnumerator();
								try
								{
									while (<>s__58.MoveNext())
									{
										<de>5__59 = (DictionaryEntry)<>s__58.Current;
										<>4__this.AddItemEntry(<de>5__59.Value, <set>5__43);
										<de>5__59 = default(DictionaryEntry);
									}
								}
								finally
								{
									if (<>s__58 is IDisposable disposable2)
									{
										disposable2.Dispose();
									}
								}
								<>s__58 = null;
							}
							<statsType>5__53 = null;
							<stats>5__54 = null;
							<dictFi>5__55 = null;
							<dictObj>5__56 = null;
							<dict>5__57 = null;
						}
						if (<set>5__43.Count == 0)
						{
							<>s__60 = new string[3] { "ItemManager", "ItemsManager", "InventoryManager" };
							for (<>s__61 = 0; <>s__61 < <>s__60.Length; <>s__61++)
							{
								<alt>5__62 = <>s__60[<>s__61];
								<t>5__63 = FindTypeBySimpleName(<alt>5__62);
								if (!(<t>5__63 == null))
								{
									<inst>5__64 = <t>5__63.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) ?? <t>5__63.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null, null);
									if (<inst>5__64 != null)
									{
										<>s__65 = new string[3] { "allItems", "items", "itemList" };
										for (<>s__66 = 0; <>s__66 < <>s__65.Length; <>s__66++)
										{
											<lf>5__67 = <>s__65[<>s__66];
											<fi>5__68 = <t>5__63.GetField(<lf>5__67, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
											<en>5__69 = <fi>5__68?.GetValue(<inst>5__64) as IEnumerable;
											if (<en>5__69 != null)
											{
												<>s__70 = <en>5__69.GetEnumerator();
												try
												{
													while (<>s__70.MoveNext())
													{
														<entry>5__71 = <>s__70.Current;
														<>4__this.AddItemEntry(<entry>5__71, <set>5__43);
														<entry>5__71 = null;
													}
												}
												finally
												{
													if (<>s__70 is IDisposable disposable3)
													{
														disposable3.Dispose();
													}
												}
												<>s__70 = null;
												<fi>5__68 = null;
												<en>5__69 = null;
												<lf>5__67 = null;
											}
										}
										<>s__65 = null;
										<t>5__63 = null;
										<inst>5__64 = null;
										<alt>5__62 = null;
									}
								}
							}
							<>s__60 = null;
						}
						<>4__this._itemNames.AddRange(<set>5__43.OrderBy<string, string>((string x) => x, StringComparer.OrdinalIgnoreCase));
						<itemCount>5__3 = <>4__this._itemNames.Count;
						<set>5__43 = null;
						<shopType>5__44 = null;
						<shop>5__45 = null;
					}
					catch (Exception ex)
					{
						<ex>5__72 = ex;
						Logger.LogWarning((object)("Item discovery failed: " + <ex>5__72.Message));
					}
					<>4__this._discovered = <enemyCount>5__1 + <valCount>5__2 + <itemCount>5__3 > 0;
					<>4__this._discovering = false;
					Logger.LogInfo((object)$"Discovered {<enemyCount>5__1} enemies, {<valCount>5__2} valuables, {<itemCount>5__3} items.");
					if (_uiVisible)
					{
						<>4__this.RefreshCurrentTab();
					}
					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 <InitializeCanvasDelayed>d__57 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SpawnBrowser <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.BuildCanvas();
					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 bool _uiVisible;

		private int _tabIndex = 0;

		private string _searchEnemies = "";

		private string _searchValuables = "";

		private string _searchItems = "";

		private readonly List<string> _enemyNames = new List<string>();

		private readonly List<string> _valuableNames = new List<string>();

		private readonly List<string> _itemNames = new List<string>();

		private readonly Dictionary<string, ScriptableObject> _enemyByKey = new Dictionary<string, ScriptableObject>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<string, object> _valuableByKey = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<string, object> _itemByKey = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);

		private bool _discovered;

		private bool _discovering;

		private CursorLockMode _prevLock;

		private bool _prevVisible;

		private static readonly Regex RxEnemyTrim = new Regex("^Enemy( -)?\\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled);

		private static readonly Regex RxValuableTrim = new Regex("^Valuable\\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled);

		private static readonly Regex RxItemTrim = new Regex("^Item\\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled);

		private GameObject _canvasRoot;

		private Canvas _canvas;

		private GameObject _panelRoot;

		private ScrollRect _scrollRect;

		private Transform _contentContainer;

		private TextMeshProUGUI _titleText;

		private TextMeshProUGUI _statusText;

		private TextMeshProUGUI _countText;

		private Button _refreshButton;

		private Button[] _tabButtons = (Button[])(object)new Button[3];

		private GameObject _itemRowPrefab;

		private ConfigEntry<KeyCode> _toggleKey;

		private ConfigEntry<float> _scrollSpeed;

		private Color _bg = new Color(0.02f, 0.02f, 0.02f, 0.95f);

		private Color _bg2 = new Color(0.04f, 0.01f, 0.01f, 0.98f);

		private Color _fg = new Color(0.9f, 0.9f, 0.9f, 1f);

		private Color _mutedCol = new Color(0.6f, 0.6f, 0.65f, 0.8f);

		private Color _accentBase = new Color(0.8f, 0.1f, 0.1f, 1f);

		private Color _accentHover = new Color(0.95f, 0.2f, 0.2f, 1f);

		private Color _accentDisabled = new Color(0.4f, 0.1f, 0.1f, 0.7f);

		private TMP_InputField _searchInput;

		private ConfigEntry<float> _uiScale;

		private ConfigEntry<Vector2> _uiPosition;

		private ConfigEntry<bool> _showTooltips;

		internal static SpawnBrowser Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		internal static bool UIActive => _uiVisible;

		private void Awake()
		{
			//IL_00be: 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_010e: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input", "ToggleKey", (KeyCode)277, "Key to toggle the Spawn Browser UI.");
			_scrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "ScrollSpeed", 35f, "Mouse wheel scroll sensitivity for the Spawn Browser list.");
			_uiScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "UIScale", 1f, "Scale of the UI panel (0.5 to 2.0).");
			_uiPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("UI", "UIPosition", new Vector2(0f, 0f), "Custom offset position for the UI panel.");
			_showTooltips = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowTooltips", true, "Enable tooltips for spawn items.");
			Harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			Harmony.PatchAll();
			Logger.LogInfo((object)"\r\n ________  __       __  _______   _______   ________   ______    ______  \r\n/        |/  \\     /  |/       \\ /       \\ /        | /      \\  /      \\ \r\n$$$$$$$$/ $$  \\   /$$ |$$$$$$$  |$$$$$$$  |$$$$$$$$/ /$$$$$$  |/$$$$$$  |\r\n$$ |__    $$$  \\ /$$$ |$$ |__$$ |$$ |__$$ |$$ |__    $$ \\__$$/ $$ \\__$$/ \r\n$$    |   $$$$  /$$$$ |$$    $$/ $$    $$< $$    |   $$      \\ $$      \\ \r\n$$$$$/    $$ $$ $$/$$ |$$$$$$$/  $$$$$$$  |$$$$$/     $$$$$$  | $$$$$$  |\r\n$$ |_____ $$ |$$$/ $$ |$$ |      $$ |  $$ |$$ |_____ /  \\__$$ |/  \\__$$ |\r\n$$       |$$ | $/  $$ |$$ |      $$ |  $$ |$$       |$$    $$/ $$    $$/ \r\n$$$$$$$$/ $$/      $$/ $$/       $$/   $$/ $$$$$$$$/  $$$$$$/   $$$$$$/  \r\n");
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded. Press {_toggleKey.Value} to open/close the spawn browser.");
			((MonoBehaviour)this).StartCoroutine(InitializeCanvasDelayed());
		}

		[IteratorStateMachine(typeof(<InitializeCanvasDelayed>d__57))]
		private IEnumerator InitializeCanvasDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeCanvasDelayed>d__57(0)
			{
				<>4__this = this
			};
		}

		private void OnDestroy()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			if (_uiVisible)
			{
				RestoreCursor();
			}
			if (Object.op_Implicit((Object)(object)_canvasRoot))
			{
				Object.Destroy((Object)(object)_canvasRoot);
			}
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_toggleKey.Value))
			{
				_uiVisible = !_uiVisible;
				if (_uiVisible)
				{
					if (!_discovered && !_discovering)
					{
						((MonoBehaviour)this).StartCoroutine(DiscoverRoutine());
					}
					TakeCursor();
					ShowCanvas();
				}
				else
				{
					RestoreCursor();
					HideCanvas();
				}
			}
			if (_uiVisible)
			{
				KeepCursorFree();
			}
			if ((Object)(object)_scrollRect != (Object)null && _scrollRect.scrollSensitivity != _scrollSpeed.Value)
			{
				_scrollRect.scrollSensitivity = _scrollSpeed.Value;
			}
			if ((Object)(object)_panelRoot != (Object)null)
			{
				RectTransform component = _panelRoot.GetComponent<RectTransform>();
				((Transform)component).localScale = new Vector3(_uiScale.Value, _uiScale.Value, 1f);
				component.anchoredPosition = _uiPosition.Value;
			}
		}

		private void BuildCanvas()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Expected O, but got Unknown
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Expected O, but got Unknown
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0870: Unknown result type (might be due to invalid IL or missing references)
			//IL_0887: Unknown result type (might be due to invalid IL or missing references)
			//IL_089e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_090f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0958: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Unknown result type (might be due to invalid IL or missing references)
			//IL_099d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bfc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d54: Unknown result type (might be due to invalid IL or missing references)
			_canvasRoot = new GameObject("SpawnBrowserCanvas_EMPRESS");
			Object.DontDestroyOnLoad((Object)(object)_canvasRoot);
			_canvasRoot.layer = LayerMask.NameToLayer("UI");
			_canvas = _canvasRoot.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.sortingOrder = 32767;
			_canvas.overrideSorting = true;
			CanvasScaler val = _canvasRoot.AddComponent<CanvasScaler>();
			val.uiScaleMode = (ScaleMode)1;
			val.referenceResolution = new Vector2(1920f, 1080f);
			val.matchWidthOrHeight = 1f;
			_canvasRoot.AddComponent<GraphicRaycaster>();
			if ((Object)(object)EventSystem.current == (Object)null)
			{
				GameObject val2 = new GameObject("EventSystem_EMPRESS");
				Object.DontDestroyOnLoad((Object)(object)val2);
				val2.AddComponent<EventSystem>();
				val2.AddComponent<StandaloneInputModule>();
			}
			_panelRoot = CreateUIElement("Panel", _canvasRoot.transform);
			RectTransform component = _panelRoot.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(600f, 700f);
			component.anchoredPosition = _uiPosition.Value;
			Image val3 = _panelRoot.AddComponent<Image>();
			((Graphic)val3).color = _bg;
			Outline val4 = _panelRoot.AddComponent<Outline>();
			((Shadow)val4).effectColor = new Color(0.5f, 0.1f, 0.1f, 0.5f);
			((Shadow)val4).effectDistance = new Vector2(2f, -2f);
			GameObject val5 = CreateUIElement("Header", _panelRoot.transform);
			RectTransform component2 = val5.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(0.5f, 1f);
			component2.sizeDelta = new Vector2(-28f, 60f);
			component2.anchoredPosition = new Vector2(0f, -14f);
			HorizontalLayoutGroup val6 = val5.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val6).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val6).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val6).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val6).spacing = 10f;
			GameObject val7 = CreateUIElement("Title", val5.transform);
			LayoutElement val8 = val7.AddComponent<LayoutElement>();
			val8.flexibleWidth = 1f;
			val8.minWidth = 200f;
			_titleText = val7.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_titleText).text = "<b>☠ Empress Spawn Browser</b> <color=#FF4444>- Hello World</color>";
			((TMP_Text)_titleText).fontSize = 20f;
			((TMP_Text)_titleText).fontStyle = (FontStyles)1;
			((Graphic)_titleText).color = _fg;
			((TMP_Text)_titleText).alignment = (TextAlignmentOptions)4097;
			GameObject val9 = CreateButton("CloseBtn", val5.transform, "X");
			LayoutElement val10 = val9.AddComponent<LayoutElement>();
			val10.preferredWidth = 40f;
			val10.preferredHeight = 26f;
			Button component3 = val9.GetComponent<Button>();
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				_uiVisible = false;
				RestoreCursor();
				HideCanvas();
			});
			GameObject val11 = CreateButton("RefreshBtn", val5.transform, "↻ Refresh");
			LayoutElement val12 = val11.AddComponent<LayoutElement>();
			val12.preferredWidth = 90f;
			val12.preferredHeight = 26f;
			_refreshButton = val11.GetComponent<Button>();
			((UnityEvent)_refreshButton.onClick).AddListener((UnityAction)delegate
			{
				((MonoBehaviour)this).StartCoroutine(DiscoverRoutine());
			});
			DrawDivider(_panelRoot.transform, -80f);
			GameObject val13 = CreateUIElement("TabBar", _panelRoot.transform);
			RectTransform component4 = val13.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 1f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.pivot = new Vector2(0.5f, 1f);
			component4.sizeDelta = new Vector2(-28f, 40f);
			component4.anchoredPosition = new Vector2(0f, -88f);
			HorizontalLayoutGroup val14 = val13.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val14).spacing = 10f;
			((HorizontalOrVerticalLayoutGroup)val14).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val14).childForceExpandHeight = true;
			string[] array = new string[3] { "ENEMIES ☠", "VALUABLES \ud83d\udc80", "ITEMS \ud83e\ude78" };
			for (int i = 0; i < 3; i++)
			{
				int index = i;
				GameObject val15 = CreateButton($"Tab{i}", val13.transform, array[i]);
				Image component5 = val15.GetComponent<Image>();
				((Graphic)component5).color = _bg2;
				Button component6 = val15.GetComponent<Button>();
				((Selectable)component6).transition = (Transition)1;
				ColorBlock colors = default(ColorBlock);
				((ColorBlock)(ref colors)).normalColor = Color.white;
				((ColorBlock)(ref colors)).highlightedColor = _accentHover;
				((ColorBlock)(ref colors)).pressedColor = _accentBase;
				((ColorBlock)(ref colors)).selectedColor = _accentBase;
				((ColorBlock)(ref colors)).disabledColor = _accentDisabled;
				((ColorBlock)(ref colors)).colorMultiplier = 1f;
				((ColorBlock)(ref colors)).fadeDuration = 0.1f;
				((Selectable)component6).colors = colors;
				_tabButtons[i] = component6;
				((UnityEvent)_tabButtons[i].onClick).AddListener((UnityAction)delegate
				{
					SwitchTab(index);
				});
			}
			DrawDivider(_panelRoot.transform, -136f);
			GameObject val16 = CreateUIElement("Search", _panelRoot.transform);
			RectTransform component7 = val16.GetComponent<RectTransform>();
			component7.anchorMin = new Vector2(0f, 1f);
			component7.anchorMax = new Vector2(1f, 1f);
			component7.pivot = new Vector2(0.5f, 1f);
			component7.sizeDelta = new Vector2(-28f, 40f);
			component7.anchoredPosition = new Vector2(0f, -144f);
			Image val17 = val16.AddComponent<Image>();
			((Graphic)val17).color = _bg2;
			_searchInput = val16.AddComponent<TMP_InputField>();
			_searchInput.textViewport = component7;
			TextMeshProUGUI val18 = CreateTextMeshPro("Text", val16.transform, "", 13f, _fg, (TextAlignmentOptions)513);
			((TMP_Text)val18).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)val18).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)val18).rectTransform.sizeDelta = Vector2.zero;
			((TMP_Text)val18).margin = new Vector4(10f, 0f, 0f, 0f);
			_searchInput.textComponent = (TMP_Text)(object)val18;
			TextMeshProUGUI val19 = CreateTextMeshPro("Placeholder", val16.transform, "Search...", 13f, _mutedCol, (TextAlignmentOptions)513);
			((TMP_Text)val19).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)val19).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)val19).rectTransform.sizeDelta = Vector2.zero;
			((TMP_Text)val19).margin = new Vector4(10f, 0f, 0f, 0f);
			_searchInput.placeholder = (Graphic)(object)((Component)val19).GetComponent<TextMeshProUGUI>();
			((UnityEvent<string>)(object)_searchInput.onValueChanged).AddListener((UnityAction<string>)OnSearchChanged);
			DrawDivider(_panelRoot.transform, -192f);
			GameObject val20 = CreateUIElement("Status", _panelRoot.transform);
			RectTransform component8 = val20.GetComponent<RectTransform>();
			component8.anchorMin = new Vector2(0f, 1f);
			component8.anchorMax = new Vector2(1f, 1f);
			component8.pivot = new Vector2(0.5f, 1f);
			component8.sizeDelta = new Vector2(-28f, 30f);
			component8.anchoredPosition = new Vector2(0f, -200f);
			_statusText = val20.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_statusText).fontSize = 11f;
			((Graphic)_statusText).color = new Color(0.95f, 0.75f, 0.3f, 1f);
			((TMP_Text)_statusText).alignment = (TextAlignmentOptions)514;
			GameObject val21 = CreateUIElement("ScrollView", _panelRoot.transform);
			RectTransform component9 = val21.GetComponent<RectTransform>();
			component9.anchorMin = new Vector2(0f, 0f);
			component9.anchorMax = new Vector2(1f, 1f);
			component9.offsetMin = new Vector2(14f, 50f);
			component9.offsetMax = new Vector2(-34f, -276f);
			_scrollRect = val21.AddComponent<ScrollRect>();
			_scrollRect.horizontal = false;
			_scrollRect.vertical = true;
			_scrollRect.scrollSensitivity = _scrollSpeed.Value;
			_scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			GameObject val22 = CreateUIElement("Viewport", val21.transform);
			RectTransform component10 = val22.GetComponent<RectTransform>();
			component10.anchorMin = Vector2.zero;
			component10.anchorMax = Vector2.one;
			component10.sizeDelta = Vector2.zero;
			val22.AddComponent<RectMask2D>();
			_scrollRect.viewport = component10;
			GameObject val23 = CreateUIElement("Content", val22.transform);
			RectTransform component11 = val23.GetComponent<RectTransform>();
			component11.anchorMin = new Vector2(0f, 1f);
			component11.anchorMax = new Vector2(1f, 1f);
			component11.pivot = new Vector2(0.5f, 1f);
			component11.sizeDelta = new Vector2(0f, 500f);
			VerticalLayoutGroup val24 = val23.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val24).spacing = 4f;
			((HorizontalOrVerticalLayoutGroup)val24).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val24).childForceExpandHeight = false;
			val23.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			_scrollRect.content = component11;
			_contentContainer = val23.transform;
			GameObject val25 = CreateUIElement("Scrollbar", val21.transform);
			RectTransform component12 = val25.GetComponent<RectTransform>();
			component12.anchorMin = new Vector2(1f, 0f);
			component12.anchorMax = new Vector2(1f, 1f);
			component12.pivot = new Vector2(1f, 1f);
			component12.sizeDelta = new Vector2(20f, 0f);
			component12.anchoredPosition = new Vector2(0f, 0f);
			Image val26 = val25.AddComponent<Image>();
			((Graphic)val26).color = _bg2;
			Scrollbar val27 = val25.AddComponent<Scrollbar>();
			val27.direction = (Direction)2;
			GameObject val28 = CreateUIElement("Sliding Area", val25.transform);
			RectTransform component13 = val28.GetComponent<RectTransform>();
			component13.anchorMin = Vector2.zero;
			component13.anchorMax = Vector2.one;
			component13.sizeDelta = new Vector2(-10f, -10f);
			GameObject val29 = CreateUIElement("Handle", val28.transform);
			RectTransform component14 = val29.GetComponent<RectTransform>();
			component14.anchorMin = Vector2.zero;
			component14.anchorMax = Vector2.one;
			component14.sizeDelta = Vector2.zero;
			Image val30 = val29.AddComponent<Image>();
			((Graphic)val30).color = _accentBase;
			((Selectable)val27).targetGraphic = (Graphic)(object)val30;
			val27.handleRect = component14;
			_scrollRect.verticalScrollbar = val27;
			GameObject val31 = CreateUIElement("Count", _panelRoot.transform);
			RectTransform component15 = val31.GetComponent<RectTransform>();
			component15.anchorMin = new Vector2(0f, 0f);
			component15.anchorMax = new Vector2(1f, 0f);
			component15.pivot = new Vector2(0.5f, 0f);
			component15.sizeDelta = new Vector2(-28f, 30f);
			component15.anchoredPosition = new Vector2(0f, 12f);
			_countText = val31.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_countText).fontSize = 12f;
			((Graphic)_countText).color = _mutedCol;
			((TMP_Text)_countText).alignment = (TextAlignmentOptions)514;
			CreateItemRowPrefab();
			_canvasRoot.SetActive(false);
			UpdateTabVisuals();
		}

		private void OnSearchChanged(string value)
		{
			switch (_tabIndex)
			{
			case 0:
				_searchEnemies = value;
				break;
			case 1:
				_searchValuables = value;
				break;
			case 2:
				_searchItems = value;
				break;
			}
			RefreshCurrentTab();
		}

		private void DrawDivider(Transform parent, float yPos)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIElement("Divider", parent);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.sizeDelta = new Vector2(-28f, 1f);
			component.anchoredPosition = new Vector2(0f, yPos);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.8f, 0.1f, 0.1f, 0.2f);
		}

		private GameObject CreateUIElement(string name, Transform parent)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			return val;
		}

		private GameObject CreateButton(string name, Transform parent, string text)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIElement(name, parent);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = _bg2;
			Button val3 = val.AddComponent<Button>();
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			TextMeshProUGUI val4 = CreateTextMeshPro("Text", val.transform, text, 13f, _fg, (TextAlignmentOptions)514);
			RectTransform component = ((Component)val4).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			return val;
		}

		private TextMeshProUGUI CreateTextMeshPro(string name, Transform parent, string text, float fontSize, Color color, TextAlignmentOptions alignment)
		{
			//IL_0023: 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)
			GameObject val = CreateUIElement(name, parent);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = fontSize;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = alignment;
			return val2;
		}

		private void CreateItemRowPrefab()
		{
			//IL_0041: 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_00cc: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			_itemRowPrefab = CreateUIElement("ItemRowPrefab", _panelRoot.transform);
			_itemRowPrefab.SetActive(false);
			RectTransform component = _itemRowPrefab.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(0f, 32f);
			HorizontalLayoutGroup val = _itemRowPrefab.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = true;
			((HorizontalOrVerticalLayoutGroup)val).spacing = 8f;
			TextMeshProUGUI val2 = CreateTextMeshPro("Label", _itemRowPrefab.transform, "", 13f, _fg, (TextAlignmentOptions)4097);
			LayoutElement val3 = ((Component)val2).gameObject.AddComponent<LayoutElement>();
			val3.flexibleWidth = 1f;
			RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			if (_showTooltips.Value)
			{
				EventTrigger val4 = _itemRowPrefab.AddComponent<EventTrigger>();
				Entry val5 = new Entry
				{
					eventID = (EventTriggerType)0
				};
				((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Expected O, but got Unknown
					ShowTooltip((PointerEventData)data);
				});
				val4.triggers.Add(val5);
				Entry val6 = new Entry
				{
					eventID = (EventTriggerType)1
				};
				((UnityEvent<BaseEventData>)(object)val6.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					HideTooltip();
				});
				val4.triggers.Add(val6);
			}
			GameObject val7 = CreateButton("SpawnBtn", _itemRowPrefab.transform, "SPAWN");
			LayoutElement val8 = val7.AddComponent<LayoutElement>();
			val8.preferredWidth = 90f;
			val8.preferredHeight = 26f;
			Image component3 = val7.GetComponent<Image>();
			((Graphic)component3).color = _accentBase;
			Button component4 = val7.GetComponent<Button>();
			((Selectable)component4).transition = (Transition)1;
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = _accentHover;
			((ColorBlock)(ref colors)).pressedColor = new Color(0.6f, 0.1f, 0.1f, 1f);
			((ColorBlock)(ref colors)).selectedColor = _accentBase;
			((ColorBlock)(ref colors)).disabledColor = _accentDisabled;
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((Selectable)component4).colors = colors;
		}

		private void ShowTooltip(PointerEventData data)
		{
			Logger.LogInfo((object)"Tooltip: Hovering over item - Description would go here.");
		}

		private void HideTooltip()
		{
		}

		private void ShowCanvas()
		{
			if (Object.op_Implicit((Object)(object)_canvasRoot))
			{
				_canvasRoot.SetActive(true);
			}
			RefreshCurrentTab();
			_searchInput.text = GetCurrentSearch();
		}

		private void HideCanvas()
		{
			if (Object.op_Implicit((Object)(object)_canvasRoot))
			{
				_canvasRoot.SetActive(false);
			}
		}

		private void SwitchTab(int index)
		{
			_tabIndex = index;
			UpdateTabVisuals();
			_searchInput.text = GetCurrentSearch();
			RefreshCurrentTab();
		}

		private string GetCurrentSearch()
		{
			return (_tabIndex == 0) ? _searchEnemies : ((_tabIndex == 1) ? _searchValuables : _searchItems);
		}

		private void UpdateTabVisuals()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _tabButtons.Length; i++)
			{
				if (!((Object)(object)_tabButtons[i] == (Object)null))
				{
					Image component = ((Component)_tabButtons[i]).GetComponent<Image>();
					((Graphic)component).color = (Color)((_tabIndex == i) ? new Color(0.1f, 0.02f, 0.02f, 1f) : _bg2);
				}
			}
		}

		private void RefreshCurrentTab()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_contentContainer == (Object)null)
			{
				return;
			}
			if ((Object)(object)_itemRowPrefab == (Object)null)
			{
				CreateItemRowPrefab();
			}
			foreach (Transform item in _contentContainer)
			{
				Transform val = item;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			bool flag = IsHostOrOffline();
			string text = "";
			if (!flag)
			{
				text = "⚠ Host only — ask the lobby owner to spawn.";
			}
			else if (InRoom())
			{
				text = "⚠ Networked room: prefab must be PUN-registered (ResourcePath).";
			}
			if (Object.op_Implicit((Object)(object)_statusText))
			{
				((TMP_Text)_statusText).text = text;
			}
			if (!_discovered && _discovering)
			{
				if (Object.op_Implicit((Object)(object)_countText))
				{
					((TMP_Text)_countText).text = "Discovering...";
				}
				return;
			}
			List<string> src = ((_tabIndex == 0) ? _enemyNames : ((_tabIndex == 1) ? _valuableNames : _itemNames));
			string currentSearch = GetCurrentSearch();
			List<string> list = FilterAndSort(src, currentSearch);
			foreach (string item2 in list)
			{
				GameObject val2 = Object.Instantiate<GameObject>(_itemRowPrefab, _contentContainer);
				val2.SetActive(true);
				Transform obj = val2.transform.Find("Label");
				TextMeshProUGUI val3 = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
				if (Object.op_Implicit((Object)(object)val3))
				{
					((TMP_Text)val3).text = item2;
				}
				Transform obj2 = val2.transform.Find("SpawnBtn");
				Button val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
				if (!Object.op_Implicit((Object)(object)val4))
				{
					continue;
				}
				((Selectable)val4).interactable = flag;
				Image component = ((Component)val4).GetComponent<Image>();
				if (!flag && Object.op_Implicit((Object)(object)component))
				{
					((Graphic)component).color = _accentDisabled;
				}
				string captured = item2;
				((UnityEventBase)val4.onClick).RemoveAllListeners();
				((UnityEvent)val4.onClick).AddListener((UnityAction)delegate
				{
					if (_tabIndex == 0)
					{
						SpawnEnemy(captured);
					}
					else if (_tabIndex == 1)
					{
						SpawnValuable(captured);
					}
					else
					{
						SpawnItem(captured);
					}
				});
			}
			if (Object.op_Implicit((Object)(object)_countText))
			{
				string arg = ((_tabIndex == 0) ? "enemies" : ((_tabIndex == 1) ? "valuables" : "items"));
				((TMP_Text)_countText).text = $"{list.Count} {arg} found";
			}
		}

		private static List<string> FilterAndSort(IEnumerable<string> src, string search)
		{
			string search2 = search;
			return (src ?? Enumerable.Empty<string>()).Where((string s) => !string.IsNullOrEmpty(s) && (string.IsNullOrWhiteSpace(search2) || s.IndexOf(search2.Trim(), StringComparison.OrdinalIgnoreCase) >= 0)).OrderBy<string, string>((string n) => n, StringComparer.OrdinalIgnoreCase).ToList();
		}

		[IteratorStateMachine(typeof(<DiscoverRoutine>d__76))]
		private IEnumerator DiscoverRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DiscoverRoutine>d__76(0)
			{
				<>4__this = this
			};
		}

		private void AddItemEntry(object entry, HashSet<string> set)
		{
			if (entry == null)
			{
				return;
			}
			string text = null;
			Type type = entry.GetType();
			try
			{
				text = type.GetField("itemName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(entry)?.ToString();
				if (string.IsNullOrWhiteSpace(text))
				{
					text = type.GetProperty("itemName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(entry, null)?.ToString();
				}
			}
			catch
			{
			}
			if (string.IsNullOrWhiteSpace(text))
			{
				Object val = (Object)((entry is Object) ? entry : null);
				if (val != null && val != (Object)null)
				{
					text = val.name;
				}
				if (string.IsNullOrWhiteSpace(text))
				{
					text = type.Name;
				}
			}
			text = RxItemTrim.Replace(text, "").Trim();
			if (!string.IsNullOrEmpty(text))
			{
				string key = text.ToLowerInvariant();
				if (!_itemByKey.ContainsKey(key))
				{
					_itemByKey[key] = entry;
				}
				set.Add(text);
			}
		}

		private void SpawnEnemy(string displayName)
		{
			//IL_019a: 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_025b: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			if (!IsHostOrOffline())
			{
				Logger.LogWarning((object)"Spawn blocked: Only the master client (host) or offline can spawn.");
			}
			else
			{
				if (string.IsNullOrWhiteSpace(displayName))
				{
					return;
				}
				string key = displayName.Trim().ToLowerInvariant();
				if (_enemyByKey.TryGetValue(key, out ScriptableObject value) && !((Object)(object)value == (Object)null))
				{
					try
					{
						Type type = ((object)value).GetType();
						if (!(type.GetField("spawnObjects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value) is IEnumerable enumerable))
						{
							Logger.LogWarning((object)("Enemy '" + displayName + "' has no spawnObjects."));
						}
						else
						{
							LevelPoint closestLevelPoint = GetClosestLevelPoint();
							Vector3 val = (((Object)(object)closestLevelPoint != (Object)null) ? ((Component)closestLevelPoint).transform.position : GetPlayerPosition());
							Type type2 = FindTypeBySimpleName("EnemyDirector");
							Object val2 = Object.FindObjectOfType(type2);
							FieldInfo fieldInfo = type2?.GetField("debugSpawnClose", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							bool flag = false;
							if (val2 != (Object)null && fieldInfo != null)
							{
								flag = (bool)(fieldInfo.GetValue(val2) ?? ((object)false));
								fieldInfo.SetValue(val2, true);
							}
							foreach (object item in enumerable)
							{
								if (item != null)
								{
									GameObject val3 = InstantiatePrefabRef(item, val, Quaternion.identity);
									if (Object.op_Implicit((Object)(object)val3))
									{
										if (InRoom() && !HasValidPhotonView(val3))
										{
											Logger.LogWarning((object)"Spawned enemy has no valid PhotonView. Skipping enemy RPCs to prevent viewID=0 errors.");
										}
										else
										{
											EnemyParent component = val3.GetComponent<EnemyParent>();
											if ((Object)(object)component != (Object)null)
											{
												try
												{
													component.SetupDone = true;
												}
												catch
												{
												}
												try
												{
													component.firstSpawnPointUsed = true;
												}
												catch
												{
												}
											}
											Enemy componentInChildren = val3.GetComponentInChildren<Enemy>();
											if ((Object)(object)componentInChildren != (Object)null)
											{
												try
												{
													if (!InRoom() || HasValidPhotonView(val3))
													{
														componentInChildren.EnemyTeleported(val);
													}
												}
												catch
												{
												}
											}
										}
									}
								}
							}
							if (val2 != (Object)null && fieldInfo != null)
							{
								fieldInfo.SetValue(val2, flag);
							}
						}
						return;
					}
					catch (Exception ex)
					{
						Logger.LogWarning((object)("Enemy spawn failed: " + ex.Message));
						return;
					}
				}
				Logger.LogWarning((object)("Enemy not found: " + displayName));
			}
		}

		private void SpawnValuable(string displayName)
		{
			//IL_0098: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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)
			if (!IsHostOrOffline())
			{
				Logger.LogWarning((object)"Spawn blocked: Only the master client (host) or offline can spawn.");
			}
			else
			{
				if (string.IsNullOrWhiteSpace(displayName))
				{
					return;
				}
				string key = displayName.Trim().ToLowerInvariant();
				if (_valuableByKey.TryGetValue(key, out object value) && value != null)
				{
					try
					{
						LevelPoint closestLevelPoint = GetClosestLevelPoint();
						Vector3 pos = (((Object)(object)closestLevelPoint != (Object)null) ? ((Component)closestLevelPoint).transform.position : GetPlayerPosition()) + Vector3.up;
						GameObject val = InstantiatePrefabRef(value, pos, Quaternion.identity);
						if (Object.op_Implicit((Object)(object)val))
						{
							if (!InRoom() || HasValidPhotonView(val))
							{
								try
								{
									ValuableObject component = val.GetComponent<ValuableObject>();
									if (component != null)
									{
										component.DollarValueSetLogic();
									}
									return;
								}
								catch
								{
									return;
								}
							}
							Logger.LogWarning((object)"Spawned valuable has no valid PhotonView; blocking post-init to avoid viewID=0 RPCs.");
						}
						return;
					}
					catch (Exception ex)
					{
						Logger.LogWarning((object)("Valuable spawn failed: " + ex.Message));
						return;
					}
				}
				Logger.LogWarning((object)("Valuable not found: " + displayName));
			}
		}

		private void SpawnItem(string displayName)
		{
			//IL_0200: 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_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: 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)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			if (!IsHostOrOffline())
			{
				Logger.LogWarning((object)"Spawn blocked: Only the master client (host) or offline can spawn.");
			}
			else
			{
				if (string.IsNullOrWhiteSpace(displayName))
				{
					return;
				}
				string key = displayName.Trim().ToLowerInvariant();
				if (_itemByKey.TryGetValue(key, out object value) && value != null)
				{
					try
					{
						Type type = value.GetType();
						object obj = type.GetField("prefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value) ?? type.GetProperty("prefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value, null);
						if (obj == null)
						{
							Logger.LogWarning((object)("Item '" + displayName + "' has no prefab reference."));
						}
						else
						{
							Quaternion rot = Quaternion.identity;
							try
							{
								Type type2 = FindTypeBySimpleName("ShopManager");
								object obj2 = type2?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
								Component val = (Component)((obj2 != null) ? /*isinst with value type is only supported in some contexts*/: null);
								if ((Object)(object)val != (Object)null)
								{
									val.transform.parent = null;
									rot = val.transform.rotation;
								}
								else
								{
									object obj3 = type.GetField("spawnRotationOffset", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value) ?? type.GetProperty("spawnRotationOffset", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value, null);
									if (obj3 is Quaternion)
									{
										Quaternion val2 = (Quaternion)obj3;
										if (true)
										{
											rot = val2;
										}
									}
								}
							}
							catch
							{
							}
							LevelPoint closestLevelPoint = GetClosestLevelPoint();
							Vector3 pos = (((Object)(object)closestLevelPoint != (Object)null) ? ((Component)closestLevelPoint).transform.position : GetPlayerPosition()) + Vector3.up;
							GameObject val3 = InstantiatePrefabRef(obj, pos, rot);
							if (!Object.op_Implicit((Object)(object)val3))
							{
								Logger.LogWarning((object)("Failed to spawn item '" + displayName + "'."));
							}
							else if (InRoom() && !HasValidPhotonView(val3))
							{
								Logger.LogError((object)("Blocked item '" + displayName + "' spawn: missing valid PhotonView (viewID=0). Destroying local-only clone to prevent RPC errors."));
								try
								{
									Object.Destroy((Object)(object)val3);
									return;
								}
								catch
								{
									return;
								}
							}
						}
						return;
					}
					catch (Exception ex)
					{
						Logger.LogWarning((object)("Item spawn failed: " + ex.Message));
						return;
					}
				}
				Logger.LogWarning((object)("Item not found: " + displayName));
			}
		}

		private GameObject InstantiatePrefabRef(object prefabRef, Vector3 pos, Quaternion rot)
		{
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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)
			if (InRoom() && !IsHost())
			{
				Logger.LogWarning((object)"Instantiate blocked: not master client.");
				return null;
			}
			try
			{
				Type type = prefabRef.GetType();
				bool flag = true;
				try
				{
					MethodInfo method = type.GetMethod("IsValid", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null)
					{
						flag = InvokeBool(method, prefabRef);
					}
				}
				catch
				{
				}
				if (!flag)
				{
					Logger.LogWarning((object)"PrefabRef invalid.");
					return null;
				}
				string text = GetString(type.GetProperty("ResourcePath", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), prefabRef) ?? type.GetField("ResourcePath", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(prefabRef)?.ToString();
				object? obj2 = type.GetProperty("Prefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(prefabRef, null);
				GameObject val = (GameObject)(((obj2 is GameObject) ? obj2 : null) ?? ((object)/*isinst with value type is only supported in some contexts*/));
				GameObject result = null;
				if (InRoom() && PhotonNetwork.IsConnectedAndReady)
				{
					if (string.IsNullOrEmpty(text))
					{
						Logger.LogError((object)"Blocked network instantiate: missing ResourcePath (PUN-registered prefab).");
						return null;
					}
					result = PhotonNetwork.Instantiate(text, pos, rot, (byte)0, (object[])null);
				}
				else if ((Object)(object)val != (Object)null)
				{
					result = Object.Instantiate<GameObject>(val, pos, rot);
				}
				else if (!string.IsNullOrEmpty(text))
				{
					result = Object.Instantiate<GameObject>(Resources.Load<GameObject>(text), pos, rot);
				}
				return result;
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)("Instantiate PrefabRef failed: " + ex.Message));
				return null;
			}
		}

		private static bool HasValidPhotonView(GameObject go)
		{
			try
			{
				PhotonView[] componentsInChildren = go.GetComponentsInChildren<PhotonView>(true);
				if (componentsInChildren == null || componentsInChildren.Length == 0)
				{
					return false;
				}
				return componentsInChildren.Any((PhotonView pv) => (Object)(object)pv != (Object)null && pv.ViewID != 0);
			}
			catch
			{
				return false;
			}
		}

		private void TakeCursor()
		{
			//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)
			_prevLock = Cursor.lockState;
			_prevVisible = Cursor.visible;
			Type type = FindTypeBySimpleName("CursorManager");
			object obj = type?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
			if (obj != null)
			{
				try
				{
					type.GetMethod("Unlock", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(obj, new object[1] { 9999f });
				}
				catch
				{
				}
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}

		private void KeepCursorFree()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Cursor.lockState > 0)
			{
				Cursor.lockState = (CursorLockMode)0;
			}
			if (!Cursor.visible)
			{
				Cursor.visible = true;
			}
		}

		private void RestoreCursor()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Cursor.lockState = _prevLock;
			Cursor.visible = _prevVisible;
		}

		private static LevelPoint? GetClosestLevelPoint()
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = FindTypeBySimpleName("LevelGenerator");
				Object val = ((type != null) ? Object.FindObjectOfType(type) : null);
				if (val != (Object)null && type.GetField("LevelPathPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(val) is IEnumerable enumerable)
				{
					Vector3 playerPosition = GetPlayerPosition();
					LevelPoint val2 = null;
					float num = float.MaxValue;
					foreach (object item in enumerable)
					{
						LevelPoint val3 = (LevelPoint)((item is LevelPoint) ? item : null);
						if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).transform == (Object)null))
						{
							float num2 = Vector3.SqrMagnitude(((Component)val3).transform.position - playerPosition);
							if (num2 < num)
							{
								num = num2;
								val2 = val3;
							}
						}
					}
					if ((Object)(object)val2 != (Object)null)
					{
						return val2;
					}
				}
			}
			catch
			{
			}
			try
			{
				LevelPoint[] array = Object.FindObjectsOfType<LevelPoint>();
				if (array != null && array.Length != 0)
				{
					Vector3 playerPosition2 = GetPlayerPosition();
					LevelPoint result = null;
					float num3 = float.MaxValue;
					LevelPoint[] array2 = array;
					foreach (LevelPoint val4 in array2)
					{
						if (!((Object)(object)val4 == (Object)null))
						{
							float num4 = Vector3.SqrMagnitude(((Component)val4).transform.position - playerPosition2);
							if (num4 < num3)
							{
								num3 = num4;
								result = val4;
							}
						}
					}
					return result;
				}
			}
			catch
			{
			}
			return null;
		}

		private static Vector3 GetPlayerPosition()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = FindTypeBySimpleName("PlayerController");
				Component val = (Component)((type != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if ((Object)(object)val != (Object)null)
				{
					return val.transform.position;
				}
			}
			catch
			{
			}
			if ((Object)(object)Camera.main != (Object)null)
			{
				return ((Component)Camera.main).transform.position;
			}
			return Vector3.zero;
		}

		private static bool InRoom()
		{
			try
			{
				return PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsSoloRoom()
		{
			try
			{
				return InRoom() && PhotonNetwork.CurrentRoom.PlayerCount <= 1;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsMultiplayer()
		{
			try
			{
				return InRoom() && PhotonNetwork.CurrentRoom.PlayerCount >= 2;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsHost()
		{
			try
			{
				return InRoom() && PhotonNetwork.IsMasterClient;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsHostOrOffline()
		{
			try
			{
				if (!InRoom())
				{
					return true;
				}
				if (IsSoloRoom())
				{
					return true;
				}
				return PhotonNetwork.IsMasterClient;
			}
			catch
			{
				return true;
			}
		}

		private static Type? FindTypeBySimpleName(string simpleName)
		{
			string simpleName2 = simpleName;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type type = null;
				try
				{
					type = assembly.GetTypes().FirstOrDefault((Type x) => x.Name == simpleName2 || (x.FullName?.EndsWith("." + simpleName2) ?? false));
				}
				catch
				{
				}
				if (type != null)
				{
					return type;
				}
			}
			return null;
		}

		private static bool InvokeBool(MethodInfo mi, object target)
		{
			try
			{
				object obj = mi?.Invoke(target, null);
				if (obj is bool)
				{
					bool result = (bool)obj;
					if (true)
					{
						return result;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static string GetString(PropertyInfo pi, object target)
		{
			try
			{
				return pi?.GetValue(target, null)?.ToString();
			}
			catch
			{
				return null;
			}
		}
	}
}
namespace Empress.SpawnBrowser.Addons
{
	internal sealed class LevelGizmoOverlay : MonoBehaviour
	{
		private static LevelGizmoOverlay _instance;

		private GameObject _root;

		private readonly List<GameObject> _lines = new List<GameObject>();

		private readonly List<GameObject> _markers = new List<GameObject>();

		private static Material _cachedLineMat;

		public bool Active => (Object)(object)_root != (Object)null && _root.activeSelf;

		public static bool ExistsAndActive => (Object)(object)_instance != (Object)null && _instance.Active;

		public static LevelGizmoOverlay Ensure()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if ((Object)(object)_instance != (Object)null)
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_LevelGizmos_ROOT");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<LevelGizmoOverlay>();
			_instance._root = val;
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if ((Object)(object)_instance != (Object)null && (Object)(object)_instance._root != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)_instance._root);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			if (!Active)
			{
				_root.SetActive(true);
				Rebuild();
			}
			else
			{
				_root.SetActive(false);
				Clear();
			}
		}

		public void Rebuild()
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: 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_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			Clear();
			List<LevelPoint> list = TryGetPointsFromLevelGenerator();
			if (list == null || list.Count == 0)
			{
				list = Object.FindObjectsOfType<LevelPoint>()?.ToList();
			}
			if (list == null || list.Count == 0)
			{
				LevelToolsPlugin.Logger.LogWarning((object)"No LevelPoints found in scene.");
				return;
			}
			foreach (LevelPoint item2 in list)
			{
				if (Object.op_Implicit((Object)(object)item2) && Object.op_Implicit((Object)(object)((Component)item2).transform))
				{
					GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
					((Object)val).name = "LP:" + ((Object)item2).name;
					val.layer = 0;
					val.transform.SetParent(_root.transform, false);
					val.transform.position = ((Component)item2).transform.position + Vector3.up * 0.1f;
					val.transform.localScale = Vector3.one * 0.35f;
					Collider component = val.GetComponent<Collider>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Object.Destroy((Object)(object)component);
					}
					Renderer component2 = val.GetComponent<Renderer>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.shadowCastingMode = (ShadowCastingMode)0;
						component2.receiveShadows = false;
					}
					_markers.Add(val);
				}
			}
			HashSet<ulong> hashSet = new HashSet<ulong>();
			int num = 0;
			foreach (LevelPoint item3 in list)
			{
				if (!Object.op_Implicit((Object)(object)item3))
				{
					continue;
				}
				IEnumerable<LevelPoint> enumerable = TryGetConnections(item3);
				if (enumerable == null)
				{
					continue;
				}
				Vector3 val2 = ((Component)item3).transform.position + Vector3.up * 0.05f;
				foreach (LevelPoint item4 in enumerable)
				{
					if (Object.op_Implicit((Object)(object)item4))
					{
						ulong num2 = (ulong)((Object)item3).GetInstanceID();
						ulong num3 = (ulong)((Object)item4).GetInstanceID();
						ulong item = ((num2 < num3) ? ((num2 << 32) | num3) : ((num3 << 32) | num2));
						if (hashSet.Add(item))
						{
							GameObject val3 = new GameObject("Path:" + ((Object)item3).name + "->" + ((Object)item4).name);
							val3.transform.SetParent(_root.transform, false);
							LineRenderer val4 = val3.AddComponent<LineRenderer>();
							val4.useWorldSpace = true;
							val4.positionCount = 2;
							val4.startWidth = 0.05f;
							val4.endWidth = 0.05f;
							val4.numCapVertices = 4;
							val4.numCornerVertices = 2;
							((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
							((Renderer)val4).receiveShadows = false;
							((Renderer)val4).material = GetDefaultLineMaterial();
							val4.startColor = new Color(0.85f, 0.85f, 0.85f, 0.9f);
							val4.endColor = new Color(0.85f, 0.85f, 0.85f, 0.9f);
							val4.SetPosition(0, val2);
							val4.SetPosition(1, ((Component)item4).transform.position + Vector3.up * 0.05f);
							_lines.Add(val3);
							num++;
						}
					}
				}
			}
			LevelToolsPlugin.Logger.LogInfo((object)$"Level gizmos: {list.Count} points, {num} segments.");
		}

		private void Clear()
		{
			foreach (GameObject marker in _markers)
			{
				if (Object.op_Implicit((Object)(object)marker))
				{
					Object.Destroy((Object)(object)marker);
				}
			}
			foreach (GameObject line in _lines)
			{
				if (Object.op_Implicit((Object)(object)line))
				{
					Object.Destroy((Object)(object)line);
				}
			}
			_markers.Clear();
			_lines.Clear();
		}

		private static Material GetDefaultLineMaterial()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_cachedLineMat))
			{
				return _cachedLineMat;
			}
			Shader val = Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
			}
			_cachedLineMat = (Object.op_Implicit((Object)(object)val) ? new Material(val) : new Material(Shader.Find("Sprites/Default")));
			((Object)_cachedLineMat).hideFlags = (HideFlags)61;
			return _cachedLineMat;
		}

		private static List<LevelPoint> TryGetPointsFromLevelGenerator()
		{
			try
			{
				Type type = AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => SafeGetTypes(a)).FirstOrDefault((Type t) => t.Name == "LevelGenerator" || (t.FullName?.EndsWith(".LevelGenerator") ?? false));
				if (type == null)
				{
					return null;
				}
				Object obj = Object.FindObjectOfType(type);
				Component val = (Component)(object)((obj is Component) ? obj : null);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				IList list = null;
				FieldInfo field = type.GetField("LevelPathPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					list = field.GetValue(val) as IList;
				}
				if (list == null)
				{
					PropertyInfo property = type.GetProperty("LevelPathPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null)
					{
						list = property.GetValue(val, null) as IList;
					}
				}
				if (list == null || list.Count == 0)
				{
					return null;
				}
				List<LevelPoint> list2 = new List<LevelPoint>(list.Count);
				foreach (object item in list)
				{
					LevelPoint val2 = (LevelPoint)((item is LevelPoint) ? item : null);
					if (val2 != null)
					{
						list2.Add(val2);
					}
				}
				return list2;
			}
			catch
			{
				return null;
			}
		}

		private static IEnumerable<Type> SafeGetTypes(Assembly a)
		{
			try
			{
				return a.GetTypes();
			}
			catch
			{
				return Enumerable.Empty<Type>();
			}
		}

		private static IEnumerable<LevelPoint> TryGetConnections(LevelPoint p)
		{
			Type type = ((object)p).GetType();
			string[] array = new string[6] { "ConnectedPoints", "connectedPoints", "Neighbours", "Neighbors", "connections", "links" };
			foreach (string name in array)
			{
				try
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(p);
						IEnumerable<LevelPoint> enumerable = AsLevelPointEnumerable(value);
						if (enumerable != null)
						{
							return enumerable;
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null)
					{
						object value2 = property.GetValue(p, null);
						IEnumerable<LevelPoint> enumerable2 = AsLevelPointEnumerable(value2);
						if (enumerable2 != null)
						{
							return enumerable2;
						}
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private static IEnumerable<LevelPoint> AsLevelPointEnumerable(object v)
		{
			if (v == null)
			{
				return null;
			}
			if (v is IEnumerable enumerable)
			{
				List<LevelPoint> list = new List<LevelPoint>();
				foreach (object item in enumerable)
				{
					LevelPoint val = (LevelPoint)((item is LevelPoint) ? item : null);
					if (val != null)
					{
						list.Add(val);
					}
				}
				return list;
			}
			return null;
		}
	}
	[BepInPlugin("Empress.SpawnBrowser.LevelTools", "Spawn Browser - Level Tools", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class LevelToolsPlugin : BaseUnityPlugin
	{
		private Harmony _harmony = null;

		private const int MyTabIndex = 3;

		private static object _spawnBrowser;

		private static GameObject _panelRoot;

		private static Transform _contentContainer;

		private static TMP_InputField _searchInput;

		private static TextMeshProUGUI _statusText;

		private static TextMeshProUGUI _countText;

		private static Button _levelTabButton;

		private static Color _bg2;

		private static Color _fg;

		private static Color _accentBase;

		private static Color _accentHover;

		private static Color _accentDisabled;

		internal static LevelToolsPlugin Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		private void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			_harmony = new Harmony("Empress.SpawnBrowser.LevelTools");
			TryPatch();
			SceneManager.activeSceneChanged += OnSceneChanged;
			Logger.LogInfo((object)"LevelTools loaded. New LEVELS tab + buttons are ready to play.");
		}

		private void OnDestroy()
		{
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			SceneManager.activeSceneChanged -= OnSceneChanged;
			LevelGizmoOverlay.DestroyIfExists();
		}

		private void OnSceneChanged(Scene a, Scene b)
		{
			if (LevelGizmoOverlay.ExistsAndActive)
			{
				LevelGizmoOverlay.Ensure().Rebuild();
			}
		}

		private static Type FindType(string fullName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type type = assembly.GetType(fullName, throwOnError: false, ignoreCase: false);
					if (type != null)
					{
						return type;
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private void TryPatch()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			Type type = FindType("Empress.SpawnBrowser.SpawnBrowser");
			if (type == null)
			{
				Logger.LogError((object)"SpawnBrowser type not found. Is the base plugin loaded?");
				return;
			}
			MethodInfo method = type.GetMethod("BuildCanvas", BindingFlags.Instance | BindingFlags.NonPublic);
			_harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(LevelToolsPlugin), "BuildCanvas_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo method2 = type.GetMethod("SwitchTab", BindingFlags.Instance | BindingFlags.NonPublic);
			_harmony.Patch((MethodBase)method2, new HarmonyMethod(typeof(LevelToolsPlugin), "SwitchTab_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo method3 = type.GetMethod("RefreshCurrentTab", BindingFlags.Instance | BindingFlags.NonPublic);
			_harmony.Patch((MethodBase)method3, new HarmonyMethod(typeof(LevelToolsPlugin), "RefreshCurrentTab_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void BuildCanvas_Postfix(object __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			object __instance2 = __instance;
			try
			{
				_spawnBrowser = __instance2;
				Type type = __instance2.GetType();
				_panelRoot = (GameObject)type.GetField("_panelRoot", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_contentContainer = (Transform)type.GetField("_contentContainer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_searchInput = (TMP_InputField)type.GetField("_searchInput", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_statusText = (TextMeshProUGUI)type.GetField("_statusText", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_countText = (TextMeshProUGUI)type.GetField("_countText", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_bg2 = (Color)type.GetField("_bg2", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_fg = (Color)type.GetField("_fg", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_accentBase = (Color)type.GetField("_accentBase", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_accentHover = (Color)type.GetField("_accentHover", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				_accentDisabled = (Color)type.GetField("_accentDisabled", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance2);
				Transform val = FindChildRecursive(_panelRoot.transform, "TabBar");
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogWarning((object)"TabBar not found; cannot add 'LEVELS' tab.");
					return;
				}
				_levelTabButton = CreateTabButton(val, "LEVELS \ud83d\uddfa");
				((UnityEventBase)_levelTabButton.onClick).RemoveAllListeners();
				((UnityEvent)_levelTabButton.onClick).AddListener((UnityAction)delegate
				{
					SetSpawnBrowserTabIndex(__instance2, 3);
					RenderLevelsTab();
				});
				Logger.LogInfo((object)"LEVELS tab injected.");
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)("BuildCanvas_Postfix failed: " + ex.Message));
			}
		}

		private static bool SwitchTab_Prefix(object __instance, int index)
		{
			if (index == 3)
			{
				SetSpawnBrowserTabIndex(__instance, 3);
				RenderLevelsTab();
				return false;
			}
			return true;
		}

		private static bool RefreshCurrentTab_Prefix(object __instance)
		{
			Type type = __instance.GetType();
			int num = (int)type.GetField("_tabIndex", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
			if (num == 3)
			{
				RenderLevelsTab();
				return false;
			}
			return true;
		}

		private static void RenderLevelsTab()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			if ((Object)(object)_contentContainer == (Object)null)
			{
				return;
			}
			foreach (Transform item in _contentContainer)
			{
				Transform val = item;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			if ((Object)(object)_searchInput != (Object)null)
			{
				_searchInput.text = string.Empty;
			}
			if (Object.op_Implicit((Object)(object)_statusText))
			{
				((TMP_Text)_statusText).text = "Level tools: host-only for switching. Gizmos are local-only.";
			}
			TextMeshProUGUI val2 = CreateTMP(_contentContainer, "<b>LEVEL TOOLS</b>", 16f, _fg, (TextAlignmentOptions)4097);
			LayoutElement val3 = ((Component)val2).gameObject.AddComponent<LayoutElement>();
			val3.minHeight = 32f;
			GameObject val4 = CreateRow(_contentContainer);
			Button val5 = CreateActionButton(val4.transform, "Next Level ▶", delegate
			{
				TryAdvanceLevel();
			});
			((Selectable)val5).interactable = IsMasterClientOrSingleplayer();
			if (!((Selectable)val5).interactable)
			{
				Image component = ((Component)val5).GetCompone