Decompiled source of TooMuchHUD v1.2.1

TooMuchHUD.dll

Decompiled 6 days 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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnboundLib;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StatusHUD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StatusHUD")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8c5560eb-18d6-4df5-8a09-91960103a612")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TooMuchHUD;

public class HealthBarText : MonoBehaviour
{
	private Player player;

	private TextMeshProUGUI tm;

	private GameObject textObj;

	private HealthBar nativeBar;

	private Transform playerNameTransform;

	private Transform healthBarTransform;

	private bool hasCapturedElements = false;

	private float lastHealth = -999f;

	private float lastMaxHealth = -999f;

	private bool lastDeadState = false;

	private void Start()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		player = ((Component)this).GetComponent<Player>();
		nativeBar = ((Component)player).GetComponentInChildren<HealthBar>();
		textObj = new GameObject("StatusHealthText");
		if ((Object)(object)nativeBar != (Object)null)
		{
			Canvas componentInChildren = ((Component)nativeBar).GetComponentInChildren<Canvas>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				textObj.transform.SetParent(((Component)componentInChildren).transform);
				healthBarTransform = ((Component)componentInChildren).transform.Find("Image");
			}
		}
		else
		{
			textObj.transform.SetParent(((Component)this).transform);
		}
		Transform[] componentsInChildren = ((Component)player).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			if (((Object)val).name == "PlayerName")
			{
				playerNameTransform = val;
				break;
			}
		}
		hasCapturedElements = true;
		tm = textObj.AddComponent<TextMeshProUGUI>();
		((TMP_Text)tm).enableWordWrapping = false;
		((TMP_Text)tm).overflowMode = (TextOverflowModes)0;
		((TMP_Text)tm).alignment = (TextAlignmentOptions)1026;
		((TMP_Text)tm).fontStyle = (FontStyles)1;
		((Graphic)tm).raycastTarget = false;
		RectTransform component = textObj.GetComponent<RectTransform>();
		component.pivot = new Vector2(0.5f, 0f);
		component.sizeDelta = new Vector2(1000f, 100f);
		textObj.transform.localScale = Vector3.one;
		Canvas componentInParent = textObj.GetComponentInParent<Canvas>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			componentInParent.sortingOrder = 999;
			componentInParent.overrideSorting = true;
		}
	}

	private void Update()
	{
		//IL_018a: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		if (!hasCapturedElements || !Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)textObj) || !Object.op_Implicit((Object)(object)tm))
		{
			return;
		}
		if ((Object)(object)playerNameTransform != (Object)null)
		{
			bool value = StatusHUDMod.ShowPlayerName.Value;
			if (((Component)playerNameTransform).gameObject.activeSelf != value)
			{
				((Component)playerNameTransform).gameObject.SetActive(value);
			}
			if (value)
			{
				playerNameTransform.localPosition = new Vector3(playerNameTransform.localPosition.x, 35f + StatusHUDMod.PlayerNameHeight.Value, playerNameTransform.localPosition.z);
			}
		}
		if ((Object)(object)healthBarTransform != (Object)null)
		{
			bool value2 = StatusHUDMod.ShowHealthBar.Value;
			if (((Component)healthBarTransform).gameObject.activeSelf != value2)
			{
				((Component)healthBarTransform).gameObject.SetActive(value2);
			}
			if (value2)
			{
				healthBarTransform.localPosition = new Vector3(healthBarTransform.localPosition.x, StatusHUDMod.HealthBarHeight.Value, healthBarTransform.localPosition.z);
			}
		}
		textObj.transform.localPosition = new Vector3(0f, StatusHUDMod.HealthTextHeight.Value, 0f);
		((TMP_Text)tm).fontSize = StatusHUDMod.HealthTextSize.Value * 10f;
		if (player.data.dead || !StatusHUDMod.ShowHealthNumbers.Value)
		{
			if (((TMP_Text)tm).text != "")
			{
				((TMP_Text)tm).text = "";
			}
			lastDeadState = true;
		}
		else if (lastDeadState || Mathf.Abs(player.data.health - lastHealth) > 0.5f || Mathf.Abs(player.data.maxHealth - lastMaxHealth) > 0.5f)
		{
			int num = Mathf.CeilToInt(player.data.health);
			int num2 = Mathf.CeilToInt(player.data.maxHealth);
			((TMP_Text)tm).text = $"{Mathf.Max(0, num)}/{num2}";
			float num3 = Mathf.Clamp01(player.data.health / player.data.maxHealth);
			((Graphic)tm).color = Color.HSVToRGB(Mathf.Lerp(0f, 0.3f, num3), 1f, 1f);
			lastHealth = player.data.health;
			lastMaxHealth = player.data.maxHealth;
			lastDeadState = false;
		}
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)textObj))
		{
			Object.Destroy((Object)(object)textObj);
		}
	}
}
public class HUDText : MonoBehaviour
{
	private TextMeshProUGUI tm;

	private float lifeTime = 0.8f;

	private Vector3 motionVector;

	public static void Create(Vector3 position, float amount, Color c, bool isHealing)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)StatusHUDMod.GlobalCanvasTransform == (Object)null))
		{
			GameObject val = new GameObject("DamageNumber");
			val.transform.SetParent(StatusHUDMod.GlobalCanvasTransform, false);
			val.transform.position = position + new Vector3(Random.Range(-0.5f, 0.5f), 0f, 0f);
			HUDText hUDText = val.AddComponent<HUDText>();
			hUDText.Setup(amount, c, isHealing);
		}
	}

	private void Awake()
	{
		//IL_006d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		tm = ((Component)this).gameObject.AddComponent<TextMeshProUGUI>();
		((TMP_Text)tm).alignment = (TextAlignmentOptions)514;
		((TMP_Text)tm).enableWordWrapping = false;
		((TMP_Text)tm).overflowMode = (TextOverflowModes)0;
		((Graphic)tm).raycastTarget = false;
		((TMP_Text)tm).fontSize = 4f;
		RectTransform component = ((Component)this).GetComponent<RectTransform>();
		component.pivot = new Vector2(0.5f, 0.5f);
		component.sizeDelta = new Vector2(5f, 5f);
		Material val = new Material(((TMP_Text)tm).fontMaterial);
		val.SetInt("unity_GUIZTestMode", 8);
		val.renderQueue = 4000;
		((TMP_Text)tm).fontMaterial = val;
	}

	public void Setup(float amount, Color c, bool isHealing)
	{
		//IL_0021: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		((TMP_Text)tm).text = Mathf.RoundToInt(amount).ToString();
		((Graphic)tm).color = c;
		lifeTime = 0.8f + Mathf.Clamp(amount / 200f, 0f, 1.2f);
		if (isHealing)
		{
			((TMP_Text)tm).text = "+" + ((TMP_Text)tm).text;
			((Component)this).transform.localScale = new Vector3(0.15f, 0.15f, 0.15f);
			motionVector = new Vector3(0f, 3f, 0f);
		}
		else
		{
			float num = ((amount > 150f) ? 0.3f : ((amount > 30f) ? 0.2f : 0.12f));
			((TMP_Text)tm).fontStyle = (FontStyles)(amount > 30f);
			((Component)this).transform.localScale = new Vector3(num, num, num);
			motionVector = new Vector3(0f, (amount > 150f) ? 8f : ((amount > 30f) ? 5f : 3f), 0f);
		}
	}

	private void Update()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = ((Component)this).transform;
		transform.position += motionVector * Time.deltaTime;
		motionVector -= motionVector * 6f * Time.deltaTime;
		lifeTime -= Time.deltaTime;
		if (lifeTime < 0.4f)
		{
			Color color = ((Graphic)tm).color;
			color.a -= 4f * Time.deltaTime;
			((Graphic)tm).color = color;
			if (color.a <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)tm != (Object)null && (Object)(object)((TMP_Text)tm).fontMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)((TMP_Text)tm).fontMaterial);
		}
	}
}
public class PlayerData
{
	public float lastHealth;

	public Vector3 lastPos;

	public Color lastColor = Color.white;

	public float damageBuffer = 0f;

	public float healingBuffer = 0f;

	public float printTimer = 0f;

	public bool wasDead = false;
}
public static class StatSpy
{
	public static void TakeDamagePostfix(HealthHandler __instance, Vector2 damage, Color dmgColor, Player damagingPlayer)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance == (Object)null))
		{
			Player component = ((Component)__instance).GetComponent<Player>();
			if ((Object)(object)StatusHUDMod.Instance != (Object)null)
			{
				StatusHUDMod.Instance.RegisterHitColor(component, dmgColor);
			}
		}
	}

	public static void HealPostfix(HealthHandler __instance, float healAmount)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		Player component = ((Component)__instance).GetComponent<Player>();
		if ((Object)(object)component != (Object)null)
		{
			StatTracker component2 = ((Component)component).GetComponent<StatTracker>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.AddHeal(healAmount);
			}
		}
	}
}
public class StatTracker : MonoBehaviour
{
	private float healingAccumulator = 0f;

	private float timeElapsed = 0f;

	private float displayHPS = 0f;

	public void AddHeal(float amount)
	{
		healingAccumulator += amount;
	}

	public float GetHPS()
	{
		return displayHPS;
	}

	private void Update()
	{
		timeElapsed += Time.deltaTime;
		if (timeElapsed >= 1f)
		{
			displayHPS = healingAccumulator / timeElapsed;
			healingAccumulator = 0f;
			timeElapsed = 0f;
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Xomik.TooMuchHUD", "TooMuchHUD", "1.2.1")]
[BepInProcess("Rounds.exe")]
public class StatusHUDMod : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__17_0;

		public static Func<Type, bool> <>9__19_0;

		public static Func<MethodInfo, bool> <>9__19_1;

		public static Func<Player, bool> <>9__19_2;

		public static Func<Player, string> <>9__19_3;

		public static Func<Player, bool> <>9__19_4;

		public static Func<Player, string> <>9__19_5;

		public static Func<Player, bool> <>9__19_6;

		public static Func<Player, string> <>9__19_7;

		public static Func<Player, bool> <>9__19_8;

		public static Func<Player, string> <>9__19_9;

		public static Func<Player, bool> <>9__19_10;

		public static Func<Player, string> <>9__19_11;

		public static Func<Player, bool> <>9__19_12;

		public static Func<Player, string> <>9__19_13;

		public static Func<Player, bool> <>9__19_14;

		public static Func<Player, string> <>9__19_15;

		internal void <Start>b__17_0()
		{
		}

		internal bool <RegisterTabInfoStats>b__19_0(Type t)
		{
			return t.Name == "TabInfoManager";
		}

		internal bool <RegisterTabInfoStats>b__19_1(MethodInfo m)
		{
			return m.Name == "RegisterStat" && m.GetParameters().Length == 4;
		}

		internal bool <RegisterTabInfoStats>b__19_2(Player p)
		{
			return p.data.weaponHandler.gun.numberOfProjectiles > 1;
		}

		internal string <RegisterTabInfoStats>b__19_3(Player p)
		{
			return p.data.weaponHandler.gun.numberOfProjectiles.ToString();
		}

		internal bool <RegisterTabInfoStats>b__19_4(Player p)
		{
			return p.data.weaponHandler.gun.reflects > 0;
		}

		internal string <RegisterTabInfoStats>b__19_5(Player p)
		{
			return p.data.weaponHandler.gun.reflects.ToString();
		}

		internal bool <RegisterTabInfoStats>b__19_6(Player p)
		{
			return Mathf.Abs(p.data.weaponHandler.gun.knockback - 1f) > 0.01f;
		}

		internal string <RegisterTabInfoStats>b__19_7(Player p)
		{
			return Mathf.RoundToInt(p.data.weaponHandler.gun.knockback * 100f) + "%";
		}

		internal bool <RegisterTabInfoStats>b__19_8(Player p)
		{
			return p.data.stats.lifeSteal > 0f;
		}

		internal string <RegisterTabInfoStats>b__19_9(Player p)
		{
			return Mathf.RoundToInt(p.data.stats.lifeSteal * 100f) + "%";
		}

		internal bool <RegisterTabInfoStats>b__19_10(Player p)
		{
			StatTracker component = ((Component)p).GetComponent<StatTracker>();
			return Object.op_Implicit((Object)(object)component) && component.GetHPS() > 0.5f;
		}

		internal string <RegisterTabInfoStats>b__19_11(Player p)
		{
			StatTracker component = ((Component)p).GetComponent<StatTracker>();
			return Object.op_Implicit((Object)(object)component) ? component.GetHPS().ToString("F0") : "0";
		}

		internal bool <RegisterTabInfoStats>b__19_12(Player p)
		{
			return p.data.jumps > 1;
		}

		internal string <RegisterTabInfoStats>b__19_13(Player p)
		{
			return p.data.jumps.ToString();
		}

		internal bool <RegisterTabInfoStats>b__19_14(Player p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Abs(((Component)p).transform.localScale.x / 1.2f - 1f) > 0.05f;
		}

		internal string <RegisterTabInfoStats>b__19_15(Player p)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Component)p).transform.localScale.x / 1.2f;
			return (num * num).ToString("F2") + "x";
		}
	}

	[CompilerGenerated]
	private sealed class <RegisterTabInfoStats>d__19 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public StatusHUDMod <>4__this;

		private Type <managerType>5__1;

		private Assembly[] <>s__2;

		private int <>s__3;

		private Assembly <asm>5__4;

		private MethodInfo <regCat>5__5;

		private object <categoryObj>5__6;

		private MethodInfo <regStat>5__7;

		private Func<Player, bool> <projCond>5__8;

		private Func<Player, string> <projVal>5__9;

		private Func<Player, bool> <bounceCond>5__10;

		private Func<Player, string> <bounceVal>5__11;

		private Func<Player, bool> <knockCond>5__12;

		private Func<Player, string> <knockVal>5__13;

		private Func<Player, bool> <lsCond>5__14;

		private Func<Player, string> <lsVal>5__15;

		private Func<Player, bool> <hpsCond>5__16;

		private Func<Player, string> <hpsVal>5__17;

		private Func<Player, bool> <jumpCond>5__18;

		private Func<Player, string> <jumpVal>5__19;

		private Func<Player, bool> <sizeCond>5__20;

		private Func<Player, string> <sizeVal>5__21;

		private Exception <e>5__22;

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

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

		[DebuggerHidden]
		public <RegisterTabInfoStats>d__19(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<managerType>5__1 = null;
			<>s__2 = null;
			<asm>5__4 = null;
			<regCat>5__5 = null;
			<categoryObj>5__6 = null;
			<regStat>5__7 = null;
			<projCond>5__8 = null;
			<projVal>5__9 = null;
			<bounceCond>5__10 = null;
			<bounceVal>5__11 = null;
			<knockCond>5__12 = null;
			<knockVal>5__13 = null;
			<lsCond>5__14 = null;
			<lsVal>5__15 = null;
			<hpsCond>5__16 = null;
			<hpsVal>5__17 = null;
			<jumpCond>5__18 = null;
			<jumpVal>5__19 = null;
			<sizeCond>5__20 = null;
			<sizeVal>5__21 = null;
			<e>5__22 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1.5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<managerType>5__1 = null;
				<>s__2 = AppDomain.CurrentDomain.GetAssemblies();
				for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
				{
					<asm>5__4 = <>s__2[<>s__3];
					try
					{
						<managerType>5__1 = <asm>5__4.GetTypes().FirstOrDefault((Type t) => t.Name == "TabInfoManager");
						if (<managerType>5__1 != null)
						{
							break;
						}
					}
					catch
					{
					}
					<asm>5__4 = null;
				}
				<>s__2 = null;
				if (<managerType>5__1 != null)
				{
					try
					{
						<regCat>5__5 = <managerType>5__1.GetMethod("RegisterCategory", new Type[2]
						{
							typeof(string),
							typeof(int)
						});
						<categoryObj>5__6 = <regCat>5__5.Invoke(null, new object[2] { "TooMuchHUD", 10 });
						<regStat>5__7 = <managerType>5__1.GetMethods().FirstOrDefault((MethodInfo m) => m.Name == "RegisterStat" && m.GetParameters().Length == 4);
						if (<regStat>5__7 != null)
						{
							<projCond>5__8 = (Player p) => p.data.weaponHandler.gun.numberOfProjectiles > 1;
							<projVal>5__9 = (Player p) => p.data.weaponHandler.gun.numberOfProjectiles.ToString();
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "Projectiles", <projCond>5__8, <projVal>5__9 });
							<bounceCond>5__10 = (Player p) => p.data.weaponHandler.gun.reflects > 0;
							<bounceVal>5__11 = (Player p) => p.data.weaponHandler.gun.reflects.ToString();
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "Bounces", <bounceCond>5__10, <bounceVal>5__11 });
							<knockCond>5__12 = (Player p) => Mathf.Abs(p.data.weaponHandler.gun.knockback - 1f) > 0.01f;
							<knockVal>5__13 = (Player p) => Mathf.RoundToInt(p.data.weaponHandler.gun.knockback * 100f) + "%";
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "Knockback", <knockCond>5__12, <knockVal>5__13 });
							<lsCond>5__14 = (Player p) => p.data.stats.lifeSteal > 0f;
							<lsVal>5__15 = (Player p) => Mathf.RoundToInt(p.data.stats.lifeSteal * 100f) + "%";
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "Lifesteal", <lsCond>5__14, <lsVal>5__15 });
							<hpsCond>5__16 = delegate(Player p)
							{
								StatTracker component2 = ((Component)p).GetComponent<StatTracker>();
								return Object.op_Implicit((Object)(object)component2) && component2.GetHPS() > 0.5f;
							};
							<hpsVal>5__17 = delegate(Player p)
							{
								StatTracker component = ((Component)p).GetComponent<StatTracker>();
								return Object.op_Implicit((Object)(object)component) ? component.GetHPS().ToString("F0") : "0";
							};
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "HPS", <hpsCond>5__16, <hpsVal>5__17 });
							<jumpCond>5__18 = (Player p) => p.data.jumps > 1;
							<jumpVal>5__19 = (Player p) => p.data.jumps.ToString();
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "Jumps", <jumpCond>5__18, <jumpVal>5__19 });
							<sizeCond>5__20 = (Player p) => Mathf.Abs(((Component)p).transform.localScale.x / 1.2f - 1f) > 0.05f;
							<sizeVal>5__21 = delegate(Player p)
							{
								//IL_0007: Unknown result type (might be due to invalid IL or missing references)
								float num = ((Component)p).transform.localScale.x / 1.2f;
								return (num * num).ToString("F2") + "x";
							};
							<regStat>5__7.Invoke(null, new object[4] { <categoryObj>5__6, "Size", <sizeCond>5__20, <sizeVal>5__21 });
							<projCond>5__8 = null;
							<projVal>5__9 = null;
							<bounceCond>5__10 = null;
							<bounceVal>5__11 = null;
							<knockCond>5__12 = null;
							<knockVal>5__13 = null;
							<lsCond>5__14 = null;
							<lsVal>5__15 = null;
							<hpsCond>5__16 = null;
							<hpsVal>5__17 = null;
							<jumpCond>5__18 = null;
							<jumpVal>5__19 = null;
							<sizeCond>5__20 = null;
							<sizeVal>5__21 = null;
						}
						<regCat>5__5 = null;
						<categoryObj>5__6 = null;
						<regStat>5__7 = null;
					}
					catch (Exception ex)
					{
						<e>5__22 = ex;
						Debug.LogError((object)$"[TooMuchHUD] Error registering TabInfo: {<e>5__22}");
					}
				}
				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();
		}
	}

	public static ConfigEntry<bool> ShowDamageNumbers;

	public static ConfigEntry<bool> ShowHealthNumbers;

	public static ConfigEntry<bool> ShowPlayerName;

	public static ConfigEntry<bool> ShowHealthBar;

	public static ConfigEntry<float> HealthTextSize;

	public static ConfigEntry<float> HealthTextHeight;

	public static ConfigEntry<float> PlayerNameHeight;

	public static ConfigEntry<float> HealthBarHeight;

	public static GameObject GlobalCanvasObj;

	public static Transform GlobalCanvasTransform;

	private Dictionary<Player, PlayerData> playerStates = new Dictionary<Player, PlayerData>();

	private Dictionary<int, GameObject> processedPlayerObjects = new Dictionary<int, GameObject>();

	public static StatusHUDMod Instance { get; private set; }

	private void Awake()
	{
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Expected O, but got Unknown
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Expected O, but got Unknown
		Instance = this;
		ShowDamageNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Damage Numbers", true, "Show floating damage text.");
		ShowHealthNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Health Numbers", true, "Show the numeric health.");
		ShowPlayerName = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Player Name", true, "Show the player's name.");
		ShowHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Health Bar", true, "Show the vanilla health bar.");
		HealthTextSize = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Health Text Size", 17f, "Size of the health text.");
		HealthTextHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Health Text Y-Offset", 55f, "Vertical position of the health numbers.");
		HealthBarHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Health Bar Y-Offset", 50f, "Vertical position of the vanilla health bar.");
		PlayerNameHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Player Name Y-Offset", -40f, "Vertical position of the player name.");
		SetupGlobalCanvas();
		Harmony val = new Harmony("com.Xomik.TooMuchHUD");
		MethodInfo methodInfo = AccessTools.Method(typeof(HealthHandler), "TakeDamage", new Type[6]
		{
			typeof(Vector2),
			typeof(Vector2),
			typeof(Color),
			typeof(Player),
			typeof(Player),
			typeof(bool)
		}, (Type[])null);
		if (methodInfo != null)
		{
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(StatSpy).GetMethod("TakeDamagePostfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthHandler), "Heal", (Type[])null, (Type[])null);
		if (methodInfo2 != null)
		{
			val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(StatSpy).GetMethod("HealPostfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}

	private void Start()
	{
		//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_0025: Expected O, but got Unknown
		object obj = <>c.<>9__17_0;
		if (obj == null)
		{
			UnityAction val = delegate
			{
			};
			<>c.<>9__17_0 = val;
			obj = (object)val;
		}
		Unbound.RegisterMenu("TooMuchHUD", (UnityAction)obj, (Action<GameObject>)CreateSettingsMenu, (GameObject)null, true);
		((MonoBehaviour)this).StartCoroutine(RegisterTabInfoStats());
	}

	private void SetupGlobalCanvas()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		if (!((Object)(object)GlobalCanvasObj != (Object)null))
		{
			GlobalCanvasObj = new GameObject("TooMuchHUD_GlobalCanvas");
			Object.DontDestroyOnLoad((Object)(object)GlobalCanvasObj);
			Canvas val = GlobalCanvasObj.AddComponent<Canvas>();
			val.renderMode = (RenderMode)2;
			val.sortingLayerName = "MostFront";
			val.overrideSorting = true;
			val.sortingOrder = 30000;
			GlobalCanvasTransform = GlobalCanvasObj.transform;
		}
	}

	[IteratorStateMachine(typeof(<RegisterTabInfoStats>d__19))]
	private IEnumerator RegisterTabInfoStats()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RegisterTabInfoStats>d__19(0)
		{
			<>4__this = this
		};
	}

	private void CreateSettingsMenu(GameObject menu)
	{
		TextMeshProUGUI val = default(TextMeshProUGUI);
		MenuHandler.CreateText("TooMuchHUD Settings", menu, ref val, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateToggle(ShowHealthNumbers.Value, "Show Health Numbers", menu, (UnityAction<bool>)delegate(bool v)
		{
			ShowHealthNumbers.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateToggle(ShowHealthBar.Value, "Show Health Bar", menu, (UnityAction<bool>)delegate(bool v)
		{
			ShowHealthBar.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateToggle(ShowPlayerName.Value, "Show Player Name", menu, (UnityAction<bool>)delegate(bool v)
		{
			ShowPlayerName.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateToggle(ShowDamageNumbers.Value, "Show Floating Damage", menu, (UnityAction<bool>)delegate(bool v)
		{
			ShowDamageNumbers.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		Slider val2 = default(Slider);
		MenuHandler.CreateSlider("Health Text Size", menu, 30, 5f, 60f, HealthTextSize.Value, (UnityAction<float>)delegate(float v)
		{
			HealthTextSize.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateSlider("Health Text Y-Offset", menu, 30, -100f, 150f, HealthTextHeight.Value, (UnityAction<float>)delegate(float v)
		{
			HealthTextHeight.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateSlider("Health Bar Y-Offset", menu, 30, -100f, 150f, HealthBarHeight.Value, (UnityAction<float>)delegate(float v)
		{
			HealthBarHeight.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateSlider("Player Name Y-Offset", menu, 30, -100f, 300f, PlayerNameHeight.Value, (UnityAction<float>)delegate(float v)
		{
			PlayerNameHeight.Value = v;
			((BaseUnityPlugin)this).Config.Save();
		}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
	}

	public void RegisterHitColor(Player p, Color c)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)p == (Object)null))
		{
			if (!playerStates.ContainsKey(p))
			{
				playerStates[p] = new PlayerData();
			}
			if (c.a > 0.1f)
			{
				playerStates[p].lastColor = c;
			}
		}
	}

	private void Update()
	{
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: 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_0367: 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_03ac: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)PlayerManager.instance == (Object)null)
		{
			return;
		}
		for (int i = 0; i < PlayerManager.instance.players.Count; i++)
		{
			Player val = PlayerManager.instance.players[i];
			bool flag = false;
			if (!processedPlayerObjects.ContainsKey(val.playerID) || (Object)(object)processedPlayerObjects[val.playerID] != (Object)(object)((Component)val).gameObject)
			{
				flag = true;
			}
			if (flag)
			{
				if ((Object)(object)((Component)val).gameObject.GetComponent<HealthBarText>() == (Object)null)
				{
					((Component)val).gameObject.AddComponent<HealthBarText>();
				}
				if ((Object)(object)((Component)val).gameObject.GetComponent<StatTracker>() == (Object)null)
				{
					((Component)val).gameObject.AddComponent<StatTracker>();
				}
				processedPlayerObjects[val.playerID] = ((Component)val).gameObject;
			}
		}
		if (!ShowDamageNumbers.Value)
		{
			return;
		}
		foreach (Player player in PlayerManager.instance.players)
		{
			if ((Object)(object)player == (Object)null)
			{
				continue;
			}
			if (!playerStates.ContainsKey(player))
			{
				playerStates[player] = new PlayerData
				{
					lastHealth = player.data.health,
					lastPos = ((Component)player).transform.position
				};
			}
			PlayerData playerData = playerStates[player];
			playerData.printTimer -= Time.deltaTime;
			if (((Component)player).gameObject.activeInHierarchy && !player.data.dead)
			{
				playerData.lastPos = ((Component)player).transform.position;
			}
			float health = player.data.health;
			if (player.data.dead || health <= 0f)
			{
				if (!playerData.wasDead)
				{
					if (health < playerData.lastHealth)
					{
						playerData.damageBuffer += playerData.lastHealth - health;
					}
					if (playerData.damageBuffer > 0f)
					{
						SpawnText(playerData.lastPos, playerData.damageBuffer, playerData.lastColor, isHealing: false);
					}
					playerData.damageBuffer = 0f;
					playerData.wasDead = true;
					playerData.lastHealth = player.data.maxHealth;
				}
				continue;
			}
			playerData.wasDead = false;
			if (health < playerData.lastHealth)
			{
				playerData.damageBuffer += playerData.lastHealth - health;
			}
			else if (health > playerData.lastHealth)
			{
				playerData.healingBuffer += health - playerData.lastHealth;
			}
			playerData.lastHealth = health;
			if (playerData.printTimer <= 0f)
			{
				bool flag2 = false;
				if (playerData.damageBuffer >= 1f)
				{
					SpawnText(playerData.lastPos, playerData.damageBuffer, playerData.lastColor, isHealing: false);
					playerData.damageBuffer = 0f;
					flag2 = true;
				}
				else if (playerData.healingBuffer >= 1f)
				{
					SpawnText(playerData.lastPos, playerData.healingBuffer, Color.green, isHealing: true);
					playerData.healingBuffer = 0f;
					flag2 = true;
				}
				if (flag2)
				{
					playerData.printTimer = 0.2f;
				}
			}
		}
	}

	private void SpawnText(Vector3 pos, float amount, Color c, bool isHealing)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		if (!isHealing && c == Color.white)
		{
			((Color)(ref c))..ctor(0.6f, 1f, 0f);
		}
		HUDText.Create(pos + new Vector3(0f, 2f, 0f), amount, c, isHealing);
	}
}