Decompiled source of OBaCT v1.0.1

BepInEx/plugins/OBaCT.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OBaCT")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OBaCT")]
[assembly: AssemblyTitle("OBaCT")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Erenshor
{
	[BepInPlugin("erenshor.obact", "OBaCT [Overhead Bars + Combat Text]", "1.7.4")]
	public class OBaCT : BaseUnityPlugin
	{
		public enum SuppressionMode
		{
			Off,
			Hard,
			Fade
		}

		public class Tracked
		{
			public Stats stats;

			private int lastHP;

			public GameObject Go { get; private set; }

			public Transform Tf { get; private set; }

			public bool IsDead => (Object)(object)stats != (Object)null && stats.CurrentHP <= 0;

			public Tracked(GameObject go, Stats stats)
			{
				Go = go;
				Tf = go.transform;
				this.stats = stats;
				lastHP = stats.CurrentHP;
			}

			public bool RefEquals(GameObject go)
			{
				return (Object)(object)Go == (Object)(object)go;
			}

			public bool Valid()
			{
				return Object.op_Implicit((Object)(object)Go) && Object.op_Implicit((Object)(object)Tf) && (Object)(object)stats != (Object)null && Go.activeInHierarchy;
			}

			public string SafeName()
			{
				return (!string.IsNullOrEmpty(stats.MyName)) ? stats.MyName : (Object.op_Implicit((Object)(object)Go) ? ((Object)Go).name : "Unknown");
			}

			public bool TryGetLevel(out int level)
			{
				level = stats.Level;
				return true;
			}

			public void TickForDamageFloaters()
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: 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_00df: 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)
				if (!((Object)(object)stats == (Object)null))
				{
					int currentHP = stats.CurrentHP;
					int num = currentHP - lastHP;
					if (num != 0)
					{
						FloatingNum floatingNum = default(FloatingNum);
						floatingNum.world = Tf.position + Vector3.up * 2f;
						floatingNum.text = ((num < 0) ? (-num).ToString() : ("+" + num));
						floatingNum.t = 0f;
						floatingNum.life = DmgTextLifetime.Value;
						floatingNum.critScale = (((float)Mathf.Abs(num) > (float)stats.CurrentMaxHP * 0.1f) ? 1.4f : 1f);
						floatingNum.color = ((num < 0) ? Color.red : Color.green);
						floatingNum.seed = Random.value * 10f;
						FloatingNum item = floatingNum;
						floaters.Add(item);
					}
					lastHP = currentHP;
				}
			}

			private static Color HpColor(float pct)
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: 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_0045: 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)
				pct = Mathf.Clamp01(pct);
				return (pct >= 0.5f) ? Color.Lerp(Color.yellow, Color.green, (pct - 0.5f) / 0.5f) : Color.Lerp(Color.red, Color.yellow, pct / 0.5f);
			}

			private static Color NameColor(Stats stats)
			{
				//IL_001d: 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_0139: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: 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_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)stats == (Object)null || (Object)(object)stats.Myself == (Object)null)
				{
					return Color.white;
				}
				Character myself = stats.Myself;
				if (!myself.isNPC)
				{
					if ((Object)(object)myself == (Object)(object)GameData.PlayerControl.Myself)
					{
						return Color.cyan;
					}
					if ((Object)(object)GameData.GroupMember1?.MyAvatar == (Object)(object)myself || (Object)(object)GameData.GroupMember2?.MyAvatar == (Object)(object)myself || (Object)(object)GameData.GroupMember3?.MyAvatar == (Object)(object)myself)
					{
						return Color.green;
					}
					return Color.white;
				}
				if (myself.isNPC && (Object)(object)myself.MyNPC != (Object)null)
				{
					if (myself.isVendor)
					{
						return Color.yellow;
					}
					if (myself.AggressiveTowards != null && myself.AggressiveTowards.Contains((Faction)0))
					{
						return Color.red;
					}
					return Color.gray;
				}
				return new Color(0.9f, 0.85f, 0.7f);
			}

			public void DrawUnitFrame(Camera cam, GUIStyle hpStyle, GUIStyle nameStyle, GUIStyle pctStyle, int playerLevel)
			{
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: 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_0085: 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_00a7: 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_00f5: 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_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_024b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0256: Unknown result type (might be due to invalid IL or missing references)
				//IL_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_0420: Unknown result type (might be due to invalid IL or missing references)
				//IL_042b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0473: Unknown result type (might be due to invalid IL or missing references)
				//IL_047e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_050c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0517: Unknown result type (might be due to invalid IL or missing references)
				//IL_0337: Unknown result type (might be due to invalid IL or missing references)
				//IL_0342: Unknown result type (might be due to invalid IL or missing references)
				//IL_038a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0395: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03aa: Expected O, but got Unknown
				//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0291: Unknown result type (might be due to invalid IL or missing references)
				//IL_0557: Unknown result type (might be due to invalid IL or missing references)
				//IL_055c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0561: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02de: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0300: Unknown result type (might be due to invalid IL or missing references)
				//IL_0305: Unknown result type (might be due to invalid IL or missing references)
				//IL_065d: Unknown result type (might be due to invalid IL or missing references)
				//IL_069c: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0709: Unknown result type (might be due to invalid IL or missing references)
				//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0814: Unknown result type (might be due to invalid IL or missing references)
				//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0807: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Tf == (Object)null || (Object)(object)stats == (Object)null)
				{
					return;
				}
				float num = stats.CurrentHP;
				float num2 = stats.CurrentMaxHP;
				if (num2 <= 0f)
				{
					return;
				}
				Vector3 val = Tf.position + Vector3.up * YOffset.Value;
				Vector3 val2 = cam.WorldToScreenPoint(val);
				if (val2.z <= 0f || Vector3.Distance(((Component)cam).transform.position, Tf.position) > MaxDistance.Value)
				{
					return;
				}
				float num3 = Mathf.Clamp01(num / num2);
				float value = BarWidth.Value;
				float value2 = BarHeight.Value;
				float num4 = val2.x - value / 2f;
				float num5 = (float)Screen.height - val2.y - value2;
				Rect rect = default(Rect);
				((Rect)(ref rect))..ctor(num4 - 3f, num5 - 26f, value + 6f, value2 + 36f + (ShowManaBar.Value ? 8f : 0f));
				if ((int)Event.current.type == 0 && ((Rect)(ref rect)).Contains(Event.current.mousePosition))
				{
					GameData.PlayerControl.CurrentTarget = stats.Myself;
					Event.current.Use();
				}
				float num6 = 1f;
				if (SuppressMode.Value == SuppressionMode.Fade && Instance.ShouldSuppressUI())
				{
					num6 = Mathf.Clamp01(FadeAlpha.Value);
				}
				Color color = GUI.color;
				GUI.color = new Color(color.r, color.g, color.b, num6);
				if (ShowName.Value)
				{
					string text = SafeName();
					int level = 0;
					TryGetLevel(out level);
					float num7 = value - 38f;
					Rect val3 = default(Rect);
					((Rect)(ref val3))..ctor(num4, num5 - 22f, num7, 18f);
					GUI.color = Color.black;
					GUI.DrawTexture(val3, (Texture)(object)Texture2D.whiteTexture);
					GUI.color = NameColor(stats);
					if ((Object)(object)customFont != (Object)null)
					{
						nameStyle.font = customFont;
					}
					GUI.Label(val3, text, nameStyle);
					if (ShowLevel.Value && level > 0)
					{
						Rect val4 = default(Rect);
						((Rect)(ref val4))..ctor(((Rect)(ref val3)).xMax + 2f, ((Rect)(ref val3)).y, 34f, ((Rect)(ref val3)).height);
						GUI.color = Color.black;
						GUI.DrawTexture(val4, (Texture)(object)Texture2D.whiteTexture);
						DrawOutlinedLabel(val4, level.ToString(), nameStyle, Color.yellow, Color.black);
					}
				}
				if (IsDead)
				{
					Rect val5 = default(Rect);
					((Rect)(ref val5))..ctor(num4, num5, value, value2 + 2f);
					GUI.color = Color.black;
					GUI.DrawTexture(val5, (Texture)(object)Texture2D.whiteTexture);
					Rect val6 = default(Rect);
					((Rect)(ref val6))..ctor(num4 + 2f, num5 + 2f, value - 4f, value2 - 2f);
					GUI.color = new Color(0.2f, 0.2f, 0.2f, 0.8f);
					GUI.DrawTexture(val6, (Texture)(object)Texture2D.whiteTexture);
					GUIStyle val7 = new GUIStyle(hpStyle);
					val7.alignment = (TextAnchor)4;
					val7.fontStyle = (FontStyle)2;
					val7.normal.textColor = Color.gray;
					if ((Object)(object)customFont != (Object)null)
					{
						val7.font = customFont;
					}
					GUI.Label(val6, "dead", val7);
					GUI.color = Color.white;
					return;
				}
				Rect val8 = default(Rect);
				((Rect)(ref val8))..ctor(num4, num5, value, value2 + 2f);
				GUI.color = Color.black;
				GUI.DrawTexture(val8, (Texture)(object)Texture2D.whiteTexture);
				Rect val9 = default(Rect);
				((Rect)(ref val9))..ctor(num4 + 2f, num5 + 2f, value - 4f, value2 - 2f);
				GUI.color = new Color(0.05f, 0.05f, 0.05f, 0.95f);
				GUI.DrawTexture(val9, (Texture)(object)Texture2D.whiteTexture);
				float num8 = ((Rect)(ref val9)).width * num3;
				Rect val10 = default(Rect);
				((Rect)(ref val10))..ctor(((Rect)(ref val9)).x, ((Rect)(ref val9)).y, num8, ((Rect)(ref val9)).height);
				GUI.color = HpColor(num3);
				GUI.DrawTexture(val10, (Texture)(object)Texture2D.whiteTexture);
				Rect val11 = default(Rect);
				((Rect)(ref val11))..ctor(((Rect)(ref val10)).x, ((Rect)(ref val10)).y, ((Rect)(ref val10)).width, ((Rect)(ref val10)).height / 3f);
				GUI.color = new Color(1f, 1f, 1f, 0.25f);
				GUI.DrawTexture(val11, (Texture)(object)Texture2D.whiteTexture);
				if (ShowHpNumbers.Value)
				{
					string text2 = $"{Mathf.CeilToInt(num)}/{Mathf.CeilToInt(num2)}";
					DrawOutlinedLabel(val9, text2, hpStyle, Color.white, Color.black);
				}
				if (ShowHpPercent.Value)
				{
					string text3 = $"{Mathf.RoundToInt(num3 * 100f)}%";
					Rect rect2 = default(Rect);
					((Rect)(ref rect2))..ctor(((Rect)(ref val9)).x + ((Rect)(ref val9)).width + 6f, ((Rect)(ref val9)).y, 48f, ((Rect)(ref val9)).height);
					DrawOutlinedLabel(rect2, text3, pctStyle, Color.white, Color.black);
				}
				if (ShowManaBar.Value && stats.GetCurrentMaxMana() > 0)
				{
					float num9 = Mathf.Clamp01((float)stats.GetCurrentMana() / (float)stats.GetCurrentMaxMana());
					Rect val12 = default(Rect);
					((Rect)(ref val12))..ctor(num4 + 2f, num5 + value2 + 2f, value - 4f, Mathf.Max(6f, value2 * 0.5f));
					GUI.color = Color.black;
					GUI.DrawTexture(new Rect(((Rect)(ref val12)).x - 1f, ((Rect)(ref val12)).y - 1f, ((Rect)(ref val12)).width + 2f, ((Rect)(ref val12)).height + 2f), (Texture)(object)Texture2D.whiteTexture);
					GUI.color = new Color(0.05f, 0.05f, 0.1f, 0.95f);
					GUI.DrawTexture(val12, (Texture)(object)Texture2D.whiteTexture);
					Rect val13 = default(Rect);
					((Rect)(ref val13))..ctor(((Rect)(ref val12)).x, ((Rect)(ref val12)).y, ((Rect)(ref val12)).width * num9, ((Rect)(ref val12)).height);
					GUI.color = Color.blue;
					GUI.DrawTexture(val13, (Texture)(object)Texture2D.whiteTexture);
				}
				bool flag = (Object)(object)stats.Myself == (Object)(object)GameData.PlayerControl.CurrentTarget;
				bool flag2 = stats.Myself.isNPC && (Object)(object)stats.Myself.MyNPC != (Object)null && (Object)(object)stats.Myself.MyNPC.CurrentAggroTarget == (Object)(object)GameData.PlayerControl.Myself;
				if (flag)
				{
					float num10 = 0.4f + Mathf.PingPong(Time.time * 0.75f, 0.4f);
					DrawGlowBorder(rect, 2, new Color(1f, 1f, 0f, num10), 3);
				}
				if (flag2)
				{
					float num11 = 0.7f + Mathf.PingPong(Time.time * 0.5f, 0.2f);
					DrawGlowBorder(rect, 2, new Color(1f, 0f, 0f, num11), 3);
				}
				GUI.color = Color.white;
			}
		}

		public struct FloatingNum
		{
			public Vector3 world;

			public string text;

			public float t;

			public float life;

			public float critScale;

			public Color color;

			public float seed;
		}

		public static OBaCT Instance;

		private bool lastAuctionOpen;

		private bool lastBankOpen;

		private bool lastEscMenuOpen;

		private bool lastGroupOpen;

		private bool lastHelpOpen;

		private bool lastInvStatsOpen;

		private bool lastItemInfoOpen;

		private bool lastLootOpen;

		private bool lastMapOpen;

		private bool lastNpcDialogOpen;

		private bool lastOptionsOpen;

		private bool lastQuestOpen;

		private bool lastRestOpen;

		private bool lastReviveOpen;

		private bool lastRunOpen;

		private bool lastInspectOpen;

		private bool lastSimTradeOpen;

		private bool lastSmithOpen;

		private bool lastSkillsOpen;

		private bool lastTradeOpen;

		private bool lastTutOpen;

		private bool lastVendorOpen;

		private bool lastLocalLogOpen;

		private bool lastChatOpen;

		private bool lastCombatLogOpen;

		private Camera cam;

		private float rescanTimer;

		private GUIStyle hpStyle;

		private GUIStyle nameStyle;

		private GUIStyle percentStyle;

		private int playerLevelCached = 1;

		private float playerLevelTimer;

		private Rect menuRect = new Rect(60f, 120f, 460f, 600f);

		private GUIStyle menuHeader;

		private GUIStyle headerStyle;

		private GUIStyle lineStyle;

		public static readonly List<Tracked> tracked = new List<Tracked>();

		public static readonly List<FloatingNum> floaters = new List<FloatingNum>();

		public static ConfigEntry<SuppressionMode> SuppressMode;

		public static ConfigEntry<bool> EnableBars;

		public static ConfigEntry<bool> EnableDamageText;

		public static ConfigEntry<bool> ShowName;

		public static ConfigEntry<bool> ShowLevel;

		public static ConfigEntry<bool> ShowHpNumbers;

		public static ConfigEntry<bool> ShowHpPercent;

		public static ConfigEntry<bool> ShowPortrait;

		public static ConfigEntry<bool> ShowManaBar;

		public static ConfigEntry<bool> FctShadow;

		public static ConfigEntry<float> MaxDistance;

		public static ConfigEntry<float> BarWidth;

		public static ConfigEntry<float> BarHeight;

		public static ConfigEntry<float> YOffset;

		public static ConfigEntry<float> DmgTextScale;

		public static ConfigEntry<float> DmgTextLifetime;

		public static ConfigEntry<float> FctRiseSpeed;

		public static ConfigEntry<float> FctJitter;

		public static ConfigEntry<int> NameFontSize;

		public static ConfigEntry<int> HpFontSize;

		public static ConfigEntry<int> PortraitSize;

		public static ConfigEntry<float> FadeAlpha;

		public static Font customFont = Resources.GetBuiltinResource<Font>("Arial.ttf");

		public static Font wowFont;

		public static Font wowFontBold;

		public static ConfigEntry<string> CombatTextTheme;

		private static Texture2D hpGradientTex;

		private static RestWindow _restWin;

		private static RunWindow _runWin;

		private static GameObject _reviveWin;

		private static GameObject _npcDialog;

		private static GameObject _spellGo;

		private static GameObject _skillGo;

		private static GameObject _mainMenu;

		private static GameObject _minimapCanvas;

		private static GameObject _minimapPanel;

		private static float _uiRefetchCooldown = 1f;

		private static float _uiRefetchTimer = 0f;

		private bool showMenu = false;

		private Vector2 scrollPos = Vector2.zero;

		private void Awake()
		{
			Instance = this;
			EnableBars = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableBars", true, "Draw overhead bars for entities with Stats.");
			EnableDamageText = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDamageText", true, "Show floating damage numbers from HP deltas.");
			BarWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "BarWidth", 180f, "Unit frame width (px).");
			BarHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "BarHeight", 20f, "Health bar height (px).");
			YOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "YOffset", 2.6f, "Vertical offset above head (meters).");
			MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Bars", "MaxDistance", 46f, "Max distance to render bars (meters).");
			ShowName = ((BaseUnityPlugin)this).Config.Bind<bool>("Labels", "ShowName", true, "Show name strip above frame.");
			ShowLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Labels", "ShowLevel", true, "Show level box next to the name.");
			ShowHpNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("Labels", "ShowHpNumbers", true, "Show numeric HP inside bar.");
			ShowHpPercent = ((BaseUnityPlugin)this).Config.Bind<bool>("Labels", "ShowHpPercent", true, "Show HP percent to the right of bar.");
			NameFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Labels", "NameFontSize", 14, "Name label font size.");
			HpFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Labels", "HpFontSize", 15, "HP text font size.");
			ShowPortrait = ((BaseUnityPlugin)this).Config.Bind<bool>("Portrait", "ShowPortrait", true, "Show portrait box on the left.");
			PortraitSize = ((BaseUnityPlugin)this).Config.Bind<int>("Portrait", "PortraitSize", 42, "Portrait size in pixels.");
			ShowManaBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Mana", "ShowManaBar", true, "Show mana bar (blue) under the HP bar.");
			DmgTextScale = ((BaseUnityPlugin)this).Config.Bind<float>("DamageText", "Scale", 1.2f, "Base size multiplier for numbers.");
			DmgTextLifetime = ((BaseUnityPlugin)this).Config.Bind<float>("DamageText", "Lifetime", 1.15f, "Seconds numbers stay before fade.");
			FctRiseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("DamageText", "RisePerSec", 0.85f, "World-space rise speed.");
			FctJitter = ((BaseUnityPlugin)this).Config.Bind<float>("DamageText", "Jitter", 10f, "Horizontal wobble in pixels.");
			FctShadow = ((BaseUnityPlugin)this).Config.Bind<bool>("DamageText", "Shadow", true, "Draw black shadow outline for readability.");
			SuppressMode = ((BaseUnityPlugin)this).Config.Bind<SuppressionMode>("Suppression", "Mode", SuppressionMode.Hard, "Choose how OBaCT handles suppression: Off = never suppress, Hard = hide bars fully, Fade = fade bars when overlapped.");
			FadeAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Suppression", "FadeAlpha", 0.25f, "Alpha level (0.0 = invisible, 1.0 = fully visible) when suppression mode is set to Fade.");
			CombatTextTheme = ((BaseUnityPlugin)this).Config.Bind<string>("DamageText", "Theme", "wow", "Floating combat text style: 'wow' = OG WoW style, 'spartan' = minimalist.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[OBaCT] Loaded 1.7.7 Occlusion Solution");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[OBaCT] SuppressionMode set to: " + SuppressMode.Value));
			hpGradientTex = MakeHpGradient();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "assets");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[OBaCT] Created missing assets folder.");
			}
			try
			{
				string text2 = Path.Combine(text, "obactfonts");
				if (!File.Exists(text2))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[OBaCT] obactfonts AssetBundle not found. Using Arial fallback.");
					wowFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
					wowFontBold = wowFont;
					return;
				}
				AssetBundle val = AssetBundle.LoadFromFile(text2);
				if ((Object)(object)val != (Object)null)
				{
					wowFont = val.LoadAsset<Font>("QTFrizQuad");
					wowFontBold = val.LoadAsset<Font>("QTFrizQuad-Bold");
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[OBaCT] Loaded WoW fonts from AssetBundle: QTFrizQuad + Bold");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[OBaCT] Could not load obactfonts bundle, falling back to Arial.");
					wowFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
					wowFontBold = wowFont;
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[OBaCT] Font load failed: " + ex.Message));
				wowFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
				wowFontBold = wowFont;
			}
		}

		private Texture2D MakeHpGradient()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(100, 1);
			for (int i = 0; i < ((Texture)val).width; i++)
			{
				float num = (float)i / (float)(((Texture)val).width - 1);
				Color val2 = ((num >= 0.5f) ? Color.Lerp(Color.yellow, Color.green, (num - 0.5f) / 0.5f) : Color.Lerp(Color.red, Color.yellow, num / 0.5f));
				val.SetPixel(i, 0, val2);
			}
			val.Apply();
			return val;
		}

		private void Update()
		{
			if ((Object)(object)cam == (Object)null)
			{
				cam = Camera.main ?? Camera.current;
			}
			if ((Object)(object)cam == (Object)null)
			{
				return;
			}
			bool flag = ShouldSuppressUI();
			if (Input.GetKeyDown((KeyCode)292))
			{
				showMenu = !showMenu;
			}
			if (Input.GetKeyDown((KeyCode)291))
			{
			}
			rescanTimer -= Time.unscaledDeltaTime;
			if (rescanTimer <= 0f)
			{
				Rescan();
				rescanTimer = 3f;
			}
			for (int num = floaters.Count - 1; num >= 0; num--)
			{
				FloatingNum value = floaters[num];
				value.t += Time.unscaledDeltaTime;
				if (value.t >= value.life)
				{
					floaters.RemoveAt(num);
				}
				else
				{
					floaters[num] = value;
				}
			}
			for (int num2 = tracked.Count - 1; num2 >= 0; num2--)
			{
				if (!tracked[num2].Valid())
				{
					tracked.RemoveAt(num2);
				}
				else
				{
					tracked[num2].TickForDamageFloaters();
				}
			}
			playerLevelTimer -= Time.unscaledDeltaTime;
			if (playerLevelTimer <= 0f)
			{
				playerLevelCached = TryGetPlayerLevel(playerLevelCached);
				playerLevelTimer = 3f;
			}
		}

		private void OnGUI()
		{
			//IL_004e: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cam == (Object)null)
			{
				return;
			}
			bool flag = ShouldSuppressUI();
			if (SuppressMode.Value == SuppressionMode.Hard && flag)
			{
				return;
			}
			if (hpStyle == null)
			{
				hpStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				hpStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			}
			hpStyle.fontSize = Mathf.Clamp(HpFontSize.Value, 8, 32);
			if (nameStyle == null)
			{
				nameStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				nameStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			}
			nameStyle.fontSize = Mathf.Clamp(NameFontSize.Value, 8, 32);
			if (percentStyle == null)
			{
				percentStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)3,
					fontStyle = (FontStyle)1
				};
				percentStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			}
			percentStyle.fontSize = Mathf.Clamp(HpFontSize.Value, 8, 32);
			if (EnableBars.Value)
			{
				for (int num = tracked.Count - 1; num >= 0; num--)
				{
					tracked[num].DrawUnitFrame(cam, hpStyle, nameStyle, percentStyle, playerLevelCached);
				}
			}
			if (EnableDamageText.Value && floaters.Count > 0)
			{
				DrawFloaters(cam);
			}
			if (showMenu)
			{
				menuRect = GUI.Window(1337, menuRect, new WindowFunction(SettingsWindow), "OBaCT");
			}
		}

		private void SettingsWindow(int id)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			if (headerStyle == null)
			{
				headerStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					fontStyle = (FontStyle)1
				};
				headerStyle.normal.textColor = Color.cyan;
			}
			if (lineStyle == null)
			{
				lineStyle = new GUIStyle(GUI.skin.box);
				lineStyle.normal.background = Texture2D.whiteTexture;
			}
			scrollPos = GUILayout.BeginScrollView(scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(440f),
				GUILayout.Height(560f)
			});
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Frame Layout", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Box(GUIContent.none, lineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(1f) });
			GUILayout.Space(4f);
			GUILayout.Label($"Offset Y: {YOffset.Value:F2}", Array.Empty<GUILayoutOption>());
			YOffset.Value = GUILayout.HorizontalSlider(YOffset.Value, 0.5f, 4f, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Width: {BarWidth.Value:F0} px", Array.Empty<GUILayoutOption>());
			BarWidth.Value = GUILayout.HorizontalSlider(BarWidth.Value, 120f, 260f, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Height: {BarHeight.Value:F0} px", Array.Empty<GUILayoutOption>());
			BarHeight.Value = GUILayout.HorizontalSlider(BarHeight.Value, 14f, 30f, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Max Distance: {MaxDistance.Value:F0} m", Array.Empty<GUILayoutOption>());
			MaxDistance.Value = GUILayout.HorizontalSlider(MaxDistance.Value, 10f, 80f, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Labels", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Box(GUIContent.none, lineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(1f) });
			GUILayout.Space(4f);
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			ShowName.Value = GUILayout.Toggle(ShowName.Value, " Show Name", Array.Empty<GUILayoutOption>());
			ShowLevel.Value = GUILayout.Toggle(ShowLevel.Value, " Show Level", Array.Empty<GUILayoutOption>());
			ShowHpNumbers.Value = GUILayout.Toggle(ShowHpNumbers.Value, " Show HP Numbers", Array.Empty<GUILayoutOption>());
			ShowHpPercent.Value = GUILayout.Toggle(ShowHpPercent.Value, " Show HP Percent", Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.Label($"Name Font Size: {NameFontSize.Value}", Array.Empty<GUILayoutOption>());
			NameFontSize.Value = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)NameFontSize.Value, 10f, 28f, Array.Empty<GUILayoutOption>()));
			GUILayout.Label($"HP Font Size: {HpFontSize.Value}", Array.Empty<GUILayoutOption>());
			HpFontSize.Value = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)HpFontSize.Value, 10f, 28f, Array.Empty<GUILayoutOption>()));
			GUILayout.Space(8f);
			GUILayout.Label("Portrait", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Box(GUIContent.none, lineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(1f) });
			GUILayout.Space(4f);
			ShowPortrait.Value = GUILayout.Toggle(ShowPortrait.Value, " Show Portrait", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Mana", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Box(GUIContent.none, lineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(1f) });
			GUILayout.Space(4f);
			ShowManaBar.Value = GUILayout.Toggle(ShowManaBar.Value, " Show Mana Bar", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Suppression", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Box(GUIContent.none, lineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(1f) });
			GUILayout.Space(4f);
			if (GUILayout.Toggle(SuppressMode.Value == SuppressionMode.Off, " Off", Array.Empty<GUILayoutOption>()))
			{
				SuppressMode.Value = SuppressionMode.Off;
			}
			if (GUILayout.Toggle(SuppressMode.Value == SuppressionMode.Hard, " Hard (hide bars)", Array.Empty<GUILayoutOption>()))
			{
				SuppressMode.Value = SuppressionMode.Hard;
			}
			if (GUILayout.Toggle(SuppressMode.Value == SuppressionMode.Fade, " Fade (experimental)", Array.Empty<GUILayoutOption>()))
			{
				SuppressMode.Value = SuppressionMode.Fade;
			}
			if (SuppressMode.Value == SuppressionMode.Fade)
			{
				GUILayout.Label($"Fade Alpha: {FadeAlpha.Value:F2}", Array.Empty<GUILayoutOption>());
				FadeAlpha.Value = GUILayout.HorizontalSlider(FadeAlpha.Value, 0f, 1f, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(8f);
			GUILayout.Label("Combat Text", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Box(GUIContent.none, lineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(1f) });
			GUILayout.Space(4f);
			GUILayout.Label($"Scale: {DmgTextScale.Value:F1}", Array.Empty<GUILayoutOption>());
			DmgTextScale.Value = GUILayout.HorizontalSlider(DmgTextScale.Value, 0.5f, 3f, Array.Empty<GUILayoutOption>());
			FctShadow.Value = GUILayout.Toggle(FctShadow.Value, " Enable Shadow", Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.Label("Theme:", Array.Empty<GUILayoutOption>());
			if (GUILayout.Toggle(CombatTextTheme.Value == "wow", " WoW Style", Array.Empty<GUILayoutOption>()))
			{
				CombatTextTheme.Value = "wow";
			}
			if (GUILayout.Toggle(CombatTextTheme.Value == "spartan", " Spartan Style", Array.Empty<GUILayoutOption>()))
			{
				CombatTextTheme.Value = "spartan";
			}
			GUILayout.Space(12f);
			if (GUILayout.Button("\ud83d\udcbe Save Settings", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				((BaseUnityPlugin)this).Config.Save();
			}
			GUILayout.EndVertical();
			GUILayout.EndScrollView();
		}

		private void DrawFloaters(Camera camRef)
		{
			//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_0021: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0109: 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_011c: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			Rect val3 = default(Rect);
			for (int i = 0; i < floaters.Count; i++)
			{
				FloatingNum floatingNum = floaters[i];
				Vector3 val = camRef.WorldToScreenPoint(floatingNum.world);
				if (val.z <= 0f)
				{
					continue;
				}
				float num = floatingNum.t / floatingNum.life;
				float num2 = Mathf.Sin(num * MathF.PI * 0.5f);
				float num3 = FctRiseSpeed.Value * num2 * floatingNum.life;
				float num4 = Mathf.Clamp01(1f - num);
				float num5 = val.x + Mathf.Sin(floatingNum.seed + floatingNum.t * 2f) * FctJitter.Value;
				float num6 = (float)Screen.height - val.y - num3 * 40f;
				int num7 = Mathf.RoundToInt(20f * floatingNum.critScale * DmgTextScale.Value);
				num7 = Mathf.Clamp(num7, 12, 64);
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = num7,
					fontStyle = (FontStyle)1
				};
				if (CombatTextTheme.Value == "wow")
				{
					if (floatingNum.critScale > 1f && (Object)(object)wowFontBold != (Object)null)
					{
						val2.font = wowFontBold;
					}
					else if ((Object)(object)wowFont != (Object)null)
					{
						val2.font = wowFont;
					}
				}
				else if ((Object)(object)customFont != (Object)null)
				{
					val2.font = customFont;
				}
				else
				{
					val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				}
				Color color = Color.white;
				if (CombatTextTheme.Value == "wow")
				{
					color = ((floatingNum.critScale > 1f) ? new Color(1f, 0.6f, 0.2f, num4) : new Color(1f, 0.82f, 0.2f, num4));
				}
				else if (floatingNum.text.StartsWith("+"))
				{
					((Color)(ref color))..ctor(0.2f, 1f, 0.2f, num4);
				}
				else if (floatingNum.critScale > 1f)
				{
					((Color)(ref color))..ctor(1f, 0.4f, 0.2f, num4);
				}
				else
				{
					((Color)(ref color))..ctor(1f, 1f, 1f, num4);
				}
				float num8 = (float)num7 * 10f;
				float num9 = (float)num7 * 1.6f;
				((Rect)(ref val3))..ctor(num5 - num8 / 2f, num6 - num9 / 2f, num8, num9);
				if (FctShadow.Value)
				{
					GUI.color = new Color(0f, 0f, 0f, num4);
					GUI.Label(new Rect(((Rect)(ref val3)).x + 1f, ((Rect)(ref val3)).y + 1f, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), floatingNum.text, val2);
				}
				GUI.color = color;
				GUI.Label(val3, floatingNum.text, val2);
				GUI.color = Color.white;
			}
		}

		private void Rescan()
		{
			//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)
			HashSet<GameObject> seen = new HashSet<GameObject>();
			rescanTimer = 3f;
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				if (!val.activeInHierarchy)
				{
					continue;
				}
				Stats[] componentsInChildren = val.GetComponentsInChildren<Stats>(false);
				Stats[] array = componentsInChildren;
				foreach (Stats stats in array)
				{
					if (!((Object)(object)stats == (Object)null) && ((Component)stats).gameObject.activeInHierarchy && (stats.MyName == null || !stats.MyName.Contains("Mineral Deposit")) && stats.CurrentMaxHP <= 50000 && stats.CurrentMaxHP > 1)
					{
						seen.Add(((Component)stats).gameObject);
						if (!tracked.Any((Tracked t) => t.RefEquals(((Component)stats).gameObject)))
						{
							tracked.Add(new Tracked(((Component)stats).gameObject, stats));
						}
					}
				}
			}
			tracked.RemoveAll((Tracked t) => !t.Valid() || !seen.Contains(t.Go));
		}

		private static int TryGetPlayerLevel(int fallback)
		{
			return Mathf.Max(1, fallback);
		}

		private static void DrawBorder(Rect rect, int thickness, Color color)
		{
			//IL_0001: 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_0049: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = color;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, (float)thickness), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - (float)thickness, ((Rect)(ref rect)).width, (float)thickness), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, (float)thickness, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - (float)thickness, ((Rect)(ref rect)).y, (float)thickness, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
		}

		private static void DrawGlowBorder(Rect rect, int thickness, Color color, int layers)
		{
			//IL_0009: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			Color color2 = default(Color);
			Rect rect2 = default(Rect);
			for (int i = 0; i < layers; i++)
			{
				float num = color.a * (1f - (float)i * 0.4f);
				if (num <= 0f)
				{
					break;
				}
				((Color)(ref color2))..ctor(color.r, color.g, color.b, num);
				((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x - (float)i, ((Rect)(ref rect)).y - (float)i, ((Rect)(ref rect)).width + (float)(i * 2), ((Rect)(ref rect)).height + (float)(i * 2));
				DrawBorder(rect2, thickness, color2);
			}
		}

		private static void DrawOutlinedLabel(Rect rect, string text, GUIStyle style, Color textColor, Color outlineColor)
		{
			//IL_0001: 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_005a: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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)
			GUI.color = outlineColor;
			GUI.Label(new Rect(((Rect)(ref rect)).x - 1f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y - 1f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 1f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.color = textColor;
			GUI.Label(rect, text, style);
		}

		private static Color HpGradient(float pct)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0045: 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)
			pct = Mathf.Clamp01(pct);
			return (pct >= 0.5f) ? Color.Lerp(Color.yellow, Color.green, (pct - 0.5f) / 0.5f) : Color.Lerp(Color.red, Color.yellow, pct / 0.5f);
		}

		private bool ShouldSuppressUI()
		{
			bool flag = false;
			try
			{
				flag |= GameData.AuctionWindowOpen || GameData.PlayerAuctionItemsOpen;
				bool num = flag;
				BankUI bankUI = GameData.BankUI;
				int num2;
				if (bankUI == null)
				{
					num2 = 0;
				}
				else
				{
					GameObject bankWindow = bankUI.BankWindow;
					num2 = (((bankWindow != null) ? new bool?(bankWindow.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num ? 1u : 0u) | (uint)num2) != 0;
				bool num3 = flag;
				GameManager gM = GameData.GM;
				int num4;
				if (gM == null)
				{
					num4 = 0;
				}
				else
				{
					GameObject escapeMenu = gM.EscapeMenu;
					num4 = (((escapeMenu != null) ? new bool?(escapeMenu.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num3 ? 1u : 0u) | (uint)num4) != 0;
				bool num5 = flag;
				GroupBuilder groupBuilder = GameData.GroupBuilder;
				int num6;
				if (groupBuilder == null)
				{
					num6 = 0;
				}
				else
				{
					GameObject gameObject = ((Component)groupBuilder).gameObject;
					num6 = (((gameObject != null) ? new bool?(gameObject.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num5 ? 1u : 0u) | (uint)num6) != 0;
				bool num7 = flag;
				Misc misc = GameData.Misc;
				int num8;
				if (misc == null)
				{
					num8 = 0;
				}
				else
				{
					GameObject helpWindow = misc.HelpWindow;
					num8 = (((helpWindow != null) ? new bool?(helpWindow.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num7 ? 1u : 0u) | (uint)num8) != 0;
				bool num9 = flag;
				Inventory playerInv = GameData.PlayerInv;
				int num10;
				if (playerInv != null)
				{
					GameObject invWindow = playerInv.InvWindow;
					if (((invWindow != null) ? new bool?(invWindow.activeSelf) : null).GetValueOrDefault())
					{
						num10 = 1;
						goto IL_0154;
					}
				}
				Inventory playerInv2 = GameData.PlayerInv;
				if (playerInv2 == null)
				{
					num10 = 0;
				}
				else
				{
					GameObject statWindow = playerInv2.StatWindow;
					num10 = (((statWindow != null) ? new bool?(statWindow.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				goto IL_0154;
				IL_0154:
				flag = (byte)((num9 ? 1u : 0u) | (uint)num10) != 0;
				bool num11 = flag;
				ItemInfoWindow itemInfoWindow = GameData.ItemInfoWindow;
				flag = num11 | (itemInfoWindow != null && itemInfoWindow.isWindowActive());
				bool num12 = flag;
				LootWindow lootWindow = GameData.LootWindow;
				int num13;
				if (lootWindow == null)
				{
					num13 = 0;
				}
				else
				{
					GameObject windowParent = lootWindow.WindowParent;
					num13 = (((windowParent != null) ? new bool?(windowParent.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num12 ? 1u : 0u) | (uint)num13) != 0;
				bool num14 = flag;
				HotkeyManager hKMngr = GameData.HKMngr;
				int num15;
				if (hKMngr == null)
				{
					num15 = 0;
				}
				else
				{
					GameObject map = hKMngr.Map;
					num15 = (((map != null) ? new bool?(map.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num14 ? 1u : 0u) | (uint)num15) != 0;
				bool num16 = flag;
				HotkeyManager hKMngr2 = GameData.HKMngr;
				int num17;
				if (hKMngr2 == null)
				{
					num17 = 0;
				}
				else
				{
					GameObject optionsMenu = hKMngr2.OptionsMenu;
					num17 = (((optionsMenu != null) ? new bool?(optionsMenu.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num16 ? 1u : 0u) | (uint)num17) != 0;
				flag |= GameData.VendorWindowOpen;
				bool num18 = flag;
				QuestLog questLog = GameData.QuestLog;
				int num19;
				if (questLog == null)
				{
					num19 = 0;
				}
				else
				{
					GameObject questWindow = questLog.QuestWindow;
					num19 = (((questWindow != null) ? new bool?(questWindow.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num18 ? 1u : 0u) | (uint)num19) != 0;
				bool num20 = flag;
				Smithing smithing = GameData.Smithing;
				int num21;
				if (smithing == null)
				{
					num21 = 0;
				}
				else
				{
					GameObject smithingWindow = smithing.SmithingWindow;
					num21 = (((smithingWindow != null) ? new bool?(smithingWindow.activeSelf) : null).GetValueOrDefault() ? 1 : 0);
				}
				flag = (byte)((num20 ? 1u : 0u) | (uint)num21) != 0;
				flag |= (Object)(object)_spellGo != (Object)null && _spellGo.activeSelf;
				flag |= (Object)(object)_skillGo != (Object)null && _skillGo.activeSelf;
				flag |= (Object)(object)_restWin != (Object)null && ((Component)_restWin).gameObject.activeSelf;
				flag |= (Object)(object)_runWin != (Object)null && ((Component)_runWin).gameObject.activeSelf;
				flag |= (Object)(object)_reviveWin != (Object)null && _reviveWin.activeSelf;
				flag |= (Object)(object)_npcDialog != (Object)null && _npcDialog.activeSelf;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("[OBaCT] Error in ShouldSuppressUI: " + ex));
			}
			if (SuppressMode.Value == SuppressionMode.Off)
			{
				return false;
			}
			if (SuppressMode.Value == SuppressionMode.Hard)
			{
				return flag;
			}
			if (SuppressMode.Value == SuppressionMode.Fade)
			{
				return false;
			}
			return flag;
		}

		private void TrackWindow(ref bool lastState, bool currentState, string name, List<string> list)
		{
			if (currentState)
			{
				list.Add(name);
			}
			if (currentState != lastState)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[OBaCT] {name} active = {currentState}");
				lastState = currentState;
			}
		}

		private static bool IsOpenByName(ref GameObject cache, string name)
		{
			if ((Object)(object)cache == (Object)null)
			{
				cache = GameObject.Find(name);
			}
			if ((Object)(object)cache != (Object)null)
			{
				return cache.activeSelf || cache.activeInHierarchy;
			}
			return false;
		}

		private void RefreshUIRefsTick()
		{
			_uiRefetchTimer -= Time.unscaledDeltaTime;
			if (_uiRefetchTimer > 0f)
			{
				return;
			}
			_uiRefetchTimer = _uiRefetchCooldown;
			if ((Object)(object)_spellGo == (Object)null)
			{
				_spellGo = GameObject.Find("SpellBook");
			}
			if ((Object)(object)_skillGo == (Object)null)
			{
				_skillGo = GameObject.Find("SkillBook");
			}
			if ((Object)(object)_mainMenu == (Object)null)
			{
				_mainMenu = GameObject.Find("MainMenu");
			}
			if ((Object)(object)_minimapCanvas == (Object)null)
			{
				_minimapCanvas = GameObject.Find("MinimapCanvas");
			}
			if ((Object)(object)_minimapPanel == (Object)null)
			{
				_minimapPanel = GameObject.Find("MinimapPanel");
			}
			if (!((Object)(object)_spellGo == (Object)null) && !((Object)(object)_skillGo == (Object)null) && !((Object)(object)_mainMenu == (Object)null) && !((Object)(object)_minimapCanvas == (Object)null) && !((Object)(object)_minimapPanel == (Object)null))
			{
				return;
			}
			Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
			foreach (Transform val in array)
			{
				string name = ((Object)val).name;
				if ((Object)(object)_spellGo == (Object)null && name.Equals("SpellBook", StringComparison.OrdinalIgnoreCase))
				{
					_spellGo = ((Component)val).gameObject;
				}
				if ((Object)(object)_skillGo == (Object)null && name.Equals("SkillBook", StringComparison.OrdinalIgnoreCase))
				{
					_skillGo = ((Component)val).gameObject;
				}
				if ((Object)(object)_mainMenu == (Object)null && name.Equals("MainMenu", StringComparison.OrdinalIgnoreCase))
				{
					_mainMenu = ((Component)val).gameObject;
				}
				if ((Object)(object)_minimapCanvas == (Object)null && name.Equals("MinimapCanvas", StringComparison.OrdinalIgnoreCase))
				{
					_minimapCanvas = ((Component)val).gameObject;
				}
				if ((Object)(object)_minimapPanel == (Object)null && name.Equals("MinimapPanel", StringComparison.OrdinalIgnoreCase))
				{
					_minimapPanel = ((Component)val).gameObject;
				}
			}
		}
	}
}