Decompiled source of Customizable Hud v1.0.2

CustomizableHud.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("adae4720-c7c6-4fb5-92cb-019b6182cba6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WhiteKnuckleHealthMod;

[BepInPlugin("com.yourname.customizablehud", "Customizable HUD", "1.0.0")]
public class HealthModPlugin : BaseUnityPlugin
{
	public static ConfigFile PluginConfig;

	public static ConfigEntry<string> MenuKey;

	public static ConfigEntry<bool> HpShake;

	public static ConfigEntry<bool> HpAutoHide;

	public static ConfigEntry<float> HpAutoHideDelay;

	public static ConfigEntry<float> HpAutoHideDuration;

	public static ConfigEntry<bool> ShowHp;

	public static ConfigEntry<bool> ShowHpText;

	public static ConfigEntry<bool> HpVertical;

	public static ConfigEntry<float> HpX;

	public static ConfigEntry<float> HpY;

	public static ConfigEntry<float> HpW;

	public static ConfigEntry<float> HpH;

	public static ConfigEntry<float> HpOpacity;

	public static ConfigEntry<float> HpTextOpacity;

	public static ConfigEntry<float> HpTextScale;

	public static ConfigEntry<string> HpBorderColor;

	public static ConfigEntry<float> HpBorderThick;

	public static ConfigEntry<float> HpLowThreshold;

	public static ConfigEntry<string> HpColor;

	public static ConfigEntry<string> HpLowColor;

	public static ConfigEntry<string> HpGhostColor;

	public static ConfigEntry<bool> Stam0Shake;

	public static ConfigEntry<bool> Stam0AutoHide;

	public static ConfigEntry<float> Stam0AutoHideDelay;

	public static ConfigEntry<float> Stam0AutoHideDuration;

	public static ConfigEntry<bool> ShowStam0;

	public static ConfigEntry<bool> ShowStam0Text;

	public static ConfigEntry<bool> Stam0Vertical;

	public static ConfigEntry<float> Stam0X;

	public static ConfigEntry<float> Stam0Y;

	public static ConfigEntry<float> Stam0W;

	public static ConfigEntry<float> Stam0H;

	public static ConfigEntry<float> Stam0Opacity;

	public static ConfigEntry<float> Stam0TextOpacity;

	public static ConfigEntry<float> Stam0TextScale;

	public static ConfigEntry<string> Stam0BorderColor;

	public static ConfigEntry<float> Stam0BorderThick;

	public static ConfigEntry<float> Stam0LowThreshold;

	public static ConfigEntry<string> Stam0Color;

	public static ConfigEntry<string> Stam0LowColor;

	public static ConfigEntry<string> Stam0GhostColor;

	public static ConfigEntry<bool> Stam1Shake;

	public static ConfigEntry<bool> Stam1AutoHide;

	public static ConfigEntry<float> Stam1AutoHideDelay;

	public static ConfigEntry<float> Stam1AutoHideDuration;

	public static ConfigEntry<bool> ShowStam1;

	public static ConfigEntry<bool> ShowStam1Text;

	public static ConfigEntry<bool> Stam1Vertical;

	public static ConfigEntry<float> Stam1X;

	public static ConfigEntry<float> Stam1Y;

	public static ConfigEntry<float> Stam1W;

	public static ConfigEntry<float> Stam1H;

	public static ConfigEntry<float> Stam1Opacity;

	public static ConfigEntry<float> Stam1TextOpacity;

	public static ConfigEntry<float> Stam1TextScale;

	public static ConfigEntry<string> Stam1BorderColor;

	public static ConfigEntry<float> Stam1BorderThick;

	public static ConfigEntry<float> Stam1LowThreshold;

	public static ConfigEntry<string> Stam1Color;

	public static ConfigEntry<string> Stam1LowColor;

	public static ConfigEntry<string> Stam1GhostColor;

	public static ConfigEntry<bool> ShowBuffs;

	public static ConfigEntry<float> BuffsX;

	public static ConfigEntry<float> BuffsY;

	public static ConfigEntry<float> BuffsW;

	public static ConfigEntry<float> BuffsH;

	public static ConfigEntry<float> BuffsOpacity;

	public static ConfigEntry<float> BuffsTextOpacity;

	public static ConfigEntry<float> BuffsTextScale;

	public static ConfigEntry<string> BuffsBgColor;

	public static ConfigEntry<string> BuffsFillColor;

	public static ConfigEntry<string> BuffsTextColor;

	private void Awake()
	{
		PluginConfig = ((BaseUnityPlugin)this).Config;
		MenuKey = ((BaseUnityPlugin)this).Config.Bind<string>("0_Main Settings", "MenuKey", "F10", "=========================================================\n HOTKEY TO OPEN THE IN-GAME SETTINGS MENU\n=========================================================\nJust type the key name here (e.g. F10, K, Space, RightAlt)");
		HpShake = ((BaseUnityPlugin)this).Config.Bind<bool>("HP Bar", "EnableShake", true, "Shake on damage and low health");
		HpAutoHide = ((BaseUnityPlugin)this).Config.Bind<bool>("HP Bar", "AutoHide", true, "Hide HP when full");
		HpAutoHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "AutoHideDelay", 0.5f, "Seconds before HP auto-hides");
		HpAutoHideDuration = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "AutoHideDuration", 0.5f, "Seconds the fade out takes");
		ShowHp = ((BaseUnityPlugin)this).Config.Bind<bool>("HP Bar", "Show", true, "");
		ShowHpText = ((BaseUnityPlugin)this).Config.Bind<bool>("HP Bar", "ShowText", true, "Show numerical value");
		HpVertical = ((BaseUnityPlugin)this).Config.Bind<bool>("HP Bar", "Vertical", false, "Draw bar vertically");
		HpX = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "X", 0.012f, "Screen fraction X");
		HpY = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "Y", 0.905f, "Screen fraction Y");
		HpW = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "Width", 0.207f, "Screen fraction Width");
		HpH = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "Height", 0.028f, "Screen fraction Height");
		HpOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "Opacity", 100f, "Opacity in %");
		HpTextOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "TextOpacity", 100f, "Text Opacity in %");
		HpTextScale = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "TextScale", 1f, "Text size multiplier");
		HpBorderColor = ((BaseUnityPlugin)this).Config.Bind<string>("HP Bar", "BorderColor", "#0C0A07CC", "");
		HpBorderThick = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "BorderThickness", 2f, "");
		HpLowThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("HP Bar", "LowThreshold", 25f, "");
		HpColor = ((BaseUnityPlugin)this).Config.Bind<string>("HP Bar", "Color", "#D8D8D8BF", "");
		HpLowColor = ((BaseUnityPlugin)this).Config.Bind<string>("HP Bar", "LowColor", "#F22626BF", "");
		HpGhostColor = ((BaseUnityPlugin)this).Config.Bind<string>("HP Bar", "GhostColor", "#8C1A1A99", "");
		Stam0Shake = ((BaseUnityPlugin)this).Config.Bind<bool>("Left Stamina", "EnableShake", true, "Shake on damage and low stamina");
		Stam0AutoHide = ((BaseUnityPlugin)this).Config.Bind<bool>("Left Stamina", "AutoHide", true, "Hide left stamina when full");
		Stam0AutoHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "AutoHideDelay", 0.5f, "Seconds before auto-hides");
		Stam0AutoHideDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "AutoHideDuration", 0.5f, "Seconds the fade out takes");
		ShowStam0 = ((BaseUnityPlugin)this).Config.Bind<bool>("Left Stamina", "Show", true, "");
		ShowStam0Text = ((BaseUnityPlugin)this).Config.Bind<bool>("Left Stamina", "ShowText", true, "Show numerical value");
		Stam0Vertical = ((BaseUnityPlugin)this).Config.Bind<bool>("Left Stamina", "Vertical", false, "Draw bar vertically");
		Stam0X = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "X", 0.012f, "");
		Stam0Y = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "Y", 0.94f, "");
		Stam0W = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "Width", 0.101f, "");
		Stam0H = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "Height", 0.028f, "");
		Stam0Opacity = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "Opacity", 100f, "Opacity in %");
		Stam0TextOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "TextOpacity", 100f, "Text Opacity in %");
		Stam0TextScale = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "TextScale", 1f, "Text size multiplier");
		Stam0BorderColor = ((BaseUnityPlugin)this).Config.Bind<string>("Left Stamina", "BorderColor", "#0C0A07CC", "");
		Stam0BorderThick = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "BorderThickness", 2f, "");
		Stam0LowThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Left Stamina", "LowThreshold", 30f, "");
		Stam0Color = ((BaseUnityPlugin)this).Config.Bind<string>("Left Stamina", "Color", "#D8D8D8BF", "");
		Stam0LowColor = ((BaseUnityPlugin)this).Config.Bind<string>("Left Stamina", "LowColor", "#F23333BF", "");
		Stam0GhostColor = ((BaseUnityPlugin)this).Config.Bind<string>("Left Stamina", "GhostColor", "#2659D999", "");
		Stam1Shake = ((BaseUnityPlugin)this).Config.Bind<bool>("Right Stamina", "EnableShake", true, "Shake on damage and low stamina");
		Stam1AutoHide = ((BaseUnityPlugin)this).Config.Bind<bool>("Right Stamina", "AutoHide", true, "Hide right stamina when full");
		Stam1AutoHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "AutoHideDelay", 0.5f, "Seconds before auto-hides");
		Stam1AutoHideDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "AutoHideDuration", 0.5f, "Seconds the fade out takes");
		ShowStam1 = ((BaseUnityPlugin)this).Config.Bind<bool>("Right Stamina", "Show", true, "");
		ShowStam1Text = ((BaseUnityPlugin)this).Config.Bind<bool>("Right Stamina", "ShowText", true, "Show numerical value");
		Stam1Vertical = ((BaseUnityPlugin)this).Config.Bind<bool>("Right Stamina", "Vertical", false, "Draw bar vertically");
		Stam1X = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "X", 0.118f, "");
		Stam1Y = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "Y", 0.94f, "");
		Stam1W = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "Width", 0.101f, "");
		Stam1H = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "Height", 0.028f, "");
		Stam1Opacity = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "Opacity", 100f, "Opacity in %");
		Stam1TextOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "TextOpacity", 100f, "Text Opacity in %");
		Stam1TextScale = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "TextScale", 1f, "Text size multiplier");
		Stam1BorderColor = ((BaseUnityPlugin)this).Config.Bind<string>("Right Stamina", "BorderColor", "#0C0A07CC", "");
		Stam1BorderThick = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "BorderThickness", 2f, "");
		Stam1LowThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Right Stamina", "LowThreshold", 30f, "");
		Stam1Color = ((BaseUnityPlugin)this).Config.Bind<string>("Right Stamina", "Color", "#D8D8D8BF", "");
		Stam1LowColor = ((BaseUnityPlugin)this).Config.Bind<string>("Right Stamina", "LowColor", "#F23333BF", "");
		Stam1GhostColor = ((BaseUnityPlugin)this).Config.Bind<string>("Right Stamina", "GhostColor", "#2659D999", "");
		ShowBuffs = ((BaseUnityPlugin)this).Config.Bind<bool>("Buffs", "ShowBuffs", true, "");
		BuffsX = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "PositionX", 0.05f, "");
		BuffsY = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "PositionY", 0.35f, "");
		BuffsW = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "Width", 0.15f, "");
		BuffsH = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "Height", 0.015f, "");
		BuffsOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "Opacity", 100f, "");
		BuffsTextOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "TextOpacity", 100f, "");
		BuffsTextScale = ((BaseUnityPlugin)this).Config.Bind<float>("Buffs", "TextScale", 1f, "");
		BuffsBgColor = ((BaseUnityPlugin)this).Config.Bind<string>("Buffs", "BgColor", "#202020FF", "");
		BuffsFillColor = ((BaseUnityPlugin)this).Config.Bind<string>("Buffs", "FillColor", "#A09060FF", "");
		BuffsTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("Buffs", "TextColor", "#E0E0E0FF", "");
		SceneManager.sceneLoaded += delegate
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)GameObject.Find("HealthModGUI")))
			{
				GameObject val = new GameObject("HealthModGUI");
				val.AddComponent<HealthModGUI>();
				val.AddComponent<HealthModMenuGUI>();
			}
		};
	}
}
public class HealthModGUI : MonoBehaviour
{
	public static HealthModGUI Instance;

	private const float HEALTH_MULTIPLIER = 20f;

	private const float GHOST_DELAY = 0.5f;

	private const float GHOST_SPEED = 0.4f;

	private const float HP_LOW_SHAKE_STRENGTH = 3f;

	private const float STAMINA_SHAKE_STRENGTH = 2f;

	private const float STAMINA_GHOST_MIN_LOSS = 0.05f;

	private float _hpFadeAlpha = 1f;

	private float _hpFadeDelayTimer = 0f;

	private float _hpFadeOutTimer = 0f;

	private bool _hpIsFading = false;

	private float _stam0FadeAlpha = 1f;

	private float _stam0FadeDelayTimer = 0f;

	private float _stam0FadeOutTimer = 0f;

	private bool _stam0IsFading = false;

	private float _stam1FadeAlpha = 1f;

	private float _stam1FadeDelayTimer = 0f;

	private float _stam1FadeOutTimer = 0f;

	private bool _stam1IsFading = false;

	private Texture2D _hpFill;

	private Texture2D _hpFillLow;

	private Texture2D _hpGhost;

	private Texture2D _hpBg;

	private Texture2D _hpBorder;

	private Texture2D _stam0Fill;

	private Texture2D _stam0FillLow;

	private Texture2D _stam0Ghost;

	private Texture2D _stam0Bg;

	private Texture2D _stam0Border;

	private Texture2D _stam1Fill;

	private Texture2D _stam1FillLow;

	private Texture2D _stam1Ghost;

	private Texture2D _stam1Bg;

	private Texture2D _stam1Border;

	private Texture2D _buffBg;

	private Texture2D _buffFill;

	private Dictionary<string, float> _maxBuffTimes = new Dictionary<string, float>();

	private static FieldInfo _fiCurBuffs;

	private static FieldInfo _fiCurrentBuffsList;

	private static FieldInfo _fiBuffId;

	private static FieldInfo _fiBuffDesc;

	private static FieldInfo _fiBuffBuffs;

	private static FieldInfo _fiBuffTime;

	private static FieldInfo _fiBuffLoseOverTime;

	private static FieldInfo _fiBuffLoseRate;

	private static FieldInfo _fiInnerAmount;

	private static FieldInfo _fiInnerMaxAmount;

	private static FieldInfo _fiInnerId;

	private GUIStyle _textStyle;

	private GUIStyle _shadowStyle;

	private Font _gameFont;

	private bool _fontSearched = false;

	private float _ghostHp = 1f;

	private float _ghostTimer = 0f;

	private float _prevHpNorm = 1f;

	private float _ghostStam0 = 1f;

	private float _ghostStam1 = 1f;

	private float _ghostStamTimer0 = 0f;

	private float _ghostStamTimer1 = 0f;

	private float _prevStam0 = 1f;

	private float _prevStam1 = 1f;

	private float _panelShakeTime = 0f;

	private float _panelShakeStrength = 0f;

	private int _cachedHpVal = -1;

	private int _cachedStam0Val = -1;

	private int _cachedStam1Val = -1;

	private string _cachedHpStr = "";

	private string _cachedStam0Str = "";

	private string _cachedStam1Str = "";

	private int _cachedHpLen = 0;

	private int _cachedStam0Len = 0;

	private int _cachedStam1Len = 0;

	private Texture2D MakeTex(Color c)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Expected O, but got Unknown
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(1, 1);
		val.SetPixel(0, 0, c);
		val.Apply();
		return val;
	}

	private Color ParseHex(string hex, Color defaultColor)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrEmpty(hex))
		{
			return defaultColor;
		}
		if (!hex.StartsWith("#"))
		{
			hex = "#" + hex;
		}
		Color result = default(Color);
		if (ColorUtility.TryParseHtmlString(hex, ref result))
		{
			return result;
		}
		return defaultColor;
	}

	public void ApplyColors()
	{
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: 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_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: 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_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		DestroyTex(ref _hpFill);
		DestroyTex(ref _hpFillLow);
		DestroyTex(ref _hpGhost);
		DestroyTex(ref _hpBorder);
		DestroyTex(ref _hpBg);
		DestroyTex(ref _stam0Fill);
		DestroyTex(ref _stam0FillLow);
		DestroyTex(ref _stam0Ghost);
		DestroyTex(ref _stam0Border);
		DestroyTex(ref _stam0Bg);
		DestroyTex(ref _stam1Fill);
		DestroyTex(ref _stam1FillLow);
		DestroyTex(ref _stam1Ghost);
		DestroyTex(ref _stam1Border);
		DestroyTex(ref _stam1Bg);
		DestroyTex(ref _buffBg);
		DestroyTex(ref _buffFill);
		_buffBg = MakeTex(ParseHex(HealthModPlugin.BuffsBgColor.Value, new Color(0.12f, 0.12f, 0.12f, 1f)));
		_buffFill = MakeTex(ParseHex(HealthModPlugin.BuffsFillColor.Value, new Color(0.6f, 0.5f, 0.3f, 1f)));
		_hpFill = MakeTex(ParseHex(HealthModPlugin.HpColor.Value, Color.gray));
		_hpFillLow = MakeTex(ParseHex(HealthModPlugin.HpLowColor.Value, Color.red));
		_hpGhost = MakeTex(ParseHex(HealthModPlugin.HpGhostColor.Value, Color.red));
		_hpBorder = MakeTex(ParseHex(HealthModPlugin.HpBorderColor.Value, Color.black));
		_hpBg = MakeTex(new Color(0.1f, 0.1f, 0.1f, 0.6f));
		_stam0Fill = MakeTex(ParseHex(HealthModPlugin.Stam0Color.Value, Color.gray));
		_stam0FillLow = MakeTex(ParseHex(HealthModPlugin.Stam0LowColor.Value, Color.red));
		_stam0Ghost = MakeTex(ParseHex(HealthModPlugin.Stam0GhostColor.Value, Color.blue));
		_stam0Border = MakeTex(ParseHex(HealthModPlugin.Stam0BorderColor.Value, Color.black));
		_stam0Bg = MakeTex(new Color(0.1f, 0.1f, 0.1f, 0.6f));
		_stam1Fill = MakeTex(ParseHex(HealthModPlugin.Stam1Color.Value, Color.gray));
		_stam1FillLow = MakeTex(ParseHex(HealthModPlugin.Stam1LowColor.Value, Color.red));
		_stam1Ghost = MakeTex(ParseHex(HealthModPlugin.Stam1GhostColor.Value, Color.blue));
		_stam1Border = MakeTex(ParseHex(HealthModPlugin.Stam1BorderColor.Value, Color.black));
		_stam1Bg = MakeTex(new Color(0.1f, 0.1f, 0.1f, 0.6f));
	}

	private void DestroyTex(ref Texture2D t)
	{
		if ((Object)(object)t != (Object)null)
		{
			Object.Destroy((Object)(object)t);
			t = null;
		}
	}

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

	private void FindFont()
	{
		if (_fontSearched)
		{
			return;
		}
		_fontSearched = true;
		Font[] array = Resources.FindObjectsOfTypeAll<Font>();
		foreach (Font val in array)
		{
			if (((Object)val).name == "m3x6")
			{
				_gameFont = val;
				break;
			}
		}
	}

	private void EnsureStyles()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		FindFont();
		if (_textStyle == null)
		{
			_textStyle = new GUIStyle();
			_textStyle.alignment = (TextAnchor)4;
			_textStyle.normal.textColor = Color.white;
			if (Object.op_Implicit((Object)(object)_gameFont))
			{
				_textStyle.font = _gameFont;
			}
			_shadowStyle = new GUIStyle(_textStyle);
			_shadowStyle.normal.textColor = new Color(0f, 0f, 0f, 0.8f);
		}
	}

	private void DrawOutlined(Rect r, string text, int size, float textAlpha)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		_textStyle.fontSize = size;
		_shadowStyle.fontSize = size;
		Color white = Color.white;
		white.a = textAlpha;
		_textStyle.normal.textColor = white;
		Color textColor = default(Color);
		((Color)(ref textColor))..ctor(0f, 0f, 0f, 0.8f * textAlpha);
		_shadowStyle.normal.textColor = textColor;
		float num = Mathf.Max(1f, (float)size * 0.05f);
		GUI.Label(new Rect(((Rect)(ref r)).x - num, ((Rect)(ref r)).y, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x + num, ((Rect)(ref r)).y, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y - num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x - num, ((Rect)(ref r)).y - num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x + num, ((Rect)(ref r)).y - num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x - num, ((Rect)(ref r)).y + num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(new Rect(((Rect)(ref r)).x + num, ((Rect)(ref r)).y + num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, _shadowStyle);
		GUI.Label(r, text, _textStyle);
	}

	private void UpdateFade(ref float fadeAlpha, ref bool isFading, ref float delayTimer, ref float outTimer, bool autoHide, float autoHideDelay, float autoHideDur, bool isFull, float dt)
	{
		if (autoHide && !HealthModMenuGUI.IsMenuOpen)
		{
			if (isFull)
			{
				if (!isFading)
				{
					delayTimer += dt;
					if (delayTimer >= autoHideDelay)
					{
						isFading = true;
					}
					return;
				}
				float num = Mathf.Max(0.01f, autoHideDur);
				if (outTimer < num)
				{
					outTimer += dt;
				}
				fadeAlpha = 1f - outTimer / num;
			}
			else
			{
				isFading = false;
				delayTimer = 0f;
				outTimer = 0f;
				fadeAlpha = 1f;
			}
		}
		else
		{
			fadeAlpha = 1f;
		}
	}

	private void Update()
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if (!Object.op_Implicit((Object)(object)player))
		{
			return;
		}
		float deltaTime = Time.deltaTime;
		bool isFull = ((GameEntity)player).health * 20f >= ((GameEntity)player).maxHealth * 20f;
		bool isFull2 = player.hands[0].gripStrength / player.gripStrengthTimer >= 1f;
		bool isFull3 = player.hands[1].gripStrength / player.gripStrengthTimer >= 1f;
		UpdateFade(ref _hpFadeAlpha, ref _hpIsFading, ref _hpFadeDelayTimer, ref _hpFadeOutTimer, HealthModPlugin.HpAutoHide.Value, HealthModPlugin.HpAutoHideDelay.Value, HealthModPlugin.HpAutoHideDuration.Value, isFull, deltaTime);
		UpdateFade(ref _stam0FadeAlpha, ref _stam0IsFading, ref _stam0FadeDelayTimer, ref _stam0FadeOutTimer, HealthModPlugin.Stam0AutoHide.Value, HealthModPlugin.Stam0AutoHideDelay.Value, HealthModPlugin.Stam0AutoHideDuration.Value, isFull2, deltaTime);
		UpdateFade(ref _stam1FadeAlpha, ref _stam1IsFading, ref _stam1FadeDelayTimer, ref _stam1FadeOutTimer, HealthModPlugin.Stam1AutoHide.Value, HealthModPlugin.Stam1AutoHideDelay.Value, HealthModPlugin.Stam1AutoHideDuration.Value, isFull3, deltaTime);
		float num = Mathf.Clamp01(((GameEntity)player).health / ((GameEntity)player).maxHealth);
		if (num < _prevHpNorm)
		{
			_ghostTimer = 0.5f;
			_ghostHp = _prevHpNorm;
			_panelShakeTime = 0.2f;
			_panelShakeStrength = ((((GameEntity)player).health <= HealthModPlugin.HpLowThreshold.Value / 20f) ? 3f : 1f);
		}
		else if (num > _prevHpNorm)
		{
			_ghostHp = Mathf.Max(_ghostHp, num);
		}
		if (_ghostTimer > 0f)
		{
			_ghostTimer -= deltaTime;
		}
		else if (_ghostHp > num)
		{
			_ghostHp = Mathf.MoveTowards(_ghostHp, num, 0.4f * deltaTime);
		}
		if (_ghostHp < num)
		{
			_ghostHp = num;
		}
		_prevHpNorm = num;
		float num2 = Mathf.Clamp01(player.hands[0].gripStrength / player.gripStrengthTimer);
		if (num2 < _prevStam0)
		{
			if (_prevStam0 - num2 >= 0.05f)
			{
				_ghostStamTimer0 = 0.5f;
				_ghostStam0 = _prevStam0;
			}
		}
		else if (num2 > _prevStam0)
		{
			_ghostStam0 = Mathf.Max(_ghostStam0, num2);
		}
		if (_ghostStamTimer0 > 0f)
		{
			_ghostStamTimer0 -= deltaTime;
		}
		else if (_ghostStam0 > num2)
		{
			_ghostStam0 = Mathf.MoveTowards(_ghostStam0, num2, 0.4f * deltaTime);
		}
		if (_ghostStam0 < num2)
		{
			_ghostStam0 = num2;
		}
		_prevStam0 = num2;
		float num3 = Mathf.Clamp01(player.hands[1].gripStrength / player.gripStrengthTimer);
		if (num3 < _prevStam1)
		{
			if (_prevStam1 - num3 >= 0.05f)
			{
				_ghostStamTimer1 = 0.5f;
				_ghostStam1 = _prevStam1;
			}
		}
		else if (num3 > _prevStam1)
		{
			_ghostStam1 = Mathf.Max(_ghostStam1, num3);
		}
		if (_ghostStamTimer1 > 0f)
		{
			_ghostStamTimer1 -= deltaTime;
		}
		else if (_ghostStam1 > num3)
		{
			_ghostStam1 = Mathf.MoveTowards(_ghostStam1, num3, 0.4f * deltaTime);
		}
		if (_ghostStam1 < num3)
		{
			_ghostStam1 = num3;
		}
		_prevStam1 = num3;
		if (_panelShakeTime > 0f)
		{
			_panelShakeTime -= deltaTime;
		}
	}

	private Vector2 ShakeOffset(float strength)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if (strength <= 0f)
		{
			return Vector2.zero;
		}
		return new Vector2((Random.value - 0.5f) * 2f * strength, (Random.value - 0.5f) * 2f * strength);
	}

	private void DrawBar(bool show, bool showText, bool isVert, float xF, float yF, float wF, float hF, float borderThick, Texture2D borderTex, Texture2D bgTex, Texture2D ghostTex, Texture2D fillLowTex, Texture2D fillTex, float fillNorm, float ghostNorm, bool isLow, string textVal, int textLen, Vector2 shake, float textAlpha, float textScale)
	{
		//IL_0022: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: 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_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		if (!show)
		{
			return;
		}
		float num = Screen.width;
		float num2 = Screen.height;
		float num3 = Mathf.Round(num * xF + shake.x);
		float num4 = Mathf.Round(num2 * yF + shake.y);
		float num5 = Mathf.Round(num * wF);
		float num6 = Mathf.Round(num2 * hF);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(num3, num4, num5, num6);
		if (borderThick > 0f)
		{
			GUI.DrawTexture(new Rect(((Rect)(ref val)).x - borderThick, ((Rect)(ref val)).y - borderThick, ((Rect)(ref val)).width + borderThick * 2f, ((Rect)(ref val)).height + borderThick * 2f), (Texture)(object)borderTex);
		}
		GUI.DrawTexture(val, (Texture)(object)bgTex);
		if (isVert)
		{
			float num7 = Mathf.Round(((Rect)(ref val)).height * fillNorm);
			float num8 = Mathf.Round(((Rect)(ref val)).height * ghostNorm);
			if (ghostNorm > fillNorm)
			{
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + (((Rect)(ref val)).height - num8), ((Rect)(ref val)).width, num8), (Texture)(object)ghostTex);
			}
			GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + (((Rect)(ref val)).height - num7), ((Rect)(ref val)).width, num7), (Texture)(object)(isLow ? fillLowTex : fillTex));
		}
		else
		{
			float num9 = Mathf.Round(((Rect)(ref val)).width * fillNorm);
			float num10 = Mathf.Round(((Rect)(ref val)).width * ghostNorm);
			if (ghostNorm > fillNorm)
			{
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, num10, ((Rect)(ref val)).height), (Texture)(object)ghostTex);
			}
			GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, num9, ((Rect)(ref val)).height), (Texture)(object)(isLow ? fillLowTex : fillTex));
		}
		if (showText)
		{
			Color color = GUI.color;
			GUI.color = Color.white;
			int size;
			if (isVert)
			{
				size = Mathf.Max(9, Mathf.RoundToInt(num5 * 0.6f * textScale));
			}
			else
			{
				float num11 = num5 / (float)Mathf.Max(1, textLen);
				size = Mathf.Max(9, Mathf.RoundToInt(Mathf.Min(num6, num11 * 1.5f) * 0.75f * textScale));
			}
			DrawOutlined(val, textVal, size, textAlpha);
			GUI.color = color;
		}
	}

	private void OnGUI()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_060a: 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_0126: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: 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_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0414: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_055f: 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_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_0566: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
		ENT_Player player = ENT_Player.GetPlayer();
		if (!Object.op_Implicit((Object)(object)player))
		{
			return;
		}
		bool flag = _hpFadeAlpha > 0f || _stam0FadeAlpha > 0f || _stam1FadeAlpha > 0f;
		EnsureStyles();
		Color color = GUI.color;
		Vector2 val = ((_panelShakeTime > 0f) ? ShakeOffset(_panelShakeStrength) : Vector2.zero);
		if (flag)
		{
			float num = Mathf.Clamp(HealthModPlugin.HpOpacity.Value, 0f, 100f) / 100f;
			GUI.color = new Color(1f, 1f, 1f, _hpFadeAlpha * num);
			float fillNorm = Mathf.Clamp01(((GameEntity)player).health / ((GameEntity)player).maxHealth);
			float num2 = ((GameEntity)player).health * 20f;
			bool flag2 = num2 <= HealthModPlugin.HpLowThreshold.Value;
			Vector2 val2 = (flag2 ? ShakeOffset(3f * Mathf.Lerp(1.2f, 0.6f, num2 / HealthModPlugin.HpLowThreshold.Value)) : Vector2.zero);
			int num3 = Mathf.RoundToInt(num2);
			if (num3 != _cachedHpVal)
			{
				_cachedHpVal = num3;
				_cachedHpStr = num3.ToString();
				_cachedHpLen = _cachedHpStr.Length;
			}
			float textAlpha = Mathf.Clamp(HealthModPlugin.HpTextOpacity.Value, 0f, 100f) / 100f * _hpFadeAlpha;
			Vector2 shake = (HealthModPlugin.HpShake.Value ? (val + val2) : Vector2.zero);
			DrawBar(HealthModPlugin.ShowHp.Value, HealthModPlugin.ShowHpText.Value, HealthModPlugin.HpVertical.Value, HealthModPlugin.HpX.Value, HealthModPlugin.HpY.Value, HealthModPlugin.HpW.Value, HealthModPlugin.HpH.Value, HealthModPlugin.HpBorderThick.Value, _hpBorder, _hpBg, _hpGhost, _hpFillLow, _hpFill, fillNorm, _ghostHp, flag2, _cachedHpStr, _cachedHpLen, shake, textAlpha, HealthModPlugin.HpTextScale.Value);
			float num4 = Mathf.Clamp(HealthModPlugin.Stam0Opacity.Value, 0f, 100f) / 100f;
			GUI.color = new Color(1f, 1f, 1f, _stam0FadeAlpha * num4);
			float num5 = Mathf.Clamp01(player.hands[0].gripStrength / player.gripStrengthTimer) * 100f;
			float fillNorm2 = num5 / 100f;
			bool flag3 = num5 <= HealthModPlugin.Stam0LowThreshold.Value;
			Vector2 val3 = (flag3 ? ShakeOffset(2f * Mathf.Lerp(1.1f, 0.5f, num5 / HealthModPlugin.Stam0LowThreshold.Value)) : Vector2.zero);
			int num6 = Mathf.RoundToInt(num5);
			if (num6 != _cachedStam0Val)
			{
				_cachedStam0Val = num6;
				_cachedStam0Str = num6.ToString();
				_cachedStam0Len = _cachedStam0Str.Length;
			}
			float textAlpha2 = Mathf.Clamp(HealthModPlugin.Stam0TextOpacity.Value, 0f, 100f) / 100f * _stam0FadeAlpha;
			Vector2 shake2 = (HealthModPlugin.Stam0Shake.Value ? (val + val3) : Vector2.zero);
			DrawBar(HealthModPlugin.ShowStam0.Value, HealthModPlugin.ShowStam0Text.Value, HealthModPlugin.Stam0Vertical.Value, HealthModPlugin.Stam0X.Value, HealthModPlugin.Stam0Y.Value, HealthModPlugin.Stam0W.Value, HealthModPlugin.Stam0H.Value, HealthModPlugin.Stam0BorderThick.Value, _stam0Border, _stam0Bg, _stam0Ghost, _stam0FillLow, _stam0Fill, fillNorm2, _ghostStam0, flag3, _cachedStam0Str, _cachedStam0Len, shake2, textAlpha2, HealthModPlugin.Stam0TextScale.Value);
			float num7 = Mathf.Clamp(HealthModPlugin.Stam1Opacity.Value, 0f, 100f) / 100f;
			GUI.color = new Color(1f, 1f, 1f, _stam1FadeAlpha * num7);
			float num8 = Mathf.Clamp01(player.hands[1].gripStrength / player.gripStrengthTimer) * 100f;
			float fillNorm3 = num8 / 100f;
			bool flag4 = num8 <= HealthModPlugin.Stam1LowThreshold.Value;
			Vector2 val4 = (flag4 ? ShakeOffset(2f * Mathf.Lerp(1.1f, 0.5f, num8 / HealthModPlugin.Stam1LowThreshold.Value)) : Vector2.zero);
			int num9 = Mathf.RoundToInt(num8);
			if (num9 != _cachedStam1Val)
			{
				_cachedStam1Val = num9;
				_cachedStam1Str = num9.ToString();
				_cachedStam1Len = _cachedStam1Str.Length;
			}
			float textAlpha3 = Mathf.Clamp(HealthModPlugin.Stam1TextOpacity.Value, 0f, 100f) / 100f * _stam1FadeAlpha;
			Vector2 shake3 = (HealthModPlugin.Stam1Shake.Value ? (val + val4) : Vector2.zero);
			DrawBar(HealthModPlugin.ShowStam1.Value, HealthModPlugin.ShowStam1Text.Value, HealthModPlugin.Stam1Vertical.Value, HealthModPlugin.Stam1X.Value, HealthModPlugin.Stam1Y.Value, HealthModPlugin.Stam1W.Value, HealthModPlugin.Stam1H.Value, HealthModPlugin.Stam1BorderThick.Value, _stam1Border, _stam1Bg, _stam1Ghost, _stam1FillLow, _stam1Fill, fillNorm3, _ghostStam1, flag4, _cachedStam1Str, _cachedStam1Len, shake3, textAlpha3, HealthModPlugin.Stam1TextScale.Value);
		}
		DrawBuffs(player);
		GUI.color = color;
	}

	private void EnsureBuffFieldsCache(ENT_Player p)
	{
		if (_fiCurBuffs != null && _fiBuffId != null)
		{
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
		_fiCurBuffs = typeof(ENT_Player).GetField("curBuffs", bindingAttr);
		if (_fiCurBuffs == null)
		{
			return;
		}
		object value = _fiCurBuffs.GetValue(p);
		if (value == null)
		{
			return;
		}
		Type type = value.GetType();
		_fiCurrentBuffsList = type.GetField("currentBuffs", bindingAttr);
		if (_fiCurrentBuffsList?.GetValue(value) is IList { Count: >0 } list)
		{
			Type type2 = list[0].GetType();
			_fiBuffId = type2.GetField("id", bindingAttr);
			_fiBuffDesc = type2.GetField("desc", bindingAttr);
			_fiBuffBuffs = type2.GetField("buffs", bindingAttr);
			_fiBuffTime = type2.GetField("buffTime", bindingAttr);
			_fiBuffLoseOverTime = type2.GetField("loseOverTime", bindingAttr);
			_fiBuffLoseRate = type2.GetField("loseRate", bindingAttr);
			if (_fiBuffBuffs?.GetValue(list[0]) is IList { Count: >0 } list2)
			{
				Type type3 = list2[0].GetType();
				_fiInnerAmount = type3.GetField("amount", bindingAttr);
				_fiInnerMaxAmount = type3.GetField("maxAmount", bindingAttr);
				_fiInnerId = type3.GetField("id", bindingAttr);
			}
		}
	}

	private void DrawBuffs(ENT_Player p)
	{
		//IL_0790: Unknown result type (might be due to invalid IL or missing references)
		//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0718: Unknown result type (might be due to invalid IL or missing references)
		//IL_071d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0722: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0756: Unknown result type (might be due to invalid IL or missing references)
		//IL_0769: Unknown result type (might be due to invalid IL or missing references)
		//IL_0777: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0828: Unknown result type (might be due to invalid IL or missing references)
		//IL_082d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0854: Unknown result type (might be due to invalid IL or missing references)
		//IL_0859: Unknown result type (might be due to invalid IL or missing references)
		//IL_085e: Unknown result type (might be due to invalid IL or missing references)
		//IL_086b: Unknown result type (might be due to invalid IL or missing references)
		//IL_08df: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0900: Unknown result type (might be due to invalid IL or missing references)
		if (!HealthModPlugin.ShowBuffs.Value)
		{
			return;
		}
		float num = Mathf.Clamp(HealthModPlugin.BuffsOpacity.Value, 0f, 100f) / 100f;
		if (num <= 0f)
		{
			return;
		}
		float num2 = Mathf.Clamp(HealthModPlugin.BuffsTextOpacity.Value, 0f, 100f) / 100f;
		try
		{
			EnsureBuffFieldsCache(p);
			if (_fiCurBuffs == null || _fiCurrentBuffsList == null)
			{
				return;
			}
			object value = _fiCurBuffs.GetValue(p);
			if (value == null || !(_fiCurrentBuffsList.GetValue(value) is IList list))
			{
				return;
			}
			float num3 = (float)Screen.width * HealthModPlugin.BuffsX.Value;
			float num4 = (float)Screen.height * HealthModPlugin.BuffsY.Value;
			float num5 = (float)Screen.width * HealthModPlugin.BuffsW.Value;
			float num6 = (float)Screen.height * HealthModPlugin.BuffsH.Value;
			float num7 = num6 * 3f;
			int num8 = 0;
			Rect r = default(Rect);
			Rect val = default(Rect);
			Rect r2 = default(Rect);
			foreach (object item in list)
			{
				if (item == null)
				{
					continue;
				}
				string text = _fiBuffId?.GetValue(item) as string;
				string text2 = _fiBuffDesc?.GetValue(item) as string;
				float num9 = 0f;
				float num10 = 1f;
				if (_fiBuffBuffs?.GetValue(item) is IList { Count: >0 } list2)
				{
					object obj = list2[0];
					if (obj != null)
					{
						num9 = (float)(_fiInnerAmount?.GetValue(obj) ?? ((object)0f));
						num10 = (float)(_fiInnerMaxAmount?.GetValue(obj) ?? ((object)1f));
						if (num10 <= 0f)
						{
							num10 = 1f;
						}
						if (string.IsNullOrEmpty(text))
						{
							text = _fiInnerId?.GetValue(obj) as string;
						}
					}
				}
				if (string.IsNullOrEmpty(text))
				{
					text = "Unknown";
				}
				string text3 = text;
				if (!string.IsNullOrEmpty(text2) && text2.Length < 30)
				{
					text3 = text2;
				}
				else
				{
					switch (text.ToLower())
					{
					case "food":
						text3 = "Well Fed";
						break;
					case "pilled":
						text3 = "Painkillers";
						break;
					case "boosted":
						text3 = "Adrenaline";
						break;
					case "unbound":
						text3 = "Unbound";
						break;
					case "bloodied":
						text3 = "Bleeding";
						break;
					case "freezing":
						text3 = "Freezing";
						break;
					case "warming":
						text3 = "Warming";
						break;
					case "poisoned":
						text3 = "Poisoned";
						break;
					case "roided":
						text3 = "Steroids";
						break;
					case "gooped":
						text3 = "Gooped";
						break;
					case "addjump":
						text3 = "Jump Boost";
						break;
					case "addspeed":
						text3 = "Speed Boost";
						break;
					case "addclimb":
						text3 = "Climbing Speed";
						break;
					case "addreach":
						text3 = "Extended Reach";
						break;
					}
				}
				float num11 = (float)(_fiBuffTime?.GetValue(item) ?? ((object)0f));
				bool flag = (bool)(_fiBuffLoseOverTime?.GetValue(item) ?? ((object)false));
				float num12 = (float)(_fiBuffLoseRate?.GetValue(item) ?? ((object)0f));
				float num13 = num11;
				if (flag && num12 > 0f)
				{
					num13 = num9 / num12;
				}
				if (num13 <= 0.05f)
				{
					continue;
				}
				if (!_maxBuffTimes.ContainsKey(text) || num13 > _maxBuffTimes[text])
				{
					_maxBuffTimes[text] = num13;
				}
				float num14 = Mathf.Max(num13, _maxBuffTimes[text]);
				float num15 = Mathf.Clamp01(num13 / num14);
				float num16 = num4 + (float)num8 * num7;
				if (num2 > 0f)
				{
					GUI.color = new Color(1f, 1f, 1f, num2);
					int size = Mathf.Max(10, Mathf.RoundToInt(num6 * 1.6f * HealthModPlugin.BuffsTextScale.Value));
					TextAnchor alignment = _textStyle.alignment;
					_textStyle.alignment = (TextAnchor)6;
					_shadowStyle.alignment = (TextAnchor)6;
					Color textColor = ParseHex(HealthModPlugin.BuffsTextColor.Value, Color.white);
					_textStyle.normal.textColor = textColor;
					((Rect)(ref r))..ctor(num3, num16 - num6 * 1.6f, num5, num6 * 1.6f);
					DrawOutlined(r, text3, size, num2);
					_textStyle.alignment = alignment;
					_shadowStyle.alignment = alignment;
				}
				GUI.color = new Color(1f, 1f, 1f, num);
				((Rect)(ref val))..ctor(num3, num16, num5, num6);
				GUI.DrawTexture(val, (Texture)(object)_buffBg);
				GUI.DrawTexture(new Rect(num3, num16, num5 * num15, num6), (Texture)(object)_buffFill);
				if (num2 > 0f)
				{
					GUI.color = new Color(1f, 1f, 1f, num2);
					int size2 = Mathf.Max(9, Mathf.RoundToInt(num6 * 1.1f * HealthModPlugin.BuffsTextScale.Value));
					TextAnchor alignment2 = _textStyle.alignment;
					_textStyle.alignment = (TextAnchor)5;
					_shadowStyle.alignment = (TextAnchor)5;
					Color textColor2 = ParseHex(HealthModPlugin.BuffsTextColor.Value, Color.white);
					_textStyle.normal.textColor = textColor2;
					string text4 = num13.ToString("F1");
					if (num9 > 0f)
					{
						int num17 = Mathf.Clamp(Mathf.RoundToInt(num9 / num10 * 100f), 0, 100);
						text4 += $" (Power: {num17}%)";
					}
					((Rect)(ref r2))..ctor(num3, num16, num5 - num6 * 0.2f, num6);
					DrawOutlined(r2, text4, size2, num2);
					_textStyle.alignment = alignment2;
					_shadowStyle.alignment = alignment2;
				}
				num8++;
			}
		}
		catch
		{
		}
	}
}
public class HealthModMenuGUI : MonoBehaviour
{
	public static bool IsMenuOpen;

	private bool _showMenu = false;

	private Rect _windowRect = new Rect(100f, 100f, 450f, 600f);

	private Vector2 _scrollPos;

	private int _tab = 0;

	private string[] _tabs = new string[4] { "HP", "L. Stam", "R. Stam", "Buffs" };

	private FieldInfo _camLockedField;

	private GUIStyle _windowStyle;

	private GUIStyle _buttonStyle;

	private GUIStyle _activeTabStyle;

	private GUIStyle _sliderTrackStyle;

	private GUIStyle _sliderThumbStyle;

	private GUIStyle _toggleStyle;

	private GUIStyle _labelStyle;

	private GUIStyle _headerStyle;

	private GUIStyle _inputStyle;

	private bool _stylesInitialized = false;

	private Dictionary<string, string> _sliderTexts = new Dictionary<string, string>();

	private Dictionary<string, float> _sliderPreviousValues = new Dictionary<string, float>();

	private void Start()
	{
		_camLockedField = typeof(ENT_Player).GetField("camLocked", BindingFlags.Instance | BindingFlags.NonPublic);
	}

	private void Update()
	{
		//IL_0006: 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_0027: 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)
		KeyCode val = (KeyCode)291;
		try
		{
			val = (KeyCode)Enum.Parse(typeof(KeyCode), HealthModPlugin.MenuKey.Value, ignoreCase: true);
		}
		catch
		{
		}
		if (Input.GetKeyDown(val))
		{
			_showMenu = !_showMenu;
			IsMenuOpen = _showMenu;
			ENT_Player player = ENT_Player.GetPlayer();
			if (!_showMenu)
			{
				HealthModPlugin.PluginConfig.Save();
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
				if (Object.op_Implicit((Object)(object)player) && _camLockedField != null)
				{
					_camLockedField.SetValue(player, false);
				}
			}
			else if (Object.op_Implicit((Object)(object)player) && _camLockedField != null)
			{
				_camLockedField.SetValue(player, true);
			}
		}
		if (_showMenu)
		{
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			ENT_Player player2 = ENT_Player.GetPlayer();
			if (Object.op_Implicit((Object)(object)player2) && _camLockedField != null)
			{
				_camLockedField.SetValue(player2, true);
			}
		}
	}

	private Texture2D MakeTex(int width, int height, Color col)
	{
		//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = col;
		}
		Texture2D val = new Texture2D(width, height);
		val.SetPixels(array);
		val.Apply();
		((Object)val).hideFlags = (HideFlags)61;
		return val;
	}

	private void InitStyles()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_013d: 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: Expected O, but got Unknown
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Expected O, but got Unknown
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Expected O, but got Unknown
		//IL_02b2: 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_02df: Expected O, but got Unknown
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Expected O, but got Unknown
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Expected O, but got Unknown
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_039d: Expected O, but got Unknown
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Expected O, but got Unknown
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Expected O, but got Unknown
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_049f: Expected O, but got Unknown
		//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Unknown result type (might be due to invalid IL or missing references)
		if (!_stylesInitialized)
		{
			Texture2D background = MakeTex(2, 2, new Color(0.12f, 0.12f, 0.12f, 0.95f));
			Texture2D background2 = MakeTex(2, 2, new Color(0.2f, 0.2f, 0.2f, 1f));
			Texture2D background3 = MakeTex(2, 2, new Color(0.3f, 0.3f, 0.3f, 1f));
			Texture2D background4 = MakeTex(2, 2, new Color(0.15f, 0.15f, 0.15f, 1f));
			Texture2D background5 = MakeTex(2, 2, new Color(0.85f, 0.45f, 0.15f, 1f));
			Texture2D background6 = MakeTex(2, 2, new Color(0.95f, 0.55f, 0.25f, 1f));
			Texture2D background7 = MakeTex(2, 2, new Color(0.05f, 0.05f, 0.05f, 1f));
			Texture2D background8 = MakeTex(2, 2, new Color(0.7f, 0.7f, 0.7f, 1f));
			Texture2D background9 = MakeTex(2, 2, new Color(0.9f, 0.9f, 0.9f, 1f));
			_windowStyle = new GUIStyle(GUI.skin.window);
			_windowStyle.normal.background = background;
			_windowStyle.onNormal.background = background;
			_windowStyle.normal.textColor = Color.white;
			_windowStyle.onNormal.textColor = Color.white;
			_windowStyle.fontSize = 16;
			_windowStyle.fontStyle = (FontStyle)1;
			_buttonStyle = new GUIStyle(GUI.skin.button);
			_buttonStyle.normal.background = background2;
			_buttonStyle.hover.background = background3;
			_buttonStyle.active.background = background4;
			_buttonStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f);
			_buttonStyle.hover.textColor = Color.white;
			_buttonStyle.fontSize = 14;
			_activeTabStyle = new GUIStyle(_buttonStyle);
			_activeTabStyle.normal.background = background5;
			_activeTabStyle.hover.background = background6;
			_activeTabStyle.active.background = background5;
			_activeTabStyle.normal.textColor = Color.white;
			_activeTabStyle.fontStyle = (FontStyle)1;
			_sliderTrackStyle = new GUIStyle(GUI.skin.horizontalSlider);
			_sliderTrackStyle.normal.background = background7;
			_sliderTrackStyle.fixedHeight = 8f;
			_sliderThumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb);
			_sliderThumbStyle.normal.background = background8;
			_sliderThumbStyle.hover.background = background9;
			_sliderThumbStyle.active.background = background9;
			_sliderThumbStyle.fixedWidth = 16f;
			_sliderThumbStyle.fixedHeight = 8f;
			_sliderThumbStyle.overflow = new RectOffset(0, 0, 4, 4);
			_toggleStyle = new GUIStyle(GUI.skin.toggle);
			_toggleStyle.normal.textColor = new Color(0.85f, 0.85f, 0.85f);
			_toggleStyle.hover.textColor = Color.white;
			_toggleStyle.onNormal.textColor = Color.white;
			_toggleStyle.fontSize = 14;
			_labelStyle = new GUIStyle(GUI.skin.label);
			_labelStyle.normal.textColor = new Color(0.85f, 0.85f, 0.85f);
			_labelStyle.fontSize = 14;
			_headerStyle = new GUIStyle(GUI.skin.label);
			_headerStyle.normal.textColor = Color.white;
			_headerStyle.fontSize = 15;
			_headerStyle.fontStyle = (FontStyle)1;
			_inputStyle = new GUIStyle(GUI.skin.textField);
			_inputStyle.normal.textColor = Color.white;
			_inputStyle.focused.textColor = Color.white;
			_inputStyle.active.textColor = Color.white;
			_inputStyle.hover.textColor = Color.white;
			_inputStyle.normal.background = MakeTex(2, 2, new Color(0.15f, 0.15f, 0.15f, 1f));
			_inputStyle.focused.background = MakeTex(2, 2, new Color(0.25f, 0.25f, 0.25f, 1f));
			_stylesInitialized = true;
		}
	}

	private void OnGUI()
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//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)
		if (_showMenu)
		{
			InitStyles();
			GUI.skin.window = _windowStyle;
			GUI.skin.button = _buttonStyle;
			GUI.skin.horizontalSlider = _sliderTrackStyle;
			GUI.skin.horizontalSliderThumb = _sliderThumbStyle;
			GUI.skin.toggle = _toggleStyle;
			GUI.skin.label = _labelStyle;
			GUI.skin.textField = _inputStyle;
			GUI.depth = -100;
			_windowRect = GUILayout.Window(84923, _windowRect, new WindowFunction(DrawWindow), "Customizable HUD Settings", Array.Empty<GUILayoutOption>());
		}
	}

	private void DrawColorField(string label, ConfigEntry<string> hexColor)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: 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_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		Color val = Color.white;
		string text = (hexColor.Value.StartsWith("#") ? hexColor.Value : ("#" + hexColor.Value));
		Color val2 = default(Color);
		if (ColorUtility.TryParseHtmlString(text, ref val2))
		{
			val = val2;
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) });
		GUIStyle val3 = new GUIStyle(GUI.skin.box);
		val3.normal.background = Texture2D.whiteTexture;
		Color backgroundColor = GUI.backgroundColor;
		GUI.backgroundColor = val;
		GUILayout.Box("", val3, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(20f),
			GUILayout.Height(20f)
		});
		GUI.backgroundColor = backgroundColor;
		string text2 = GUILayout.TextField(hexColor.Value, Array.Empty<GUILayoutOption>());
		if (text2 != hexColor.Value)
		{
			hexColor.Value = text2;
		}
		GUILayout.EndHorizontal();
		float r = val.r;
		float g = val.g;
		float b = val.b;
		float a = val.a;
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("R", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
		r = GUILayout.HorizontalSlider(r, 0f, 1f, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("G", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
		g = GUILayout.HorizontalSlider(g, 0f, 1f, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("B", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
		b = GUILayout.HorizontalSlider(b, 0f, 1f, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("A", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
		a = GUILayout.HorizontalSlider(a, 0f, 1f, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		if (r != val.r || g != val.g || b != val.b || a != val.a)
		{
			Color32 val4 = Color32.op_Implicit(new Color(r, g, b, a));
			hexColor.Value = $"#{val4.r:X2}{val4.g:X2}{val4.b:X2}{val4.a:X2}";
		}
		GUILayout.EndVertical();
	}

	private void DrawSlider(string label, ConfigEntry<float> val, float min, float max, string fmt = "F3")
	{
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label(label + ":", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
		if (!_sliderTexts.TryGetValue(label, out var value))
		{
			value = val.Value.ToString(fmt, CultureInfo.InvariantCulture);
			_sliderTexts[label] = value;
			_sliderPreviousValues[label] = val.Value;
		}
		float num = (_sliderPreviousValues.ContainsKey(label) ? _sliderPreviousValues[label] : val.Value);
		if (Mathf.Abs(val.Value - num) > 1E-05f)
		{
			value = val.Value.ToString(fmt, CultureInfo.InvariantCulture);
			_sliderTexts[label] = value;
			_sliderPreviousValues[label] = val.Value;
		}
		string text = GUILayout.TextField(value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		if (text != value)
		{
			_sliderTexts[label] = text;
			if (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				val.Value = Mathf.Clamp(result, min, max);
				_sliderPreviousValues[label] = val.Value;
			}
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(2f);
		val.Value = GUILayout.HorizontalSlider(val.Value, min, max, Array.Empty<GUILayoutOption>());
		_sliderPreviousValues[label] = val.Value;
		GUILayout.Space(8f);
	}

	private void DrawBarSection(ConfigEntry<bool> shake, ConfigEntry<bool> autoHide, ConfigEntry<float> autoDelay, ConfigEntry<float> autoDur, ConfigEntry<bool> show, ConfigEntry<bool> showText, ConfigEntry<bool> isVert, ConfigEntry<float> x, ConfigEntry<float> y, ConfigEntry<float> w, ConfigEntry<float> h, ConfigEntry<float> opacity, ConfigEntry<float> textOpacity, ConfigEntry<float> textScale, ConfigEntry<float> borderT, ConfigEntry<string> borderC, ConfigEntry<float> lowT, ConfigEntry<string> col, ConfigEntry<string> lowC, ConfigEntry<string> ghC, Action resetCallback)
	{
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		show.Value = GUILayout.Toggle(show.Value, "Show Bar", Array.Empty<GUILayoutOption>());
		showText.Value = GUILayout.Toggle(showText.Value, "Show Text", Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		isVert.Value = GUILayout.Toggle(isVert.Value, "Vertical Bar", Array.Empty<GUILayoutOption>());
		autoHide.Value = GUILayout.Toggle(autoHide.Value, "Auto-Hide when full", Array.Empty<GUILayoutOption>());
		shake.Value = GUILayout.Toggle(shake.Value, "Enable Shake", Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.Space(10f);
		if (autoHide.Value)
		{
			DrawSlider("Auto-Hide Delay", autoDelay, 0f, 10f, "F1");
			DrawSlider("Auto-Hide Duration", autoDur, 0.1f, 5f, "F1");
		}
		DrawSlider("Position X", x, 0f, 1f);
		DrawSlider("Position Y", y, 0f, 1f);
		DrawSlider("Width", w, 0f, 1f);
		DrawSlider("Height", h, 0f, 1f);
		DrawSlider("Opacity %", opacity, 0f, 100f, "F0");
		DrawSlider("Text Opacity %", textOpacity, 0f, 100f, "F0");
		DrawSlider("Text Scale", textScale, 0.5f, 2.5f, "F2");
		DrawSlider("Border Thickness", borderT, 0f, 10f, "F1");
		DrawSlider("Low Warning Threshold", lowT, 1f, 100f, "F0");
		GUILayout.Space(10f);
		GUILayout.Label("Colors (HEX #RRGGBBAA):", _headerStyle, Array.Empty<GUILayoutOption>());
		DrawColorField("Border Color", borderC);
		DrawColorField("Bar Color", col);
		DrawColorField("Low Warn Color", lowC);
		DrawColorField("Ghost Color", ghC);
		GUILayout.Space(20f);
		if (GUILayout.Button("Reset This Bar To Default", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
		{
			resetCallback?.Invoke();
			GUI.changed = true;
		}
	}

	private void ResetHpDefaults()
	{
		HealthModPlugin.HpShake.Value = (bool)((ConfigEntryBase)HealthModPlugin.HpShake).DefaultValue;
		HealthModPlugin.HpAutoHide.Value = (bool)((ConfigEntryBase)HealthModPlugin.HpAutoHide).DefaultValue;
		HealthModPlugin.HpAutoHideDelay.Value = (float)((ConfigEntryBase)HealthModPlugin.HpAutoHideDelay).DefaultValue;
		HealthModPlugin.HpAutoHideDuration.Value = (float)((ConfigEntryBase)HealthModPlugin.HpAutoHideDuration).DefaultValue;
		HealthModPlugin.ShowHp.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowHp).DefaultValue;
		HealthModPlugin.ShowHpText.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowHpText).DefaultValue;
		HealthModPlugin.HpVertical.Value = (bool)((ConfigEntryBase)HealthModPlugin.HpVertical).DefaultValue;
		HealthModPlugin.HpX.Value = (float)((ConfigEntryBase)HealthModPlugin.HpX).DefaultValue;
		HealthModPlugin.HpY.Value = (float)((ConfigEntryBase)HealthModPlugin.HpY).DefaultValue;
		HealthModPlugin.HpW.Value = (float)((ConfigEntryBase)HealthModPlugin.HpW).DefaultValue;
		HealthModPlugin.HpH.Value = (float)((ConfigEntryBase)HealthModPlugin.HpH).DefaultValue;
		HealthModPlugin.HpOpacity.Value = (float)((ConfigEntryBase)HealthModPlugin.HpOpacity).DefaultValue;
		HealthModPlugin.HpTextOpacity.Value = (float)((ConfigEntryBase)HealthModPlugin.HpTextOpacity).DefaultValue;
		HealthModPlugin.HpTextScale.Value = (float)((ConfigEntryBase)HealthModPlugin.HpTextScale).DefaultValue;
		HealthModPlugin.HpBorderColor.Value = (string)((ConfigEntryBase)HealthModPlugin.HpBorderColor).DefaultValue;
		HealthModPlugin.HpBorderThick.Value = (float)((ConfigEntryBase)HealthModPlugin.HpBorderThick).DefaultValue;
		HealthModPlugin.HpLowThreshold.Value = (float)((ConfigEntryBase)HealthModPlugin.HpLowThreshold).DefaultValue;
		HealthModPlugin.HpColor.Value = (string)((ConfigEntryBase)HealthModPlugin.HpColor).DefaultValue;
		HealthModPlugin.HpLowColor.Value = (string)((ConfigEntryBase)HealthModPlugin.HpLowColor).DefaultValue;
		HealthModPlugin.HpGhostColor.Value = (string)((ConfigEntryBase)HealthModPlugin.HpGhostColor).DefaultValue;
	}

	private void ResetStam0Defaults()
	{
		HealthModPlugin.Stam0Shake.Value = (bool)((ConfigEntryBase)HealthModPlugin.Stam0Shake).DefaultValue;
		HealthModPlugin.Stam0AutoHide.Value = (bool)((ConfigEntryBase)HealthModPlugin.Stam0AutoHide).DefaultValue;
		HealthModPlugin.Stam0AutoHideDelay.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0AutoHideDelay).DefaultValue;
		HealthModPlugin.Stam0AutoHideDuration.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0AutoHideDuration).DefaultValue;
		HealthModPlugin.ShowStam0.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowStam0).DefaultValue;
		HealthModPlugin.ShowStam0Text.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowStam0Text).DefaultValue;
		HealthModPlugin.Stam0Vertical.Value = (bool)((ConfigEntryBase)HealthModPlugin.Stam0Vertical).DefaultValue;
		HealthModPlugin.Stam0X.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0X).DefaultValue;
		HealthModPlugin.Stam0Y.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0Y).DefaultValue;
		HealthModPlugin.Stam0W.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0W).DefaultValue;
		HealthModPlugin.Stam0H.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0H).DefaultValue;
		HealthModPlugin.Stam0Opacity.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0Opacity).DefaultValue;
		HealthModPlugin.Stam0TextOpacity.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0TextOpacity).DefaultValue;
		HealthModPlugin.Stam0TextScale.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0TextScale).DefaultValue;
		HealthModPlugin.Stam0BorderColor.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam0BorderColor).DefaultValue;
		HealthModPlugin.Stam0BorderThick.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0BorderThick).DefaultValue;
		HealthModPlugin.Stam0LowThreshold.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam0LowThreshold).DefaultValue;
		HealthModPlugin.Stam0Color.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam0Color).DefaultValue;
		HealthModPlugin.Stam0LowColor.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam0LowColor).DefaultValue;
		HealthModPlugin.Stam0GhostColor.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam0GhostColor).DefaultValue;
	}

	private void ResetStam1Defaults()
	{
		HealthModPlugin.Stam1Shake.Value = (bool)((ConfigEntryBase)HealthModPlugin.Stam1Shake).DefaultValue;
		HealthModPlugin.Stam1AutoHide.Value = (bool)((ConfigEntryBase)HealthModPlugin.Stam1AutoHide).DefaultValue;
		HealthModPlugin.Stam1AutoHideDelay.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1AutoHideDelay).DefaultValue;
		HealthModPlugin.Stam1AutoHideDuration.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1AutoHideDuration).DefaultValue;
		HealthModPlugin.ShowStam1.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowStam1).DefaultValue;
		HealthModPlugin.ShowStam1Text.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowStam1Text).DefaultValue;
		HealthModPlugin.Stam1Vertical.Value = (bool)((ConfigEntryBase)HealthModPlugin.Stam1Vertical).DefaultValue;
		HealthModPlugin.Stam1X.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1X).DefaultValue;
		HealthModPlugin.Stam1Y.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1Y).DefaultValue;
		HealthModPlugin.Stam1W.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1W).DefaultValue;
		HealthModPlugin.Stam1H.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1H).DefaultValue;
		HealthModPlugin.Stam1Opacity.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1Opacity).DefaultValue;
		HealthModPlugin.Stam1TextOpacity.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1TextOpacity).DefaultValue;
		HealthModPlugin.Stam1TextScale.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1TextScale).DefaultValue;
		HealthModPlugin.Stam1BorderColor.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam1BorderColor).DefaultValue;
		HealthModPlugin.Stam1BorderThick.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1BorderThick).DefaultValue;
		HealthModPlugin.Stam1LowThreshold.Value = (float)((ConfigEntryBase)HealthModPlugin.Stam1LowThreshold).DefaultValue;
		HealthModPlugin.Stam1Color.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam1Color).DefaultValue;
		HealthModPlugin.Stam1LowColor.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam1LowColor).DefaultValue;
		HealthModPlugin.Stam1GhostColor.Value = (string)((ConfigEntryBase)HealthModPlugin.Stam1GhostColor).DefaultValue;
	}

	private void DrawWindow(int id)
	{
		//IL_0073: 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)
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		for (int i = 0; i < _tabs.Length; i++)
		{
			GUIStyle val = ((i == _tab) ? _activeTabStyle : _buttonStyle);
			if (GUILayout.Button(_tabs[i], val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				_tab = i;
			}
		}
		GUILayout.EndHorizontal();
		_scrollPos = GUILayout.BeginScrollView(_scrollPos, Array.Empty<GUILayoutOption>());
		GUI.changed = false;
		if (_tab == 0)
		{
			DrawBarSection(HealthModPlugin.HpShake, HealthModPlugin.HpAutoHide, HealthModPlugin.HpAutoHideDelay, HealthModPlugin.HpAutoHideDuration, HealthModPlugin.ShowHp, HealthModPlugin.ShowHpText, HealthModPlugin.HpVertical, HealthModPlugin.HpX, HealthModPlugin.HpY, HealthModPlugin.HpW, HealthModPlugin.HpH, HealthModPlugin.HpOpacity, HealthModPlugin.HpTextOpacity, HealthModPlugin.HpTextScale, HealthModPlugin.HpBorderThick, HealthModPlugin.HpBorderColor, HealthModPlugin.HpLowThreshold, HealthModPlugin.HpColor, HealthModPlugin.HpLowColor, HealthModPlugin.HpGhostColor, ResetHpDefaults);
		}
		else if (_tab == 1)
		{
			DrawBarSection(HealthModPlugin.Stam0Shake, HealthModPlugin.Stam0AutoHide, HealthModPlugin.Stam0AutoHideDelay, HealthModPlugin.Stam0AutoHideDuration, HealthModPlugin.ShowStam0, HealthModPlugin.ShowStam0Text, HealthModPlugin.Stam0Vertical, HealthModPlugin.Stam0X, HealthModPlugin.Stam0Y, HealthModPlugin.Stam0W, HealthModPlugin.Stam0H, HealthModPlugin.Stam0Opacity, HealthModPlugin.Stam0TextOpacity, HealthModPlugin.Stam0TextScale, HealthModPlugin.Stam0BorderThick, HealthModPlugin.Stam0BorderColor, HealthModPlugin.Stam0LowThreshold, HealthModPlugin.Stam0Color, HealthModPlugin.Stam0LowColor, HealthModPlugin.Stam0GhostColor, ResetStam0Defaults);
		}
		else if (_tab == 2)
		{
			DrawBarSection(HealthModPlugin.Stam1Shake, HealthModPlugin.Stam1AutoHide, HealthModPlugin.Stam1AutoHideDelay, HealthModPlugin.Stam1AutoHideDuration, HealthModPlugin.ShowStam1, HealthModPlugin.ShowStam1Text, HealthModPlugin.Stam1Vertical, HealthModPlugin.Stam1X, HealthModPlugin.Stam1Y, HealthModPlugin.Stam1W, HealthModPlugin.Stam1H, HealthModPlugin.Stam1Opacity, HealthModPlugin.Stam1TextOpacity, HealthModPlugin.Stam1TextScale, HealthModPlugin.Stam1BorderThick, HealthModPlugin.Stam1BorderColor, HealthModPlugin.Stam1LowThreshold, HealthModPlugin.Stam1Color, HealthModPlugin.Stam1LowColor, HealthModPlugin.Stam1GhostColor, ResetStam1Defaults);
		}
		else if (_tab == 3)
		{
			DrawBuffsSection();
		}
		GUILayout.EndScrollView();
		if (GUI.changed)
		{
			HealthModGUI.Instance.ApplyColors();
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Close & Save", Array.Empty<GUILayoutOption>()))
		{
			HealthModPlugin.PluginConfig.Save();
			_showMenu = false;
		}
		GUILayout.EndHorizontal();
		GUI.DragWindow();
	}

	private void DrawBuffsSection()
	{
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		HealthModPlugin.ShowBuffs.Value = GUILayout.Toggle(HealthModPlugin.ShowBuffs.Value, "Show Buffs", Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.Space(10f);
		DrawSlider("Position X", HealthModPlugin.BuffsX, 0f, 1f);
		DrawSlider("Position Y", HealthModPlugin.BuffsY, 0f, 1f);
		DrawSlider("Width", HealthModPlugin.BuffsW, 0f, 1f);
		DrawSlider("Height", HealthModPlugin.BuffsH, 0f, 1f);
		DrawSlider("Opacity %", HealthModPlugin.BuffsOpacity, 0f, 100f, "F0");
		DrawSlider("Text Opacity %", HealthModPlugin.BuffsTextOpacity, 0f, 100f, "F0");
		DrawSlider("Text Scale", HealthModPlugin.BuffsTextScale, 0.5f, 2.5f, "F2");
		GUILayout.Space(10f);
		GUILayout.Label("Colors (HEX #RRGGBBAA):", _headerStyle, Array.Empty<GUILayoutOption>());
		DrawColorField("Background Color", HealthModPlugin.BuffsBgColor);
		DrawColorField("Fill Color", HealthModPlugin.BuffsFillColor);
		DrawColorField("Text Color", HealthModPlugin.BuffsTextColor);
		GUILayout.Space(20f);
		if (GUILayout.Button("Reset Buffs To Default", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
		{
			HealthModPlugin.ShowBuffs.Value = (bool)((ConfigEntryBase)HealthModPlugin.ShowBuffs).DefaultValue;
			HealthModPlugin.BuffsX.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsX).DefaultValue;
			HealthModPlugin.BuffsY.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsY).DefaultValue;
			HealthModPlugin.BuffsW.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsW).DefaultValue;
			HealthModPlugin.BuffsH.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsH).DefaultValue;
			HealthModPlugin.BuffsOpacity.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsOpacity).DefaultValue;
			HealthModPlugin.BuffsTextOpacity.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsTextOpacity).DefaultValue;
			HealthModPlugin.BuffsTextScale.Value = (float)((ConfigEntryBase)HealthModPlugin.BuffsTextScale).DefaultValue;
			HealthModPlugin.BuffsBgColor.Value = (string)((ConfigEntryBase)HealthModPlugin.BuffsBgColor).DefaultValue;
			HealthModPlugin.BuffsFillColor.Value = (string)((ConfigEntryBase)HealthModPlugin.BuffsFillColor).DefaultValue;
			HealthModPlugin.BuffsTextColor.Value = (string)((ConfigEntryBase)HealthModPlugin.BuffsTextColor).DefaultValue;
			GUI.changed = true;
		}
	}
}