Decompiled source of BearsDen Admin GUI v2.0.0

BearsDenAdmin.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BearsDenAdmin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BearsDenAdmin")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("144e2927-ae16-4b0e-9c99-c0a50b51dede")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BearsDenAdmin;

[BepInPlugin("com.bearsden.admin", "BearsDen Admin GUI", "2.0.0")]
public class BearsDenAdminGUI : BaseUnityPlugin
{
	public static ManualLogSource Log;

	private readonly Harmony harmony = new Harmony("com.bearsden.admin");

	private ConfigEntry<float> windowX;

	private ConfigEntry<float> windowY;

	private bool showWindow = false;

	private Texture2D windowBg;

	private Texture2D buttonBg;

	private GUIStyle labelStyle;

	private GUIStyle buttonStyle;

	private GUIStyle textFieldStyle;

	private GUIStyle windowStyle;

	private bool stylesBuilt = false;

	private Rect windowRect;

	private int activeTab = 0;

	private readonly string[] tabs = new string[5] { "World", "Items", "Spawn", "Skills", "Console" };

	private string itemSearch = "";

	private string itemQty = "1";

	private string itemLevel = "1";

	private string selectedItemPrefab = "";

	private string selectedItemDisplay = "";

	private int selectedCategoryIndex = 0;

	private Vector2 itemScrollPos;

	private Vector2 categoryScrollPos;

	private List<string> filteredItems = new List<string>();

	private static List<string> allItems = new List<string>();

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

	private static List<string> categoryNames = new List<string>();

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

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

	private static bool itemsLoaded = false;

	private string creatureSearch = "";

	private string spawnQty = "1";

	private Vector2 creatureScrollPos;

	private List<string> filteredCreatures = new List<string>();

	private static List<string> allCreatures = new List<string>();

	private static bool creaturesLoaded = false;

	private int weatherIndex = 0;

	private string gotoX = "0";

	private string gotoZ = "0";

	private bool pendingGotoConfirm = false;

	private List<PlayerInfo> onlinePlayers = new List<PlayerInfo>();

	private Vector2 playerListScroll;

	public static bool WaitingForMapPick = false;

	private float timeValue = 0.5f;

	private readonly string[] weatherOptions = new string[18]
	{
		"Clear", "Twilight_Clear", "LightRain", "Rain", "ThunderStorm", "Ashrain", "Snow", "SnowStorm", "Fog", "Darklands_dark",
		"Heath clear", "DeepForest Mist", "GDKing", "Misty", "Swamp Rain", "Bonemass mist", "Drizzle", "Swamp"
	};

	private int skillIndex = 0;

	private string skillLevel = "10";

	private readonly string[] skillNames = new string[19]
	{
		"Swords", "Knives", "Clubs", "Polearms", "Spears", "Blocking", "Axes", "Bows", "Crossbows", "ElementalMagic",
		"BloodMagic", "Unarmed", "Pickaxes", "WoodCutting", "Sneaking", "Run", "Swim", "Jump", "All"
	};

	private string consoleInput = "";

	private List<string> consoleSuggestions = new List<string>();

	private Vector2 consoleSuggestScroll;

	private List<string> consoleHistory = new List<string>();

	private Vector2 consoleHistoryScroll;

	private static List<string> allCommands = new List<string>();

	private string feedbackMsg = "";

	private float feedbackTimer = 0f;

	private void Awake()
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		windowX = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "X", 100f, "Window X position");
		windowY = ((BaseUnityPlugin)this).Config.Bind<float>("Window", "Y", 100f, "Window Y position");
		windowRect = new Rect(windowX.Value, windowY.Value, 800f, 900f);
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"BearsDen Admin GUI v2.0.0 loaded! Press Semicolon (;) to toggle.");
	}

	private void OnDestroy()
	{
		harmony.UnpatchSelf();
	}

	private void ClosePanelCleanup()
	{
		Cursor.lockState = (CursorLockMode)1;
		Cursor.visible = false;
		showWindow = false;
		AdminPanelState.IsOpen = false;
	}

	private void BuildStyles()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//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_0064: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_00e7: 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)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Expected O, but got Unknown
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Expected O, but got Unknown
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Expected O, but got Unknown
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		if (!stylesBuilt)
		{
			stylesBuilt = true;
			windowBg = new Texture2D(1, 1);
			windowBg.SetPixel(0, 0, new Color(0.06f, 0.1f, 0.18f, 0.97f));
			windowBg.Apply();
			buttonBg = new Texture2D(1, 1);
			buttonBg.SetPixel(0, 0, new Color(0.15f, 0.3f, 0.5f, 1f));
			buttonBg.Apply();
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, new Color(0.25f, 0.5f, 0.8f, 1f));
			val.Apply();
			Texture2D val2 = new Texture2D(1, 1);
			val2.SetPixel(0, 0, new Color(0.1f, 0.6f, 0.9f, 1f));
			val2.Apply();
			windowStyle = new GUIStyle(GUI.skin.window);
			windowStyle.normal.background = windowBg;
			windowStyle.onNormal.background = windowBg;
			windowStyle.normal.textColor = new Color(0.6f, 0.85f, 1f, 1f);
			labelStyle = new GUIStyle(GUI.skin.label);
			labelStyle.normal.textColor = new Color(0.75f, 0.9f, 1f, 1f);
			labelStyle.fontStyle = (FontStyle)1;
			buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.normal.background = buttonBg;
			buttonStyle.normal.textColor = new Color(0.85f, 0.95f, 1f, 1f);
			buttonStyle.hover.background = val;
			buttonStyle.hover.textColor = Color.white;
			buttonStyle.active.background = val2;
			buttonStyle.active.textColor = Color.white;
			buttonStyle.fontStyle = (FontStyle)1;
			textFieldStyle = new GUIStyle(GUI.skin.textField);
			textFieldStyle.normal.textColor = new Color(0.1f, 0.1f, 0.2f, 1f);
			textFieldStyle.fontStyle = (FontStyle)0;
		}
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)59))
		{
			showWindow = !showWindow;
			AdminPanelState.IsOpen = showWindow;
			if (showWindow)
			{
				LoadItemsIfNeeded();
				LoadCreaturesIfNeeded();
				filteredItems = new List<string>(allItems);
				filteredCreatures = new List<string>(allCreatures);
				selectedCategoryIndex = 0;
				WaitingForMapPick = false;
			}
			else
			{
				ClosePanelCleanup();
			}
		}
		if (showWindow || WaitingForMapPick)
		{
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}
		if (MapPickResult.HasResult)
		{
			MapPickResult.HasResult = false;
			gotoX = MapPickResult.X;
			gotoZ = MapPickResult.Z;
			pendingGotoConfirm = true;
			activeTab = 0;
			showWindow = true;
			AdminPanelState.IsOpen = true;
			LoadItemsIfNeeded();
			LoadCreaturesIfNeeded();
			filteredItems = new List<string>(allItems);
			filteredCreatures = new List<string>(allCreatures);
		}
		if (feedbackTimer > 0f)
		{
			feedbackTimer -= Time.deltaTime;
		}
	}

	private void OnGUI()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Invalid comparison between Unknown and I4
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Invalid comparison between Unknown and I4
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: 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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Expected O, but got Unknown
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Invalid comparison between Unknown and I4
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Invalid comparison between Unknown and I4
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Invalid comparison between Unknown and I4
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Invalid comparison between Unknown and I4
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Invalid comparison between Unknown and I4
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Invalid comparison between Unknown and I4
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Invalid comparison between Unknown and I4
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Invalid comparison between Unknown and I4
		if (!showWindow || (Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		BuildStyles();
		if ((int)Event.current.type == 6)
		{
			Event.current.Use();
		}
		if ((int)Event.current.type == 4 || (int)Event.current.type == 5)
		{
			KeyCode keyCode = Event.current.keyCode;
			if (((int)keyCode >= 48 && (int)keyCode <= 57) || (int)keyCode == 9 || (int)keyCode == 101 || (int)keyCode == 102 || (int)keyCode == 105 || (int)keyCode == 109 || (int)keyCode == 27)
			{
				Event.current.Use();
			}
		}
		float num = 1.6f;
		Matrix4x4 matrix = GUI.matrix;
		GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f));
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(((Rect)(ref windowRect)).x / num, ((Rect)(ref windowRect)).y / num, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height);
		val = GUI.Window(9001, val, new WindowFunction(DrawWindow), "BearsDen Admin Panel", windowStyle);
		windowRect = new Rect(((Rect)(ref val)).x * num, ((Rect)(ref val)).y * num, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height);
		GUI.matrix = matrix;
		windowX.Value = ((Rect)(ref windowRect)).x;
		windowY.Value = ((Rect)(ref windowRect)).y;
	}

	private void DrawWindow(int windowID)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, 800f, 20f));
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		activeTab = GUILayout.Toolbar(activeTab, tabs, Array.Empty<GUILayoutOption>());
		GUILayout.Space(6f);
		switch (activeTab)
		{
		case 0:
			DrawWorldTab();
			break;
		case 1:
			DrawItemsTab();
			break;
		case 2:
			DrawSpawnTab();
			break;
		case 3:
			DrawSkillsTab();
			break;
		case 4:
			DrawConsoleTab();
			break;
		}
		GUILayout.FlexibleSpace();
		if (feedbackTimer > 0f)
		{
			GUI.color = Color.green;
			GUILayout.Label(feedbackMsg, labelStyle, Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
		}
		GUILayout.Space(4f);
		if (GUILayout.Button("Close (;)", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			showWindow = false;
			AdminPanelState.IsOpen = false;
			ClosePanelCleanup();
		}
		GUILayout.EndVertical();
	}

	private void DrawItemsTab()
	{
		//IL_00c5: 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_01eb: 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_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Search:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		string text = GUILayout.TextField(itemSearch, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		GUILayout.EndHorizontal();
		if (text != itemSearch)
		{
			itemSearch = text;
			selectedCategoryIndex = 0;
			FilterItems();
		}
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
		GUILayout.Label("Category", labelStyle, Array.Empty<GUILayoutOption>());
		categoryScrollPos = GUILayout.BeginScrollView(categoryScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(160f),
			GUILayout.Height(420f)
		});
		for (int i = 0; i < categoryNames.Count; i++)
		{
			if (selectedCategoryIndex == i)
			{
				GUI.color = new Color(0.3f, 0.8f, 1f, 1f);
			}
			if (GUILayout.Button(categoryNames[i], buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(145f) }))
			{
				selectedCategoryIndex = i;
				itemSearch = "";
				FilterItemsByCategory();
			}
			GUI.color = Color.white;
		}
		GUILayout.EndScrollView();
		GUILayout.EndVertical();
		GUILayout.Space(6f);
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Items ({filteredItems.Count})", labelStyle, Array.Empty<GUILayoutOption>());
		itemScrollPos = GUILayout.BeginScrollView(itemScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(420f) });
		foreach (string filteredItem in filteredItems)
		{
			string text2 = (prefabToDisplay.ContainsKey(filteredItem) ? prefabToDisplay[filteredItem] : filteredItem);
			if (selectedItemPrefab == filteredItem)
			{
				GUI.color = new Color(0.3f, 0.8f, 1f, 1f);
			}
			if (GUILayout.Button(text2, buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				selectedItemPrefab = filteredItem;
				selectedItemDisplay = text2;
			}
			GUI.color = Color.white;
		}
		GUILayout.EndScrollView();
		GUILayout.EndVertical();
		GUILayout.EndHorizontal();
		GUILayout.Space(6f);
		if (!string.IsNullOrEmpty(selectedItemPrefab))
		{
			GUILayout.Label("Selected: " + selectedItemDisplay, labelStyle, Array.Empty<GUILayoutOption>());
		}
		else
		{
			GUILayout.Label("No item selected - click one above", labelStyle, Array.Empty<GUILayoutOption>());
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Qty:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
		itemQty = GUILayout.TextField(itemQty, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) });
		GUILayout.Label("Level:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) });
		itemLevel = GUILayout.TextField(itemLevel, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(35f) });
		GUILayout.Label("(1-4)", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Add to Inventory", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			if (string.IsNullOrEmpty(selectedItemPrefab))
			{
				ShowFeedback("Select an item first!");
			}
			else
			{
				GiveItemToSelf(selectedItemPrefab, itemQty.Trim(), itemLevel.Trim());
			}
		}
		if (GUILayout.Button("Spawn to Ground", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			if (string.IsNullOrEmpty(selectedItemPrefab))
			{
				ShowFeedback("Select an item first!");
			}
			else
			{
				RunCommand("spawn " + selectedItemPrefab + " " + itemQty.Trim() + " " + itemLevel.Trim());
			}
		}
		GUILayout.EndHorizontal();
	}

	private void DrawSpawnTab()
	{
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("Spawn creature in front of you:", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) });
		string text = GUILayout.TextField(creatureSearch, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		GUILayout.EndHorizontal();
		if (text != creatureSearch)
		{
			creatureSearch = text;
			FilterCreatures();
		}
		GUILayout.Space(4f);
		GUILayout.Label($"Results: {filteredCreatures.Count}", labelStyle, Array.Empty<GUILayoutOption>());
		creatureScrollPos = GUILayout.BeginScrollView(creatureScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(400f) });
		foreach (string filteredCreature in filteredCreatures)
		{
			if (GUILayout.Button(filteredCreature, buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				creatureSearch = filteredCreature;
				FilterCreatures();
			}
		}
		GUILayout.EndScrollView();
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Name:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) });
		creatureSearch = GUILayout.TextField(creatureSearch, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label("Qty:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
		spawnQty = GUILayout.TextField(spawnQty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		if (GUILayout.Button("Spawn", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("spawn " + creatureSearch.Trim() + " " + spawnQty.Trim());
		}
	}

	private void DrawWorldTab()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_0579: 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_0638: Unknown result type (might be due to invalid IL or missing references)
		//IL_0673: Unknown result type (might be due to invalid IL or missing references)
		//IL_073d: 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_0745: Unknown result type (might be due to invalid IL or missing references)
		//IL_075c: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_09fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a23: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a9f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0901: Unknown result type (might be due to invalid IL or missing references)
		//IL_0906: Unknown result type (might be due to invalid IL or missing references)
		//IL_0909: Unknown result type (might be due to invalid IL or missing references)
		//IL_0923: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("─── Weather ───", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		int num = 3;
		for (int i = 0; i < weatherOptions.Length; i += num)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int j = i; j < Mathf.Min(i + num, weatherOptions.Length); j++)
			{
				if (weatherIndex == j)
				{
					GUI.color = Color.yellow;
				}
				if (GUILayout.Button(weatherOptions[j], buttonStyle, Array.Empty<GUILayoutOption>()))
				{
					weatherIndex = j;
				}
				GUI.color = Color.white;
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(6f);
		if (GUILayout.Button("Set Weather: " + weatherOptions[weatherIndex], buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("env " + weatherOptions[weatherIndex]);
		}
		if (GUILayout.Button("Reset Weather", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("resetenv");
		}
		GUILayout.Space(12f);
		GUILayout.Label("─── Time of Day ───", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Time:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
		timeValue = GUILayout.HorizontalSlider(timeValue, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		string timeLabel = GetTimeLabel(timeValue);
		GUILayout.Label(timeLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Dawn", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			timeValue = 0.15f;
		}
		if (GUILayout.Button("Noon", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			timeValue = 0.5f;
		}
		if (GUILayout.Button("Dusk", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			timeValue = 0.75f;
		}
		if (GUILayout.Button("Midnight", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			timeValue = 0f;
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		if (GUILayout.Button("Set Time: " + timeLabel + " (server sync)", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			SetServerTime(timeValue);
		}
		GUILayout.Space(12f);
		GUILayout.Label("─── Other ───", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("God Mode ON", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("god");
		}
		if (GUILayout.Button("No Cost Build", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("nocost");
		}
		if (GUILayout.Button("Ghost Mode", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("ghost");
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Fly ON/OFF", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("fly");
		}
		if (GUILayout.Button("Kill All Near", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("killall");
		}
		if (GUILayout.Button("Remove Drops", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("removedrops");
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(12f);
		GUILayout.Label("─── Goto Location ───", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("X:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) });
		gotoX = GUILayout.TextField(gotoX, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
		GUILayout.Space(8f);
		GUILayout.Label("Z:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) });
		gotoZ = GUILayout.TextField(gotoZ, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		if (pendingGotoConfirm)
		{
			GUI.color = new Color(1f, 0.9f, 0.3f, 1f);
			GUILayout.Label("Teleport to  X: " + gotoX + "   Z: " + gotoZ + " ?", labelStyle, Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.color = new Color(0.3f, 1f, 0.4f, 1f);
			if (GUILayout.Button("✔ Confirm Teleport", buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				pendingGotoConfirm = false;
				if (float.TryParse(gotoX, out var result) && float.TryParse(gotoZ, out var result2))
				{
					RunCommand($"goto {result:F0} {result2:F0}");
				}
				else
				{
					ShowFeedback("Invalid coordinates!");
				}
			}
			GUI.color = new Color(1f, 0.3f, 0.3f, 1f);
			if (GUILayout.Button("✘ Cancel", buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				pendingGotoConfirm = false;
				ShowFeedback("Teleport cancelled.");
			}
			GUI.color = Color.white;
			GUILayout.EndHorizontal();
		}
		else
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Go", buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				if (float.TryParse(gotoX, out var result3) && float.TryParse(gotoZ, out var result4))
				{
					RunCommand($"goto {result3:F0} {result4:F0}");
				}
				else
				{
					ShowFeedback("Invalid coordinates!");
				}
			}
			if (GUILayout.Button("My Position", buttonStyle, Array.Empty<GUILayoutOption>()) && (Object)(object)Player.m_localPlayer != (Object)null)
			{
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				gotoX = ((int)position.x).ToString();
				gotoZ = ((int)position.z).ToString();
				ShowFeedback("Set to current pos: " + gotoX + ", " + gotoZ);
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(4f);
		if (WaitingForMapPick)
		{
			GUI.color = Color.yellow;
			GUILayout.Label("Open map and click a location...", labelStyle, Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			if (GUILayout.Button("Cancel Map Pick", buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				WaitingForMapPick = false;
			}
		}
		else if (GUILayout.Button("Pick from Map", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			WaitingForMapPick = true;
			showWindow = false;
			AdminPanelState.IsOpen = false;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			ShowFeedback("Open map (M) and click a location. ; to return.");
		}
		GUILayout.Space(12f);
		GUILayout.Label("─── Go To Player ───", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Refresh Players", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			onlinePlayers.Clear();
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				string text = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerName() : "");
				List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
				foreach (PlayerInfo item in playerList)
				{
					if (item.m_name != text)
					{
						onlinePlayers.Add(item);
					}
				}
				ShowFeedback($"Found {onlinePlayers.Count} other player(s).");
			}
			else
			{
				ShowFeedback("ZNet not available.");
			}
		}
		GUILayout.EndHorizontal();
		if (onlinePlayers.Count == 0)
		{
			GUILayout.Label("No other players found — click Refresh.", labelStyle, Array.Empty<GUILayoutOption>());
			return;
		}
		playerListScroll = GUILayout.BeginScrollView(playerListScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) });
		foreach (PlayerInfo onlinePlayer in onlinePlayers)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(onlinePlayer.m_name, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
			if (onlinePlayer.m_publicPosition)
			{
				GUILayout.Label($"({(int)onlinePlayer.m_position.x}, {(int)onlinePlayer.m_position.z})", labelStyle, Array.Empty<GUILayoutOption>());
			}
			if (GUILayout.Button("Go To", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
			{
				RunCommand("goto " + onlinePlayer.m_name);
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.EndScrollView();
	}

	private void DrawSkillsTab()
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("Modify your own skills:", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.Label("Select Skill:", labelStyle, Array.Empty<GUILayoutOption>());
		int num = 3;
		for (int i = 0; i < skillNames.Length; i += num)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int j = i; j < Mathf.Min(i + num, skillNames.Length); j++)
			{
				if (skillIndex == j)
				{
					GUI.color = Color.yellow;
				}
				if (GUILayout.Button(skillNames[j], buttonStyle, Array.Empty<GUILayoutOption>()))
				{
					skillIndex = j;
				}
				GUI.color = Color.white;
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(8f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Level (1-100):", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
		skillLevel = GUILayout.TextField(skillLevel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		GUILayout.EndHorizontal();
		GUILayout.Space(6f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Raise " + skillNames[skillIndex], buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("raiseskill " + skillNames[skillIndex] + " " + skillLevel);
		}
		if (GUILayout.Button("Reset " + skillNames[skillIndex], buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("resetskill " + skillNames[skillIndex]);
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(8f);
		GUILayout.Label("─── Quick Presets ───", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Max All Skills (100)", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			string[] array = skillNames;
			foreach (string text in array)
			{
				if (text != "All")
				{
					RunCommand("raiseskill " + text + " 100");
				}
			}
			ShowFeedback("All skills set to 100!");
		}
		if (GUILayout.Button("Reset All Skills", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			RunCommand("resetskill All");
			ShowFeedback("All skills reset!");
		}
		GUILayout.EndHorizontal();
	}

	private void DrawConsoleTab()
	{
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("Custom Console Command:", labelStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUI.SetNextControlName("consoleField");
		string text = GUILayout.TextField(consoleInput, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		if (GUILayout.Button("Run", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
		{
			ExecuteConsoleInput();
		}
		GUILayout.EndHorizontal();
		if (text != consoleInput)
		{
			consoleInput = text;
			UpdateConsoleSuggestions();
		}
		if (consoleSuggestions.Count > 0)
		{
			GUILayout.Label("Suggestions:", labelStyle, Array.Empty<GUILayoutOption>());
			consoleSuggestScroll = GUILayout.BeginScrollView(consoleSuggestScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) });
			foreach (string consoleSuggestion in consoleSuggestions)
			{
				if (GUILayout.Button(consoleSuggestion, buttonStyle, Array.Empty<GUILayoutOption>()))
				{
					consoleInput = consoleSuggestion + " ";
					UpdateConsoleSuggestions();
				}
			}
			GUILayout.EndScrollView();
		}
		GUILayout.Space(8f);
		GUILayout.Label("─── History ───", labelStyle, Array.Empty<GUILayoutOption>());
		consoleHistoryScroll = GUILayout.BeginScrollView(consoleHistoryScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(300f) });
		for (int num = consoleHistory.Count - 1; num >= 0; num--)
		{
			if (GUILayout.Button(consoleHistory[num], buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				consoleInput = consoleHistory[num];
				UpdateConsoleSuggestions();
			}
		}
		GUILayout.EndScrollView();
		GUILayout.Space(4f);
		if (GUILayout.Button("Clear History", buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			consoleHistory.Clear();
		}
	}

	private void ExecuteConsoleInput()
	{
		string text = consoleInput.Trim();
		if (!string.IsNullOrEmpty(text))
		{
			RunCommand(text);
			if (!consoleHistory.Contains(text))
			{
				consoleHistory.Add(text);
			}
			consoleInput = "";
			consoleSuggestions.Clear();
		}
	}

	private void UpdateConsoleSuggestions()
	{
		consoleSuggestions.Clear();
		if (string.IsNullOrEmpty(consoleInput))
		{
			return;
		}
		string value = consoleInput.ToLower();
		if (consoleInput.Contains(" "))
		{
			return;
		}
		foreach (string allCommand in allCommands)
		{
			if (allCommand.ToLower().StartsWith(value))
			{
				consoleSuggestions.Add(allCommand);
			}
		}
	}

	private void GiveItemToSelf(string itemName, string qtyStr, string levelStr = "1")
	{
		if (string.IsNullOrEmpty(itemName))
		{
			ShowFeedback("No item name entered!");
			return;
		}
		if (!int.TryParse(qtyStr, out var result) || result < 1)
		{
			result = 1;
		}
		if (!int.TryParse(levelStr, out var result2) || result2 < 1)
		{
			result2 = 1;
		}
		if (result2 > 4)
		{
			result2 = 4;
		}
		ObjectDB instance = ObjectDB.instance;
		GameObject val = ((instance != null) ? instance.GetItemPrefab(itemName) : null);
		if ((Object)(object)val == (Object)null)
		{
			ShowFeedback("Item not found: " + itemName);
			return;
		}
		ItemData val2 = val.GetComponent<ItemDrop>().m_itemData.Clone();
		val2.m_stack = Mathf.Clamp(result, 1, (val2.m_shared.m_maxStackSize <= 0) ? 1 : val2.m_shared.m_maxStackSize);
		val2.m_quality = result2;
		val2.m_durability = val2.m_shared.m_maxDurability;
		if (((Humanoid)Player.m_localPlayer).GetInventory().AddItem(val2))
		{
			ShowFeedback($"Added {result}x {itemName} (Lv{result2}) to inventory!");
		}
		else
		{
			ShowFeedback("Inventory full!");
		}
	}

	private void SetServerTime(float fraction)
	{
		if (ZRoutedRpc.instance == null)
		{
			ShowFeedback("ZRoutedRpc not available!");
			return;
		}
		long value = Traverse.Create((object)ZRoutedRpc.instance).Method("GetServerPeerID", Array.Empty<object>()).GetValue<long>();
		ZRoutedRpc.instance.InvokeRoutedRPC(value, "BearsDen_SetTime", new object[1] { fraction });
		ShowFeedback("Server time set to " + GetTimeLabel(fraction) + " for all players!");
	}

	private void RunCommand(string command)
	{
		if ((Object)(object)Console.instance != (Object)null)
		{
			((Terminal)Console.instance).TryRunCommand(command, false, false);
			ShowFeedback("Ran: " + command);
		}
		else
		{
			ShowFeedback("Console not available! Open console first (F5).");
		}
	}

	private void ShowFeedback(string msg)
	{
		feedbackMsg = msg;
		feedbackTimer = 3f;
		Log.LogInfo((object)msg);
	}

	private string GetTimeLabel(float t)
	{
		int num = Mathf.RoundToInt(t * 24f) % 24;
		string arg = ((num < 12) ? "AM" : "PM");
		int num2 = ((num == 0) ? 12 : ((num > 12) ? (num - 12) : num));
		return $"{num2}:00 {arg}";
	}

	private void FilterItems()
	{
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		filteredItems.Clear();
		string value = itemSearch.ToLower();
		List<string> currentCategoryPool = GetCurrentCategoryPool();
		foreach (string item in currentCategoryPool)
		{
			string text = (prefabToDisplay.ContainsKey(item) ? prefabToDisplay[item] : item);
			if (string.IsNullOrEmpty(value) || text.ToLower().Contains(value) || item.ToLower().Contains(value))
			{
				filteredItems.Add(item);
			}
		}
		itemScrollPos = Vector2.zero;
	}

	private void FilterItemsByCategory()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		filteredItems.Clear();
		List<string> currentCategoryPool = GetCurrentCategoryPool();
		filteredItems.AddRange(currentCategoryPool);
		itemScrollPos = Vector2.zero;
	}

	private List<string> GetCurrentCategoryPool()
	{
		if (selectedCategoryIndex == 0 || categoryNames.Count == 0)
		{
			return allItems;
		}
		string key = categoryNames[selectedCategoryIndex];
		if (itemsByCategory.ContainsKey(key))
		{
			return itemsByCategory[key];
		}
		return allItems;
	}

	private void FilterCreatures()
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		filteredCreatures.Clear();
		string value = creatureSearch.ToLower();
		foreach (string allCreature in allCreatures)
		{
			if (string.IsNullOrEmpty(value) || allCreature.ToLower().Contains(value))
			{
				filteredCreatures.Add(allCreature);
			}
		}
		creatureScrollPos = Vector2.zero;
	}

	private void LoadItemsIfNeeded()
	{
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Invalid comparison between Unknown and I4
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		if (itemsLoaded || (Object)(object)ObjectDB.instance == (Object)null)
		{
			return;
		}
		allItems.Clear();
		itemsByCategory.Clear();
		categoryNames.Clear();
		prefabToDisplay.Clear();
		displayToPrefab.Clear();
		foreach (GameObject item in ObjectDB.instance.m_items)
		{
			if ((Object)(object)item == (Object)null)
			{
				continue;
			}
			ItemDrop component = item.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				continue;
			}
			ItemType itemType = component.m_itemData.m_shared.m_itemType;
			if ((int)itemType != 0)
			{
				string text = SplitPascalCase(((Object)item).name);
				string text2 = text;
				int num = 2;
				while (displayToPrefab.ContainsKey(text2))
				{
					text2 = text + " (" + num++ + ")";
				}
				prefabToDisplay[((Object)item).name] = text2;
				displayToPrefab[text2] = ((Object)item).name;
				string categoryName = GetCategoryName(itemType);
				if (!itemsByCategory.ContainsKey(categoryName))
				{
					itemsByCategory[categoryName] = new List<string>();
				}
				itemsByCategory[categoryName].Add(((Object)item).name);
				allItems.Add(((Object)item).name);
			}
		}
		allItems.Sort();
		foreach (KeyValuePair<string, List<string>> item2 in itemsByCategory)
		{
			item2.Value.Sort();
		}
		categoryNames.Add("All");
		categoryNames.AddRange(itemsByCategory.Keys.OrderBy((string k) => k));
		itemsLoaded = true;
		Log.LogInfo((object)$"Loaded {allItems.Count} items in {itemsByCategory.Count} categories.");
	}

	private string SplitPascalCase(string input)
	{
		if (string.IsNullOrEmpty(input))
		{
			return input;
		}
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = 0; i < input.Length; i++)
		{
			char c = input[i];
			if (c == '_')
			{
				stringBuilder.Append(' ');
				continue;
			}
			if (i > 0 && char.IsUpper(c) && !char.IsUpper(input[i - 1]))
			{
				stringBuilder.Append(' ');
			}
			stringBuilder.Append(c);
		}
		return stringBuilder.ToString().Trim();
	}

	private string GetCategoryName(ItemType type)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected I4, but got Unknown
		return (type - 1) switch
		{
			2 => "Weapons (1H)", 
			13 => "Weapons (2H)", 
			21 => "Weapons (2H Off)", 
			4 => "Shields", 
			3 => "Bows", 
			5 => "Armor (Head)", 
			6 => "Armor (Chest)", 
			10 => "Armor (Legs)", 
			16 => "Armor (Shoulder)", 
			17 => "Utility", 
			18 => "Tools", 
			14 => "Torches", 
			8 => "Ammo", 
			22 => "Ammo", 
			1 => "Food & Potions", 
			0 => "Materials", 
			9 => "Cosmetics", 
			15 => "Misc", 
			20 => "Fish", 
			_ => "Other", 
		};
	}

	private void LoadCreaturesIfNeeded()
	{
		if (!creaturesLoaded)
		{
			allCreatures.Clear();
			string[] collection = new string[51]
			{
				"Deer", "Boar", "Neck", "Greyling", "Greydwarf", "Greydwarf_Elite", "Greydwarf_Shaman", "Troll", "Ghost", "Skeleton",
				"Draugr", "Draugr_Elite", "Leech", "Blob", "Oozer", "Abomination", "Wolf", "Drake", "Fenring", "StoneGolem",
				"Cultist", "Ulv", "Deathsquito", "Fuling", "Fuling_Berserker", "Fuling_Shaman", "GoblinBrute", "Lox", "BlobTar", "Growth",
				"Serpent", "Bat", "Gjall", "Tick", "Seeker", "Seeker_Brood", "SeekerBrute", "Hare", "Dvergr", "DvergrMage",
				"Soldier", "Charred_Melee", "Charred_Archer", "Charred_Twitcher", "Morgen", "Fader", "Bonemass", "Eikthyr", "gd_king", "Dragon",
				"GoblinKing"
			};
			allCreatures.AddRange(collection);
			allCreatures.Sort();
			creaturesLoaded = true;
			allCommands.Clear();
			string[] collection2 = new string[35]
			{
				"god", "fly", "ghost", "nocost", "tod", "env", "resetenv", "spawn", "killall", "removedrops",
				"raiseskill", "resetskill", "kick", "ban", "unban", "banned", "save", "heal", "puke", "exploremap",
				"resetmap", "location", "goto", "wind", "resetwind", "event", "stopevent", "setkey", "removekey", "listkeys",
				"players", "ping", "dpsdebug", "freefly", "debugmode"
			};
			allCommands.AddRange(collection2);
		}
	}
}
[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
public class GameCameraPatch
{
	private static bool Prefix()
	{
		if (!AdminPanelState.IsOpen)
		{
			return true;
		}
		Cursor.lockState = (CursorLockMode)0;
		Cursor.visible = true;
		return false;
	}
}
[HarmonyPatch(typeof(PlayerController), "TakeInput")]
public class PlayerControllerPatch
{
	private static bool Prefix()
	{
		return !AdminPanelState.IsOpen;
	}
}
[HarmonyPatch(typeof(Chat), "Update")]
public class ChatUpdatePatch
{
	private static bool Prefix()
	{
		return !AdminPanelState.IsOpen;
	}
}
[HarmonyPatch(typeof(Minimap), "Update")]
public class MinimapClickPatch
{
	private static void Postfix(Minimap __instance)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Invalid comparison between Unknown and I4
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		if (BearsDenAdminGUI.WaitingForMapPick && (int)__instance.m_mode == 2 && Input.GetMouseButtonDown(0))
		{
			Vector3 value = Traverse.Create((object)__instance).Method("ScreenToWorldPoint", new object[1] { Input.mousePosition }).GetValue<Vector3>();
			MapPickResult.X = ((int)value.x).ToString();
			MapPickResult.Z = ((int)value.z).ToString();
			MapPickResult.HasResult = true;
			BearsDenAdminGUI.WaitingForMapPick = false;
			__instance.SetMapMode((MapMode)1);
		}
	}
}
public static class MapPickResult
{
	public static bool HasResult = false;

	public static string X = "0";

	public static string Z = "0";
}
public static class AdminPanelState
{
	public static bool IsOpen;
}