Decompiled source of TooMuchHUD v1.1.0

TooMuchHUD.dll

Decompiled 19 hours 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;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Xomik.TooMuchHUD", "TooMuchHUD", "1.1.0")]
[BepInProcess("Rounds.exe")]
public class StatusHUDMod : BaseUnityPlugin
{
	private 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;
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__14_0;

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

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

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

		internal void <Start>b__14_0()
		{
		}

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

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

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

	[CompilerGenerated]
	private sealed class <RegisterTabInfoStats>d__15 : 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 Type[] <>s__5;

		private int <>s__6;

		private Type <type>5__7;

		private MethodInfo <regCat>5__8;

		private object <categoryObj>5__9;

		private MethodInfo <regStat>5__10;

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

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

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<managerType>5__1 = null;
			<>s__2 = null;
			<asm>5__4 = null;
			<>s__5 = null;
			<type>5__7 = null;
			<regCat>5__8 = null;
			<categoryObj>5__9 = null;
			<regStat>5__10 = null;
			<hpsCond>5__11 = null;
			<hpsVal>5__12 = 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(1f);
				<>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
					{
						<>s__5 = <asm>5__4.GetTypes();
						for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
						{
							<type>5__7 = <>s__5[<>s__6];
							if (<type>5__7.Name == "TabInfoManager")
							{
								<managerType>5__1 = <type>5__7;
								break;
							}
							<type>5__7 = null;
						}
						<>s__5 = null;
					}
					catch
					{
					}
					if (<managerType>5__1 != null)
					{
						break;
					}
					<asm>5__4 = null;
				}
				<>s__2 = null;
				if (<managerType>5__1 != null)
				{
					try
					{
						<regCat>5__8 = <managerType>5__1.GetMethod("RegisterCategory", new Type[2]
						{
							typeof(string),
							typeof(int)
						});
						<categoryObj>5__9 = <regCat>5__8.Invoke(null, new object[2] { "TooMuchHUD", 10 });
						<regStat>5__10 = <managerType>5__1.GetMethods().FirstOrDefault((MethodInfo m) => m.Name == "RegisterStat" && m.GetParameters().Length == 4);
						if (<regStat>5__10 != null)
						{
							<hpsCond>5__11 = delegate(Player p)
							{
								StatTracker component2 = ((Component)p).GetComponent<StatTracker>();
								return Object.op_Implicit((Object)(object)component2) && component2.GetHPS() > 0.5f;
							};
							<hpsVal>5__12 = delegate(Player p)
							{
								StatTracker component = ((Component)p).GetComponent<StatTracker>();
								return Object.op_Implicit((Object)(object)component) ? component.GetHPS().ToString("F0") : "0";
							};
							<regStat>5__10.Invoke(null, new object[4] { <categoryObj>5__9, "HPS", <hpsCond>5__11, <hpsVal>5__12 });
							<hpsCond>5__11 = null;
							<hpsVal>5__12 = null;
						}
						<regCat>5__8 = null;
						<categoryObj>5__9 = null;
						<regStat>5__10 = null;
					}
					catch
					{
					}
				}
				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;

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

	public static StatusHUDMod Instance;

	public static Sprite circleSprite;

	public static Sprite squareSprite;

	private void Awake()
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Expected O, but got Unknown
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Expected O, but got Unknown
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Expected O, but got Unknown
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: 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_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Expected O, but got Unknown
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: 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.");
		if ((Object)(object)circleSprite == (Object)null)
		{
			int num = 64;
			Texture2D val = new Texture2D(num, num);
			Color[] array = (Color[])(object)new Color[num * num];
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((float)num / 2f, (float)num / 2f);
			float num2 = (float)num / 2f - 2f;
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num3 = Vector2.Distance(new Vector2((float)j, (float)i), val2);
					array[i * num + j] = ((num3 <= num2) ? Color.white : Color.clear);
				}
			}
			val.SetPixels(array);
			val.Apply();
			circleSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f));
		}
		if ((Object)(object)squareSprite == (Object)null)
		{
			Texture2D val3 = new Texture2D(2, 2);
			val3.SetPixels((Color[])(object)new Color[4]
			{
				Color.white,
				Color.white,
				Color.white,
				Color.white
			});
			val3.Apply();
			squareSprite = Sprite.Create(val3, new Rect(0f, 0f, 2f, 2f), new Vector2(0.5f, 0.5f));
		}
		Harmony val4 = new Harmony("com.Xomik.TooMuchHUD");
		MethodInfo[] methods = typeof(HealthHandler).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		MethodInfo[] array2 = methods;
		foreach (MethodInfo methodInfo in array2)
		{
			if (methodInfo.Name == "TakeDamage")
			{
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (parameters.Length != 0 && parameters[^1].ParameterType == typeof(Color))
				{
					val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(StatSpy).GetMethod("TakeDamagePostfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			if (methodInfo.Name == "Heal")
			{
				ParameterInfo[] parameters2 = methodInfo.GetParameters();
				if (parameters2.Length == 1 && parameters2[0].ParameterType == typeof(float))
				{
					val4.Patch((MethodBase)methodInfo, (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__14_0;
		if (obj == null)
		{
			UnityAction val = delegate
			{
			};
			<>c.<>9__14_0 = val;
			obj = (object)val;
		}
		Unbound.RegisterMenu("TooMuchHUD", (UnityAction)obj, (Action<GameObject>)CreateSettingsMenu, (GameObject)null, true);
		((MonoBehaviour)this).StartCoroutine(RegisterTabInfoStats());
	}

	[IteratorStateMachine(typeof(<RegisterTabInfoStats>d__15))]
	private IEnumerator RegisterTabInfoStats()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RegisterTabInfoStats>d__15(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 (Default: 17)", 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.CreateText(" ", menu, ref val, 10, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateSlider("Health Text Y-Offset (Default: 55)", 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.CreateText(" ", menu, ref val, 10, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateSlider("Health Bar Y-Offset (Default: 50)", 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.CreateText(" ", menu, ref val, 10, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		MenuHandler.CreateSlider("Player Name Y-Offset (Default: -40)", 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_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)PlayerManager.instance == (Object)null)
		{
			return;
		}
		foreach (Player player in PlayerManager.instance.players)
		{
			if ((Object)(object)player == (Object)null)
			{
				continue;
			}
			if ((Object)(object)((Component)player).gameObject.GetComponent<HealthBarText>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<HealthBarText>();
			}
			if ((Object)(object)((Component)player).gameObject.GetComponent<StatTracker>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<StatTracker>();
			}
			if (!ShowDamageNumbers.Value)
			{
				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 flag = false;
				if (playerData.damageBuffer >= 1f)
				{
					SpawnText(playerData.lastPos, playerData.damageBuffer, playerData.lastColor, isHealing: false);
					playerData.damageBuffer = 0f;
					flag = true;
				}
				else if (playerData.healingBuffer >= 1f)
				{
					SpawnText(playerData.lastPos, playerData.healingBuffer, Color.green, isHealing: true);
					playerData.healingBuffer = 0f;
					flag = true;
				}
				if (flag)
				{
					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);
	}
}
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;
		}
	}
}
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 void Start()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: 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);
		Transform[] array = componentsInChildren;
		foreach (Transform val in array)
		{
			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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: 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)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		if (!hasCapturedElements)
		{
			return;
		}
		if ((Object)(object)playerNameTransform != (Object)null)
		{
			bool value = StatusHUDMod.ShowPlayerName.Value;
			((Component)playerNameTransform).gameObject.SetActive(value);
			if (value)
			{
				float num = 35f;
				float value2 = StatusHUDMod.PlayerNameHeight.Value;
				playerNameTransform.localPosition = new Vector3(playerNameTransform.localPosition.x, num + value2, playerNameTransform.localPosition.z);
			}
		}
		if ((Object)(object)healthBarTransform != (Object)null)
		{
			bool value3 = StatusHUDMod.ShowHealthBar.Value;
			((Component)healthBarTransform).gameObject.SetActive(value3);
			if (value3)
			{
				float value4 = StatusHUDMod.HealthBarHeight.Value;
				healthBarTransform.localPosition = new Vector3(healthBarTransform.localPosition.x, value4, healthBarTransform.localPosition.z);
			}
		}
		if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)textObj) && Object.op_Implicit((Object)(object)tm))
		{
			bool value5 = StatusHUDMod.ShowHealthNumbers.Value;
			if (player.data.dead || !value5)
			{
				((TMP_Text)tm).text = "";
				return;
			}
			float value6 = StatusHUDMod.HealthTextSize.Value;
			float value7 = StatusHUDMod.HealthTextHeight.Value;
			((TMP_Text)tm).fontSize = value6 * 10f;
			textObj.transform.localPosition = new Vector3(0f, value7, 0f);
			int num2 = Mathf.CeilToInt(player.data.health);
			int num3 = Mathf.CeilToInt(player.data.maxHealth);
			((TMP_Text)tm).text = $"{Mathf.Max(0, num2)}/{num3}";
			((Graphic)tm).color = Color.Lerp(Color.red, Color.green, player.data.health / player.data.maxHealth);
		}
	}

	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_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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)
		GameObject val = new GameObject("DamageNumber");
		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_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Expected O, but got Unknown
		Canvas val = ((Component)this).gameObject.AddComponent<Canvas>();
		val.renderMode = (RenderMode)2;
		val.sortingLayerName = "MostFront";
		val.overrideSorting = true;
		val.sortingOrder = 30000;
		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 val2 = new Material(((TMP_Text)tm).fontMaterial);
		val2.SetInt("unity_GUIZTestMode", 8);
		val2.SetInt("_ZTest", 8);
		val2.renderQueue = 4000;
		((TMP_Text)tm).fontMaterial = val2;
	}

	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);
			}
		}
	}
}
public 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)
		try
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				Player component = ((Component)__instance).GetComponent<Player>();
				if ((Object)(object)StatusHUDMod.Instance != (Object)null)
				{
					StatusHUDMod.Instance.RegisterHitColor(component, dmgColor);
				}
			}
		}
		catch
		{
		}
	}

	public static void HealPostfix(HealthHandler __instance, float healAmount)
	{
		try
		{
			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);
				}
			}
		}
		catch
		{
		}
	}
}