Decompiled source of QuestTracker v1.2.0

plugins/QuestTracker/QuestTracker.dll

Decompiled 19 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using Assets.Scripts.Actors.Enemies;
using Assets.Scripts.Managers;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Rewired;
using UnityEngine;
using UnityEngine.EventSystems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("QuestTracker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("QuestTracker")]
[assembly: AssemblyTitle("QuestTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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 QuestTracker
{
	internal static class Hud
	{
		private enum Drag
		{
			None,
			Move,
			Resize
		}

		private const float PanelWidth = 400f;

		private const float Pad = 12f;

		private const float TitleRow = 26f;

		private const float StatusRow = 24f;

		private const float BarRow = 16f;

		private const float Handle = 22f;

		private const float RemoveSize = 22f;

		private static bool _stylesReady;

		private static GUIStyle _title;

		private static GUIStyle _desc;

		private static GUIStyle _status;

		private static GUIStyle _timer;

		private static GUIStyle _hint;

		private static GUIStyle _tag;

		private static GUIStyle _header;

		private static GUIStyle _rowTitle;

		private static GUIStyle _rowDesc;

		private static GUIStyle _button;

		private static GUIStyle _tab;

		private static GUIStyle _tabOn;

		private static GUIStyle _field;

		private static Texture2D _white;

		private static readonly Color Gold = new Color(1f, 0.82f, 0.25f);

		private static readonly Color Green = new Color(0.35f, 0.95f, 0.45f);

		private static readonly Color Yellow = new Color(1f, 0.85f, 0.2f);

		private static readonly Color Red = new Color(1f, 0.33f, 0.3f);

		private static readonly Color Grey = new Color(0.72f, 0.72f, 0.78f);

		private static readonly Color Blue = new Color(0.45f, 0.78f, 1f);

		private static string _toast;

		private static float _toastUntil;

		private static bool _mouseHeld;

		private static Drag _drag;

		private static Vector2 _dragStart;

		private static float _startX;

		private static float _startY;

		private static float _startScale;

		private static readonly TrackedQuest Sample = new TrackedQuest
		{
			Id = "_sample",
			Title = L.T("Example quest", "مهمة تجريبية"),
			Description = L.T("Kill 15,000 enemies as Ogre", "اقتل 15,000 من الأعداء بشخصية الغول"),
			HasCount = true,
			Current = 11162,
			Target = 15000,
			Progress = 0.744f,
			Status = QuestStatus.InProgress,
			StatusText = L.T("3,838 left  ·  +312 this run", "متبقي 3,838  ·  +312 في هذه الجولة")
		};

		private static readonly Dictionary<IntPtr, GUIStyle> RightStyles = new Dictionary<IntPtr, GUIStyle>();

		public static bool LayoutMode { get; private set; }

		internal static float BaseScale => Mathf.Clamp((float)Screen.height / 1080f, 0.6f, 3f);

		private static float PanelScale => BaseScale * Mathf.Clamp(Plugin.Cfg.Scale.Value, 0.5f, 2.5f);

		internal static GUIStyle Header => _header;

		internal static GUIStyle RowTitle => _rowTitle;

		internal static GUIStyle RowDesc => _rowDesc;

		internal static GUIStyle Button => _button;

		internal static GUIStyle Tab => _tab;

		internal static GUIStyle TabOn => _tabOn;

		internal static GUIStyle Field => _field;

		internal static Color GoldColor => Gold;

		internal static Color GreenColor => Green;

		internal static Color GreyColor => Grey;

		public static void Draw()
		{
			//IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_00bf: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EnsureStyles();
				Event current = Event.current;
				Settings cfg = Plugin.Cfg;
				Vector2 mousePosition = current.mousePosition;
				HandleKeys(current);
				UiHoverScanner.Scan(current);
				if ((int)current.type == 0)
				{
					_mouseHeld = true;
				}
				else if ((int)current.type == 1)
				{
					_mouseHeld = false;
				}
				int num;
				int block;
				if (!Picker.Open)
				{
					num = (LayoutMode ? 1 : 0);
					if (num == 0)
					{
						block = ((InputBlocker.Blocking && _mouseHeld) ? 1 : 0);
						goto IL_0067;
					}
				}
				else
				{
					num = 1;
				}
				block = 1;
				goto IL_0067;
				IL_0067:
				InputBlocker.Update((byte)block != 0);
				if (num != 0)
				{
					CursorGuard.Hold();
				}
				else if (!InputBlocker.Blocking)
				{
					CursorGuard.Release();
				}
				List<TrackedQuest> list = PanelCards();
				bool num2 = LayoutMode || (cfg.ShowHud.Value && list.Count > 0 && (Tracker.InRun || cfg.ShowInMenus.Value));
				Matrix4x4 matrix = GUI.matrix;
				Rect? val = null;
				if (num2)
				{
					float panelScale = PanelScale;
					List<float> list2 = list.Select((TrackedQuest q) => CardHeight(q, 376f)).ToList();
					float num3 = 12f + list2.Sum((float x) => x + 12f);
					Rect val2 = PanelScreenRect(panelScale, num3);
					if (LayoutMode)
					{
						HandleLayoutMouse(current, val2, panelScale, list, list2);
					}
					val2 = PanelScreenRect(panelScale, num3);
					if (!LayoutMode && !Picker.Open && Cursor.visible && ((Rect)(ref val2)).Contains(current.mousePosition))
					{
						val = val2;
					}
					GUI.matrix = Matrix4x4.Scale(new Vector3(panelScale, panelScale, 1f));
					DrawPanel(list, list2, ((Rect)(ref val2)).x / panelScale, ((Rect)(ref val2)).y / panelScale, num3);
					GUI.matrix = matrix;
				}
				float baseScale = BaseScale;
				GUI.matrix = Matrix4x4.Scale(new Vector3(baseScale, baseScale, 1f));
				float sw = (float)Screen.width / baseScale;
				float sh = (float)Screen.height / baseScale;
				if (LayoutMode)
				{
					DrawLayoutHelp(sw);
				}
				if (val.HasValue)
				{
					DrawPanelTag(val.Value, baseScale, sh);
				}
				if (Tracker.HoveredId != null && !Picker.Open && !LayoutMode)
				{
					DrawHoverHint(mousePosition / baseScale);
				}
				if (Picker.Open)
				{
					Picker.Draw(sw, sh, mousePosition / baseScale);
				}
				if (_toast != null && Time.unscaledTime < _toastUntil)
				{
					DrawToast(sw);
				}
				GUI.matrix = matrix;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Quest Tracker draw error: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				logger.LogWarning(val3);
			}
		}

		private static List<TrackedQuest> PanelCards()
		{
			if (LayoutMode)
			{
				if (Tracker.Pinned.Count != 0)
				{
					return Tracker.Pinned.ToList();
				}
				return new List<TrackedQuest> { Sample };
			}
			return Tracker.Pinned.Where((TrackedQuest q) => !Tracker.IsHidden(q)).ToList();
		}

		private static List<Rect> CardRects(float x, float y, List<float> heights)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			List<Rect> list = new List<Rect>();
			float num = y + 12f;
			foreach (float height in heights)
			{
				list.Add(new Rect(x + 12f + 4f, num, 372f, height));
				num += height + 12f;
			}
			return list;
		}

		private static Rect RemoveButton(Rect card)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref card)).xMax - 22f, ((Rect)(ref card)).y + 2f, 22f, 22f);
		}

		private static Rect PanelScreenRect(float s, float h)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Settings cfg = Plugin.Cfg;
			float num = 400f * s;
			float num2 = h * s;
			float num3 = Mathf.Clamp(cfg.PosX.Value * (float)Screen.width, 0f, Mathf.Max(0f, (float)Screen.width - num));
			float num4 = Mathf.Clamp(cfg.PosY.Value * (float)Screen.height, 0f, Mathf.Max(0f, (float)Screen.height - num2));
			return new Rect(num3, num4, num, num2);
		}

		private static void HandleKeys(Event e)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_00d4: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_0125: 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_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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_0076: Invalid comparison between Unknown and I4
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: 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_008d: Invalid comparison between Unknown and I4
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Invalid comparison between Unknown and I4
			//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)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			if (e == null || (int)e.type != 4 || (int)e.keyCode == 0)
			{
				return;
			}
			Settings cfg = Plugin.Cfg;
			if (Picker.SearchFocused && e.keyCode != cfg.PickerKey.Value)
			{
				return;
			}
			if (LayoutMode)
			{
				if ((int)e.keyCode == 27 || e.keyCode == cfg.LayoutKey.Value || (int)e.keyCode == 13)
				{
					SetLayoutMode(on: false);
					return;
				}
				if ((int)e.keyCode == 114)
				{
					ResetLayout();
					return;
				}
				KeyCode keyCode = e.keyCode;
				if (((int)keyCode == 43 || (int)keyCode == 61 || (int)keyCode == 270) ? true : false)
				{
					Resize(0.1f);
					return;
				}
				keyCode = e.keyCode;
				if (((int)keyCode == 45 || (int)keyCode == 269) ? true : false)
				{
					Resize(-0.1f);
				}
			}
			else if (e.keyCode == cfg.PinKey.Value && Tracker.HoveredId != null)
			{
				bool num = Tracker.IsPinned(Tracker.HoveredId);
				Tracker.TogglePinHovered();
				Toast(num ? L.T("Quest untracked", "تم إلغاء تتبع المهمة") : L.T("Quest tracked!", "تم تتبع المهمة!"));
			}
			else if (e.keyCode == cfg.PickerKey.Value)
			{
				Picker.Toggle();
			}
			else if ((int)e.keyCode == 27 && Picker.Open)
			{
				Picker.Toggle();
			}
			else if (e.keyCode == cfg.LayoutKey.Value)
			{
				SetLayoutMode(on: true);
			}
			else if (e.keyCode == cfg.HudKey.Value)
			{
				cfg.ShowHud.Value = !cfg.ShowHud.Value;
				cfg.Save();
				Toast(cfg.ShowHud.Value ? L.T("Quest tracker shown", "تم إظهار متتبع المهام") : L.T("Quest tracker hidden", "تم إخفاء متتبع المهام"));
			}
			else if (e.keyCode == cfg.DumpKey.Value)
			{
				try
				{
					Toast(L.T("Quest list saved to ", "تم حفظ قائمة المهام في ") + Path.GetFileName(Tracker.ExportAll()));
				}
				catch (Exception ex)
				{
					Toast(L.T("Export failed: ", "فشل التصدير: ") + ex.Message);
				}
			}
		}

		public static void SetLayoutMode(bool on)
		{
			LayoutMode = on;
			_drag = Drag.None;
			if (on)
			{
				if (Picker.Open)
				{
					Picker.Toggle();
				}
				Plugin.Cfg.ShowHud.Value = true;
			}
			else
			{
				Plugin.Cfg.Save();
				Toast(L.T("Tracker position saved", "تم حفظ موضع المتتبع"));
			}
		}

		private static void ResetLayout()
		{
			Settings cfg = Plugin.Cfg;
			cfg.PosX.Value = 0.012f;
			cfg.PosY.Value = 0.36f;
			cfg.Scale.Value = 1f;
			Toast(L.T("Tracker reset to default", "تمت إعادة المتتبع للوضع الافتراضي"));
		}

		private static void Resize(float delta)
		{
			Settings cfg = Plugin.Cfg;
			cfg.Scale.Value = Mathf.Clamp((float)Math.Round(cfg.Scale.Value + delta, 2), 0.5f, 2.5f);
		}

		private static void HandleLayoutMouse(Event e, Rect r, float s, List<TrackedQuest> cards, List<float> heights)
		{
			//IL_0007: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected I4, but got Unknown
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: 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_01e0: 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_008f: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			Settings cfg = Plugin.Cfg;
			Vector2 mousePosition = e.mousePosition;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref r)).xMax - 22f * s, ((Rect)(ref r)).yMax - 22f * s, 22f * s, 22f * s);
			if ((int)e.type == 0 && e.button == 0)
			{
				List<Rect> list = CardRects(((Rect)(ref r)).x / s, ((Rect)(ref r)).y / s, heights);
				Rect val3 = default(Rect);
				for (int i = 0; i < cards.Count; i++)
				{
					if (cards[i] != Sample)
					{
						Rect val2 = RemoveButton(list[i]);
						((Rect)(ref val3))..ctor(((Rect)(ref val2)).x * s, ((Rect)(ref val2)).y * s, ((Rect)(ref val2)).width * s, ((Rect)(ref val2)).height * s);
						if (((Rect)(ref val3)).Contains(mousePosition))
						{
							Tracker.Untrack(cards[i]);
							Toast(L.T("Quest untracked", "تم إلغاء تتبع المهمة"));
							e.Use();
							return;
						}
					}
				}
			}
			EventType type = e.type;
			switch ((int)type)
			{
			case 0:
				if (e.button == 0 && ((Rect)(ref r)).Contains(mousePosition))
				{
					_drag = ((!((Rect)(ref val)).Contains(mousePosition)) ? Drag.Move : Drag.Resize);
					_dragStart = mousePosition;
					_startX = ((Rect)(ref r)).x;
					_startY = ((Rect)(ref r)).y;
					_startScale = cfg.Scale.Value;
					e.Use();
				}
				break;
			case 3:
				if (_drag != Drag.None)
				{
					Vector2 val4 = mousePosition - _dragStart;
					if (_drag == Drag.Move)
					{
						cfg.PosX.Value = Mathf.Clamp01((_startX + val4.x) / (float)Screen.width);
						cfg.PosY.Value = Mathf.Clamp01((_startY + val4.y) / (float)Screen.height);
					}
					else
					{
						float num = 400f * BaseScale * _startScale;
						cfg.Scale.Value = Mathf.Clamp(_startScale * (num + val4.x) / num, 0.5f, 2.5f);
					}
					e.Use();
				}
				break;
			case 1:
				if (_drag != Drag.None)
				{
					_drag = Drag.None;
					e.Use();
				}
				break;
			case 6:
				Resize((e.delta.y > 0f) ? (-0.05f) : 0.05f);
				e.Use();
				break;
			case 2:
			case 4:
			case 5:
				break;
			}
		}

		public static void Toast(string text)
		{
			_toast = text;
			_toastUntil = Time.unscaledTime + 2.5f;
		}

		private static void DrawPanel(List<TrackedQuest> cards, List<float> heights, float x, float y, float total)
		{
			//IL_000f: 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_0059: 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_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_00b7: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			Settings cfg = Plugin.Cfg;
			Fill(new Rect(x, y, 400f, total), new Color(0.05f, 0.05f, 0.08f, Mathf.Max(cfg.Opacity.Value, LayoutMode ? 0.85f : 0f)));
			Fill(new Rect(x, y, 4f, total), Gold);
			if (LayoutMode)
			{
				Outline(new Rect(x, y, 400f, total), Gold, 2f);
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(x + 400f - 22f, y + total - 22f, 22f, 22f);
				Fill(r, Gold);
				Fill(new Rect(((Rect)(ref r)).x + 5f, ((Rect)(ref r)).yMax - 8f, 12f, 3f), Color.black);
				Fill(new Rect(((Rect)(ref r)).xMax - 8f, ((Rect)(ref r)).y + 5f, 3f, 12f), Color.black);
			}
			List<Rect> list = CardRects(x, y, heights);
			for (int i = 0; i < cards.Count; i++)
			{
				TrackedQuest trackedQuest = cards[i];
				if (LayoutMode && Tracker.IsHidden(trackedQuest))
				{
					Fill(list[i], new Color(1f, 1f, 1f, 0.06f));
				}
				DrawCard(trackedQuest, list[i]);
				if (LayoutMode && trackedQuest != Sample)
				{
					Rect r2 = RemoveButton(list[i]);
					Fill(r2, Red);
					Fill(new Rect(((Rect)(ref r2)).x + 5f, ((Rect)(ref r2)).center.y - 1.5f, ((Rect)(ref r2)).width - 10f, 3f), Color.white);
				}
			}
		}

		private static float CardHeight(TrackedQuest q, float w)
		{
			float num = 26f;
			num += TextHeight(q.Description, _desc, w - 4f);
			if (ShowsBar(q))
			{
				num += 16f;
			}
			return num + 24f;
		}

		private static bool ShowsBar(TrackedQuest q)
		{
			if (!q.HasCount)
			{
				return q.TimerFraction >= 0f;
			}
			return true;
		}

		private static void DrawCard(TrackedQuest q, Rect r)
		{
			//IL_0092: 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_0062: 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)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime < q.FlashUntil)
			{
				float num = 0.25f + 0.25f * Mathf.Sin(Time.unscaledTime * 10f);
				Fill(new Rect(((Rect)(ref r)).x - 6f, ((Rect)(ref r)).y - 5f, ((Rect)(ref r)).width + 12f, ((Rect)(ref r)).height + 10f), new Color(Green.r, Green.g, Green.b, num));
			}
			Color c = StatusColor(q);
			float y = ((Rect)(ref r)).y;
			string timerText = q.TimerText;
			float num2 = (string.IsNullOrEmpty(timerText) ? 0f : 70f);
			float num3 = ((LayoutMode && q != Sample) ? 28f : 0f);
			Fill(new Rect(((Rect)(ref r)).x, y + 8f, 10f, 10f), c);
			Label(new Rect(((Rect)(ref r)).x + 16f, y, ((Rect)(ref r)).width - 16f - num2 - num3, 26f), q.Title, _title, Gold);
			if (num2 > 0f)
			{
				Label(new Rect(((Rect)(ref r)).xMax - num3 - num2, y, num2, 26f), timerText, _timer, c);
			}
			y += 26f;
			float num4 = TextHeight(q.Description, _desc, ((Rect)(ref r)).width);
			Label(new Rect(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, num4), q.Description, _desc, Color.white);
			y += num4;
			if (ShowsBar(q))
			{
				float num5 = ((q.TimerFraction >= 0f) ? q.TimerFraction : q.Progress);
				Rect r2 = default(Rect);
				((Rect)(ref r2))..ctor(((Rect)(ref r)).x, y + 4f, ((Rect)(ref r)).width, 8f);
				Fill(r2, new Color(1f, 1f, 1f, 0.15f));
				Fill(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, ((Rect)(ref r2)).width * Mathf.Clamp01(num5), ((Rect)(ref r2)).height), c);
				y += 16f;
			}
			string text;
			switch (q.Status)
			{
			case QuestStatus.Success:
			case QuestStatus.Complete:
				text = L.T("DONE  ", "تم  ");
				break;
			case QuestStatus.Failed:
				text = "";
				break;
			default:
				text = ((q.HasCount && q.TimerFraction < 0f) ? $"{q.Current:N0} / {q.Target:N0}   " : "");
				break;
			}
			string text2 = text;
			Label(new Rect(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, 24f), text2 + q.StatusText, _status, c);
		}

		private static Color StatusColor(TrackedQuest q)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: 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)
			//IL_0071: 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)
			//IL_004c: 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)
			switch (q.Status)
			{
			case QuestStatus.Success:
			case QuestStatus.Complete:
				return Green;
			case QuestStatus.Failed:
				return Red;
			case QuestStatus.Hurry:
				return (q.TimerFraction < 0.1f) ? Red : Yellow;
			case QuestStatus.OnTrack:
				return Green;
			case QuestStatus.Idle:
			case QuestStatus.NotThisStage:
				return Grey;
			default:
				return Blue;
			}
		}

		private static void DrawLayoutHelp(float sw)
		{
			//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_001f: 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_0043: 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)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			string text = L.T("MOVE / RESIZE TRACKER   ·   Drag the panel to move it   ·   Scroll or drag the corner to resize   ·   Red button: untrack   ·   [R] reset   ·   [Esc] done", "تحريك وتغيير حجم المتتبع   ·   اسحب اللوحة لتحريكها   ·   استخدم العجلة أو اسحب الزاوية لتغيير الحجم   ·   الزر الأحمر: إلغاء التتبع   ·   [R] إعادة ضبط   ·   [Esc] تم");
			Vector2 val = Measure(text, _hint);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor((sw - val.x) / 2f - 14f, 20f, val.x + 28f, val.y + 14f);
			Fill(r, new Color(0f, 0f, 0f, 0.9f));
			Outline(r, Gold, 2f);
			Label(new Rect(((Rect)(ref r)).x + 14f, ((Rect)(ref r)).y + 7f, val.x, val.y), text, _hint, Gold);
		}

		private static void DrawPanelTag(Rect panelScreen, float b, float sh)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			string text = L.T($"Press [{Plugin.Cfg.LayoutKey.Value}] to move / resize / remove", $"اضغط [{Plugin.Cfg.LayoutKey.Value}] للتحريك / تغيير الحجم / الإزالة");
			Vector2 val = Measure(text, _tag);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(val.x + 14f, val.y + 6f);
			float num = ((Rect)(ref panelScreen)).x / b;
			float num2 = ((Rect)(ref panelScreen)).y / b - val2.y - 2f;
			if (num2 < 0f)
			{
				num2 = ((Rect)(ref panelScreen)).yMax / b + 2f;
			}
			num2 = Mathf.Min(num2, sh - val2.y);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(num, num2, val2.x, val2.y);
			Fill(r, new Color(0f, 0f, 0f, 0.85f));
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, 3f, ((Rect)(ref r)).height), Gold);
			Label(new Rect(((Rect)(ref r)).x + 8f, ((Rect)(ref r)).y + 3f, val.x, val.y), text, _tag, Gold);
		}

		private static void DrawHoverHint(Vector2 mouse)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0134: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Tracker.IsPinned(Tracker.HoveredId);
			string text = (flag ? L.T("Untrack quest", "إلغاء تتبع المهمة") : L.T("Track quest", "تتبع المهمة"));
			string text2 = ((Tracker.HoveredKind == HoverKind.Clickable && Plugin.Cfg.ClickToTrack.Value) ? L.T($"[Double-click] or [{Plugin.Cfg.PinKey.Value}]", $"[نقرتان] أو [{Plugin.Cfg.PinKey.Value}]") : $"[{Plugin.Cfg.PinKey.Value}]") + " " + text;
			Vector2 val = Measure(text2, _hint);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(mouse.x + 20f, mouse.y + 20f, val.x + 18f, val.y + 10f);
			Fill(r, new Color(0f, 0f, 0f, 0.88f));
			Outline(r, flag ? Grey : Gold, 1f);
			Label(new Rect(((Rect)(ref r)).x + 9f, ((Rect)(ref r)).y + 5f, val.x, val.y), text2, _hint, flag ? Grey : Gold);
		}

		private static void DrawToast(float sw)
		{
			//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_0013: 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_0037: 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_005d: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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)
			Vector2 val = Measure(_toast, _hint);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor((sw - val.x) / 2f - 14f, 80f, val.x + 28f, val.y + 14f);
			Fill(r, new Color(0f, 0f, 0f, 0.88f));
			Label(new Rect(((Rect)(ref r)).x + 14f, ((Rect)(ref r)).y + 7f, val.x, val.y), _toast, _hint, Gold);
		}

		internal static void Fill(Rect r, Color c)
		{
			//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)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)_white);
			GUI.color = color;
		}

		internal static void Outline(Rect r, Color c, float t)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), c);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), c);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c);
			Fill(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c);
		}

		internal static bool Btn(Rect r, string text, GUIStyle style)
		{
			//IL_0000: 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_0021: Expected O, but got Unknown
			return GUI.Button(r, new GUIContent(Rtl.Visual(text ?? "", style, 0f)), style);
		}

		internal static void Label(Rect r, string text, GUIStyle style, Color c)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			if (text == null)
			{
				text = "";
			}
			if (Rtl.HasArabic(text))
			{
				text = Rtl.Visual(text, style, ((Rect)(ref r)).width);
				style = RightAligned(style);
			}
			Color contentColor = GUI.contentColor;
			GUI.contentColor = c;
			GUI.Label(r, text, style);
			GUI.contentColor = contentColor;
		}

		internal static Vector2 Measure(string text, GUIStyle style)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return style.CalcSize(new GUIContent(Rtl.Visual(text ?? "", style, 0f)));
		}

		internal static float TextHeight(string text, GUIStyle style, float width)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (text == null)
			{
				text = "";
			}
			if (!Rtl.HasArabic(text))
			{
				return style.CalcHeight(new GUIContent(text), width);
			}
			return RightAligned(style).CalcHeight(new GUIContent(Rtl.Visual(text, style, width)), width);
		}

		private static GUIStyle RightAligned(GUIStyle s)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_004e: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0043: 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)
			if (RightStyles.TryGetValue(((Il2CppObjectBase)s).Pointer, out var value))
			{
				return value;
			}
			value = new GUIStyle(s)
			{
				wordWrap = false
			};
			GUIStyle val = value;
			TextAnchor alignment = s.alignment;
			TextAnchor alignment2 = (((int)alignment == 0) ? ((TextAnchor)2) : (((int)alignment == 3) ? ((TextAnchor)5) : (((int)alignment != 6) ? s.alignment : ((TextAnchor)8))));
			val.alignment = alignment2;
			return RightStyles[((Il2CppObjectBase)s).Pointer] = value;
		}

		private static void EnsureStyles()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			if (!_stylesReady || !((Object)(object)_white != (Object)null))
			{
				_white = new Texture2D(1, 1);
				_white.SetPixel(0, 0, Color.white);
				_white.Apply();
				((Object)_white).hideFlags = (HideFlags)61;
				_title = Make(GUI.skin.label, 19, (FontStyle)1);
				_desc = Make(GUI.skin.label, 15, (FontStyle)0, wrap: true);
				_status = Make(GUI.skin.label, 15, (FontStyle)1);
				_timer = Make(GUI.skin.label, 19, (FontStyle)1);
				_timer.alignment = (TextAnchor)5;
				_hint = Make(GUI.skin.label, 15, (FontStyle)1);
				_tag = Make(GUI.skin.label, 12, (FontStyle)1);
				_header = Make(GUI.skin.label, 20, (FontStyle)1);
				_rowTitle = Make(GUI.skin.label, 16, (FontStyle)1);
				_rowDesc = Make(GUI.skin.label, 13, (FontStyle)0, wrap: true);
				_button = Make(GUI.skin.button, 14, (FontStyle)1);
				_tab = Make(GUI.skin.button, 13, (FontStyle)0);
				_tabOn = Make(GUI.skin.button, 13, (FontStyle)1);
				_tabOn.normal.textColor = Gold;
				_field = Make(GUI.skin.textField, 15, (FontStyle)0);
				_stylesReady = true;
			}
		}

		private static GUIStyle Make(GUIStyle baseStyle, int size, FontStyle fs, bool wrap = false)
		{
			//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_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_0022: 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_0033: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(baseStyle)
			{
				fontSize = size,
				fontStyle = fs,
				wordWrap = wrap,
				richText = true
			};
			val.normal.textColor = Color.white;
			return val;
		}
	}
	internal static class CursorGuard
	{
		private static bool _held;

		private static CursorLockMode _lock;

		private static bool _visible;

		public static void Hold()
		{
			//IL_0007: 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)
			if (!_held)
			{
				_lock = Cursor.lockState;
				_visible = Cursor.visible;
				_held = true;
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}

		public static void Release()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (_held)
			{
				_held = false;
				if (Tracker.InRun && Time.timeScale > 0f)
				{
					Cursor.lockState = (CursorLockMode)1;
					Cursor.visible = false;
				}
				else
				{
					Cursor.lockState = _lock;
					Cursor.visible = _visible;
				}
			}
		}
	}
	internal static class InputBlocker
	{
		private static readonly List<Player> PausedPlayers = new List<Player>();

		private static EventSystem _eventSystem;

		private static bool _eventSystemWasEnabled;

		public static bool Blocking { get; private set; }

		public static void Update(bool block)
		{
			if (block != Blocking)
			{
				Blocking = block;
				if (block)
				{
					Block();
				}
				else
				{
					Unblock();
				}
			}
		}

		private static void Block()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (ReInput.isReady)
				{
					PlayerHelper players = ReInput.players;
					for (int i = 0; i < players.playerCount; i++)
					{
						Player player = players.GetPlayer(i);
						if (player != null && player.isPlaying)
						{
							player.isPlaying = false;
							PausedPlayers.Add(player);
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Input block (Rewired): ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogDebug(val);
			}
			try
			{
				_eventSystem = EventSystem.current;
				if ((Object)(object)_eventSystem != (Object)null)
				{
					_eventSystemWasEnabled = ((Behaviour)_eventSystem).enabled;
					((Behaviour)_eventSystem).enabled = false;
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Input block (UI): ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
				}
				logger2.LogDebug(val);
			}
		}

		private static void Unblock()
		{
			foreach (Player pausedPlayer in PausedPlayers)
			{
				try
				{
					pausedPlayer.isPlaying = true;
				}
				catch
				{
				}
			}
			PausedPlayers.Clear();
			try
			{
				if ((Object)(object)_eventSystem != (Object)null && !((Il2CppObjectBase)_eventSystem).WasCollected)
				{
					((Behaviour)_eventSystem).enabled = _eventSystemWasEnabled;
				}
			}
			catch
			{
			}
			_eventSystem = null;
		}
	}
	internal static class Picker
	{
		private sealed class Entry
		{
			public string Id;

			public string Name;

			public string Desc;

			public string Type;

			public string Progress;

			public MyAchievement Ach;

			public bool Done;
		}

		private const float RowH = 62f;

		private const float ScrollbarW = 10f;

		private const int MaxSearchLength = 40;

		private static List<Entry> _entries = new List<Entry>();

		private static string[] _tabs = new string[1] { "All" };

		private static string _tab = "All";

		private static string _search = "";

		private static bool _searchFocused;

		private static bool _showDone;

		private static int _scrollRow;

		private static bool _draggingScrollbar;

		public static bool Open { get; private set; }

		public static bool SearchFocused
		{
			get
			{
				if (Open)
				{
					return _searchFocused;
				}
				return false;
			}
		}

		public static void Toggle()
		{
			Open = !Open;
			_searchFocused = false;
			_draggingScrollbar = false;
			if (Open)
			{
				Refresh();
			}
		}

		private static void Refresh()
		{
			//IL_0071: 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)
			Tracker.LoadAll();
			List<Entry> list = new List<Entry>();
			foreach (MyAchievement value in Tracker.All.Values)
			{
				try
				{
					if (!value.IsHiddenInMenus())
					{
						list.Add(new Entry
						{
							Id = value.internalName,
							Ach = value,
							Name = Strip(value.GetDisplayName()),
							Desc = Strip(value.GetUnlockRequirement()),
							Type = ((object)value.achievementType/*cast due to .constrained prefix*/).ToString(),
							Done = value.IsCompleted(),
							Progress = ((value.IsUsingTargetValue() && value.targetValue > 1) ? $"{Math.Max(0, value.GetCurrentValue()):N0} / {value.targetValue:N0}" : "")
						});
					}
				}
				catch
				{
				}
			}
			_entries = (from e in list
				orderby e.Done, e.Type, e.Name
				select e).ToList();
			_tabs = new string[2] { "All", "Tracked" }.Concat(_entries.Select((Entry e) => e.Type).Distinct()).ToArray();
			_scrollRow = 0;
		}

		public static void Draw(float sw, float sh, Vector2 mouse)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: 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_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: 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_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			HandleTyping(current);
			float num = Mathf.Min(680f, sw - 40f);
			float num2 = Mathf.Min(660f, sh - 40f);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor((sw - num) / 2f, (sh - num2) / 2f, num, num2);
			Hud.Fill(r, new Color(0.04f, 0.04f, 0.07f, 0.96f));
			Hud.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 4f), Hud.GoldColor);
			float num3 = ((Rect)(ref r)).x + 16f;
			float num4 = ((Rect)(ref r)).y + 14f;
			float num5 = ((Rect)(ref r)).width - 32f;
			Hud.Label(new Rect(num3, num4, num5 - 220f, 28f), L.T($"Quest Tracker  ·  {Tracker.Pinned.Count}/{Plugin.Cfg.MaxPinned.Value} tracked", $"متتبع المهام  ·  {Tracker.Pinned.Count}/{Plugin.Cfg.MaxPinned.Value} متتبعة"), Hud.Header, Hud.GoldColor);
			if (Hud.Btn(new Rect(((Rect)(ref r)).xMax - 196f, ((Rect)(ref r)).y + 12f, 140f, 28f), L.T("Move / Resize", "تحريك / تحجيم"), Hud.Button))
			{
				Hud.SetLayoutMode(on: true);
				return;
			}
			if (Hud.Btn(new Rect(((Rect)(ref r)).xMax - 48f, ((Rect)(ref r)).y + 12f, 34f, 28f), "X", Hud.Button))
			{
				Toggle();
				return;
			}
			num4 += 38f;
			DrawSearchBox(new Rect(num3, num4, num5 - 210f, 30f), current, mouse);
			if (Hud.Btn(new Rect(((Rect)(ref r)).xMax - 190f, num4 + 3f, 174f, 24f), (_showDone ? "[x]" : "[  ]") + L.T("  Show completed", "  إظهار المكتملة"), Hud.Tab))
			{
				_showDone = !_showDone;
				_scrollRow = 0;
			}
			num4 += 40f;
			float num6 = num3;
			string[] tabs = _tabs;
			foreach (string text in tabs)
			{
				float num7 = Hud.Measure(TabName(text), Hud.Tab).x + 18f;
				if (num6 + num7 > num3 + num5)
				{
					break;
				}
				if (Hud.Btn(new Rect(num6, num4, num7, 26f), TabName(text), (text == _tab) ? Hud.TabOn : Hud.Tab))
				{
					_tab = text;
					_scrollRow = 0;
				}
				num6 += num7 + 4f;
			}
			num4 += 34f;
			List<Entry> list = Filtered().ToList();
			Rect view = default(Rect);
			((Rect)(ref view))..ctor(num3, num4, num5, ((Rect)(ref r)).yMax - num4 - 36f);
			int num8 = Mathf.Max(1, (int)(((Rect)(ref view)).height / 62f));
			int num9 = Mathf.Max(0, list.Count - num8);
			HandleScrolling(current, mouse, view, num8, num9, list.Count);
			_scrollRow = Mathf.Clamp(_scrollRow, 0, num9);
			float num10 = ((Rect)(ref view)).width - 10f - 8f;
			for (int j = 0; j < num8 && _scrollRow + j < list.Count; j++)
			{
				DrawRow(list[_scrollRow + j], new Rect(((Rect)(ref view)).x, ((Rect)(ref view)).y + (float)j * 62f, num10, 58f));
			}
			if (list.Count == 0)
			{
				Hud.Label(new Rect(((Rect)(ref view)).x + 10f, ((Rect)(ref view)).y + 10f, ((Rect)(ref view)).width - 20f, 24f), (_search.Length > 0) ? L.T("No quests match \"" + _search + "\"", "لا توجد مهام تطابق \"" + _search + "\"") : L.T("No quests here", "لا توجد مهام هنا"), Hud.RowDesc, Hud.GreyColor);
			}
			if (num9 > 0)
			{
				DrawScrollbar(ScrollbarRect(view), num8, list.Count);
			}
			Hud.Label(new Rect(num3, ((Rect)(ref r)).yMax - 30f, num5, 22f), L.T($"{list.Count} quests  ·  Scroll with the mouse wheel  ·  Tip: hover any quest or locked skin in the game's menus and press [{Plugin.Cfg.PinKey.Value}]  ·  [Esc] close", $"{list.Count} مهمة  ·  استخدم عجلة الفأرة للتمرير  ·  نصيحة: مرر فوق أي مهمة أو مظهر مقفل في قوائم اللعبة واضغط [{Plugin.Cfg.PinKey.Value}]  ·  [Esc] إغلاق"), Hud.RowDesc, Hud.GreyColor);
		}

		private static void DrawSearchBox(Rect box, Event e, Vector2 mouse)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			if ((int)e.type == 0 && e.button == 0)
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref box)).xMax - 28f, ((Rect)(ref box)).y, 28f, ((Rect)(ref box)).height);
				if (_search.Length > 0 && ((Rect)(ref val)).Contains(mouse))
				{
					_search = "";
					_scrollRow = 0;
					_searchFocused = true;
					e.Use();
				}
				else if (((Rect)(ref box)).Contains(mouse))
				{
					_searchFocused = true;
					e.Use();
				}
				else
				{
					_searchFocused = false;
				}
			}
			Hud.Fill(box, new Color(1f, 1f, 1f, _searchFocused ? 0.12f : 0.07f));
			Hud.Outline(box, (Color)(_searchFocused ? Hud.GoldColor : new Color(1f, 1f, 1f, 0.25f)), 1f);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(((Rect)(ref box)).x + 8f, ((Rect)(ref box)).y + 5f, ((Rect)(ref box)).width - 44f, ((Rect)(ref box)).height - 8f);
			if (_search.Length == 0 && !_searchFocused)
			{
				Hud.Label(r, L.T("Click here to search quests...", "انقر هنا للبحث عن مهمة..."), Hud.RowDesc, Hud.GreyColor);
				return;
			}
			bool flag = _searchFocused && (int)(Time.unscaledTime * 2f) % 2 == 0;
			Hud.Label(r, _search + (flag ? "|" : ""), Hud.Field, Color.white);
			if (_search.Length > 0)
			{
				Hud.Label(new Rect(((Rect)(ref box)).xMax - 22f, ((Rect)(ref box)).y + 5f, 18f, 20f), "x", Hud.RowTitle, Hud.GreyColor);
			}
		}

		private static void HandleTyping(Event e)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if (!_searchFocused || (int)e.type != 4)
			{
				return;
			}
			KeyCode keyCode = e.keyCode;
			if ((int)keyCode <= 13)
			{
				if ((int)keyCode == 8)
				{
					if (_search.Length > 0)
					{
						_search = _search.Substring(0, _search.Length - 1);
						_scrollRow = 0;
					}
					e.Use();
					return;
				}
				if ((int)keyCode == 13)
				{
					goto IL_006d;
				}
			}
			else if ((int)keyCode == 27 || (int)keyCode == 271)
			{
				goto IL_006d;
			}
			char character = e.character;
			if (character != 0 && !char.IsControl(character))
			{
				if (_search.Length < 40)
				{
					_search += character;
					_scrollRow = 0;
				}
				e.Use();
			}
			return;
			IL_006d:
			_searchFocused = false;
			e.Use();
		}

		private static Rect ScrollbarRect(Rect view)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref view)).xMax - 10f, ((Rect)(ref view)).y, 10f, ((Rect)(ref view)).height);
		}

		private static void HandleScrolling(Event e, Vector2 mouse, Rect view, int visible, int maxRow, int total)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000b: 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_0078: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Invalid comparison between Unknown and I4
			if ((int)e.type == 6 && ((Rect)(ref view)).Contains(mouse))
			{
				_scrollRow += ((e.delta.y > 0f) ? 2 : (-2));
				e.Use();
			}
			else if (maxRow != 0)
			{
				Rect val = ScrollbarRect(view);
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref val)).x - 6f, ((Rect)(ref val)).y, ((Rect)(ref val)).width + 12f, ((Rect)(ref val)).height);
				if ((int)e.type == 0 && e.button == 0 && ((Rect)(ref val2)).Contains(mouse))
				{
					_draggingScrollbar = true;
				}
				if ((int)e.type == 1)
				{
					_draggingScrollbar = false;
				}
				if (_draggingScrollbar && ((int)e.type == 0 || (int)e.type == 3))
				{
					_scrollRow = Mathf.RoundToInt(Mathf.InverseLerp(((Rect)(ref val)).y, ((Rect)(ref val)).yMax, mouse.y) * (float)maxRow);
					e.Use();
				}
			}
		}

		private static void DrawScrollbar(Rect bar, int visible, int total)
		{
			//IL_0000: 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_006d: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			Hud.Fill(bar, new Color(1f, 1f, 1f, 0.08f));
			float num = Mathf.Max(30f, ((Rect)(ref bar)).height * (float)visible / (float)total);
			float num2 = Mathf.Max(1, total - visible);
			float num3 = ((Rect)(ref bar)).y + (((Rect)(ref bar)).height - num) * ((float)_scrollRow / num2);
			Hud.Fill(new Rect(((Rect)(ref bar)).x, num3, ((Rect)(ref bar)).width, num), (Color)(_draggingScrollbar ? Hud.GoldColor : new Color(1f, 1f, 1f, 0.45f)));
		}

		private static IEnumerable<Entry> Filtered()
		{
			string s = (_search ?? "").Trim();
			foreach (Entry entry in _entries)
			{
				bool flag = Tracker.IsPinned(entry.Id);
				if ((!(_tab == "Tracked") || flag) && (!(_tab != "All") || !(_tab != "Tracked") || !(entry.Type != _tab)) && (!entry.Done || _showDone || flag) && (s.Length <= 0 || entry.Name.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0 || entry.Desc.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0))
				{
					yield return entry;
				}
			}
		}

		private static void DrawRow(Entry e, Rect r)
		{
			//IL_000c: 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_0024: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Tracker.IsPinned(e.Id);
			Hud.Fill(r, flag ? new Color(1f, 0.82f, 0.25f, 0.14f) : new Color(1f, 1f, 1f, 0.04f));
			float num = 96f;
			string text = e.Name + (e.Done ? L.T("  <size=12>(completed)</size>", "  (مكتملة)") : "") + ((e.Progress.Length > 0) ? ("   <size=12>(" + e.Progress + ")</size>") : "");
			Hud.Label(new Rect(((Rect)(ref r)).x + 10f, ((Rect)(ref r)).y + 5f, ((Rect)(ref r)).width - num - 24f, 22f), text, Hud.RowTitle, e.Done ? Hud.GreenColor : Color.white);
			Hud.Label(new Rect(((Rect)(ref r)).x + 10f, ((Rect)(ref r)).y + 27f, ((Rect)(ref r)).width - num - 24f, ((Rect)(ref r)).height - 28f), e.Desc, Hud.RowDesc, Hud.GreyColor);
			if (Hud.Btn(new Rect(((Rect)(ref r)).xMax - num - 8f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 30f) / 2f, num, 30f), flag ? L.T("Untrack", "إلغاء") : L.T("Track", "تتبع"), Hud.Button))
			{
				Tracker.TogglePin(e.Ach);
				Hud.Toast(flag ? L.T("Quest untracked", "تم إلغاء تتبع المهمة") : L.T("Quest tracked!", "تم تتبع المهمة!"));
			}
		}

		private static string TabName(string tab)
		{
			if (!L.Arabic)
			{
				return tab;
			}
			return tab switch
			{
				"All" => "الكل", 
				"Tracked" => "المتتبعة", 
				"General" => "عام", 
				"Characters" => "الشخصيات", 
				"Weapons" => "الأسلحة", 
				"Challenges" => "التحديات", 
				"Items" => "الأغراض", 
				"Tomes" => "الكتب", 
				"Skins" => "المظاهر", 
				"Hats" => "القبعات", 
				_ => tab, 
			};
		}

		private static string Strip(string s)
		{
			if (!string.IsNullOrEmpty(s))
			{
				return Regex.Replace(s, "<.*?>", "").Trim();
			}
			return "";
		}
	}
	[BepInPlugin("questtracker.megabonk", "Quest Tracker", "1.2.0")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "questtracker.megabonk";

		public const string Name = "Quest Tracker";

		public const string Version = "1.2.0";

		internal static ManualLogSource Logger;

		internal static Settings Cfg;

		internal static UpdateChecker Updates;

		public override void Load()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00f1: 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)
			Logger = ((BasePlugin)this).Log;
			Cfg = new Settings(((BasePlugin)this).Config);
			Tracker.LoadPins();
			((BasePlugin)this).AddComponent<TrackerBehaviour>();
			if (Cfg.CheckForUpdates.Value)
			{
				Updates = new UpdateChecker("Quest Tracker", 192, "1.2.0", 0, () => L.Arabic, (string s) => Rtl.Visual(s, GUI.skin.label, 0f));
				Updates.Start(delegate(string msg)
				{
					((BasePlugin)this).Log.LogInfo((object)msg);
				});
			}
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(81, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Quest Tracker");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.2.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Hover a quest and press ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(Cfg.PinKey.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to track it, or press ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(Cfg.PickerKey.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to open the quest list.");
			}
			log.LogInfo(val);
		}
	}
	public class TrackerBehaviour : MonoBehaviour
	{
		private float _nextTick;

		public TrackerBehaviour(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Update()
		{
			if (!(Time.unscaledTime < _nextTick))
			{
				_nextTick = Time.unscaledTime + 0.2f;
				Tracker.Tick();
			}
		}

		public void OnGUI()
		{
			Hud.Draw();
			try
			{
				Plugin.Updates?.OnGUI(!Tracker.InRun);
			}
			catch
			{
			}
		}
	}
	internal static class Rtl
	{
		private static readonly Dictionary<(string, int, int, int), string> Cache = new Dictionary<(string, int, int, int), string>();

		private static readonly Dictionary<char, char[]> Forms = new Dictionary<char, char[]>
		{
			['ء'] = new char[4] { 'ﺀ', '\0', '\0', '\0' },
			['آ'] = new char[4] { 'ﺁ', 'ﺂ', '\0', '\0' },
			['أ'] = new char[4] { 'ﺃ', 'ﺄ', '\0', '\0' },
			['ؤ'] = new char[4] { 'ﺅ', 'ﺆ', '\0', '\0' },
			['إ'] = new char[4] { 'ﺇ', 'ﺈ', '\0', '\0' },
			['ئ'] = new char[4] { 'ﺉ', 'ﺊ', 'ﺋ', 'ﺌ' },
			['ا'] = new char[4] { 'ﺍ', 'ﺎ', '\0', '\0' },
			['ب'] = new char[4] { 'ﺏ', 'ﺐ', 'ﺑ', 'ﺒ' },
			['ة'] = new char[4] { 'ﺓ', 'ﺔ', '\0', '\0' },
			['ت'] = new char[4] { 'ﺕ', 'ﺖ', 'ﺗ', 'ﺘ' },
			['ث'] = new char[4] { 'ﺙ', 'ﺚ', 'ﺛ', 'ﺜ' },
			['ج'] = new char[4] { 'ﺝ', 'ﺞ', 'ﺟ', 'ﺠ' },
			['ح'] = new char[4] { 'ﺡ', 'ﺢ', 'ﺣ', 'ﺤ' },
			['خ'] = new char[4] { 'ﺥ', 'ﺦ', 'ﺧ', 'ﺨ' },
			['د'] = new char[4] { 'ﺩ', 'ﺪ', '\0', '\0' },
			['ذ'] = new char[4] { 'ﺫ', 'ﺬ', '\0', '\0' },
			['ر'] = new char[4] { 'ﺭ', 'ﺮ', '\0', '\0' },
			['ز'] = new char[4] { 'ﺯ', 'ﺰ', '\0', '\0' },
			['س'] = new char[4] { 'ﺱ', 'ﺲ', 'ﺳ', 'ﺴ' },
			['ش'] = new char[4] { 'ﺵ', 'ﺶ', 'ﺷ', 'ﺸ' },
			['ص'] = new char[4] { 'ﺹ', 'ﺺ', 'ﺻ', 'ﺼ' },
			['ض'] = new char[4] { 'ﺽ', 'ﺾ', 'ﺿ', 'ﻀ' },
			['ط'] = new char[4] { 'ﻁ', 'ﻂ', 'ﻃ', 'ﻄ' },
			['ظ'] = new char[4] { 'ﻅ', 'ﻆ', 'ﻇ', 'ﻈ' },
			['ع'] = new char[4] { 'ﻉ', 'ﻊ', 'ﻋ', 'ﻌ' },
			['غ'] = new char[4] { 'ﻍ', 'ﻎ', 'ﻏ', 'ﻐ' },
			['ـ'] = new char[4] { 'ـ', 'ـ', 'ـ', 'ـ' },
			['ف'] = new char[4] { 'ﻑ', 'ﻒ', 'ﻓ', 'ﻔ' },
			['ق'] = new char[4] { 'ﻕ', 'ﻖ', 'ﻗ', 'ﻘ' },
			['ك'] = new char[4] { 'ﻙ', 'ﻚ', 'ﻛ', 'ﻜ' },
			['ل'] = new char[4] { 'ﻝ', 'ﻞ', 'ﻟ', 'ﻠ' },
			['م'] = new char[4] { 'ﻡ', 'ﻢ', 'ﻣ', 'ﻤ' },
			['ن'] = new char[4] { 'ﻥ', 'ﻦ', 'ﻧ', 'ﻨ' },
			['ه'] = new char[4] { 'ﻩ', 'ﻪ', 'ﻫ', 'ﻬ' },
			['و'] = new char[4] { 'ﻭ', 'ﻮ', '\0', '\0' },
			['ى'] = new char[4] { 'ﻯ', 'ﻰ', '\0', '\0' },
			['ي'] = new char[4] { 'ﻱ', 'ﻲ', 'ﻳ', 'ﻴ' }
		};

		private static readonly Dictionary<char, (char Isolated, char Final)> LamAlef = new Dictionary<char, (char, char)>
		{
			['آ'] = ('ﻵ', 'ﻶ'),
			['أ'] = ('ﻷ', 'ﻸ'),
			['إ'] = ('ﻹ', 'ﻺ'),
			['ا'] = ('ﻻ', 'ﻼ')
		};

		private const char Lam = 'ل';

		public static bool HasArabic(string s)
		{
			return NeedsShaping(s);
		}

		public static string Visual(string text, GUIStyle style, float width)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected I4, but got Unknown
			//IL_0081: 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_008f: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (!HasArabic(text))
			{
				return text;
			}
			bool flag = style.wordWrap && width > 1f;
			(string, int, int, int) key = (text, flag ? ((int)width) : 0, style.fontSize, (int)style.fontStyle);
			if (Cache.TryGetValue(key, out var value))
			{
				return value;
			}
			string text2 = Shape(text);
			List<string> list = new List<string>();
			string[] array = text2.Split('\n');
			foreach (string text3 in array)
			{
				if (!flag)
				{
					list.Add(text3);
					continue;
				}
				GUIStyle val = new GUIStyle(style)
				{
					wordWrap = false
				};
				string[] array2 = text3.Split(' ');
				StringBuilder stringBuilder = new StringBuilder();
				string[] array3 = array2;
				foreach (string text4 in array3)
				{
					string text5 = ((stringBuilder.Length == 0) ? text4 : (stringBuilder?.ToString() + " " + text4));
					if (stringBuilder.Length > 0 && val.CalcSize(new GUIContent(Reverse(text5))).x > width)
					{
						list.Add(stringBuilder.ToString());
						stringBuilder.Clear().Append(text4);
					}
					else
					{
						stringBuilder.Clear().Append(text5);
					}
				}
				list.Add(stringBuilder.ToString());
			}
			StringBuilder stringBuilder2 = new StringBuilder();
			for (int k = 0; k < list.Count; k++)
			{
				if (k > 0)
				{
					stringBuilder2.Append('\n');
				}
				stringBuilder2.Append(Reverse(list[k]));
			}
			if (Cache.Count > 2048)
			{
				Cache.Clear();
			}
			return Cache[key] = stringBuilder2.ToString();
		}

		private static string Reverse(string s)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < s.Length; i++)
			{
				if (s[i] == '<')
				{
					int num = s.IndexOf('>', i + 1);
					if (num > i && num - i < 80)
					{
						list.Add(s.Substring(i, num - i + 1));
						i = num;
						continue;
					}
				}
				list.Add(s[i].ToString());
			}
			list.Reverse();
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			foreach (string item in list)
			{
				stringBuilder.Append((item.Length > 1 && item.StartsWith("<")) ? FlipTag(item) : item);
			}
			return stringBuilder.ToString();
		}

		private static string FlipTag(string tag)
		{
			bool flag = tag.StartsWith("</");
			int num = ((!flag) ? 1 : 2);
			int num2 = tag.IndexOfAny(new char[3] { '=', ' ', '>' }, num);
			string text = tag.Substring(num, num2 - num);
			if ((!(text == "b") && !(text == "i")) || 1 == 0)
			{
				return "";
			}
			if (!flag)
			{
				return "</" + text + ">";
			}
			return "<" + text + ">";
		}

		public static bool NeedsShaping(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return false;
			}
			foreach (char c in s)
			{
				if (c >= 'ء' && c <= 'ي')
				{
					return true;
				}
			}
			return false;
		}

		public static bool ContainsArabic(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return false;
			}
			foreach (char c in s)
			{
				if ((c >= '\u0600' && c <= 'ۿ') || (c >= 'ﹰ' && c <= '\ufeff'))
				{
					return true;
				}
			}
			return false;
		}

		public static string Shape(string s)
		{
			bool[] tag = MarkTags(s);
			string s2 = JoinLetters(s, tag);
			return FixDirection(s2, MarkTags(s2));
		}

		private static string JoinLetters(string s, bool[] tag)
		{
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			for (int i = 0; i < s.Length; i++)
			{
				char c = s[i];
				if (tag[i] || !Forms.TryGetValue(c, out var value))
				{
					stringBuilder.Append(c);
					continue;
				}
				int num = Neighbour(s, tag, i, -1);
				int num2 = Neighbour(s, tag, i, 1);
				bool flag = num >= 0 && JoinsForward(s[num]);
				if (c == 'ل' && num2 >= 0 && LamAlef.TryGetValue(s[num2], out (char, char) value2) && OnlyTransparentBetween(s, tag, i, num2))
				{
					stringBuilder.Append(flag ? value2.Item2 : value2.Item1);
					for (int j = i + 1; j < num2; j++)
					{
						stringBuilder.Append(s[j]);
					}
					i = num2;
				}
				else
				{
					bool num3 = num2 >= 0 && JoinsBackward(s[num2]);
					bool flag2 = flag && value[1] != '\0';
					bool flag3 = num3 && value[2] != '\0';
					char value3 = ((flag2 && flag3 && value[3] != 0) ? value[3] : (flag2 ? value[1] : (flag3 ? value[2] : value[0])));
					stringBuilder.Append(value3);
				}
			}
			return stringBuilder.ToString();
		}

		private static bool JoinsForward(char c)
		{
			if (Forms.TryGetValue(c, out var value))
			{
				return value[2] != '\0';
			}
			return false;
		}

		private static bool JoinsBackward(char c)
		{
			if (Forms.TryGetValue(c, out var value))
			{
				return value[1] != '\0';
			}
			return false;
		}

		private static bool IsTransparent(char c)
		{
			if (c < '\u064b' || c > '\u065f')
			{
				return c == '\u0670';
			}
			return true;
		}

		private static int Neighbour(string s, bool[] tag, int i, int step)
		{
			for (int j = i + step; j >= 0 && j < s.Length; j += step)
			{
				if (!tag[j] && !IsTransparent(s[j]))
				{
					return j;
				}
			}
			return -1;
		}

		private static bool OnlyTransparentBetween(string s, bool[] tag, int a, int b)
		{
			for (int i = a + 1; i < b; i++)
			{
				if (!tag[i] && !IsTransparent(s[i]))
				{
					return false;
				}
			}
			return true;
		}

		private static string FixDirection(string s, bool[] tag)
		{
			char[] array = s.ToCharArray();
			int num = 0;
			while (num < array.Length)
			{
				if (tag[num])
				{
					num++;
				}
				else if (IsRunChar(array, num))
				{
					int num2 = num;
					for (int i = num + 1; i < array.Length && !tag[i] && !IsRtl(array[i]) && array[i] != '\n'; i++)
					{
						if (IsRunChar(array, i))
						{
							num2 = i;
						}
					}
					Array.Reverse(array, num, num2 - num + 1);
					num = num2 + 1;
				}
				else
				{
					array[num] = Mirror(array[num]);
					num++;
				}
			}
			return new string(array);
		}

		private static bool IsNumberAffix(char c)
		{
			switch (c)
			{
			case '%':
			case '+':
			case '-':
			case '٪':
				return true;
			default:
				return false;
			}
		}

		private static bool IsRunChar(char[] chars, int i)
		{
			char c = chars[i];
			if (IsLtrStrong(c))
			{
				return true;
			}
			if (!IsNumberAffix(c))
			{
				return false;
			}
			bool num = i > 0 && chars[i - 1] >= '0' && chars[i - 1] <= '9';
			bool flag = i + 1 < chars.Length && chars[i + 1] >= '0' && chars[i + 1] <= '9';
			return num || flag;
		}

		private static bool IsRtl(char c)
		{
			if (c < '\u0600' || c > 'ۿ')
			{
				if (c >= 'ﹰ')
				{
					return c <= '\ufeff';
				}
				return false;
			}
			return true;
		}

		private static bool IsLtrStrong(char c)
		{
			if ((c < '0' || c > '9') && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z'))
			{
				if (c >= 'À')
				{
					return c <= 'ɏ';
				}
				return false;
			}
			return true;
		}

		private static char Mirror(char c)
		{
			return c switch
			{
				'(' => ')', 
				')' => '(', 
				'[' => ']', 
				']' => '[', 
				'{' => '}', 
				'}' => '{', 
				'«' => '»', 
				'»' => '«', 
				_ => c, 
			};
		}

		private static bool[] MarkTags(string s)
		{
			bool[] array = new bool[s.Length];
			for (int i = 0; i < s.Length; i++)
			{
				if (s[i] != '<' || i + 1 >= s.Length)
				{
					continue;
				}
				char c = s[i + 1];
				if ((!char.IsLetter(c) || c >= '\u0080') && c != '/' && c != '#')
				{
					continue;
				}
				int num = s.IndexOf('>', i + 1);
				if (num >= 0 && num - i <= 80 && s.IndexOf('<', i + 1, num - i - 1) < 0)
				{
					for (int j = i; j <= num; j++)
					{
						array[j] = true;
					}
					i = num;
				}
			}
			return array;
		}
	}
	internal static class L
	{
		private static bool _arabic;

		private static int _checkedFrame = -1;

		private static bool _looked;

		private static PropertyInfo _arabicMode;

		private static bool _alwaysArabic;

		public static bool Arabic
		{
			get
			{
				string value = Plugin.Cfg.Language.Value;
				if (value == "Arabic")
				{
					return true;
				}
				if (value == "English")
				{
					return false;
				}
				if (Time.frameCount == _checkedFrame)
				{
					return _arabic;
				}
				_checkedFrame = Time.frameCount;
				try
				{
					if (!_looked)
					{
						_looked = true;
						if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("arabic.megabonk", out var value2))
						{
							_arabicMode = (value2.Instance?.GetType().Assembly.GetType("MegabonkArabic.Plugin"))?.GetProperty("ArabicOn", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
							_alwaysArabic = _arabicMode == null;
						}
					}
					_arabic = _alwaysArabic || (_arabicMode != null && (bool)_arabicMode.GetValue(null));
				}
				catch
				{
					_arabic = false;
				}
				return _arabic;
			}
		}

		public static string T(string english, string arabic)
		{
			if (!Arabic)
			{
				return english;
			}
			return arabic;
		}
	}
	internal class Settings
	{
		public const float DefaultPosX = 0.012f;

		public const float DefaultPosY = 0.36f;

		public const float DefaultScale = 1f;

		public readonly ConfigEntry<KeyCode> PinKey;

		public readonly ConfigEntry<KeyCode> PickerKey;

		public readonly ConfigEntry<KeyCode> HudKey;

		public readonly ConfigEntry<KeyCode> LayoutKey;

		public readonly ConfigEntry<KeyCode> DumpKey;

		public readonly ConfigEntry<float> PosX;

		public readonly ConfigEntry<float> PosY;

		public readonly ConfigEntry<float> Scale;

		public readonly ConfigEntry<float> Opacity;

		public readonly ConfigEntry<bool> ShowHud;

		public readonly ConfigEntry<bool> ShowInMenus;

		public readonly ConfigEntry<bool> ClickToTrack;

		public readonly ConfigEntry<float> HideFailedAfter;

		public readonly ConfigEntry<float> HideCompletedAfter;

		public readonly ConfigEntry<string> Language;

		public readonly ConfigEntry<bool> CheckForUpdates;

		public readonly ConfigEntry<int> MaxPinned;

		public readonly ConfigEntry<string> Pinned;

		public readonly ConfigEntry<string> TimerOverrides;

		private readonly ConfigFile _file;

		public void Save()
		{
			_file.Save();
		}

		public Settings(ConfigFile cfg)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Expected O, but got Unknown
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Expected O, but got Unknown
			_file = cfg;
			PinKey = cfg.Bind<KeyCode>("Keys", "TrackHoveredQuest", (KeyCode)116, "Hover a quest (Quests menu, main-menu quests, a locked skin or a locked unlock) and press this key to track or untrack it.");
			PickerKey = cfg.Bind<KeyCode>("Keys", "OpenQuestList", (KeyCode)288, "Opens the quest list so you can pick quests to track from anywhere.");
			HudKey = cfg.Bind<KeyCode>("Keys", "ToggleTracker", (KeyCode)287, "Shows or hides the tracker panel.");
			LayoutKey = cfg.Bind<KeyCode>("Keys", "MoveResizeTracker", (KeyCode)289, "Layout mode: drag the panel to move it, scroll or drag its corner to resize. Press again (or Esc) when done.");
			DumpKey = cfg.Bind<KeyCode>("Keys", "ExportQuestList", (KeyCode)290, "Writes every quest and its progress to BepInEx/QuestTracker_quests.tsv (handy for bug reports).");
			PosX = cfg.Bind<float>("Panel", "PositionX", 0.012f, new ConfigDescription("Left edge of the panel, as a share of screen width (0 = left, 1 = right). Easier: press F8 in game and drag it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PosY = cfg.Bind<float>("Panel", "PositionY", 0.36f, new ConfigDescription("Top edge of the panel, as a share of screen height (0 = top, 1 = bottom).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Scale = cfg.Bind<float>("Panel", "Size", 1f, new ConfigDescription("Size of the panel (1 = default). It also scales with your screen resolution.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>()));
			Opacity = cfg.Bind<float>("Panel", "BackgroundOpacity", 0.8f, new ConfigDescription("How dark the panel background is.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ShowHud = cfg.Bind<bool>("Panel", "Visible", true, "Whether the tracker panel is shown (also toggled in game with the ToggleTracker key).");
			ShowInMenus = cfg.Bind<bool>("Panel", "ShowInMenus", true, "Also show tracked quests while in the main menu.");
			ClickToTrack = cfg.Bind<bool>("Panel", "ClickToTrack", true, "Double-clicking a main-menu quest, a locked skin or a locked unlock also tracks it.");
			HideFailedAfter = cfg.Bind<float>("Panel", "HideFailedAfterSeconds", 8f, new ConfigDescription("A failed quest disappears from the panel after this many seconds (it stays tracked and comes back on the next stage or run). 0 = never hide.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
			HideCompletedAfter = cfg.Bind<float>("Panel", "HideCompletedAfterSeconds", 8f, new ConfigDescription("A completed quest disappears from the panel after this many seconds (remove it for good in F8 layout mode). 0 = never hide.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
			Language = cfg.Bind<string>("Panel", "Language", "Auto", new ConfigDescription("Language of the tracker's own labels. Auto = Arabic when the game is set to Arabic (Megabonk Arabic mod).", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Auto", "English", "Arabic" }), Array.Empty<object>()));
			CheckForUpdates = cfg.Bind<bool>("General", "CheckForUpdates", true, "Once per launch, ask Nexus if a newer Quest Tracker is out and show a small notice in the menus. Nothing is downloaded.");
			MaxPinned = cfg.Bind<int>("Tracking", "MaxTrackedQuests", 3, new ConfigDescription("How many quests you can track at once.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>()));
			Pinned = cfg.Bind<string>("Tracking", "TrackedQuests", "", "Internal names of the quests you are tracking (managed by the mod, no need to edit).");
			TimerOverrides = cfg.Bind<string>("Tracking", "TimerOverrides", "", "Advanced: force a timer for a quest. Format: questName=boss:30, otherQuest=stage:360 (boss = timer starts when the boss spawns, stage = timer starts when the stage starts, values in seconds).");
			cfg.SaveOnConfigSet = false;
			cfg.Save();
		}
	}
	internal enum TimerAnchor
	{
		None,
		Stage,
		Boss,
		Info
	}
	internal enum QuestStatus
	{
		Idle,
		InProgress,
		OnTrack,
		Hurry,
		Failed,
		Success,
		Complete,
		NotThisStage
	}
	internal enum HoverKind
	{
		KeyOnly,
		Clickable
	}
	internal class TrackedQuest
	{
		public string Id;

		public MyAchievement Ach;

		public string Title = "";

		public string Description = "";

		public bool HasCount;

		public int Current;

		public int Target;

		public int RunStartValue = -1;

		public float Progress;

		public TimerAnchor Anchor;

		public float LimitSeconds;

		public bool FirstStageOnly;

		public bool NoDamage;

		public bool WasCompleteWhenPinned;

		public bool FailedThisStage;

		public bool SucceededThisRun;

		public QuestStatus Status;

		public string StatusText = "";

		public string TimerText = "";

		public float TimerFraction = -1f;

		public float FlashUntil;

		public ECharacter? RequiredCharacter;

		public string RequiredCharacterName;

		public bool CharacterResolved;

		public float FinishedAt = -1f;

		public QuestStatus FinishedStatus;
	}
	internal static class Tracker
	{
		public static readonly List<TrackedQuest> Pinned = new List<TrackedQuest>();

		private static MyAchievement _hovered;

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

		private static float _stageStart = -1f;

		private static float _bossStart = -1f;

		private static bool _bossDefeated;

		private static float _bossKillSeconds = -1f;

		private static bool _loggedError;

		private static readonly Regex TimeRx = new Regex("(\\d+(?:[.,]\\d+)?)\\s*(seconds?|secs?|minutes?|mins?|s\\b|m\\b|ثانية|ثوان|ثواني|دقيقة|دقائق)", RegexOptions.IgnoreCase | RegexOptions.Compiled);

		private static IntPtr _runPtr;

		private static int _stage = -1;

		private static List<(string Name, ECharacter Character)> _characterNames;

		public static string HoveredId { get; private set; }

		public static HoverKind HoveredKind { get; private set; }

		public static bool InRun { get; private set; }

		public static int StageIndex { get; private set; }

		public static IReadOnlyDictionary<string, MyAchievement> All
		{
			get
			{
				if (_all.Count == 0)
				{
					LoadAll();
				}
				return _all;
			}
		}

		public static void LoadAll()
		{
			Dictionary<string, MyAchievement> dictionary = new Dictionary<string, MyAchievement>();
			try
			{
				foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<MyAchievement>()))
				{
					MyAchievement val = ((Il2CppObjectBase)item).TryCast<MyAchievement>();
					if (!((Object)(object)val == (Object)null) && val.isEnabled && !string.IsNullOrEmpty(val.internalName))
					{
						dictionary[val.internalName] = val;
					}
				}
			}
			catch (Exception e)
			{
				LogOnce("Could not read the quest list", e);
			}
			_all = dictionary;
			foreach (TrackedQuest item2 in Pinned)
			{
				if ((Object)(object)item2.Ach == (Object)null && _all.TryGetValue(item2.Id, out var value))
				{
					Bind(item2, value);
				}
			}
		}

		public static void LoadPins()
		{
			Pinned.Clear();
			string[] array = Plugin.Cfg.Pinned.Value.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
			foreach (string text in array)
			{
				Pinned.Add(new TrackedQuest
				{
					Id = text,
					Title = text
				});
			}
		}

		private static void SavePins()
		{
			Plugin.Cfg.Pinned.Value = string.Join(",", Pinned.Select((TrackedQuest p) => p.Id));
			Plugin.Cfg.Save();
		}

		public static bool IsPinned(string id)
		{
			return Pinned.Any((TrackedQuest p) => p.Id == id);
		}

		public static void TogglePin(MyAchievement a)
		{
			if ((Object)(object)a == (Object)null)
			{
				return;
			}
			string id = a.internalName;
			TrackedQuest trackedQuest = Pinned.FirstOrDefault((TrackedQuest p) => p.Id == id);
			if (trackedQuest != null)
			{
				Pinned.Remove(trackedQuest);
			}
			else
			{
				while (Pinned.Count >= Math.Max(1, Plugin.Cfg.MaxPinned.Value))
				{
					Pinned.RemoveAt(0);
				}
				TrackedQuest trackedQuest2 = new TrackedQuest
				{
					Id = id
				};
				Bind(trackedQuest2, a);
				trackedQuest2.WasCompleteWhenPinned = SafeIsCompleted(a);
				if (InRun)
				{
					trackedQuest2.RunStartValue = trackedQuest2.Current;
				}
				Pinned.Add(trackedQuest2);
			}
			SavePins();
		}

		public static void TogglePinHovered()
		{
			if ((Object)(object)_hovered != (Object)null)
			{
				TogglePin(_hovered);
			}
		}

		public static void SetHovered(MyAchievement a, HoverKind kind)
		{
			if (!((Object)(object)a == (Object)null))
			{
				_hovered = a;
				HoveredId = a.internalName;
				HoveredKind = kind;
			}
		}

		public static void ClearHovered(MyAchievement a)
		{
			if ((Object)(object)a == (Object)null || a.internalName == HoveredId)
			{
				_hovered = null;
				HoveredId = null;
			}
		}

		public static void ClickTrack(MyAchievement a)
		{
			if (!((Object)(object)a == (Object)null) && Plugin.Cfg.ClickToTrack.Value)
			{
				bool num = IsPinned(a.internalName);
				TogglePin(a);
				Hud.Toast(num ? L.T("Quest untracked", "تم إلغاء تتبع المهمة") : L.T("Quest tracked!", "تم تتبع المهمة!"));
			}
		}

		private static void Bind(TrackedQuest q, MyAchievement a)
		{
			q.Ach = a;
			try
			{
				q.Title = Clean(a.GetDisplayName());
				string text = Clean(a.GetUnlockRequirement());
				if (string.IsNullOrWhiteSpace(text))
				{
					text = Clean(a.GetUnlockDescription());
				}
				q.Description = text;
			}
			catch (Exception e)
			{
				LogOnce("Could not read quest text", e);
			}
			ParseRules(q);
			q.WasCompleteWhenPinned = SafeIsCompleted(a);
			ReadValues(q);
		}

		public static void OnRunStarted()
		{
			StageIndex = 0;
			foreach (TrackedQuest item in Pinned)
			{
				item.SucceededThisRun = false;
				item.RunStartValue = -1;
			}
		}

		public static void OnStageStarted()
		{
			StageIndex++;
			_stageStart = Time.time;
			_bossStart = -1f;
			_bossDefeated = false;
			_bossKillSeconds = -1f;
			foreach (TrackedQuest item in Pinned)
			{
				item.FailedThisStage = false;
			}
		}

		public static void OnBossSpawned()
		{
			if (_bossStart < 0f)
			{
				_bossStart = Time.time;
			}
		}

		public static void OnBossDefeated()
		{
			_bossDefeated = true;
			if (_bossKillSeconds < 0f && _bossStart >= 0f)
			{
				_bossKillSeconds = Time.time - _bossStart;
			}
		}

		public static void Tick()
		{
			try
			{
				PollGame();
			}
			catch (Exception e)
			{
				InRun = false;
				LogOnce("Could not read run state", e);
			}
			if (Pinned.Any((TrackedQuest p) => (Object)(object)p.Ach == (Object)null))
			{
				LoadAll();
			}
			foreach (TrackedQuest item in Pinned)
			{
				if ((Object)(object)item.Ach == (Object)null)
				{
					item.Status = QuestStatus.Idle;
					item.StatusText = L.T("Quest not found in this game version", "المهمة غير موجودة في هذه النسخة من اللعبة");
					continue;
				}
				try
				{
					Update(item);
				}
				catch (Exception e2)
				{
					LogOnce("Could not update a tracked quest", e2);
				}
				QuestStatus questStatus = (IsFinished(item.Status) ? ((item.Status == QuestStatus.Failed) ? QuestStatus.Failed : QuestStatus.Complete) : QuestStatus.Idle);
				if (questStatus == QuestStatus.Idle)
				{
					item.FinishedAt = -1f;
				}
				else if (item.FinishedAt < 0f || item.FinishedStatus != questStatus)
				{
					item.FinishedAt = Time.unscaledTime;
					item.FinishedStatus = questStatus;
				}
			}
		}

		private static void PollGame()
		{
			GameManager instance = GameManager.Instance;
			bool inRun = InRun;
			InRun = (Object)(object)instance != (Object)null;
			if (!InRun)
			{
				if (inRun)
				{
					_stageStart = -1f;
					_bossStart = -1f;
					_bossDefeated = false;
				}
				_runPtr = IntPtr.Zero;
				_stage = -1;
				return;
			}
			if (((Il2CppObjectBase)instance).Pointer != _runPtr)
			{
				bool num = !inRun && _runPtr == IntPtr.Zero && Time.timeSinceLevelLoad > 5f;
				_runPtr = ((Il2CppObjectBase)instance).Pointer;
				_stage = -1;
				OnRunStarted();
				if (num)
				{
					_stageStart = Time.time;
				}
			}
			int index = MapController.index;
			if (index != _stage)
			{
				_stage = index;
				OnStageStarted();
				StageIndex = index + 1;
			}
			EnemyManager instance2 = EnemyManager.Instance;
			if (!((Object)(object)instance2 == (Object)null))
			{
				List<Enemy> stageBosses = instance2.stageBosses;
				if (_bossStart < 0f && !_bossDefeated && stageBosses != null && stageBosses.Count > 0)
				{
					OnBossSpawned();
				}
				if (_bossStart >= 0f && !_bossDefeated && instance2.stageBossIsDead)
				{
					OnBossDefeated();
				}
			}
		}

		private static bool IsFinished(QuestStatus s)
		{
			if ((uint)(s - 4) <= 2u)
			{
				return true;
			}
			return false;
		}

		public static bool IsHidden(TrackedQuest q)
		{
			if (q.FinishedAt < 0f || !IsFinished(q.Status))
			{
				return false;
			}
			float num = ((q.FinishedStatus == QuestStatus.Failed) ? Plugin.Cfg.HideFailedAfter.Value : Plugin.Cfg.HideCompletedAfter.Value);
			if (num > 0f)
			{
				return Time.unscaledTime - q.FinishedAt > num;
			}
			return false;
		}

		public static void Untrack(TrackedQuest q)
		{
			if (Pinned.Remove(q))
			{
				SavePins();
			}
		}

		private static void Update(TrackedQuest q)
		{
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			QuestStatus status = q.Status;
			ReadValues(q);
			if (InRun && q.RunStartValue < 0)
			{
				q.RunStartValue = q.Current;
			}
			q.TimerText = "";
			q.TimerFraction = -1f;
			if (SafeIsCompleted(q.Ach))
			{
				q.Status = QuestStatus.Complete;
				q.StatusText = (q.WasCompleteWhenPinned ? L.T("Already completed", "مكتملة مسبقا") : L.T("COMPLETE!", "اكتملت!"));
				Flash(q, status);
				return;
			}
			if (q.SucceededThisRun)
			{
				q.Status = QuestStatus.Success;
				q.StatusText = L.T("Done! It unlocks when the game saves your progress", "تم! ستفتح عندما تحفظ اللعبة تقدمك");
				Flash(q, status);
				return;
			}
			if (!q.CharacterResolved)
			{
				ResolveCharacter(q);
			}
			if (!InRun)
			{
				q.Status = QuestStatus.Idle;
				string text = (q.HasCount ? L.T($"{Math.Max(0, q.Target - q.Current):N0} to go", $"متبقي {Math.Max(0, q.Target - q.Current):N0}") : L.T("Start a run to track this quest", "ابدأ جولة لتتبع هذه المهمة"));
				q.StatusText = (q.RequiredCharacter.HasValue ? L.T("Play as " + q.RequiredCharacterName + "  ·  " + text, "العب بشخصية " + q.RequiredCharacterName + "  ·  " + text) : text);
				return;
			}
			if (q.RequiredCharacter.HasValue)
			{
				ECharacter? val = CurrentCharacter();
				if (val.HasValue && val.Value != q.RequiredCharacter.Value)
				{
					q.Status = QuestStatus.Failed;
					q.StatusText = L.T("Needs " + q.RequiredCharacterName + ": won't count this run", "تحتاج " + q.RequiredCharacterName + ": لن تحتسب هذه الجولة");
					return;
				}
			}
			if (q.FirstStageOnly && StageIndex > 1)
			{
				q.Status = QuestStatus.NotThisStage;
				q.StatusText = L.T("Only counts on the first stage", "تحتسب في المرحلة الأولى فقط");
				return;
			}
			if (q.NoDamage && SafeTookDamage())
			{
				q.Status = QuestStatus.Failed;
				q.StatusText = L.T("FAILED: you took damage this run", "فشلت: تلقيت ضررا في هذه الجولة");
				return;
			}
			switch (q.Anchor)
			{
			case TimerAnchor.Stage:
				UpdateTimer(q, _stageStart, L.T("Stage clock", "وقت المرحلة"));
				return;
			case TimerAnchor.Boss:
				if (_bossStart < 0f && !_bossDefeated)
				{
					q.Status = QuestStatus.InProgress;
					q.TimerText = FormatTime(q.LimitSeconds);
					q.StatusText = L.T("Waiting for the boss. You'll have " + FormatTime(q.LimitSeconds), "بانتظار الزعيم. أمامك " + FormatTime(q.LimitSeconds));
				}
				else
				{
					UpdateTimer(q, _bossStart, L.T("Boss fight", "قتال الزعيم"));
				}
				return;
			case TimerAnchor.Info:
				q.Status = QuestStatus.InProgress;
				q.TimerText = FormatTime(q.LimitSeconds);
				q.StatusText = L.T("Time limit: " + FormatTime(q.LimitSeconds), "الوقت المحدد: " + FormatTime(q.LimitSeconds));
				return;
			}
			q.Status = QuestStatus.InProgress;
			if (q.HasCount)
			{
				int value = Math.Max(0, q.Target - q.Current);
				int num = ((q.RunStartValue >= 0) ? Math.Max(0, q.Current - q.RunStartValue) : 0);
				q.StatusText = ((num > 0) ? L.T($"{value:N0} left  ·  +{num:N0} this run", $"متبقي {value:N0}  ·  +{num:N0} في هذه الجولة") : L.T($"{value:N0} left", $"متبقي {value:N0}"));
			}
			else
			{
				q.StatusText = (q.NoDamage ? L.T("No damage taken so far", "لم تتلق أي ضرر حتى الآن") : L.T("In progress", "قيد التنفيذ"));
			}
		}

		private static void UpdateTimer(TrackedQuest q, float start, string label)
		{
			if (start < 0f)
			{
				start = Time.time;
			}
			if (_bossDefeated && _bossKillSeconds >= 0f && (q.Anchor == TimerAnchor.Boss || MentionsBoss(q)))
			{
				bool flag = _bossKillSeconds <= q.LimitSeconds;
				q.TimerText = FormatTime(_bossKillSeconds);
				q.TimerFraction = (flag ? 1f : 0f