Decompiled source of CaveFinder v1.4.0

CaveFinder.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Catedral;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Digger.Core")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CaveFinder")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Floating icons inside the cave: chests by rarity, cave entrance, other players (class, name, health, weapon), pets, lore logs and weapons on the ground. Hold F6 to choose what shows.")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+1e60d3d4ad200be5c15a22191e7426ee0b63a8a4")]
[assembly: AssemblyProduct("CaveFinder")]
[assembly: AssemblyTitle("CaveFinder")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 CaveFinder
{
	internal class CaveFinderOverlay : MonoBehaviour
	{
		private struct ChestTarget
		{
			public Vector3 Position;

			public float Distance;

			public Rarity? Rarity;

			public ChestKind Kind;
		}

		private struct PickupTarget
		{
			public Vector3 Position;

			public float Distance;

			public Texture2D Icon;

			public Color TextColor;

			public string TopLabel;
		}

		private struct PlayerTarget
		{
			public FirstPersonController Player;

			public Texture2D ClassIcon;

			public Texture2D WeaponIcon;

			public string Name;

			public string Health;

			public float Fill;

			public bool Dead;
		}

		private const float CompassBaseDistance = 10f;

		private static readonly Vector3 CaveEntrancePosition = new Vector3(66.76f, 8.5f, 149.64f);

		private const float InsideCaveMaxX = 70f;

		private const float RefreshInterval = 0.25f;

		private const float ChestIconHeight = 0.9f;

		private const float PickupIconHeight = 0.8f;

		private const float PlayerCardHeight = 2.2f;

		private readonly List<ChestTarget> _chests = new List<ChestTarget>();

		private readonly List<PickupTarget> _pickups = new List<PickupTarget>();

		private readonly List<PlayerTarget> _players = new List<PlayerTarget>();

		private readonly List<PickupTarget> _weaponBuffer = new List<PickupTarget>();

		private float _refreshTimer;

		private bool _slowTurn;

		private bool _visible = true;

		private FirstPersonController _player;

		private float _currentRange;

		private float _entranceDistance;

		private bool _active;

		private bool _insideCave;

		private Sprite _entranceSprite;

		private bool _spritesResolved;

		private GUIStyle _noticeStyle;

		private float _toggleNoticeUntil;

		private string _lastScene;

		private readonly IconPanel _panel = new IconPanel();

		private float _keyDownAt;

		private bool _holdHandled;

		private const int MaxNameLength = 14;

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

		private string _lastDiag;

		private float _nextDiagTime;

		private void Awake()
		{
			IconToggles.Load();
		}

		private void Update()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			HandleToggleKey();
			_panel.Update();
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (name != _lastScene)
			{
				_lastScene = name;
				if (!_visible)
				{
					Plugin.Log.LogInfo((object)"CaveFinder: novo mapa, ícones religados.");
				}
				_visible = true;
				_panel.Close();
			}
			_refreshTimer -= Time.unscaledDeltaTime;
			if (_refreshTimer > 0f)
			{
				return;
			}
			_refreshTimer = 0.25f;
			try
			{
				Refresh();
			}
			catch (Exception ex)
			{
				_active = false;
				Plugin.Log.LogError((object)("CaveFinder: " + ex));
			}
		}

		private void HandleToggleKey()
		{
			if (Input.GetKeyDown((KeyCode)287))
			{
				_keyDownAt = Time.unscaledTime;
				_holdHandled = false;
			}
			if (!_holdHandled && Input.GetKey((KeyCode)287) && Time.unscaledTime - _keyDownAt >= 0.5f)
			{
				_holdHandled = true;
				if (!_panel.IsOpen)
				{
					_panel.Open();
					_visible = true;
				}
			}
			if (Input.GetKeyUp((KeyCode)287) && !_holdHandled)
			{
				if (_panel.IsOpen)
				{
					_panel.Close();
					return;
				}
				_visible = !_visible;
				_toggleNoticeUntil = Time.unscaledTime + 2.5f;
				Plugin.Log.LogInfo((object)("CaveFinder: " + (_visible ? "ligado" : "desligado")));
			}
		}

		private void Refresh()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//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)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00de: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			_active = false;
			GameManager instance = GameManager.Instance;
			if ((Object)(object)instance == (Object)null || !instance.IsInitialized || (int)instance.SceneType != 1)
			{
				_spritesResolved = false;
				ClearTargets();
				return;
			}
			_player = instance.LocalPlayer;
			if ((Object)(object)_player == (Object)null || (Object)(object)_player.PlayerStats == (Object)null)
			{
				ClearTargets();
				return;
			}
			Vector3 position = ((Component)_player).transform.position;
			_insideCave = position.x <= 70f;
			_currentRange = 10f * _player.PlayerStats.CompassRange.Value * 1f;
			_entranceDistance = Vector3.Distance(position, CaveEntrancePosition);
			_active = true;
			if (!_spritesResolved)
			{
				ResolveSprites();
			}
			RefreshPlayers(position);
			if (!_insideCave)
			{
				_chests.Clear();
				_pickups.Clear();
				return;
			}
			RefreshChests(position);
			_slowTurn = !_slowTurn;
			if (_slowTurn)
			{
				RefreshPickups(position);
			}
		}

		private void ClearTargets()
		{
			_chests.Clear();
			_pickups.Clear();
			_players.Clear();
		}

		private void RefreshChests(Vector3 playerPos)
		{
			//IL_0120: 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_006c: 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_006f: 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)
			//IL_009d: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			_chests.Clear();
			if (!IconToggles.Get(IconKind.Chests))
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			float num3 = float.MaxValue;
			TreasureChest[] array = Object.FindObjectsByType<TreasureChest>((FindObjectsSortMode)0);
			foreach (TreasureChest val in array)
			{
				num++;
				if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && !val.isOpened)
				{
					num2++;
					Vector3 position = ((Component)val).transform.position;
					float num4 = Vector3.Distance(playerPos, position);
					num3 = Mathf.Min(num3, num4);
					if (!(num4 >= _currentRange))
					{
						_chests.Add(new ChestTarget
						{
							Position = position + Vector3.up * 0.9f,
							Distance = num4,
							Rarity = GetRarity(val),
							Kind = ChestIcons.KindOf(val)
						});
					}
				}
			}
			_chests.Sort((ChestTarget a, ChestTarget b) => a.Distance.CompareTo(b.Distance));
			LogDiagnostics(num, num2, num3, playerPos);
		}

		private void RefreshPickups(Vector3 playerPos)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: 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_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: 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_027a: Unknown result type (might be due to invalid IL or missing references)
			_pickups.Clear();
			if (IconToggles.Get(IconKind.Pets))
			{
				RescuePet[] array = Object.FindObjectsByType<RescuePet>((FindObjectsSortMode)0);
				foreach (RescuePet val in array)
				{
					if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled)
					{
						Vector3 position = ((Component)val).transform.position;
						float num = Vector3.Distance(playerPos, position);
						if (!(num >= _currentRange))
						{
							_pickups.Add(new PickupTarget
							{
								Position = position + Vector3.up * 0.8f,
								Distance = num,
								Icon = MarkerIcons.Pet(),
								TextColor = Plugin.PetColor
							});
						}
					}
				}
			}
			if (IconToggles.Get(IconKind.Lore))
			{
				CollectableLoreLog[] array2 = Object.FindObjectsByType<CollectableLoreLog>((FindObjectsSortMode)0);
				foreach (CollectableLoreLog val2 in array2)
				{
					if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && !((Object)(object)val2.Network_collector != (Object)null))
					{
						Vector3 position2 = ((Component)val2).transform.position;
						float num2 = Vector3.Distance(playerPos, position2);
						if (!(num2 >= _currentRange))
						{
							_pickups.Add(new PickupTarget
							{
								Position = position2 + Vector3.up * 0.8f,
								Distance = num2,
								Icon = MarkerIcons.Note(),
								TextColor = Plugin.LoreColor
							});
						}
					}
				}
			}
			if (!IconToggles.Get(IconKind.Weapons))
			{
				return;
			}
			_weaponBuffer.Clear();
			PickableItem[] array3 = Object.FindObjectsByType<PickableItem>((FindObjectsSortMode)0);
			foreach (PickableItem val3 in array3)
			{
				if ((Object)(object)val3 == (Object)null || !((Behaviour)val3).isActiveAndEnabled || val3.SyncPlayerID != 0L)
				{
					continue;
				}
				ItemDataSO obj = val3.ItemDataSO ?? ItemInfo.Get(val3.SyncItemID);
				WeaponDataSO val4 = (WeaponDataSO)(object)((obj is WeaponDataSO) ? obj : null);
				if (val4 != null)
				{
					Vector3 position3 = ((Component)val3).transform.position;
					float num3 = Vector3.Distance(playerPos, position3);
					if (!(num3 >= _currentRange))
					{
						Rarity? rarity = ((ItemDataSO)val4).Rarity;
						_weaponBuffer.Add(new PickupTarget
						{
							Position = position3 + Vector3.up * 0.8f,
							Distance = num3,
							Icon = MarkerIcons.Weapon(MarkerIcons.LookOf(val4), rarity),
							TextColor = ChestIcons.MetalColor(rarity),
							TopLabel = ItemInfo.RarityWord(rarity)
						});
					}
				}
			}
			_weaponBuffer.Sort((PickupTarget a, PickupTarget b) => a.Distance.CompareTo(b.Distance));
			int num4 = Mathf.Min(_weaponBuffer.Count, 6);
			for (int num5 = 0; num5 < num4; num5++)
			{
				_pickups.Add(_weaponBuffer[num5]);
			}
		}

		private void RefreshPlayers(Vector3 playerPos)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			_players.Clear();
			if (!IconToggles.Get(IconKind.Players))
			{
				return;
			}
			foreach (FirstPersonController localPlayer in FirstPersonController.LocalPlayers)
			{
				if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)localPlayer == (Object)(object)_player) && ((Behaviour)localPlayer).isActiveAndEnabled)
				{
					PlayerStats playerStats = localPlayer.PlayerStats;
					if (!((Object)(object)playerStats == (Object)null))
					{
						float networksyncMaxHealth = playerStats.NetworksyncMaxHealth;
						float num = Mathf.Max(0f, playerStats.GetCurrentHealth());
						bool isDead = playerStats.isDead;
						_players.Add(new PlayerTarget
						{
							Player = localPlayer,
							ClassIcon = MarkerIcons.Class(localPlayer.playerClass),
							WeaponIcon = WeaponInHand(localPlayer),
							Name = ShortName(localPlayer.playerName),
							Health = (isDead ? Plugin.DownLabel : (Mathf.RoundToInt(num) + "/" + Mathf.RoundToInt(networksyncMaxHealth))),
							Fill = ((networksyncMaxHealth > 0f) ? (num / networksyncMaxHealth) : 0f),
							Dead = isDead
						});
					}
				}
			}
		}

		private static string ShortName(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return "?";
			}
			if (name.Length <= 14)
			{
				return name;
			}
			if (ShortNames.TryGetValue(name, out var value))
			{
				return value;
			}
			value = name.Substring(0, 13) + "…";
			if (ShortNames.Count > 32)
			{
				ShortNames.Clear();
			}
			ShortNames[name] = value;
			return value;
		}

		private static Texture2D WeaponInHand(FirstPersonController other)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			PlayerEquipment playerEquipment = other.PlayerEquipment;
			if ((Object)(object)playerEquipment == (Object)null)
			{
				return null;
			}
			string currentEquippedItemID = playerEquipment.GetCurrentEquippedItemID();
			if (string.IsNullOrEmpty(currentEquippedItemID))
			{
				return null;
			}
			ItemDataSO obj = ItemInfo.Get(currentEquippedItemID);
			WeaponDataSO val = (WeaponDataSO)(object)((obj is WeaponDataSO) ? obj : null);
			if (val == null)
			{
				return null;
			}
			return MarkerIcons.Weapon(MarkerIcons.LookOf(val), ((ItemDataSO)val).Rarity);
		}

		private void LogDiagnostics(int total, int closed, float nearestAny, Vector3 playerPos)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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)
			if (!(Time.unscaledTime < _nextDiagTime))
			{
				Camera camera = GetCamera();
				object[] array = new object[4];
				Scene activeScene = SceneManager.GetActiveScene();
				array[0] = ((Scene)(ref activeScene)).name;
				array[1] = total;
				array[2] = closed;
				array[3] = _chests.Count;
				string text = string.Format("{0}|{1}|{2}|{3}|", array) + string.Format("{0}|{1}|{2}", _pickups.Count, _players.Count, ((Object)(object)camera != (Object)null) ? ((Object)camera).name : "null");
				if (!(text == _lastDiag))
				{
					_lastDiag = text;
					_nextDiagTime = Time.unscaledTime + 5f;
					ManualLogSource log = Plugin.Log;
					string[] obj = new string[9] { "CaveFinder diag: mapa=", null, null, null, null, null, null, null, null };
					activeScene = SceneManager.GetActiveScene();
					obj[1] = ((Scene)(ref activeScene)).name;
					obj[2] = " ";
					obj[3] = $"baus_no_mapa={total} fechados={closed} no_alcance={_chests.Count} coletaveis={_pickups.Count} ";
					obj[4] = $"jogadores={_players.Count} alcance={_currentRange:0.0}m ";
					obj[5] = "mais_proximo=";
					obj[6] = ((nearestAny < float.MaxValue) ? (nearestAny.ToString("0.0") + "m") : "-");
					obj[7] = " ";
					obj[8] = string.Format("jogador=({0:0.0},{1:0.0},{2:0.0}) camera={3}", playerPos.x, playerPos.y, playerPos.z, ((Object)(object)camera != (Object)null) ? ((Object)camera).name : "NENHUMA");
					log.LogInfo((object)string.Concat(obj));
				}
			}
		}

		private static Camera GetCamera()
		{
			if ((Object)(object)CameraManager.Instance != (Object)null && (Object)(object)CameraManager.Instance.MainCamera != (Object)null && ((Behaviour)CameraManager.Instance.MainCamera).isActiveAndEnabled)
			{
				return CameraManager.Instance.MainCamera;
			}
			return Camera.main;
		}

		private static Rarity? GetRarity(TreasureChest chest)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			ChestDataSO val = chest.ChestDataSO;
			if ((Object)(object)val == (Object)null && (Object)(object)ItemManager.Instance != (Object)null && !string.IsNullOrEmpty(((CarriableObject)chest).SyncCarriableID))
			{
				CarriableDataSO carriableDataSoByID = ItemManager.Instance.GetCarriableDataSoByID(((CarriableObject)chest).SyncCarriableID);
				val = (ChestDataSO)(object)((carriableDataSoByID is ChestDataSO) ? carriableDataSoByID : null);
			}
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return val.Rarity;
		}

		private void ResolveSprites()
		{
			_spritesResolved = true;
			HudCompass val = (((Object)(object)Hud.Instance != (Object)null) ? Hud.Instance.HudCompass : null);
			if (val != null && (Object)(object)val.compassSO != (Object)null)
			{
				_entranceSprite = val.compassSO.CaveEntrySprite;
			}
			_panel.EntranceSprite = _entranceSprite;
			if ((Object)(object)_entranceSprite == (Object)null)
			{
				Plugin.Log.LogWarning((object)"CaveFinder: icone da entrada da caverna nao encontrado, usando icone simples.");
			}
		}

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			bool num = (int)Event.current.type == 7;
			bool flag = num && Time.unscaledTime < _toggleNoticeUntil;
			bool flag2 = num && _visible && _active && !_panel.IsOpen && (Object)(object)_player != (Object)null && !Cursor.visible;
			if (!flag && !flag2 && !_panel.IsOpen)
			{
				return;
			}
			Ui.EnsureStyles();
			if (flag)
			{
				DrawToggleNotice();
			}
			_panel.Draw();
			if (!flag2)
			{
				return;
			}
			Camera camera = GetCamera();
			if ((Object)(object)camera == (Object)null)
			{
				return;
			}
			float num2 = 32f;
			for (int num3 = _players.Count - 1; num3 >= 0; num3--)
			{
				DrawPlayerCard(camera, _players[num3], num2);
			}
			for (int num4 = _pickups.Count - 1; num4 >= 0; num4--)
			{
				PickupTarget pickupTarget = _pickups[num4];
				if (TryWorldToGui(camera, pickupTarget.Position, clampToScreen: false, num2, out var guiPos))
				{
					DrawMarker(guiPos, num2, (Texture)(object)pickupTarget.Icon, new Rect(0f, 0f, 1f, 1f), Txt.Distance(pickupTarget.Distance), pickupTarget.TextColor, 0.85f);
					if (pickupTarget.TopLabel != null)
					{
						Ui.Outlined(new Rect(guiPos.x - 80f, guiPos.y - num2 / 2f - 20f, 160f, 20f), pickupTarget.TopLabel, Ui.Tiny, Ui.WithAlpha(pickupTarget.TextColor, 0.85f), (TextAnchor)7);
					}
				}
			}
			for (int num5 = _chests.Count - 1; num5 >= 0; num5--)
			{
				ChestTarget chestTarget = _chests[num5];
				bool flag3 = num5 == 0;
				if (TryWorldToGui(camera, chestTarget.Position, clampToScreen: false, num2, out var guiPos2))
				{
					float iconSize = (flag3 ? (num2 * 1.5f) : num2) * 1.375f;
					float alpha = (flag3 ? 1f : 0.8f);
					Rarity? rarity = chestTarget.Rarity;
					Texture2D texture = ChestIcons.Get(rarity, chestTarget.Kind);
					DrawMarker(guiPos2, iconSize, (Texture)(object)texture, new Rect(0f, 0f, 1f, 1f), Txt.Distance(chestTarget.Distance), ChestIcons.MetalColor(rarity), alpha);
				}
			}
			if (_insideCave && IconToggles.Get(IconKind.CaveEntrance) && TryWorldToGui(camera, CaveEntrancePosition, clampToScreen: true, num2, out var guiPos3))
			{
				Texture2D texture2 = (((Object)(object)_entranceSprite != (Object)null) ? _entranceSprite.texture : Texture2D.whiteTexture);
				Rect uv = (Rect)(((Object)(object)_entranceSprite != (Object)null) ? SpriteUV(_entranceSprite) : new Rect(0f, 0f, 1f, 1f));
				DrawMarker(guiPos3, num2, (Texture)(object)texture2, uv, Plugin.EntranceLabel + " " + Txt.Distance(_entranceDistance), new Color(0.7f, 0.9f, 1f), 0.95f);
			}
			GUI.color = Color.white;
		}

		private void DrawPlayerCard(Camera cam, PlayerTarget target, float size)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target.Player == (Object)null)
			{
				return;
			}
			Vector3 world = ((Component)target.Player).transform.position + Vector3.up * 2.2f;
			if (TryWorldToGui(cam, world, clampToScreen: false, size, out var guiPos))
			{
				float num = size / 32f;
				float num2 = 176f * num;
				float num3 = 46f * num;
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(Mathf.Round(guiPos.x - num2 / 2f), Mathf.Round(guiPos.y - num3), num2, num3);
				Ui.Plate(r, 0.92f);
				float num4 = 5f * num;
				Rect r2 = default(Rect);
				((Rect)(ref r2))..ctor(((Rect)(ref r)).x + num4, ((Rect)(ref r)).y + num4, 36f * num, 36f * num);
				Ui.Icon(r2, (Texture)(object)target.ClassIcon);
				float num5 = ((Rect)(ref r2)).xMax + 5f * num;
				float num6 = ((Rect)(ref r)).xMax - num4 - num5;
				Rect r3 = new Rect(num5, ((Rect)(ref r)).y + 2f * num, num6, 18f * num);
				Ui.Label(r3, target.Name, Ui.Small, target.Dead ? Ui.HpLow : Ui.Title, (TextAnchor)3);
				Ui.Label(r3, Txt.Distance(Vector3.Distance(((Component)_player).transform.position, ((Component)target.Player).transform.position)), Ui.Tiny, Ui.Dim, (TextAnchor)5);
				float num7 = (((Object)(object)target.WeaponIcon != (Object)null) ? (20f * num) : 0f);
				Rect r4 = default(Rect);
				((Rect)(ref r4))..ctor(num5, ((Rect)(ref r)).y + 22f * num, num6 - ((num7 > 0f) ? (num7 + 3f * num) : 0f), 17f * num);
				Ui.Bar(r4, target.Dead ? 0f : target.Fill, (target.Fill <= 0.3f) ? Ui.HpLow : Ui.HpFill, target.Health, Ui.Tiny);
				if (num7 > 0f)
				{
					Ui.Icon(new Rect(((Rect)(ref r)).xMax - num4 - num7, ((Rect)(ref r4)).y - 1f * num, num7, num7), (Texture)(object)target.WeaponIcon);
				}
			}
		}

		private void DrawToggleNotice()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			//IL_0033: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if (_noticeStyle == null)
			{
				_noticeStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = 20,
					fontStyle = (FontStyle)1
				};
				_noticeStyle.normal.textColor = Color.white;
			}
			string text = (_visible ? Lang.T("Ícones ligados", "Icons on") : Lang.T("Ícones desligados", "Icons off"));
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, (float)Screen.height * 0.12f, (float)Screen.width, 32f);
			GUI.color = new Color(0f, 0f, 0f, 0.85f);
			GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, _noticeStyle);
			GUI.color = (_visible ? new Color(0.55f, 1f, 0.55f) : new Color(1f, 0.6f, 0.4f));
			GUI.Label(val, text, _noticeStyle);
			GUI.color = Color.white;
		}

		private static Rect SpriteUV(Sprite sprite)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Rect textureRect = sprite.textureRect;
			Texture2D texture = sprite.texture;
			return new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
		}

		private static bool TryWorldToGui(Camera cam, Vector3 world, bool clampToScreen, float margin, out Vector2 guiPos)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00f8: 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_0093: 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)
			//IL_00af: 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)
			Vector3 val = cam.WorldToScreenPoint(world);
			bool flag = val.z < 0f;
			if (flag)
			{
				if (!clampToScreen)
				{
					guiPos = default(Vector2);
					return false;
				}
				val.x = (float)Screen.width - val.x;
				val.y = (float)Screen.height - val.y;
			}
			bool flag2 = flag || val.x < 0f || val.x > (float)Screen.width || val.y < 0f || val.y > (float)Screen.height;
			if (flag2 && !clampToScreen)
			{
				guiPos = default(Vector2);
				return false;
			}
			if (flag2)
			{
				if (flag)
				{
					val.y = 0f;
				}
				val.x = Mathf.Clamp(val.x, margin, (float)Screen.width - margin);
				val.y = Mathf.Clamp(val.y, margin, (float)Screen.height - margin);
			}
			guiPos = new Vector2(val.x, (float)Screen.height - val.y);
			return true;
		}

		private void DrawMarker(Vector2 center, float iconSize, Texture texture, Rect uv, string text, Color textColor, float alpha)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(Mathf.Round(center.x - iconSize / 2f), Mathf.Round(center.y - iconSize / 2f), iconSize, iconSize);
			GUI.color = new Color(0f, 0f, 0f, alpha * 0.45f);
			GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), texture, uv, true);
			GUI.color = new Color(1f, 1f, 1f, alpha);
			GUI.DrawTextureWithTexCoords(val, texture, uv, true);
			GUI.color = Color.white;
			Ui.Outlined(new Rect(center.x - 80f, ((Rect)(ref val)).yMax, 160f, 22f), text, Ui.Small, new Color(textColor.r, textColor.g, textColor.b, alpha), (TextAnchor)1);
		}
	}
	internal enum ChestKind
	{
		Unknown,
		Items,
		Tomes
	}
	internal static class ChestIcons
	{
		private const int CanvasSize = 22;

		private static readonly string[] ChestPixels = new string[16]
		{
			"................", "...OOOOOOOOOO...", "..OHHMHHHHMHHO..", ".OHWWMWWWWMWWHO.", ".OWWWMWWWWMWWWO.", ".OwwwmwwwwmwwwO.", "OMMMMMLLLLMMMMMO", "OmmmmmLKKLmmmmmO", "OWWWWMLLLLMWWWWO", "OHWWWMWWWWMWWWHO",
			"OWWWWMWWWWMWWWWO", "OwWWWMWWWWMWWWwO", "OwwwwmwwwwmwwwwO", "OMMMMMMMMMMMMMMO", "OOOOOOOOOOOOOOOO", "................"
		};

		private static readonly string[] SwordPixels = new string[10] { "......OOO.", ".....OSSO.", "....OSSO..", "...OSSO...", "O.OSSO....", "OOSSO.....", ".OGGO.....", "OHOOGO....", "OHO.OO....", ".O........" };

		private static readonly string[] BookPixels = new string[10] { ".OOOOOOOO.", "OBBBBBBPPO", "OBBYYBBPPO", "OBYBBYBPPO", "OBBYYBBPPO", "OBBBBBBPPO", "OBBBBBBPPO", "ObbbbbbPPO", "OOOOOOOOOO", ".........." };

		private static readonly Color Outline = Hex(36, 22, 14);

		private static readonly Dictionary<int, Texture2D> Cache = new Dictionary<int, Texture2D>();

		public static Texture2D Get(Rarity? rarity, ChestKind kind)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			int key = (int)(((!rarity.HasValue) ? 9 : ((int)rarity.Value)) * 10 + kind);
			if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Texture2D val = Build(MetalColor(rarity), kind);
			Cache[key] = val;
			return val;
		}

		public static ChestKind KindOf(TreasureChest chest)
		{
			string name = ((Object)((Component)chest).gameObject).name;
			string text = ((CarriableObject)chest).SyncCarriableID ?? "";
			if (name.IndexOf("Upgrade", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("UPGRADE", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return ChestKind.Tomes;
			}
			if (name.IndexOf("Treasure_Chest", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return ChestKind.Items;
			}
			return ChestKind.Unknown;
		}

		public static Color MetalColor(Rarity? rarity)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(rarity switch
			{
				(Rarity)0L => Hex(184, 188, 196), 
				(Rarity)1L => Hex(92, 214, 92), 
				(Rarity)2L => Hex(76, 154, byte.MaxValue), 
				(Rarity)3L => Hex(184, 102, byte.MaxValue), 
				(Rarity)4L => Hex(byte.MaxValue, 184, 38), 
				_ => Hex(242, 192, 64), 
			});
		}

		private static Texture2D Build(Color metal, ChestKind kind)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_007d: Expected O, but got Unknown
			Color metalDark = new Color(metal.r * 0.6f, metal.g * 0.6f, metal.b * 0.6f, 1f);
			Texture2D val = new Texture2D(22, 22, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61,
				name = "CaveFinder_ChestIcon"
			};
			Color[] pixels = (Color[])(object)new Color[484];
			val.SetPixels(pixels);
			Draw(val, ChestPixels, 0, 2, (char c) => c switch
			{
				'O' => Outline, 
				'H' => Hex(192, 132, 72), 
				'W' => Hex(150, 94, 46), 
				'w' => Hex(106, 64, 30), 
				'M' => metal, 
				'm' => metalDark, 
				'L' => Hex(byte.MaxValue, 240, 176), 
				'K' => Hex(32, 20, 8), 
				_ => null, 
			});
			switch (kind)
			{
			case ChestKind.Items:
				Draw(val, SwordPixels, 12, 12, (char c) => c switch
				{
					'O' => Outline, 
					'S' => Hex(232, 236, 242), 
					'G' => Hex(byte.MaxValue, 200, 58), 
					'H' => Hex(192, 132, 72), 
					_ => null, 
				});
				break;
			case ChestKind.Tomes:
				Draw(val, BookPixels, 12, 12, (char c) => c switch
				{
					'O' => Outline, 
					'B' => Hex(138, 60, 200), 
					'b' => Hex(94, 38, 138), 
					'Y' => Hex(byte.MaxValue, 216, 80), 
					'P' => Hex(244, 236, 216), 
					_ => null, 
				});
				break;
			}
			val.Apply(false, false);
			return val;
		}

		private static void Draw(Texture2D tex, string[] rows, int x, int y, Func<char, Color?> palette)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < rows.Length; i++)
			{
				string text = rows[i];
				for (int j = 0; j < text.Length; j++)
				{
					Color? val = palette(text[j]);
					if (val.HasValue)
					{
						int num = x + j;
						int num2 = 21 - (y + i);
						if (num >= 0 && num < 22 && num2 >= 0 && num2 < 22)
						{
							tex.SetPixel(num, num2, val.Value);
						}
					}
				}
			}
		}

		private static Color Hex(byte r, byte g, byte b)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)(int)r / 255f, (float)(int)g / 255f, (float)(int)b / 255f, 1f);
		}
	}
	internal class IconPanel
	{
		private static readonly IconKind[] Rows = new IconKind[6]
		{
			IconKind.Chests,
			IconKind.CaveEntrance,
			IconKind.Players,
			IconKind.Pets,
			IconKind.Lore,
			IconKind.Weapons
		};

		private const float Width = 460f;

		private const float RowHeight = 46f;

		private const float Pad = 22f;

		private const float HeaderHeight = 54f;

		private const float FooterHeight = 56f;

		private bool _open;

		private float _openedAt;

		public Sprite EntranceSprite { get; set; }

		public bool IsOpen => _open;

		public void Open()
		{
			if (!_open && !((Object)(object)InputManager.Instance == (Object)null))
			{
				_open = true;
				_openedAt = Time.unscaledTime;
				InputManager.Instance.SetState((InputState)13, true);
			}
		}

		public void Close()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			if (_open)
			{
				_open = false;
				Ui.ReleaseMouseCapture();
				if (!((Object)(object)InputManager.Instance == (Object)null) && (int)InputManager.Instance.CurrentInputState == 13)
				{
					FirstPersonController val = (((Object)(object)GameManager.Instance != (Object)null) ? GameManager.Instance.LocalPlayer : null);
					bool flag = (Object)(object)val != (Object)null && (Object)(object)val.PlayerStats != (Object)null && val.PlayerStats.isDead;
					InputManager.Instance.SetState((InputState)(flag ? 4 : 2), true);
				}
			}
		}

		public void Update()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			if (_open)
			{
				if ((Object)(object)InputManager.Instance == (Object)null || (int)InputManager.Instance.CurrentInputState != 13)
				{
					Close();
				}
				else if (Time.unscaledTime - _openedAt > 0.2f && Input.GetKeyDown((KeyCode)27))
				{
					Close();
				}
			}
		}

		public void Draw()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!_open)
			{
				return;
			}
			Matrix4x4 matrix = GUI.matrix;
			try
			{
				DrawPanel();
			}
			catch (Exception ex)
			{
				Ui.LogOnce("painel de ícones", ex);
				Close();
			}
			finally
			{
				GUI.matrix = matrix;
			}
		}

		private void DrawPanel()
		{
			//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_007a: 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_0099: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			float num = 76f + (float)Rows.Length * 46f + 56f + 22f;
			float num2 = Ui.WindowScale(460f, num);
			float num3 = 460f * num2;
			float num4 = num * num2;
			GUI.matrix = Matrix4x4.TRS(new Vector3(Mathf.Round(((float)Screen.width - num3) / 2f), Mathf.Round(((float)Screen.height - num4) / 2f), 0f), Quaternion.identity, new Vector3(num2, num2, 1f));
			Ui.Window(new Rect(0f, 0f, 460f, num));
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(10f, 10f, 440f, 44f);
			Ui.Header(r);
			Ui.Label(new Rect(((Rect)(ref r)).x + 16f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 32f, ((Rect)(ref r)).height), Lang.T("Ícones", "Icons"), Ui.H2, Ui.Title, (TextAnchor)3);
			Ui.Label(new Rect(((Rect)(ref r)).x + 16f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 32f, ((Rect)(ref r)).height), "F6", Ui.Small, Ui.Muted, (TextAnchor)5);
			float num5 = 65f;
			IconKind[] rows = Rows;
			foreach (IconKind kind in rows)
			{
				DrawRow(new Rect(22f, num5, 416f, 40f), kind);
				num5 += 46f;
			}
			Ui.Divider(new Rect(22f, num5 + 2f, 416f, 4f));
			float num6 = num - 56f - 6f;
			float num7 = 132f;
			if (Ui.Button(new Rect(22f, num6, num7, 46f), Lang.T("Tudo", "All"), ButtonKind.Green))
			{
				IconToggles.SetAll(on: true);
			}
			if (Ui.Button(new Rect(22f + num7 + 10f, num6, num7, 46f), Lang.T("Nada", "None"), ButtonKind.Red))
			{
				IconToggles.SetAll(on: false);
			}
			if (Ui.Button(new Rect(22f + (num7 + 10f) * 2f, num6, num7, 46f), Lang.T("Fechar", "Close"), ButtonKind.Dark))
			{
				Close();
			}
		}

		private void DrawRow(Rect r, IconKind kind)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0098: 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_00ea: 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)
			bool flag = IconToggles.Get(kind);
			Ui.Card(r);
			if (Ui.RowButton(r, out var hover))
			{
				IconToggles.Toggle(kind);
			}
			Rect r2 = default(Rect);
			((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 10f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 28f) / 2f, 28f, 28f);
			Ui.Check(r2, flag, hover);
			Rect r3 = default(Rect);
			((Rect)(ref r3))..ctor(((Rect)(ref r2)).xMax + 12f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 32f) / 2f, 32f, 32f);
			DrawRowIcon(r3, kind, flag);
			Ui.Label(new Rect(((Rect)(ref r3)).xMax + 12f, ((Rect)(ref r)).y, ((Rect)(ref r)).xMax - ((Rect)(ref r3)).xMax - 24f, ((Rect)(ref r)).height), IconToggles.Name(kind), Ui.Body, flag ? Ui.Text : Ui.Dim, (TextAnchor)3);
		}

		private void DrawRowIcon(Rect r, IconKind kind, bool on)
		{
			//IL_002f: 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_0063: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			float alpha = (on ? 1f : 0.35f);
			switch (kind)
			{
			case IconKind.Chests:
				Ui.Icon(r, (Texture)(object)ChestIcons.Get(null, ChestKind.Items), alpha);
				break;
			case IconKind.CaveEntrance:
				if ((Object)(object)EntranceSprite != (Object)null)
				{
					Ui.Sprite(r, EntranceSprite, alpha);
				}
				break;
			case IconKind.Players:
				Ui.Icon(r, (Texture)(object)MarkerIcons.Class(LocalClass()), alpha);
				break;
			case IconKind.Pets:
				Ui.Icon(r, (Texture)(object)MarkerIcons.Pet(), alpha);
				break;
			case IconKind.Lore:
				Ui.Icon(r, (Texture)(object)MarkerIcons.Note(), alpha);
				break;
			case IconKind.Weapons:
				Ui.Icon(r, (Texture)(object)MarkerIcons.Weapon(WeaponLook.Melee, null), alpha);
				break;
			}
		}

		private static PlayerClass LocalClass()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController val = (((Object)(object)GameManager.Instance != (Object)null) ? GameManager.Instance.LocalPlayer : null);
			if (!((Object)(object)val != (Object)null))
			{
				return (PlayerClass)0;
			}
			return val.playerClass;
		}
	}
	internal enum IconKind
	{
		Chests,
		CaveEntrance,
		Players,
		Pets,
		Lore,
		Weapons
	}
	internal static class IconToggles
	{
		private const string FileName = "cavefinder-icones.txt";

		private const string OldFileName = "chestfinder-icones.txt";

		private static readonly string[] Keys = new string[6] { "baus", "entrada", "jogadores", "pets", "lore", "armas" };

		private static readonly string[] NamesPt = new string[6] { "Baús", "Entrada da caverna", "Jogadores", "Pets", "Registros de lore", "Armas no chão" };

		private static readonly string[] NamesEn = new string[6] { "Chests", "Cave entrance", "Players", "Pets", "Lore logs", "Dropped weapons" };

		private static readonly bool[] On = new bool[6] { true, true, true, true, true, true };

		private static string _path;

		private static bool _loaded;

		private static string FilePath => _path ?? (_path = Path.Combine(Application.persistentDataPath, "CatedralEmChamas", "cavefinder-icones.txt"));

		public static bool Get(IconKind kind)
		{
			return On[(int)kind];
		}

		public static string Name(IconKind kind)
		{
			return Lang.T(NamesPt[(int)kind], NamesEn[(int)kind]);
		}

		public static void Toggle(IconKind kind)
		{
			On[(int)kind] = !On[(int)kind];
			Save();
		}

		public static void SetAll(bool on)
		{
			for (int i = 0; i < On.Length; i++)
			{
				On[i] = on;
			}
			Save();
		}

		public static void Load()
		{
			if (_loaded)
			{
				return;
			}
			_loaded = true;
			try
			{
				string path = FilePath;
				if (!File.Exists(path))
				{
					path = Path.Combine(Application.persistentDataPath, "CatedralEmChamas", "chestfinder-icones.txt");
					if (!File.Exists(path))
					{
						return;
					}
				}
				string[] array = File.ReadAllLines(path);
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i].Trim();
					int num = text.IndexOf('=');
					if (num <= 0)
					{
						continue;
					}
					string text2 = text.Substring(0, num).Trim();
					string text3 = text.Substring(num + 1).Trim();
					for (int j = 0; j < Keys.Length; j++)
					{
						if (Keys[j] == text2)
						{
							On[j] = text3 == "1" || text3.Equals("true", StringComparison.OrdinalIgnoreCase);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("CaveFinder: não deu para ler " + FilePath + " (segue com tudo ligado): " + ex.Message));
			}
		}

		private static void Save()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(FilePath);
				if (!string.IsNullOrEmpty(directoryName))
				{
					Directory.CreateDirectory(directoryName);
				}
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < Keys.Length; i++)
				{
					stringBuilder.Append(Keys[i]).Append('=').Append(On[i] ? '1' : '0')
						.Append('\n');
				}
				string text = FilePath + ".tmp";
				File.WriteAllText(text, stringBuilder.ToString());
				if (!File.Exists(FilePath))
				{
					File.Move(text, FilePath);
					return;
				}
				try
				{
					File.Replace(text, FilePath, null);
				}
				catch (Exception)
				{
					File.Copy(text, FilePath, overwrite: true);
					File.Delete(text);
				}
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogWarning((object)("CaveFinder: não deu para gravar " + FilePath + ": " + ex2.Message));
			}
		}
	}
	internal enum WeaponLook
	{
		Melee,
		Ranged,
		Parchment,
		Pickaxe
	}
	internal static class MarkerIcons
	{
		private const int Size = 16;

		private static readonly (string palette, string[] rows)[] ClassArt = new(string, string[])[8]
		{
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:B8BCC4 h:E4E8EE R:D23A33 B:4A6A9A b:32496C", new string[16]
			{
				".......RR.......", "......ORRO......", "....OOOhhOOO....", "...OhHHHHHHhO...", "...OHHHHHHHHO...", "..OOOOOOOOOOOO..", "...OSSSSSSSSO...", "...OSKSSSSKSO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:3E7A46 Y:F2E2A0 B:6B4A2A b:4A321B", new string[16]
			{
				"................", "...........OYO..", "....OOOOOO.OYO..", "...OHHHHHHOYO...", "...OHHHHHHHO....", "..OHHHHHHHHHO...", "..OHOSSSSSSHO...", "..OHOSKSSKSHO...", "..OHOSSSSSSHO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:8A5A22 Y:FFE066 B:5A6068 b:3C4148", new string[16]
			{
				"................", "................", "....OOOOOOOO....", "...OHHHHHHHHO...", "..OYOHHHHHHHO...", "..OOOOOOOOOOOO..", "...OSSSSSSSSO...", "...OSKSSSSKSO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:2E3444 H:3A3F52 B:24283A b:181B28", new string[16]
			{
				"................", "....OOOOOOOO....", "...OHHHHHHHHO...", "..OHHHHHHHHHHO..", "..OHHHHHHHHHHO..", "..OHOOOOOOOOHO..", "..OHOSSSSSSOHO..", "..OHOSKSSKSOHO..", "..OHOMMMMMMOHO..", "...OOMMMMMMOO...",
				"....OMMMMMMO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:C8442E G:3A3F4E W:D8E4F0 B:7A5A38 b:513A22", new string[16]
			{
				"................", "................", "....OOOOOOOO....", "...OHHHHHHHHO...", "...OHHHHHHHHO...", "..OOOOOOOOOOOO..", "...OGGGGGGGGO...", "...OGWKGGKWGO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:6B4A2A h:8C6538 B:3E5C3A b:2A4028", new string[16]
			{
				"................", "................", ".....OOOOOO.....", "....OHHHHHHO....", "....OhHHHHhO....", ".OOOOOOOOOOOOOO.", "...OSSSSSSSSO...", "...OSKSSSSKSO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:4A3A8C Y:FFD84A B:3A2E6E b:271E4C", new string[16]
			{
				".......OO.......", "......OHHO......", ".....OHYHHO.....", "....OHHHHHHO....", "..OOHHHHHHHHOO..", "..OOOOOOOOOOOO..", "...OSSSSSSSSO...", "...OSKSSSSKSO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			}),
			("O:24160E S:E8B890 K:201408 M:8A5A3A H:E4E0D2 Y:E8B430 B:C8C0AC b:9A9382", new string[16]
			{
				"................", "....OOOOOOOO....", "...OHHHYYHHHO...", "..OHHHYYYYHHHO..", "..OHHHHYYHHHHO..", "..OOOOOOOOOOOO..", "...OSSSSSSSSO...", "...OSKSSSSKSO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
				"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
			})
		};

		private static readonly (string palette, string[] rows) UnknownClassArt = (palette: "O:24160E S:E8B890 K:201408 M:8A5A3A B:5A6068 b:3C4148", rows: new string[16]
		{
			"................", "................", "....OOOOOOOO....", "...OSSSSSSSSO...", "...OSSSSSSSSO...", "...OSSSSSSSSO...", "...OSSSSSSSSO...", "...OSKSSSSKSO...", "...OSSSSSSSSO...", "...OSSSMMSSSO...",
			"....OSSSSSSO....", ".....OOOOOO.....", "...OBBBBBBBBO...", "..OBBBBBBBBBBO..", "..ObBBBBBBBBbO..", "..OOOOOOOOOOOO.."
		});

		private static readonly (string palette, string[] rows) PetArt = (palette: "O:24160E E:B87438 e:8A5222 F:D9924C K:201408 N:3A2418 T:E86A78", rows: new string[16]
		{
			"................", "..OO........OO..", ".OEEO......OEEO.", ".OEeEO....OEeEO.", ".OEeeEOOOOEeeEO.", "..OEEFFFFFFEEO..", "...OFFFFFFFFO...", "...OFKFFFFKFO...", "...OFFFFFFFFO...", "...OFFFNNFFFO...",
			"....OFFNNFFO....", "....OFTTTTFO....", ".....OFFFFO.....", "......OOOO......", "................", "................"
		});

		private static readonly (string palette, string[] rows) NoteArt = (palette: "O:24160E P:F2E8CE L:8A7A54 w:B5452E Y:E8B430", rows: new string[16]
		{
			"................", "....O.O.O.O.....", "...OOOOOOOOOO...", "...OwwwwwwwwO...", "...OPPPPPPPPO...", "...OPLLLLLLPO...", "...OPPPPPPPPO...", "...OPLLLLLLPO...", "...OPPPPPPPPO...", "...OPLLLLLLPO...",
			"...OPPPPPPPPO...", "...OPLLLLPPPO...", "...OPPPPPPYPO...", "...OOOOOOOOOO...", "................", "................"
		});

		private static readonly (string palette, string[] rows)[] WeaponArt = new(string, string[])[4]
		{
			("O:24160E G:FFC83A H:C08448", new string[16]
			{
				"..............O.", ".............OMO", "............OMMO", "...........OMMO.", "..........OMMO..", ".........OMMO...", "........OMMO....", ".......OMMO.....", "......OMMO......", ".....OMMO.......",
				"....OMMO........", "..OOGOO.........", ".OGGGO..........", "OHOGO...........", "OHO.O...........", ".O.............."
			}),
			("O:24160E S:E8E4D0", new string[16]
			{
				".......OOO......", "......OMMMO.....", ".....OMMOOO.....", ".....OMO..S.....", "....OMO...S.....", "....OMO...S.....", "....OMO...S.....", "....OMO...S.....", "....OMO...S.....", "....OMO...S.....",
				"....OMO...S.....", ".....OMO..S.....", ".....OMMOOO.....", "......OMMMO.....", ".......OOO......", "................"
			}),
			("O:24160E P:F2E8CE L:8A7A54", new string[16]
			{
				"................", "..OOOOOOOOOOOO..", ".OmmOPPPPPPOmmO.", ".OmmOPLLLLPOmmO.", ".OmmOPPPPPPOmmO.", ".OmmOPLLLLPOmmO.", ".OmmOPPPPPPOmmO.", ".OmmOPLLLLPOmmO.", ".OmmOPPPPPPOmmO.", ".OmmOPLLLLPOmmO.",
				".OmmOPPPPPPOmmO.", "..OOOOOOOOOOOO..", "................", "................", "................", "................"
			}),
			("O:24160E H:8A5A22", new string[16]
			{
				"................", "................", "...OOOOOOOOOO...", "..OMMMMMMMMMMO..", ".OMMOOOOOOOOMMO.", "OMMO..OHHO..OMMO", "OMO...OHHO...OMO", "OO....OHHO....OO", "......OHHO......", "......OHHO......",
				"......OHHO......", "......OHHO......", "......OHHO......", "......OHHO......", ".......OO.......", "................"
			})
		};

		private static readonly Texture2D[] ClassIcons = (Texture2D[])(object)new Texture2D[ClassArt.Length + 1];

		private static Texture2D _pet;

		private static Texture2D _note;

		private static readonly Dictionary<int, Texture2D> WeaponCache = new Dictionary<int, Texture2D>();

		public static Texture2D Class(PlayerClass playerClass)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Expected I4, but got Unknown
			int num = (int)playerClass;
			bool flag = num >= 0 && num < ClassArt.Length;
			int num2 = (flag ? num : ClassArt.Length);
			if ((Object)(object)ClassIcons[num2] != (Object)null)
			{
				return ClassIcons[num2];
			}
			(string, string[]) tuple = (flag ? ClassArt[num] : UnknownClassArt);
			ClassIcons[num2] = Build(tuple.Item2, Palette(tuple.Item1), "CaveFinder_Class" + num2);
			return ClassIcons[num2];
		}

		public static Texture2D Pet()
		{
			if ((Object)(object)_pet == (Object)null)
			{
				_pet = Build(PetArt.rows, Palette(PetArt.palette), "CaveFinder_Pet");
			}
			return _pet;
		}

		public static Texture2D Note()
		{
			if ((Object)(object)_note == (Object)null)
			{
				_note = Build(NoteArt.rows, Palette(NoteArt.palette), "CaveFinder_Note");
			}
			return _note;
		}

		public static Texture2D Weapon(WeaponLook look, Rarity? rarity)
		{
			//IL_0013: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			int key = (int)look * 16 + ((!rarity.HasValue) ? 9 : ((int)rarity.Value));
			if (WeaponCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			(string palette, string[] rows) tuple = WeaponArt[(int)look];
			Dictionary<char, Color> dictionary = Palette(tuple.palette);
			Color val = (dictionary['M'] = ChestIcons.MetalColor(rarity));
			dictionary['m'] = new Color(val.r * 0.6f, val.g * 0.6f, val.b * 0.6f, 1f);
			Texture2D val3 = Build(tuple.rows, dictionary, "CaveFinder_Weapon" + key);
			WeaponCache[key] = val3;
			return val3;
		}

		public static WeaponLook LookOf(WeaponDataSO weapon)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected I4, but got Unknown
			if ((Object)(object)weapon == (Object)null)
			{
				return WeaponLook.Melee;
			}
			WeaponType weaponType = weapon.weaponType;
			return (weaponType - 1) switch
			{
				0 => WeaponLook.Ranged, 
				2 => WeaponLook.Parchment, 
				3 => WeaponLook.Pickaxe, 
				_ => WeaponLook.Melee, 
			};
		}

		private static Dictionary<char, Color> Palette(string text)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<char, Color> dictionary = new Dictionary<char, Color>();
			string[] array = text.Split(' ');
			foreach (string text2 in array)
			{
				if (text2.Length == 8 && text2[1] == ':')
				{
					int num = Convert.ToInt32(text2.Substring(2), 16);
					dictionary[text2[0]] = new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, 1f);
				}
			}
			return dictionary;
		}

		private static Texture2D Build(string[] rows, Dictionary<char, Color> palette, string name)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_005e: 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)
			Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61,
				name = name
			};
			Color[] array = (Color[])(object)new Color[256];
			for (int i = 0; i < rows.Length && i < 16; i++)
			{
				string text = rows[i];
				for (int j = 0; j < text.Length && j < 16; j++)
				{
					if (palette.TryGetValue(text[j], out var value))
					{
						array[(15 - i) * 16 + j] = value;
					}
				}
			}
			val.SetPixels(array);
			val.Apply(false, false);
			return val;
		}
	}
	internal static class ItemInfo
	{
		private static readonly Dictionary<string, ItemDataSO> Items = new Dictionary<string, ItemDataSO>();

		private static readonly string[] RarityWords = new string[5];

		private static int _rarityLang = -1;

		public static ItemDataSO Get(string itemId)
		{
			if (string.IsNullOrEmpty(itemId))
			{
				return null;
			}
			if (Items.TryGetValue(itemId, out var value))
			{
				return value;
			}
			if ((Object)(object)ItemManager.Instance == (Object)null)
			{
				return null;
			}
			ItemDataSO itemDataSoByID = ItemManager.Instance.GetItemDataSoByID(itemId);
			if ((Object)(object)itemDataSoByID != (Object)null)
			{
				Items[itemId] = itemDataSoByID;
			}
			return itemDataSoByID;
		}

		public static string RarityWord(Rarity? rarity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected I4, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!rarity.HasValue)
			{
				return null;
			}
			int num = (int)rarity.Value;
			if (num < 0 || num >= RarityWords.Length)
			{
				return null;
			}
			if (_rarityLang != Lang.Version)
			{
				_rarityLang = Lang.Version;
				Array.Clear(RarityWords, 0, RarityWords.Length);
			}
			if (RarityWords[num] != null)
			{
				return RarityWords[num];
			}
			try
			{
				string rarityLocalizedString = ItemDataSO.GetRarityLocalizedString(rarity.Value, false);
				if (!string.IsNullOrEmpty(rarityLocalizedString))
				{
					RarityWords[num] = rarityLocalizedString;
				}
				return rarityLocalizedString;
			}
			catch (Exception ex)
			{
				Ui.LogOnce("palavra da raridade", ex);
				return null;
			}
		}
	}
	[BepInPlugin("catedralemchamas.stonewards.cavefinder", "CaveFinder", "1.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal const KeyCode ToggleKey = (KeyCode)287;

		internal const float HoldToOpenPanel = 0.5f;

		internal const float RangeMultiplier = 1f;

		internal const float IconSize = 32f;

		internal const bool ShowRarity = true;

		internal const bool HideWhenCursorVisible = true;

		internal const bool ShowContentBadge = true;

		internal const int MaxWeaponIcons = 6;

		internal static readonly Color PetColor = new Color(1f, 0.72f, 0.42f);

		internal static readonly Color LoreColor = new Color(0.95f, 0.91f, 0.78f);

		private const string OldGuid = "catedralemchamas.stonewards.chestfinder";

		private static bool _oldStillInstalled;

		private static float _warnUntil;

		internal static string EntranceLabel => Lang.T("Entrada", "Entrance");

		internal static string DownLabel => Lang.T("caído", "down");

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			_oldStillInstalled = Chainloader.PluginInfos.ContainsKey("catedralemchamas.stonewards.chestfinder");
			if (_oldStillInstalled)
			{
				_warnUntil = Time.realtimeSinceStartup + 30f;
				Log.LogWarning((object)"CaveFinder: o ChestFinder antigo continua instalado, entao este ficou parado para nao desenhar icone dobrado. Desinstale o ChestFinder.");
			}
			else
			{
				((Component)this).gameObject.AddComponent<CaveFinderOverlay>();
				Log.LogInfo((object)string.Format("{0} v{1} carregado. {2}: toque liga/desliga, segurar abre o painel.", "CaveFinder", "1.4.0", (object)(KeyCode)287));
			}
		}

		private void OnGUI()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (_oldStillInstalled && !(Time.realtimeSinceStartup > _warnUntil))
			{
				string text = Lang.T("CaveFinder: desinstale o ChestFinder antigo (este mod tomou o lugar dele).", "CaveFinder: uninstall the old ChestFinder (this mod took its place).");
				GUI.Label(new Rect(12f, 12f, (float)Screen.width - 24f, 24f), text);
			}
		}
	}
	internal enum ButtonKind
	{
		Green,
		Red,
		Dark,
		Gold
	}
	internal static class Ui
	{
		private sealed class Px
		{
			private readonly int _w;

			private readonly int _h;

			private readonly Color32[] _c;

			public Px(int w, int h)
			{
				_w = w;
				_h = h;
				_c = (Color32[])(object)new Color32[w * h];
			}

			public void Set(int x, int y, Color32 color)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				if (x >= 0 && y >= 0 && x < _w && y < _h)
				{
					_c[(_h - 1 - y) * _w + x] = color;
				}
			}

			public void Fill(int x, int y, int w, int h, Color32 color)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				for (int i = y; i < y + h; i++)
				{
					for (int j = x; j < x + w; j++)
					{
						Set(j, i, color);
					}
				}
			}

			public void Round(int x0, int y0, int w, int h, int r, Color32 color)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < h; i++)
				{
					for (int j = 0; j < w; j++)
					{
						if (Mathf.Min(j, w - 1 - j) + Mathf.Min(i, h - 1 - i) >= r)
						{
							Set(x0 + j, y0 + i, color);
						}
					}
				}
			}

			public Texture2D ToTexture(string name, int scale)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				int num = _w * scale;
				int num2 = _h * scale;
				Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false)
				{
					filterMode = (FilterMode)0,
					wrapMode = (TextureWrapMode)1,
					hideFlags = (HideFlags)61,
					name = name
				};
				Color32[] array = (Color32[])(object)new Color32[num * num2];
				for (int i = 0; i < num2; i++)
				{
					for (int j = 0; j < num; j++)
					{
						array[i * num + j] = _c[i / scale * _w + j / scale];
					}
				}
				val.SetPixels32(array);
				val.Apply(false, true);
				return val;
			}
		}

		public static readonly Color Ink = Rgb(724242);

		public static readonly Color Navy = Rgb(1251104);

		public static readonly Color NavyLight = Rgb(1777968);

		public static readonly Color Gold = Rgb(11903600);

		public static readonly Color Wood = Rgb(4992561);

		public static readonly Color WoodLight = Rgb(7029574);

		public static readonly Color WoodDark = Rgb(3021597);

		public static readonly Color Title = Rgb(16767370);

		public static readonly Color Text = Rgb(16052194);

		public static readonly Color Muted = Rgb(11120832);

		public static readonly Color Dim = Rgb(7107461);

		public static readonly Color HpFill = Rgb(3781962);

		public static readonly Color HpLow = Rgb(14700602);

		public static readonly Color ManaFill = Rgb(4165600);

		private static Font _gameFont;

		private static float _nextFontSearch;

		private static int _fontSearches;

		private static Font _stylesFont;

		private static bool _stylesBuilt;

		public static GUIStyle H1;

		public static GUIStyle H2;

		public static GUIStyle Body;

		public static GUIStyle Small;

		public static GUIStyle Tiny;

		public static GUIStyle SmallWrap;

		private static readonly GUIContent TempContent = new GUIContent();

		private static bool _texturesBuilt;

		private static GUIStyle _window;

		private static GUIStyle _header;

		private static GUIStyle _card;

		private static GUIStyle _inset;

		private static GUIStyle _barFill;

		private static GUIStyle _plate;

		private static readonly GUIStyle[] ButtonNormal = (GUIStyle[])(object)new GUIStyle[4];

		private static readonly GUIStyle[] ButtonHover = (GUIStyle[])(object)new GUIStyle[4];

		private static readonly GUIStyle[] ButtonPressed = (GUIStyle[])(object)new GUIStyle[4];

		private static Texture2D _glow;

		private static Texture2D _shade;

		private static readonly Vector2[] OutlineOffsets = (Vector2[])(object)new Vector2[8]
		{
			new Vector2(-1f, 0f),
			new Vector2(1f, 0f),
			new Vector2(0f, -1f),
			new Vector2(0f, 1f),
			new Vector2(-0.7f, -0.7f),
			new Vector2(0.7f, -0.7f),
			new Vector2(-0.7f, 0.7f),
			new Vector2(0.7f, 0.7f)
		};

		private static readonly Dictionary<int, float> HoverAmounts = new Dictionary<int, float>();

		private static readonly int ButtonHash = "CaveFinderUiButton".GetHashCode();

		private static float _nextLog;

		public static Font GameFont
		{
			get
			{
				if ((Object)(object)_gameFont != (Object)null || Time.unscaledTime < _nextFontSearch)
				{
					return _gameFont;
				}
				_fontSearches++;
				_nextFontSearch = Time.unscaledTime + ((_fontSearches > 30) ? 30f : 2f);
				try
				{
					Font val = null;
					Font[] array = Resources.FindObjectsOfTypeAll<Font>();
					foreach (Font val2 in array)
					{
						if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name != null && ((Object)val2).name.StartsWith("Jersey10", StringComparison.OrdinalIgnoreCase) && ((Object)(object)val == (Object)null || ((Object)val2).name.Equals("Jersey10-Regular", StringComparison.OrdinalIgnoreCase)))
						{
							val = val2;
						}
					}
					_gameFont = val;
				}
				catch (Exception ex)
				{
					LogOnce("fonte do jogo", ex);
				}
				return _gameFont;
			}
		}

		public static GUIStyle PlateStyle
		{
			get
			{
				EnsureTextures();
				return _plate;
			}
		}

		private static bool Repaint => (int)Event.current.type == 7;

		private static Color Rgb(int rgb)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, 1f);
		}

		public static Color WithAlpha(Color c, float a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Color(c.r, c.g, c.b, a);
		}

		public static float WindowScale(float width, float height, float margin = 16f)
		{
			float num = Mathf.Max(1f, (float)Screen.height / 1080f);
			float num2 = Mathf.Min(((float)Screen.width - margin) / width, ((float)Screen.height - margin) / height);
			return Mathf.Clamp(Mathf.Min(num, num2), 0.4f, 4f);
		}

		public static void EnsureStyles()
		{
			Font gameFont = GameFont;
			if (!_stylesBuilt || !((Object)(object)gameFont == (Object)(object)_stylesFont))
			{
				_stylesBuilt = true;
				_stylesFont = gameFont;
				float k = (((Object)(object)gameFont != (Object)null) ? 1f : 0.7f);
				H1 = Make(gameFont, 42, k, (TextAnchor)3, wrap: false);
				H2 = Make(gameFont, 30, k, (TextAnchor)3, wrap: false);
				Body = Make(gameFont, 25, k, (TextAnchor)3, wrap: false);
				Small = Make(gameFont, 22, k, (TextAnchor)3, wrap: false);
				Tiny = Make(gameFont, 20, k, (TextAnchor)3, wrap: false);
				SmallWrap = Make(gameFont, 22, k, (TextAnchor)0, wrap: true);
			}
		}

		private static GUIStyle Make(Font font, int size, float k, TextAnchor anchor, bool wrap)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0065: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				font = font,
				fontSize = Mathf.Max(8, Mathf.RoundToInt((float)size * k)),
				fontStyle = (FontStyle)0,
				alignment = anchor,
				wordWrap = wrap,
				richText = false,
				clipping = (TextClipping)(wrap ? 1 : 0),
				padding = new RectOffset(0, 0, 0, 0),
				margin = new RectOffset(0, 0, 0, 0)
			};
			val.normal.textColor = Color.white;
			val.hover.textColor = Color.white;
			val.active.textColor = Color.white;
			return val;
		}

		public static float TextWidth(string text, GUIStyle style)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text))
			{
				return 0f;
			}
			TempContent.text = text;
			return style.CalcSize(TempContent).x;
		}

		private static void EnsureTextures()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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_01f7: 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_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: 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_0566: 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_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: 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_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			if (!_texturesBuilt || _window == null || !((Object)(object)_window.normal.background != (Object)null))
			{
				_texturesBuilt = true;
				Color32 val = Color32.op_Implicit(Ink);
				Color32 color = Color32.op_Implicit(Navy);
				Color32 color2 = Color32.op_Implicit(NavyLight);
				Color32 color3 = Color32.op_Implicit(Gold);
				Color32 color4 = Color32.op_Implicit(Wood);
				Color32 color5 = Color32.op_Implicit(WoodLight);
				Color32 color6 = Color32.op_Implicit(WoodDark);
				Color32 color7 = default(Color32);
				((Color32)(ref color7))..ctor((byte)37, (byte)44, (byte)61, byte.MaxValue);
				Color32 color8 = default(Color32);
				((Color32)(ref color8))..ctor((byte)96, (byte)91, (byte)77, byte.MaxValue);
				Px px = new Px(24, 24);
				px.Round(0, 0, 24, 24, 2, val);
				px.Round(1, 1, 22, 22, 1, color4);
				px.Fill(2, 1, 20, 1, color5);
				px.Fill(1, 2, 1, 19, color5);
				px.Fill(1, 22, 22, 1, color6);
				px.Fill(22, 2, 1, 20, color6);
				px.Fill(4, 4, 16, 16, color3);
				px.Fill(5, 5, 14, 14, val);
				px.Fill(6, 6, 12, 12, color);
				(int, int)[] array = new(int, int)[4]
				{
					(2, 2),
					(21, 2),
					(2, 21),
					(21, 21)
				};
				for (int i = 0; i < array.Length; i++)
				{
					var (x, y) = array[i];
					px.Set(x, y, new Color32(byte.MaxValue, (byte)216, (byte)106, byte.MaxValue));
				}
				_window = Nine(px.ToTexture("CaveFinder_UiWindow", 2), 12, 12, 12, 12);
				Px px2 = new Px(8, 16);
				px2.Fill(0, 0, 8, 16, color4);
				px2.Fill(0, 0, 8, 1, color5);
				px2.Fill(0, 5, 8, 1, color6);
				px2.Fill(0, 10, 8, 1, color6);
				px2.Fill(0, 13, 8, 1, color6);
				px2.Fill(0, 14, 8, 1, color3);
				px2.Fill(0, 15, 8, 1, val);
				_header = Nine(px2.ToTexture("CaveFinder_UiHeader", 2), 0, 0, 4, 6);
				Px px3 = new Px(12, 12);
				px3.Round(0, 0, 12, 12, 2, val);
				px3.Round(1, 1, 10, 10, 1, color8);
				px3.Fill(2, 2, 8, 8, color2);
				px3.Fill(2, 2, 8, 1, color7);
				_card = Nine(px3.ToTexture("CaveFinder_UiCard", 2), 8, 8, 8, 8);
				Px px4 = new Px(8, 8);
				px4.Round(0, 0, 8, 8, 1, val);
				px4.Fill(1, 1, 6, 6, new Color32((byte)14, (byte)17, (byte)24, byte.MaxValue));
				px4.Fill(1, 1, 6, 1, new Color32((byte)6, (byte)8, (byte)12, byte.MaxValue));
				px4.Fill(1, 6, 6, 1, new Color32((byte)36, (byte)42, (byte)58, byte.MaxValue));
				_inset = Nine(px4.ToTexture("CaveFinder_UiInset", 2), 6, 6, 6, 6);
				Px px5 = new Px(4, 8);
				px5.Fill(0, 0, 4, 8, new Color32((byte)216, (byte)216, (byte)216, byte.MaxValue));
				px5.Fill(0, 0, 4, 1, new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue));
				px5.Fill(0, 5, 4, 1, new Color32((byte)188, (byte)188, (byte)188, byte.MaxValue));
				px5.Fill(0, 6, 4, 2, new Color32((byte)156, (byte)156, (byte)156, byte.MaxValue));
				_barFill = Nine(px5.ToTexture("CaveFinder_UiBarFill", 2), 0, 0, 4, 6);
				Px px6 = new Px(8, 8);
				px6.Round(0, 0, 8, 8, 2, new Color32((byte)5, (byte)6, (byte)9, (byte)200));
				px6.Round(1, 1, 6, 6, 1, new Color32((byte)16, (byte)19, (byte)27, (byte)190));
				px6.Fill(2, 1, 4, 1, new Color32((byte)42, (byte)48, (byte)64, (byte)190));
				_plate = Nine(px6.ToTexture("CaveFinder_UiPlate", 2), 6, 6, 6, 6);
				(Color32, Color32, Color32)[] array2 = new(Color32, Color32, Color32)[4]
				{
					(new Color32((byte)31, (byte)154, (byte)18, byte.MaxValue), new Color32((byte)92, (byte)207, (byte)74, byte.MaxValue), new Color32((byte)12, (byte)69, (byte)10, byte.MaxValue)),
					(new Color32((byte)178, (byte)36, (byte)46, byte.MaxValue), new Color32((byte)228, (byte)90, (byte)100, byte.MaxValue), new Color32((byte)109, (byte)36, (byte)46, byte.MaxValue)),
					(new Color32((byte)43, (byte)49, (byte)66, byte.MaxValue), new Color32((byte)70, (byte)80, (byte)106, byte.MaxValue), new Color32((byte)20, (byte)24, (byte)33, byte.MaxValue)),
					(new Color32((byte)217, (byte)154, (byte)18, byte.MaxValue), new Color32(byte.MaxValue, (byte)212, (byte)90, byte.MaxValue), new Color32((byte)122, (byte)74, (byte)8, byte.MaxValue))
				};
				for (int j = 0; j < array2.Length; j++)
				{
					var (val2, val3, lip) = array2[j];
					ButtonNormal[j] = Nine(ButtonTexture($"CaveFinder_UiButton{j}", val2, val3, lip, val, pressed: false), 6, 6, 6, 10);
					ButtonHover[j] = Nine(ButtonTexture($"CaveFinder_UiButton{j}Hover", Lighten(val2, 0.16f), Lighten(val3, 0.2f), lip, new Color32(byte.MaxValue, (byte)226, (byte)154, byte.MaxValue), pressed: false), 6, 6, 6, 10);
					ButtonPressed[j] = Nine(ButtonTexture($"CaveFinder_UiButton{j}Pressed", Darken(val2, 0.1f), val2, lip, val, pressed: true), 6, 6, 6, 10);
				}
				_glow = RadialTexture("CaveFinder_UiGlow", 48, 2f);
				_shade = RadialTexture("CaveFinder_UiShade", 48, 1.2f);
			}
		}

		private static Texture2D ButtonTexture(string name, Color32 fill, Color32 light, Color32 lip, Color32 outline, bool pressed)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Px px = new Px(16, 16);
			px.Round(0, 0, 16, 16, 2, outline);
			px.Round(1, 1, 14, 14, 1, lip);
			if (pressed)
			{
				px.Fill(1, 3, 14, 11, fill);
				px.Fill(2, 3, 12, 1, light);
			}
			else
			{
				px.Fill(2, 1, 12, 11, fill);
				px.Fill(1, 2, 14, 10, fill);
				px.Fill(2, 1, 12, 1, light);
				px.Set(1, 2, light);
				px.Set(14, 2, light);
				px.Fill(1, 11, 14, 1, Darken(fill, 0.12f));
			}
			return px.ToTexture(name, 2);
		}

		private static Texture2D RadialTexture(string name, int size, float power)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61,
				name = name
			};
			Color32[] array = (Color32[])(object)new Color32[size * size];
			float num = (float)(size - 1) / 2f;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)) / num;
					float num3 = Mathf.Pow(Mathf.Clamp01(1f - num2), power);
					array[i * size + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num3 * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return val;
		}

		private static Color32 Lighten(Color32 c, float k)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			return new Color32((byte)Mathf.Min(255f, (float)(int)c.r + (float)(255 - c.r) * k), (byte)Mathf.Min(255f, (float)(int)c.g + (float)(255 - c.g) * k), (byte)Mathf.Min(255f, (float)(int)c.b + (float)(255 - c.b) * k), c.a);
		}

		private static Color32 Darken(Color32 c, float k)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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)
			return new Color32((byte)((float)(int)c.r * (1f - k)), (byte)((float)(int)c.g * (1f - k)), (byte)((float)(int)c.b * (1f - k)), c.a);
		}

		private static GUIStyle Nine(Texture2D tex, int left, int right, int top, int bottom)
		{
			//IL_0000: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				border = new RectOffset(left, right, top, bottom)
			};
			val.normal.background = tex;
			return val;
		}

		private static void Draw(Rect r, GUIStyle style)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Repaint && style != null && ((Rect)(ref r)).width > 0f && ((Rect)(ref r)).height > 0f)
			{
				style.Draw(r, false, false, false, false);
			}
		}

		private static void Draw(Rect r, GUIStyle style, Color tint)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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)
			//IL_0042: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			if (Repaint)
			{
				Color color = GUI.color;
				GUI.color = new Color(tint.r * color.r, tint.g * color.g, tint.b * color.b, tint.a * color.a);
				Draw(r, style);
				GUI.color = color;
			}
		}

		public static void Window(Rect r)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			EnsureTextures();
			if (Repaint)
			{
				Color color = GUI.color;
				GUI.color = new Color(0f, 0f, 0f, 0.45f * color.a);
				GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 30f, ((Rect)(ref r)).y - 10f, ((Rect)(ref r)).width + 60f, ((Rect)(ref r)).height + 60f), (Texture)(object)_shade);
				GUI.color = color;
				Draw(r, _window);
			}
		}

		public static void Header(Rect r)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			EnsureTextures();
			Draw(r, _header);
		}

		public static void Card(Rect r)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			EnsureTextures();
			Draw(r, _card);
		}

		public static void Inset(Rect r)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			EnsureTextures();
			Draw(r, _inset);
		}

		public static void Plate(Rect r, float alpha = 1f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			EnsureTextures();
			Draw(r, _plate, new Color(1f, 1f, 1f, alpha));
		}

		public static void Solid(Rect r, Color color)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown resul