Decompiled source of Shadows of Doubt Tracker Control v0.5.0

BepInEx/plugins/Khundian-Shadows_of_Doubt_Tracker_Control/Khundian.SoD.TrackerControl.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Khundian.SoD.TrackerControl
{
	[BepInPlugin("Khundian.SoD.TrackerControl", "Shadows of Doubt Tracker Control", "0.5.0")]
	public sealed class Plugin : BasePlugin
	{
		public const string PluginGuid = "Khundian.SoD.TrackerControl";

		public const string PluginName = "Shadows of Doubt Tracker Control";

		public const string PluginVersion = "0.5.0";

		internal static ManualLogSource LogSrc;

		internal static Harmony Harmony;

		internal static ConfigFile Cfg;

		internal static ConfigEntry<bool> EnablePerTrackerMute;

		internal static ConfigEntry<string> MuteTrackerNamePatterns;

		internal static ConfigEntry<int> AudioMuteWindowMs;

		internal static ConfigEntry<bool> MuteUIPings;

		internal static bool TraceEnabled => false;

		public override void Load()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			LogSrc = ((BasePlugin)this).Log;
			Cfg = ((BasePlugin)this).Config;
			EnablePerTrackerMute = ((BasePlugin)this).Config.Bind<bool>("Mute", "EnablePerTrackerMute", true, "Block specific tracker toasts (and their SFX) by name pattern.");
			MuteTrackerNamePatterns = ((BasePlugin)this).Config.Bind<string>("Mute", "MuteTrackerNamePatterns", "", "Comma/semicolon-separated wildcard patterns of tracker locations to mute, e.g. \"City Hall*;William Parade\".");
			AudioMuteWindowMs = ((BasePlugin)this).Config.Bind<int>("Mute", "AudioMuteWindowMs", 100, "When a toast is muted, also suppress likely world SFX for this many ms near the player.");
			MuteUIPings = ((BasePlugin)this).Config.Bind<bool>("Mute", "MuteUIPings", true, "Attempt to mute matching 2D UI pings when we can identify the event.");
			Harmony = new Harmony("Khundian.SoD.TrackerControl");
			Harmony.PatchAll(typeof(TrackerMuter));
			Harmony.PatchAll(typeof(TrackerMuter.EnumeratorFilter));
			TrackerMuterWindow.BindConfig(Cfg);
			TrackerMuterWindow.Bootstrap();
			ManualLogSource logSrc = LogSrc;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Shadows of Doubt Tracker Control");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.5.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Muter=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(EnablePerTrackerMute.Value ? "ON" : "OFF");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" AudioMuteWindowMs=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(AudioMuteWindowMs.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms MuteUIPings=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MuteUIPings.Value ? "ON" : "OFF");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			logSrc.LogInfo(val);
		}

		public override bool Unload()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			Harmony.UnpatchSelf();
			ManualLogSource logSrc = LogSrc;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Shadows of Doubt Tracker Control");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" unloaded.");
			}
			logSrc.LogInfo(val);
			return true;
		}
	}
	[HarmonyPatch]
	internal static class TrackerMuter
	{
		[HarmonyPatch]
		internal static class EnumeratorFilter
		{
			[ThreadStatic]
			private static bool _reenter;

			private static MethodBase TargetMethod()
			{
				Type typeFromHandle = typeof(InterfaceController);
				Type[] nestedTypes = typeFromHandle.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic);
				foreach (Type type in nestedTypes)
				{
					if (type.Name.Contains("GameMessages", StringComparison.Ordinal))
					{
						MethodInfo methodInfo = AccessTools.Method(type, "MoveNext", (Type[])null, (Type[])null);
						if (methodInfo != null)
						{
							return methodInfo;
						}
					}
				}
				MethodInfo methodInfo2 = AccessTools.Method(typeFromHandle, "GameMessages", (Type[])null, (Type[])null);
				if (methodInfo2 != null)
				{
					return methodInfo2;
				}
				throw new MissingMethodException("InterfaceController.GameMessages() state machine not found.");
			}

			[HarmonyPostfix]
			private static void Postfix(object __instance, ref bool __result)
			{
				try
				{
					if (!Plugin.EnablePerTrackerMute.Value || _reenter)
					{
						return;
					}
					while (__result)
					{
						object currentGameMessage = GetCurrentGameMessage(__instance);
						if (currentGameMessage == null)
						{
							break;
						}
						string str = GetStr(currentGameMessage, "message");
						try
						{
							TrackerMuterWindow.NoteMovementFromMessage(str);
						}
						catch
						{
						}
						if (!ShouldMuteMessage(str))
						{
							break;
						}
						_reenter = true;
						try
						{
							MethodInfo methodInfo = AccessTools.Method(__instance.GetType(), "MoveNext", (Type[])null, (Type[])null);
							if (methodInfo == null)
							{
								break;
							}
							__result = (bool)(methodInfo.Invoke(__instance, Array.Empty<object>()) ?? ((object)false));
						}
						finally
						{
							_reenter = false;
						}
					}
				}
				catch
				{
				}
			}

			private static object? GetCurrentGameMessage(object state)
			{
				try
				{
					try
					{
						if (state is IEnumerator enumerator)
						{
							object current = enumerator.Current;
							if (current != null)
							{
								return current;
							}
						}
					}
					catch
					{
					}
					FieldInfo[] fields = state.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						Type fieldType = fieldInfo.FieldType;
						if (fieldType == null)
						{
							continue;
						}
						if (string.Equals(fieldType.Name, "GameMessage", StringComparison.Ordinal))
						{
							return fieldInfo.GetValue(state);
						}
						if (string.Equals(fieldInfo.Name, "current", StringComparison.OrdinalIgnoreCase))
						{
							object value = fieldInfo.GetValue(state);
							if (value != null)
							{
								return value;
							}
						}
					}
				}
				catch
				{
				}
				return null;
			}

			private static string GetStr(object gm, string fieldName)
			{
				try
				{
					return (gm.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(gm))?.ToString() ?? string.Empty;
				}
				catch
				{
					return string.Empty;
				}
			}
		}

		private sealed class RenderGuard
		{
			public double startMs;

			public int checks;
		}

		private static double _lastMuteStartMs = -1.0;

		private static Vector3 _lastMutePlayerPos = Vector3.zero;

		private static string _cachedPatternRaw = string.Empty;

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

		private static readonly Dictionary<int, RenderGuard> _renderGuards = new Dictionary<int, RenderGuard>();

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InterfaceController), "Update")]
		private static void IF_Update_Prefix(InterfaceController __instance)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			try
			{
				if (TrackerMuterWindow.IsOpen && Input.GetKeyDown((KeyCode)27))
				{
					TrackerMuterWindow.CloseUi();
					Input.ResetInputAxes();
				}
			}
			catch
			{
			}
			List<GameMessage> val = ((__instance != null) ? __instance.notificationQueue : null);
			if (val == null || val.Count == 0)
			{
				return;
			}
			bool value = Plugin.EnablePerTrackerMute.Value;
			int num = 0;
			for (int num2 = val.Count - 1; num2 >= 0; num2--)
			{
				GameMessage obj2 = val[num2];
				string text = ((obj2 != null) ? obj2.message : null) ?? string.Empty;
				try
				{
					TrackerMuterWindow.NoteMovementFromMessage(text);
				}
				catch
				{
				}
				if (value && ShouldMuteMessage(text))
				{
					val.RemoveAt(num2);
					num++;
				}
			}
			if (!value || num <= 0)
			{
				return;
			}
			_lastMuteStartMs = NowMs();
			Player val2 = FindPlayer();
			if ((Object)(object)val2 != (Object)null)
			{
				_lastMutePlayerPos = ((Component)val2).transform.position;
			}
			if (Plugin.TraceEnabled)
			{
				ManualLogSource logSrc = Plugin.LogSrc;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(58, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[TrackerMuter] Removed ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" toast(s) from queue. MuteWindow=");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(Plugin.AudioMuteWindowMs.Value);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ms");
				}
				logSrc.LogDebug(val3);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(AudioController), "PlayWorldOneShot")]
		private static bool Audio_PlayWorldOneShot_Prefix(AudioEvent eventPreset, Vector3 worldPosition, List<FMODParam> parameters, float volumeOverride = 1f)
		{
			//IL_0042: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.EnablePerTrackerMute.Value)
			{
				return true;
			}
			int value = Plugin.AudioMuteWindowMs.Value;
			if (value <= 0 || _lastMuteStartMs < 0.0)
			{
				return true;
			}
			double num = NowMs() - _lastMuteStartMs;
			if (num > (double)value)
			{
				return true;
			}
			if (Vector3.SqrMagnitude(worldPosition - _lastMutePlayerPos) <= 625f)
			{
				if (Plugin.TraceEnabled)
				{
					ManualLogSource logSrc = Plugin.LogSrc;
					bool flag = default(bool);
					BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(63, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TrackerMuter] Suppressed world SFX @ ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(worldPosition);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" within mute window (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)num);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms).");
					}
					logSrc.LogDebug(val);
				}
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(AudioController), "Play2DSound")]
		private static bool Audio_Play2DSound_Prefix(AudioEvent eventPreset, List<FMODParam> parameters, float volumeOverride = 1f)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			if (!Plugin.EnablePerTrackerMute.Value || !Plugin.MuteUIPings.Value)
			{
				return true;
			}
			int value = Plugin.AudioMuteWindowMs.Value;
			if (value <= 0 || _lastMuteStartMs < 0.0)
			{
				return true;
			}
			double num = NowMs() - _lastMuteStartMs;
			if (num > (double)value)
			{
				return true;
			}
			if (Plugin.TraceEnabled)
			{
				ManualLogSource logSrc = Plugin.LogSrc;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(61, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TrackerMuter] Suppressed 2D UI ping within mute window (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ms).");
				}
				logSrc.LogDebug(val);
			}
			return false;
		}

		private static bool ShouldMuteMessage(string msg)
		{
			if (string.IsNullOrWhiteSpace(msg))
			{
				return false;
			}
			if (msg.IndexOf("Movement Alert", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return false;
			}
			try
			{
				TrackerMuterWindow.NoteMovementFromMessage(msg);
			}
			catch
			{
			}
			List<string> patterns = GetPatterns();
			if (patterns.Count == 0)
			{
				return false;
			}
			string text = ExtractMovementLocation(msg);
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			foreach (string item in patterns)
			{
				if (text.IndexOf(item, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private static List<string> GetPatterns()
		{
			string text = Plugin.MuteTrackerNamePatterns.Value ?? "";
			if (text == _cachedPatternRaw)
			{
				return _cachedPatterns;
			}
			_cachedPatternRaw = text;
			_cachedPatterns.Clear();
			string[] array = text.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (!string.IsNullOrEmpty(text2))
				{
					_cachedPatterns.Add(text2.Replace("*", ""));
				}
			}
			return _cachedPatterns;
		}

		private static string ExtractMovementLocation(string message)
		{
			int num = message.IndexOf(':');
			if (num > 0)
			{
				return message.Substring(0, num).Trim();
			}
			return string.Empty;
		}

		private static Player? FindPlayer()
		{
			try
			{
				return Object.FindObjectOfType<Player>();
			}
			catch
			{
				return null;
			}
		}

		private static double NowMs()
		{
			return (DateTime.UtcNow - DateTime.UnixEpoch).TotalMilliseconds;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameMessageController), "OnEnable")]
		private static bool GM_OnEnable_Prefix(GameMessageController __instance)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Plugin.EnablePerTrackerMute.Value)
				{
					return true;
				}
				string text = TryGetInitialToastText(__instance);
				try
				{
					TrackerMuterWindow.NoteMovementFromMessage(text);
				}
				catch
				{
				}
				if (!ShouldMuteMessage(text))
				{
					return true;
				}
				_lastMuteStartMs = NowMs();
				Player val = FindPlayer();
				if ((Object)(object)val != (Object)null)
				{
					_lastMutePlayerPos = ((Component)val).transform.position;
				}
				Object.Destroy((Object)(object)((Component)__instance).gameObject);
				if (Plugin.TraceEnabled)
				{
					Plugin.LogSrc.LogDebug((object)"[TrackerMuter] Renderer kill-switch: destroyed muted toast in OnEnable.");
				}
				return false;
			}
			catch
			{
				return true;
			}
		}

		private static string TryGetInitialToastText(GameMessageController gmc)
		{
			try
			{
				object obj = ((object)gmc).GetType().GetField("messageText", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(gmc);
				if (obj != null)
				{
					string text = (obj.GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj))?.ToString() ?? string.Empty;
					if (!string.IsNullOrEmpty(text))
					{
						return text;
					}
				}
			}
			catch
			{
			}
			try
			{
				return gmc.displayMessage ?? string.Empty;
			}
			catch
			{
				return string.Empty;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMessageController), "OnEnable")]
		private static void GM_OnEnable_Postfix(GameMessageController __instance)
		{
			try
			{
				if (Plugin.EnablePerTrackerMute.Value)
				{
					int instanceID = ((Object)__instance).GetInstanceID();
					_renderGuards[instanceID] = new RenderGuard
					{
						startMs = NowMs(),
						checks = 0
					};
				}
			}
			catch
			{
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMessageController), "Update")]
		private static void GM_Update_Postfix(GameMessageController __instance)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Plugin.EnablePerTrackerMute.Value)
				{
					return;
				}
				int instanceID = ((Object)__instance).GetInstanceID();
				if (!_renderGuards.TryGetValue(instanceID, out RenderGuard value))
				{
					return;
				}
				value.checks++;
				double num = NowMs() - value.startMs;
				string text = TryGetInitialToastText(__instance);
				if (!string.IsNullOrEmpty(text))
				{
					try
					{
						TrackerMuterWindow.NoteMovementFromMessage(text);
					}
					catch
					{
					}
					if (ShouldMuteMessage(text))
					{
						_lastMuteStartMs = NowMs();
						Player val = FindPlayer();
						if ((Object)(object)val != (Object)null)
						{
							_lastMutePlayerPos = ((Component)val).transform.position;
						}
						Object.Destroy((Object)(object)((Component)__instance).gameObject);
						if (Plugin.TraceEnabled)
						{
							Plugin.LogSrc.LogDebug((object)"[TrackerMuter] Render guard: destroyed muted toast in Update.");
						}
						_renderGuards.Remove(instanceID);
						return;
					}
				}
				if (value.checks >= 8 || num >= 600.0)
				{
					_renderGuards.Remove(instanceID);
				}
				else
				{
					_renderGuards[instanceID] = value;
				}
			}
			catch
			{
			}
		}
	}
	internal static class UiCapture
	{
		private static bool _lastWant;

		private static bool _prevCursorVisible;

		private static CursorLockMode _prevCursorLock;

		private static bool _prevCrosshairVisible;

		private static bool _setPlayerTextInput;

		private static bool _prevPlayerTextInput;

		private static bool _weSetDesktop;

		private static bool _wePausedGame;

		private static bool _weDisabledMove;

		internal static bool IsInGameScene()
		{
			try
			{
				foreach (Canvas item in Object.FindObjectsOfType<Canvas>())
				{
					if (!((Object)(object)item == (Object)null))
					{
						GameObject gameObject = ((Component)item).gameObject;
						if (!((Object)(object)gameObject == (Object)null) && gameObject.activeInHierarchy && (((Object)gameObject).name ?? string.Empty).IndexOf("MenuCanvas", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							return false;
						}
					}
				}
			}
			catch
			{
			}
			try
			{
				return (Object)(object)Object.FindObjectOfType<Player>() != (Object)null;
			}
			catch
			{
				return false;
			}
		}

		internal static void Apply(bool want)
		{
			//IL_021c: 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_0236: Unknown result type (might be due to invalid IL or missing references)
			if (want == _lastWant)
			{
				if (want)
				{
					ForceCursor();
				}
				return;
			}
			_lastWant = want;
			InterfaceController val = Object.FindObjectOfType<InterfaceController>();
			Player val2 = Object.FindObjectOfType<Player>();
			bool flag = IsInGameScene();
			if (want)
			{
				_prevCursorVisible = Cursor.visible;
				_prevCursorLock = Cursor.lockState;
				if ((Object)(object)val != (Object)null && flag)
				{
					_prevCrosshairVisible = val.crosshairVisible;
					try
					{
						_prevPlayerTextInput = val.playerTextInputActive;
					}
					catch
					{
						_prevPlayerTextInput = false;
					}
					try
					{
						val.SetPlayerTextInput(true);
						_setPlayerTextInput = true;
					}
					catch
					{
						val.playerTextInputActive = true;
						_setPlayerTextInput = true;
					}
					try
					{
						val.SetCrosshairVisible(false);
					}
					catch
					{
						val.crosshairVisible = false;
					}
					try
					{
						SessionData val3 = Object.FindObjectOfType<SessionData>();
						if ((Object)(object)val3 != (Object)null)
						{
							val3.PauseGame(false, true, false);
							_wePausedGame = true;
						}
					}
					catch
					{
						_wePausedGame = false;
					}
					try
					{
						if ((Object)(object)val2 != (Object)null)
						{
							val2.EnablePlayerMovement(false, true);
							val2.EnablePlayerMouseLook(false, false);
							_weDisabledMove = true;
						}
					}
					catch
					{
						_weDisabledMove = false;
					}
					if (!val.desktopMode)
					{
						try
						{
							val.SetDesktopMode(true, false);
							_weSetDesktop = true;
						}
						catch
						{
							_weSetDesktop = false;
						}
					}
				}
				ForceCursor();
				return;
			}
			if ((Object)(object)val != (Object)null && flag)
			{
				if (_weSetDesktop && val.desktopMode)
				{
					try
					{
						val.SetDesktopMode(false, false);
					}
					catch
					{
					}
				}
				if (_setPlayerTextInput)
				{
					try
					{
						val.SetPlayerTextInput(_prevPlayerTextInput);
					}
					catch
					{
						val.playerTextInputActive = _prevPlayerTextInput;
					}
				}
				try
				{
					val.SetCrosshairVisible(_prevCrosshairVisible);
				}
				catch
				{
					val.crosshairVisible = _prevCrosshairVisible;
				}
				try
				{
					if (_wePausedGame)
					{
						SessionData val4 = Object.FindObjectOfType<SessionData>();
						if ((Object)(object)val4 != (Object)null)
						{
							val4.ResumeGame();
						}
					}
				}
				catch
				{
				}
				_wePausedGame = false;
				try
				{
					if ((Object)(object)val2 != (Object)null && _weDisabledMove)
					{
						val2.EnablePlayerMovement(true, true);
						val2.EnablePlayerMouseLook(true, false);
					}
				}
				catch
				{
				}
				_weDisabledMove = false;
			}
			_setPlayerTextInput = false;
			_weSetDesktop = false;
			try
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.EnablePlayerMovement(true, true);
					val2.EnablePlayerMouseLook(true, false);
				}
			}
			catch
			{
			}
			Cursor.visible = _prevCursorVisible;
			Cursor.lockState = _prevCursorLock;
			if (!flag)
			{
				if (!Cursor.visible)
				{
					Cursor.visible = true;
				}
				if ((int)Cursor.lockState != 0)
				{
					Cursor.lockState = (CursorLockMode)0;
				}
			}
		}

		internal static void Tick()
		{
			if (_lastWant)
			{
				ForceCursor();
			}
		}

		private static void ForceCursor()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!Cursor.visible)
			{
				Cursor.visible = true;
			}
			if ((int)Cursor.lockState != 0)
			{
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		private static void SafeLog(string msg)
		{
			try
			{
				if (Plugin.TraceEnabled)
				{
					Plugin.LogSrc.LogDebug((object)msg);
				}
			}
			catch
			{
			}
		}
	}
	public sealed class TrackerMuterWindow : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <SplitList>d__18 : IEnumerable<string>, IEnumerable, IEnumerator<string>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private string <>2__current;

			private int <>l__initialThreadId;

			private string raw;

			public string <>3__raw;

			private string[] <>7__wrap1;

			private int <>7__wrap2;

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

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

			[DebuggerHidden]
			public <SplitList>d__18(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

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

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_0086;
				}
				<>1__state = -1;
				if (string.IsNullOrWhiteSpace(raw))
				{
					return false;
				}
				string[] array = raw.Split(new char[2] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
				<>7__wrap1 = array;
				<>7__wrap2 = 0;
				goto IL_0094;
				IL_0086:
				<>7__wrap2++;
				goto IL_0094;
				IL_0094:
				if (<>7__wrap2 < <>7__wrap1.Length)
				{
					string text = <>7__wrap1[<>7__wrap2].Trim();
					if (text.Length > 0)
					{
						<>2__current = text;
						<>1__state = 1;
						return true;
					}
					goto IL_0086;
				}
				<>7__wrap1 = null;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

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

			[DebuggerHidden]
			IEnumerator<string> IEnumerable<string>.GetEnumerator()
			{
				<SplitList>d__18 <SplitList>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<SplitList>d__ = this;
				}
				else
				{
					<SplitList>d__ = new <SplitList>d__18(0);
				}
				<SplitList>d__.raw = <>3__raw;
				return <SplitList>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<string>)this).GetEnumerator();
			}
		}

		private static bool _registered;

		private static bool _created;

		private static TrackerMuterWindow? _inst;

		private static ConfigEntry<string>? _cfgKnown;

		private static ConfigEntry<string>? _cfgMuteList;

		private static ConfigEntry<string>? _cfgUiHotkey;

		private static bool _reloadRequested;

		private static double _reloadDueMs;

		private static readonly HashSet<string> _known = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, bool> _mute = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);

		private static KeyCode _hotkey = (KeyCode)289;

		private bool _show;

		private Rect _winRect = new Rect(60f, 60f, 520f, 520f);

		private Vector2 _scroll;

		private string _filter = string.Empty;

		private GUIStyle? _labelLeft;

		private GUIStyle? _toggleStyle;

		private int _lastHotkeyFrame = -1;

		private bool _dragging;

		private Vector2 _dragStartMouse;

		private Vector2 _dragStartPos;

		private readonly float _uiScale = 2f;

		private bool _sizeAdjustedForScale;

		private bool _resizing;

		private Vector2 _resizeStartMouseScaled;

		private Vector2 _resizeStartSize;

		internal static bool IsOpen
		{
			get
			{
				if ((Object)(object)_inst != (Object)null)
				{
					return _inst._show;
				}
				return false;
			}
		}

		public TrackerMuterWindow(IntPtr ptr)
			: base(ptr)
		{
		}//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)


		internal static void Bootstrap()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_001e: 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_0029: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!_registered)
				{
					ClassInjector.RegisterTypeInIl2Cpp<TrackerMuterWindow>();
					_registered = true;
				}
				if (!_created)
				{
					GameObject val = new GameObject("[TrackerControl UI]");
					Object.DontDestroyOnLoad((Object)val);
					((Object)val).hideFlags = (HideFlags)52;
					val.AddComponent<TrackerMuterWindow>();
					_created = true;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSrc = Plugin.LogSrc;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[TrackerMuterWindow] Bootstrap failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logSrc.LogError(val2);
			}
		}

		internal static void BindConfig(ConfigFile cfg)
		{
			_cfgKnown = cfg.Bind<string>("Mute", "KnownTrackerLocations", "", "Semicolon-separated list of known tracker locations.");
			_cfgMuteList = Plugin.MuteTrackerNamePatterns;
			_cfgUiHotkey = cfg.Bind<string>("UI", "TrackerMuterToggleKey", "F8", "Hotkey to toggle the Tracker Control UI.");
			try
			{
				if (_cfgKnown != null)
				{
					_cfgKnown.SettingChanged += OnConfigChanged;
				}
				if (_cfgMuteList != null)
				{
					_cfgMuteList.SettingChanged += OnConfigChanged;
				}
				if (_cfgUiHotkey != null)
				{
					_cfgUiHotkey.SettingChanged += OnConfigChanged;
				}
			}
			catch
			{
			}
			LoadConfig();
		}

		private static void LoadConfig()
		{
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_known.Clear();
				_mute.Clear();
				foreach (string item in SplitList(_cfgKnown?.Value ?? string.Empty))
				{
					_known.Add(item);
				}
				string text = _cfgMuteList?.Value ?? string.Empty;
				HashSet<string> hashSet = new HashSet<string>(SplitList(text), StringComparer.OrdinalIgnoreCase);
				foreach (string item2 in hashSet)
				{
					_known.Add(item2);
				}
				foreach (string item3 in _known)
				{
					_mute[item3] = hashSet.Contains(item3) || MatchesPattern(item3, text);
				}
				if (!Enum.TryParse<KeyCode>(_cfgUiHotkey?.Value ?? "F8", ignoreCase: true, out _hotkey))
				{
					_hotkey = (KeyCode)289;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSrc = Plugin.LogSrc;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TrackerMuterWindow] LoadConfig failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logSrc.LogError(val);
			}
		}

		private static void OnConfigChanged(object? sender, EventArgs e)
		{
			RequestReloadSoon();
		}

		private static void RequestReloadSoon()
		{
			_reloadRequested = true;
			_reloadDueMs = NowMs() + 250.0;
		}

		private static void SaveConfig()
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			try
			{
				if (_cfgKnown != null)
				{
					_cfgKnown.Value = string.Join(";", _known.OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase));
				}
				if (_cfgMuteList != null)
				{
					IOrderedEnumerable<string> values = (from kv in _mute
						where kv.Value
						select kv.Key).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase);
					_cfgMuteList.Value = string.Join(";", values);
				}
				Plugin.Cfg.Save();
			}
			catch (Exception ex)
			{
				ManualLogSource logSrc = Plugin.LogSrc;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TrackerMuterWindow] SaveConfig failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logSrc.LogError(val);
			}
		}

		[IteratorStateMachine(typeof(<SplitList>d__18))]
		private static IEnumerable<string> SplitList(string raw)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SplitList>d__18(-2)
			{
				<>3__raw = raw
			};
		}

		private static bool MatchesPattern(string value, string rawPatterns)
		{
			if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(rawPatterns))
			{
				return false;
			}
			foreach (string item in SplitList(rawPatterns))
			{
				string text = item.Replace("*", string.Empty);
				if (text.Length != 0 && value.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		internal static void NoteMovementFromMessage(string message)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			if (string.IsNullOrEmpty(message) || message.IndexOf("Movement Alert", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return;
			}
			string text = ExtractLocation(message);
			if (string.IsNullOrEmpty(text) || !_known.Add(text))
			{
				return;
			}
			bool flag = MatchesPattern(text, _cfgMuteList?.Value ?? string.Empty);
			_mute[text] = flag;
			SaveConfig();
			if (Plugin.TraceEnabled)
			{
				ManualLogSource logSrc = Plugin.LogSrc;
				bool flag2 = default(bool);
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(49, 2, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TrackerMuterWindow] Learned location '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', muted=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(flag ? "yes" : "no");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				logSrc.LogDebug(val);
			}
		}

		private static string ExtractLocation(string message)
		{
			int num = message.IndexOf(':');
			if (num > 0)
			{
				return message.Substring(0, num).Trim();
			}
			return string.Empty;
		}

		private static bool IsInGame()
		{
			return UiCapture.IsInGameScene();
		}

		private void Awake()
		{
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			_inst = this;
		}

		private void OnDisable()
		{
			try
			{
				UiCapture.Apply(want: false);
			}
			catch
			{
			}
		}

		private void OnDestroy()
		{
			try
			{
				UiCapture.Apply(want: false);
			}
			catch
			{
			}
			if ((Object)(object)_inst == (Object)(object)this)
			{
				_inst = null;
			}
		}

		private void Update()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			try
			{
				if (_reloadRequested && NowMs() >= _reloadDueMs)
				{
					_reloadRequested = false;
					LoadConfig();
				}
				if (_show && !IsInGame())
				{
					_show = false;
					UiCapture.Apply(want: false);
				}
				else
				{
					if (!Input.GetKeyDown(_hotkey) || _lastHotkeyFrame == Time.frameCount)
					{
						return;
					}
					_lastHotkeyFrame = Time.frameCount;
					if (!_show && !IsInGame())
					{
						return;
					}
					_show = !_show;
					if (Plugin.TraceEnabled)
					{
						ManualLogSource logSrc = Plugin.LogSrc;
						bool flag = default(bool);
						BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(34, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TrackerMuterWindow] Toggle UI => ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_show ? "OPEN" : "CLOSED");
						}
						logSrc.LogDebug(val);
					}
					UiCapture.Apply(_show);
					if (_show)
					{
						CenterWindow();
					}
				}
			}
			catch
			{
			}
		}

		private void OnGUI()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0041: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Invalid comparison between Unknown and I4
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Invalid comparison between Unknown and I4
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Invalid comparison between Unknown and I4
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Invalid comparison between Unknown and I4
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			if (_show && !IsInGame())
			{
				_show = false;
				UiCapture.Apply(want: false);
			}
			else
			{
				if (!_show)
				{
					return;
				}
				UiCapture.Tick();
				Event current = Event.current;
				if (current != null && (int)current.type == 4 && current.keyCode == _hotkey && _lastHotkeyFrame != Time.frameCount)
				{
					_lastHotkeyFrame = Time.frameCount;
					if (!_show && !IsInGame())
					{
						current.Use();
						return;
					}
					_show = !_show;
					UiCapture.Apply(_show);
					if (_show)
					{
						CenterWindow();
					}
					if (!_show)
					{
						current.Use();
						return;
					}
					current.Use();
				}
				if (_labelLeft == null)
				{
					_labelLeft = new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)3,
						wordWrap = false
					};
					_toggleStyle = new GUIStyle(GUI.skin.toggle);
				}
				if (!_sizeAdjustedForScale)
				{
					ref Rect winRect = ref _winRect;
					((Rect)(ref winRect)).width = ((Rect)(ref winRect)).width * _uiScale;
					ref Rect winRect2 = ref _winRect;
					((Rect)(ref winRect2)).height = ((Rect)(ref winRect2)).height * _uiScale;
					_sizeAdjustedForScale = true;
				}
				Matrix4x4 matrix = GUI.matrix;
				float uiScale = _uiScale;
				float num = 1f / uiScale;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref _winRect)).x * num, ((Rect)(ref _winRect)).y * num, ((Rect)(ref _winRect)).width * num, ((Rect)(ref _winRect)).height * num);
				GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(uiScale, uiScale, 1f));
				GUIStyle window = GUI.skin.window;
				GUI.Box(val, "Tracker Control", window);
				RectOffset padding = window.padding;
				GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + (float)padding.left, ((Rect)(ref val)).y + (float)padding.top, ((Rect)(ref val)).width - (float)(padding.left + padding.right), ((Rect)(ref val)).height - (float)(padding.top + padding.bottom)));
				DrawContents();
				GUILayout.EndArea();
				Event current2 = Event.current;
				float num2 = Mathf.Max(20f, (float)padding.top);
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, num2);
				if ((int)current2.type == 0 && ((Rect)(ref val2)).Contains(current2.mousePosition))
				{
					_dragging = true;
					_dragStartMouse = current2.mousePosition;
					_dragStartPos = new Vector2(((Rect)(ref _winRect)).x, ((Rect)(ref _winRect)).y);
					current2.Use();
				}
				else if ((int)current2.type == 3 && _dragging)
				{
					Vector2 val3 = (current2.mousePosition - _dragStartMouse) * uiScale;
					((Rect)(ref _winRect)).position = _dragStartPos + val3;
					current2.Use();
				}
				else if ((int)current2.type == 1 && _dragging)
				{
					_dragging = false;
					current2.Use();
				}
				float num3 = 16f;
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((Rect)(ref val)).xMax - num3, ((Rect)(ref val)).yMax - num3, num3, num3);
				EditorLikeCorner(r);
				if ((int)current2.type == 0 && ((Rect)(ref r)).Contains(current2.mousePosition))
				{
					_resizing = true;
					_resizeStartMouseScaled = current2.mousePosition;
					_resizeStartSize = new Vector2(((Rect)(ref _winRect)).width, ((Rect)(ref _winRect)).height);
					current2.Use();
				}
				else if ((int)current2.type == 3 && _resizing)
				{
					Vector2 val4 = (current2.mousePosition - _resizeStartMouseScaled) * uiScale;
					float width = Mathf.Max(360f, _resizeStartSize.x + val4.x);
					float height = Mathf.Max(240f, _resizeStartSize.y + val4.y);
					((Rect)(ref _winRect)).width = width;
					((Rect)(ref _winRect)).height = height;
					current2.Use();
				}
				else if ((int)current2.type == 1 && _resizing)
				{
					_resizing = false;
					current2.Use();
				}
				GUI.matrix = matrix;
			}
		}

		private void DrawContents()
		{
			//IL_0193: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			bool value = Plugin.EnablePerTrackerMute.Value;
			GUILayout.Label("Muting: " + (value ? "ON" : "OFF"), _labelLeft, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) });
			if (GUILayout.Button("Enable", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				Plugin.EnablePerTrackerMute.Value = true;
				try
				{
					Plugin.Cfg.Save();
				}
				catch
				{
				}
			}
			if (GUILayout.Button("Disable", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				Plugin.EnablePerTrackerMute.Value = false;
				try
				{
					Plugin.Cfg.Save();
				}
				catch
				{
				}
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label($"Known locations: {_known.Count}", _labelLeft, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
			GUILayout.FlexibleSpace();
			_filter = GUILayout.TextField(_filter ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
			if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
			{
				_filter = string.Empty;
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			try
			{
				foreach (string item in _known.OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList())
				{
					if (string.IsNullOrEmpty(_filter) || item.IndexOf(_filter, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						bool value2;
						bool flag = _mute.TryGetValue(item, out value2) && value2;
						GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
						bool flag2 = GUILayout.Toggle(flag, " mute", _toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
						if (flag2 != flag)
						{
							_mute[item] = flag2;
							SaveConfig();
						}
						GUILayout.Label(item, _labelLeft, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
						if (GUILayout.Button("Remove", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
						{
							_known.Remove(item);
							_mute.Remove(item);
							SaveConfig();
							GUILayout.EndHorizontal();
						}
						else
						{
							GUILayout.EndHorizontal();
						}
					}
				}
			}
			finally
			{
				GUILayout.EndScrollView();
			}
			GUILayout.Space(6f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Mute All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				string[] array = _known.ToArray();
				foreach (string key in array)
				{
					_mute[key] = true;
				}
				SaveConfig();
			}
			if (GUILayout.Button("Unmute All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				string[] array = _known.ToArray();
				foreach (string key2 in array)
				{
					_mute[key2] = false;
				}
				SaveConfig();
			}
			if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				LoadConfig();
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Center", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				CenterWindow();
			}
			if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				_show = false;
				UiCapture.Apply(want: false);
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private void CenterWindow()
		{
			float num = (_sizeAdjustedForScale ? ((Rect)(ref _winRect)).width : (((Rect)(ref _winRect)).width * _uiScale));
			float num2 = (_sizeAdjustedForScale ? ((Rect)(ref _winRect)).height : (((Rect)(ref _winRect)).height * _uiScale));
			float x = Mathf.Round(((float)Screen.width - num) * 0.5f);
			float y = Mathf.Round(((float)Screen.height - num2) * 0.5f);
			((Rect)(ref _winRect)).x = x;
			((Rect)(ref _winRect)).y = y;
		}

		private static void EditorLikeCorner(Rect r)
		{
			//IL_0000: 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_0023: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, 0.25f);
			GUI.Box(r, GUIContent.none);
			GUI.color = new Color(1f, 1f, 1f, 0.6f);
			GUI.Label(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 12f, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 6f, 10f, 2f), "", GUI.skin.box);
			GUI.Label(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 10f, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 10f, 8f, 2f), "", GUI.skin.box);
			GUI.Label(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 6f, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 12f, 6f, 2f), "", GUI.skin.box);
			GUI.color = color;
		}

		internal static string CurrentMuteListRaw()
		{
			IOrderedEnumerable<string> values = (from kv in _mute
				where kv.Value
				select kv.Key).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase);
			return string.Join(";", values);
		}

		internal static void CloseUi()
		{
			if ((Object)(object)_inst != (Object)null && _inst._show)
			{
				_inst._show = false;
				try
				{
					UiCapture.Apply(want: false);
				}
				catch
				{
				}
			}
		}

		private static double NowMs()
		{
			return (DateTime.UtcNow - DateTime.UnixEpoch).TotalMilliseconds;
		}
	}
}