Decompiled source of HP Barheim v1.1.1

plugins/HPBarheim.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HPBarheim.Compat;
using HPBarheim.Config;
using HPBarheim.Hud;
using HPBarheim.Patches;
using HPBarheim.Util;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.TextCore.LowLevel;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HPBarheim
{
	[BepInPlugin("DarthVladi.HPBarheim", "HP Barheim", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("valheim.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "DarthVladi.HPBarheim";

		public const string PluginName = "HP Barheim";

		public const string PluginVersion = "1.1.1";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			HPConfig.Init(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("DarthVladi.HPBarheim");
			VanillaHudPatch.Apply(_harmony);
			DamageTextHook.Apply(_harmony);
			if (HPConfig.DebugLogging.Value)
			{
				try
				{
					Log.LogInfo((object)("DamageText:\n" + DamageTextHook.Describe()));
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Could not list DamageText methods: " + ex.Message));
				}
			}
			CompatNotice.Run();
			PathOfValheimanSupport.Detect();
			StaggerProbe.Init();
			AwarenessProbe.Init();
			DamageModifierProbe.Init();
			((Component)this).gameObject.AddComponent<HudManager>();
			((Component)this).gameObject.AddComponent<DamageNumberManager>();
			((Component)this).gameObject.AddComponent<BossBarManager>();
			Log.LogInfo((object)"HP Barheim 1.1.1 loaded.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace HPBarheim.Util
{
	internal static class UiFactory
	{
		public static Canvas CreateOverlayCanvas(string name, int sortingOrder)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = sortingOrder;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val3.screenMatchMode = (ScreenMatchMode)0;
			val3.matchWidthOrHeight = 0.5f;
			return val2;
		}

		public static RectTransform Rect(string name, Transform parent)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent(parent, false);
			return val2;
		}

		public static Image Solid(string name, Transform parent, out RectTransform rt)
		{
			rt = Rect(name, parent);
			Image val = ((Component)rt).gameObject.AddComponent<Image>();
			((Graphic)val).raycastTarget = false;
			return val;
		}

		public static void Inflate(RectTransform rt, float amount, float ox = 0f, float oy = 0f)
		{
			//IL_0002: 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_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)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.offsetMin = new Vector2(0f - amount + ox, 0f - amount + oy);
			rt.offsetMax = new Vector2(amount + ox, amount + oy);
		}

		public static TextMeshProUGUI Text(string name, Transform parent, TMP_FontAsset font)
		{
			RectTransform val = Rect(name, parent);
			TextMeshProUGUI val2 = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).font = font;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			return val2;
		}
	}
}
namespace HPBarheim.Patches
{
	internal static class DamageTextHook
	{
		internal struct Hit
		{
			public Character Target;

			public Vector3 Pos;

			public string TypeName;

			public float Value;

			public bool Staggered;

			public bool Crit;

			public int PovElement;

			public int PovKind;

			public bool MySelf;
		}

		public static readonly List<Hit> Pending = new List<Hit>(16);

		private static int _iType = -1;

		private static int _iPos = -1;

		private static int _iText = -1;

		private static int _iSelf = -1;

		private static bool _loggedError;

		public static bool Active { get; private set; }

		public static bool CanHideVanilla { get; private set; }

		public static void Apply(Harmony harmony)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = Find("AddInworldText");
				CanHideVanilla = methodInfo != null;
				if (methodInfo == null)
				{
					methodInfo = Find("ShowText");
				}
				if (methodInfo == null)
				{
					Plugin.Log.LogWarning((object)"DamageText hook unavailable (no suitable method). Damage numbers fall back to measuring health changes, and vanilla numbers cannot be hidden.");
					return;
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DamageTextHook), "Prefix", (Type[])null)
				{
					priority = 0
				}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Active = true;
				Plugin.Log.LogInfo((object)("Damage numbers hooked on DamageText." + methodInfo.Name + (CanHideVanilla ? " (vanilla numbers can be hidden)." : " (capture only).")));
			}
			catch (Exception ex)
			{
				Active = false;
				CanHideVanilla = false;
				Plugin.Log.LogWarning((object)("DamageText hook failed: " + ex.Message));
			}
		}

		private static MethodInfo Find(string name)
		{
			MethodInfo[] methods = typeof(DamageText).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name != name)
				{
					continue;
				}
				int num = -1;
				int num2 = -1;
				int num3 = -1;
				int num4 = -1;
				ParameterInfo[] parameters = methodInfo.GetParameters();
				for (int j = 0; j < parameters.Length; j++)
				{
					Type parameterType = parameters[j].ParameterType;
					if (parameterType == typeof(TextType))
					{
						num = j;
					}
					else if (parameterType == typeof(Vector3) && num2 < 0)
					{
						num2 = j;
					}
					else if (parameterType == typeof(string) && num3 < 0)
					{
						num3 = j;
					}
					else if (parameterType == typeof(bool) && num4 < 0)
					{
						num4 = j;
					}
				}
				if (num >= 0 && num2 >= 0 && num3 >= 0)
				{
					_iType = num;
					_iPos = num2;
					_iText = num3;
					_iSelf = num4;
					return methodInfo;
				}
			}
			return null;
		}

		private static bool Prefix(object[] __args)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!HPConfig.EnableDamageNumbers.Value)
				{
					return true;
				}
				bool crit;
				int povElement;
				int povKind;
				string text = ResolveType(__args[_iType], out crit, out povElement, out povKind);
				if (!IsHandledType(text))
				{
					if (HPConfig.DebugLogging.Value)
					{
						Plugin.Log.LogInfo((object)("[damage-text] left to the game/other mod: type=" + __args[_iType]?.ToString() + " (" + Convert.ToInt32(__args[_iType]) + ") vanillaText=\"" + (__args[_iText] as string) + "\""));
					}
					return true;
				}
				Vector3 val = (Vector3)__args[_iPos];
				string text2 = __args[_iText] as string;
				bool flag = _iSelf >= 0 && (bool)__args[_iSelf];
				float result = 0f;
				Character val2 = null;
				if (text == "TooHard")
				{
					if (!HPConfig.EnableTooHardNumbers.Value)
					{
						return true;
					}
					Player localPlayer = Player.m_localPlayer;
					float value = HPConfig.DamageNumberMaxDistance.Value;
					if (!((Object)(object)localPlayer == (Object)null))
					{
						Vector3 val3 = val - ((Component)localPlayer).transform.position;
						if (!(((Vector3)(ref val3)).sqrMagnitude > value * value))
						{
							goto IL_0246;
						}
					}
					return true;
				}
				string s = text2?.TrimStart(new char[1] { '+' });
				if (!float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out result))
				{
					return true;
				}
				if ((text == "Heal" || text == "Blocked") && result <= 0f)
				{
					return true;
				}
				val2 = FindTarget(val, !flag);
				if ((Object)(object)val2 == (Object)null)
				{
					return true;
				}
				if (!ShouldHandle(val2, text))
				{
					return true;
				}
				goto IL_0246;
				IL_0246:
				Hit item = default(Hit);
				item.Target = val2;
				item.Pos = val;
				item.TypeName = text;
				item.Value = result;
				item.Crit = crit;
				item.PovElement = povElement;
				item.PovKind = povKind;
				item.MySelf = flag;
				item.Staggered = (Object)(object)val2 != (Object)null && !val2.IsPlayer() && val2.IsStaggering();
				Pending.Add(item);
				if (HPConfig.DebugLogging.Value)
				{
					Plugin.Log.LogInfo((object)("[damage-text] type=" + text + " vanillaText=\"" + text2 + "\" mySelf=" + flag + (crit ? " crit=True" : "") + ((text != __args[_iType].ToString()) ? (" rawType=" + Convert.ToInt32(__args[_iType])) : "") + " target=" + (((Object)(object)val2 != (Object)null) ? (val2.GetHoverName() + (val2.IsPlayer() ? " (player)" : "") + " hp=" + val2.GetHealth().ToString("0.#") + "/" + val2.GetMaxHealth().ToString("0.#")) : "(none)")));
				}
				return !CanHideVanilla || !HPConfig.HideVanillaDamageNumbers.Value;
			}
			catch (Exception ex)
			{
				if (!_loggedError)
				{
					_loggedError = true;
					Plugin.Log.LogWarning((object)("DamageText hook error (vanilla numbers left untouched): " + ex.Message));
				}
				return true;
			}
		}

		private static string ResolveType(object raw, out bool crit, out int povElement, out int povKind)
		{
			crit = false;
			povElement = -1;
			povKind = 0;
			if (PathOfValheimanSupport.Active && PathOfValheimanSupport.TryDecode(Convert.ToInt32(raw), out var typeName, out crit, out povElement, out povKind))
			{
				return typeName;
			}
			return raw.ToString();
		}

		private static bool IsHandledType(string t)
		{
			int result;
			switch (t)
			{
			default:
				result = ((t == "TooHard") ? 1 : 0);
				break;
			case "Normal":
			case "Weak":
			case "Resistant":
			case "Heal":
			case "Blocked":
				result = 1;
				break;
			}
			return (byte)result != 0;
		}

		private static bool ShouldHandle(Character c, string type)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			if (type == "Heal" && !HPConfig.EnableHealNumbers.Value)
			{
				return false;
			}
			if (type == "Blocked" && !HPConfig.EnableBlockedNumbers.Value)
			{
				return false;
			}
			if (c.IsPlayer())
			{
				return type == "Heal" || type == "Blocked" || HPConfig.ShowDamageTaken.Value;
			}
			if (!HPConfig.ShowForTamed.Value && c.IsTamed())
			{
				return false;
			}
			float value = HPConfig.DamageNumberMaxDistance.Value;
			Vector3 val = ((Component)c).transform.position - ((Component)localPlayer).transform.position;
			return ((Vector3)(ref val)).sqrMagnitude <= value * value;
		}

		private static Character FindTarget(Vector3 point, bool notLocalPlayer)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			Character result = null;
			float num = float.MaxValue;
			List<Character> allCharacters = Character.GetAllCharacters();
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val = allCharacters[i];
				if (!((Object)(object)val == (Object)null) && (!notLocalPlayer || !((Object)(object)val == (Object)(object)Player.m_localPlayer)))
				{
					Vector3 position = ((Component)val).transform.position;
					Vector3 topPoint = val.GetTopPoint();
					float num2 = Mathf.Max(topPoint.y - position.y, 0.5f);
					float num3 = Mathf.Max(1.5f, num2 * 0.5f + 1f);
					float num4 = DistanceToSegment(point, position, topPoint);
					if (num4 <= num3 && num4 < num)
					{
						num = num4;
						result = val;
					}
				}
			}
			return result;
		}

		private static float DistanceToSegment(Vector3 p, Vector3 a, Vector3 b)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			float num = ((sqrMagnitude > 0.0001f) ? Mathf.Clamp01(Vector3.Dot(p - a, val) / sqrMagnitude) : 0f);
			Vector3 val2 = p - (a + val * num);
			return ((Vector3)(ref val2)).magnitude;
		}

		internal static string Describe()
		{
			StringBuilder stringBuilder = new StringBuilder();
			MethodInfo[] methods = typeof(DamageText).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				stringBuilder.Append("  ").Append(methodInfo.ReturnType.Name).Append(' ')
					.Append(methodInfo.Name)
					.Append('(');
				ParameterInfo[] parameters = methodInfo.GetParameters();
				for (int j = 0; j < parameters.Length; j++)
				{
					stringBuilder.Append((j > 0) ? ", " : "").Append(parameters[j].ParameterType.Name).Append(' ')
						.Append(parameters[j].Name);
				}
				stringBuilder.Append(")\n");
			}
			stringBuilder.Append("  TextType values: ").Append(string.Join(", ", Enum.GetNames(typeof(TextType))));
			return stringBuilder.ToString();
		}
	}
	internal static class VanillaHudPatch
	{
		public static void Apply(Harmony harmony)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(EnemyHud), "ShowHud", (Type[])null, (Type[])null);
			if (HPConfig.DebugLogging.Value || methodInfo == null)
			{
				DumpEnemyHudMethods();
			}
			if (methodInfo == null)
			{
				Plugin.Log.LogWarning((object)"EnemyHud.ShowHud not found; Valheim's own enemy bars cannot be hidden. HP Barheim still works, but both bars will show.");
				return;
			}
			harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(VanillaHudPatch), "ShowHudPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Plugin.Log.LogInfo((object)"Patched EnemyHud.ShowHud.");
		}

		private static bool ShowHudPrefix(Character __0)
		{
			if (!HPConfig.Enabled.Value || !HPConfig.HideVanillaEnemyHud.Value)
			{
				return true;
			}
			return (Object)(object)__0 != (Object)null && __0.IsBoss();
		}

		private static void DumpEnemyHudMethods()
		{
			StringBuilder stringBuilder = new StringBuilder("EnemyHud methods:\n");
			MethodInfo[] methods = typeof(EnemyHud).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				stringBuilder.Append("  ").Append(methodInfo.ReturnType.Name).Append(' ')
					.Append(methodInfo.Name)
					.Append('(');
				ParameterInfo[] parameters = methodInfo.GetParameters();
				for (int j = 0; j < parameters.Length; j++)
				{
					stringBuilder.Append((j > 0) ? ", " : "").Append(parameters[j].ParameterType.Name).Append(' ')
						.Append(parameters[j].Name);
				}
				stringBuilder.Append(")\n");
			}
			Plugin.Log.LogInfo((object)stringBuilder.ToString());
		}
	}
}
namespace HPBarheim.Hud
{
	internal sealed class AilmentBarsView
	{
		private const float MinShown = 0.02f;

		private const float Gap = 2f;

		private const float FillSpeed = 3f;

		private const float AutoVerticalLength = 30f;

		private readonly AilmentBarSet _cfg;

		private readonly RectTransform _root;

		private readonly HealthBarView[] _bars;

		private readonly BarStyle[] _styles;

		private readonly float[] _shown;

		private readonly float[] _lastW;

		private readonly float[] _lastH;

		private int _styleVersion = -1;

		private float _barX;

		private float _barY;

		private float _barW = 140f;

		private float _barH = 14f;

		private bool _visible;

		public AilmentBarsView(Transform parent, AilmentBarSet settings)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			_cfg = settings;
			int num = PathOfValheimanGauges.Kinds.Length;
			_bars = new HealthBarView[num];
			_styles = new BarStyle[num];
			_shown = new float[num];
			_lastW = new float[num];
			_lastH = new float[num];
			_root = UiFactory.Rect("AilmentBars", parent);
			RectTransform root = _root;
			RectTransform root2 = _root;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			root2.anchorMax = val;
			root.anchorMin = val;
			_root.pivot = new Vector2(0.5f, 0.5f);
			_root.sizeDelta = Vector2.zero;
			for (int i = 0; i < num; i++)
			{
				_bars[i] = new HealthBarView((Transform)(object)_root);
				((Object)_bars[i].Root).name = "Gauge" + i;
				((Component)_bars[i].Root).gameObject.SetActive(false);
				_styles[i] = new BarStyle();
			}
			((Component)_root).gameObject.SetActive(false);
		}

		public void ApplyLayout(float barCenterX, float barCenterY, float barWidth, float barHeight)
		{
			_barX = barCenterX;
			_barY = barCenterY;
			_barW = Mathf.Max(20f, barWidth);
			_barH = Mathf.Max(1f, barHeight);
		}

		public void Hide()
		{
			if (_visible)
			{
				_visible = false;
				((Component)_root).gameObject.SetActive(false);
				for (int i = 0; i < _shown.Length; i++)
				{
					_shown[i] = 0f;
				}
			}
		}

		public void Tick(Character c, float dt)
		{
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null || !PathOfValheimanGauges.Active)
			{
				Hide();
				return;
			}
			int num = _shown.Length;
			int num2 = 0;
			float num3 = 0.75f + 0.25f * Mathf.Sin(Time.unscaledTime * 10f);
			for (int i = 0; i < num; i++)
			{
				float num4 = PathOfValheimanGauges.Read(c, PathOfValheimanGauges.Kinds[i]);
				_shown[i] = Mathf.MoveTowards(_shown[i], num4, 3f * dt);
				if (_shown[i] >= 0.02f || num4 >= 0.02f)
				{
					num2++;
				}
			}
			if (num2 == 0)
			{
				Hide();
				return;
			}
			if (!_visible)
			{
				_visible = true;
				((Component)_root).gameObject.SetActive(true);
			}
			BarSide value = _cfg.Position.Value;
			bool flag = _cfg.Orientation.Value == AilmentBarLayout.Vertical;
			float value2 = _cfg.Thickness.Value;
			float value3 = _cfg.OutlineWidth.Value;
			float num5 = _cfg.Length.Value;
			if (num5 <= 0f)
			{
				num5 = (flag ? 30f : _barW);
			}
			float num6;
			float num7;
			float num8;
			float num9;
			if (flag)
			{
				num6 = value2;
				num7 = num5;
				num8 = value2 * (float)num2 + 2f * (float)(num2 - 1);
				num9 = num5;
			}
			else
			{
				int num10 = Mathf.Max(2, num2);
				num6 = (num5 - 2f * (float)(num10 - 1)) / (float)num10;
				num7 = value2;
				num8 = num6 * (float)num2 + 2f * (float)(num2 - 1);
				num9 = value2;
			}
			float num11 = _barX;
			float num12 = _barY;
			float num13 = _cfg.Distance.Value + value3;
			switch (value)
			{
			case BarSide.Above:
				num12 += _barH * 0.5f + num13 + num9 * 0.5f;
				break;
			case BarSide.Left:
				num11 -= _barW * 0.5f + num13 + num8 * 0.5f;
				break;
			case BarSide.Right:
				num11 += _barW * 0.5f + num13 + num8 * 0.5f;
				break;
			default:
				num12 -= _barH * 0.5f + num13 + num9 * 0.5f;
				break;
			}
			_root.anchoredPosition = new Vector2(num11 + _cfg.OffsetX.Value, num12 + _cfg.OffsetY.Value);
			BarFx fx = _cfg.Fx;
			bool flag2 = _styleVersion != HPConfig.Version;
			_styleVersion = HPConfig.Version;
			bool value4 = _cfg.GlowFollowsGauge.Value;
			float num14 = (0f - num8) * 0.5f + num6 * 0.5f;
			for (int j = 0; j < num; j++)
			{
				bool flag3 = _shown[j] >= 0.02f;
				HealthBarView healthBarView = _bars[j];
				if (((Component)healthBarView.Root).gameObject.activeSelf != flag3)
				{
					((Component)healthBarView.Root).gameObject.SetActive(flag3);
				}
				if (!flag3)
				{
					continue;
				}
				BarStyle barStyle = _styles[j];
				float num15 = Mathf.Clamp01(_shown[j]);
				Color val = PathOfValheimanGauges.ColorOf(PathOfValheimanGauges.Kinds[j]);
				if (flag2 || num6 != _lastW[j] || num7 != _lastH[j] || barStyle.Width <= 0f)
				{
					barStyle.Width = num6;
					barStyle.Height = num7;
					barStyle.OffsetX = num14;
					barStyle.OffsetY = 0f;
					barStyle.FillVertical = flag;
					barStyle.Background = _cfg.BackgroundColor.Value;
					barStyle.BorderThickness = value3;
					barStyle.BorderColor = _cfg.OutlineColor.Value;
					barStyle.Phantom = false;
					barStyle.LowPulse = false;
					barStyle.LowThreshold = 0f;
					barStyle.ShadowDistance = 0f;
					barStyle.ShadowSoftness = 0f;
					barStyle.Opacity = 1f;
					fx.ApplyTo(barStyle);
					Color value5 = fx.GlowColor.Value;
					if (value4)
					{
						((Color)(ref value5))..ctor(val.r, val.g, val.b, value5.a);
					}
					barStyle.GlowColor = value5;
					healthBarView.ApplyLayout(barStyle);
					_lastW[j] = num6;
					_lastH[j] = num7;
				}
				healthBarView.Root.anchoredPosition = new Vector2(num14, 0f);
				num14 += num6 + 2f;
				float num16 = ((num15 >= 0.999f) ? num3 : 1f);
				Color val2 = val;
				val2.a *= num16;
				Color value6 = fx.GradientColor.Value;
				value6.a *= num16;
				barStyle.GradientStart = val2;
				barStyle.Hostile = (barStyle.Neutral = (barStyle.Friendly = (fx.UseGradient.Value ? value6 : val2)));
				healthBarView.Tick(num15, HudState.Hostile, dt);
			}
		}
	}
	internal static class AwarenessProbe
	{
		public static bool Available { get; private set; }

		public static bool IsAware(BaseAI ai)
		{
			return (Object)(object)ai != (Object)null && ai.HaveTarget();
		}

		public static void Init()
		{
			try
			{
				IsAware(null);
				Available = true;
				Plugin.Log.LogInfo((object)"Aware indicator uses BaseAI.HaveTarget() (same as vanilla's EnemyHud).");
			}
			catch (Exception ex)
			{
				Available = false;
				Plugin.Log.LogWarning((object)("Aware indicator unavailable: " + ex.Message));
			}
		}
	}
	internal sealed class BarGradient : BaseMeshEffect
	{
		private Color _a = Color.white;

		private Color _b = Color.white;

		private bool _vertical;

		public void Set(Color a, Color b, bool vertical)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0030: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!(a == _a) || !(b == _b) || vertical != _vertical)
			{
				_a = a;
				_b = b;
				_vertical = vertical;
				if ((Object)(object)((BaseMeshEffect)this).graphic != (Object)null)
				{
					((BaseMeshEffect)this).graphic.SetVerticesDirty();
				}
			}
		}

		public override void ModifyMesh(VertexHelper vh)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			int currentVertCount = vh.currentVertCount;
			if (!((UIBehaviour)this).IsActive() || currentVertCount == 0)
			{
				return;
			}
			UIVertex val = default(UIVertex);
			float num = float.MaxValue;
			float num2 = float.MinValue;
			for (int i = 0; i < currentVertCount; i++)
			{
				vh.PopulateUIVertex(ref val, i);
				float num3 = (_vertical ? val.position.y : val.position.x);
				if (num3 < num)
				{
					num = num3;
				}
				if (num3 > num2)
				{
					num2 = num3;
				}
			}
			float num4 = num2 - num;
			for (int j = 0; j < currentVertCount; j++)
			{
				vh.PopulateUIVertex(ref val, j);
				float num5 = (_vertical ? val.position.y : val.position.x);
				float num6 = ((num4 > 0.0001f) ? ((num5 - num) / num4) : 0f);
				val.color = Color32.op_Implicit(Color.Lerp(_a, _b, num6));
				vh.SetUIVertex(val, j);
			}
		}
	}
	internal sealed class BarPatternLayer
	{
		private const int MaxDividers = 64;

		private readonly RectTransform _clip;

		private readonly RectTransform _content;

		private readonly RawImage _tiled;

		private readonly RawImage _shine;

		private readonly RectTransform _tiledRect;

		private readonly RectTransform _shineRect;

		private readonly List<Image> _dividers = new List<Image>(16);

		private bool _fillOnly;

		private bool _active;

		private BarStyle _s;

		private float _maxHp = -1f;

		public BarPatternLayer(Transform barRoot)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			_clip = UiFactory.Rect("PatternClip", barRoot);
			((Component)_clip).gameObject.AddComponent<RectMask2D>();
			_clip.pivot = Vector2.zero;
			_content = UiFactory.Rect("PatternContent", (Transform)(object)_clip);
			_content.anchorMin = (_content.anchorMax = Vector2.zero);
			_content.pivot = Vector2.zero;
			_tiled = NewRaw("Pattern", out _tiledRect);
			_shine = NewRaw("Shine", out _shineRect);
			SetClip(1f);
		}

		private RawImage NewRaw(string name, out RectTransform rt)
		{
			//IL_0013: 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_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			rt = UiFactory.Rect(name, (Transform)(object)_content);
			RectTransform obj = rt;
			Vector2 anchorMin = (rt.anchorMax = Vector2.zero);
			obj.anchorMin = anchorMin;
			rt.pivot = Vector2.zero;
			rt.anchoredPosition = Vector2.zero;
			RawImage val = ((Component)rt).gameObject.AddComponent<RawImage>();
			((Graphic)val).raycastTarget = false;
			((Behaviour)val).enabled = false;
			return val;
		}

		public void Apply(BarStyle s)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: 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)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			_s = s;
			Dims(s, out var w, out var h);
			_fillOnly = s.PatternFillOnly;
			bool fillVertical = s.FillVertical;
			_content.sizeDelta = new Vector2(w, h);
			((Transform)_content).localEulerAngles = (Vector3)(fillVertical ? new Vector3(0f, 0f, 90f) : Vector3.zero);
			_content.anchoredPosition = (Vector2)(fillVertical ? new Vector2(h, 0f) : Vector2.zero);
			_tiledRect.sizeDelta = new Vector2(w, h);
			_shineRect.sizeDelta = new Vector2(w, h);
			((Behaviour)_tiled).enabled = false;
			float num = Mathf.Max(s.PatternThickness, 0.5f);
			float num2 = Mathf.Max(s.PatternSpacing, 1f);
			switch (s.Pattern)
			{
			case BarPattern.Stripes:
				_tiled.texture = (Texture)(object)PatternTextures.Stripes(num / num2);
				_tiled.uvRect = new Rect(0f, 0f, w / num2, 1f);
				((Behaviour)_tiled).enabled = true;
				break;
			case BarPattern.Diagonal:
			case BarPattern.DiagonalReverse:
				_tiled.texture = (Texture)(object)PatternTextures.Diagonal(num / num2, s.Pattern == BarPattern.DiagonalReverse);
				_tiled.uvRect = new Rect(0f, 0f, w / num2, h / num2);
				((Behaviour)_tiled).enabled = true;
				break;
			case BarPattern.Chevrons:
				_tiled.texture = (Texture)(object)PatternTextures.Chevrons(num / num2, h / num2);
				_tiled.uvRect = new Rect(0f, 0f, w / num2, 1f);
				((Behaviour)_tiled).enabled = true;
				break;
			case BarPattern.Diamonds:
			{
				float num3 = h / num2;
				_tiled.texture = (Texture)(object)PatternTextures.Diamonds(num / num2);
				_tiled.uvRect = new Rect(0f, 0.5f - num3 * 0.5f, w / num2, num3);
				((Behaviour)_tiled).enabled = true;
				break;
			}
			}
			if (((Behaviour)_tiled).enabled)
			{
				((Graphic)_tiled).color = s.PatternColor;
			}
			int num4 = LayoutDividers();
			((Behaviour)_shine).enabled = s.Shine > 0f;
			if (((Behaviour)_shine).enabled)
			{
				_shine.texture = (Texture)(object)PatternTextures.Shine();
				_shine.uvRect = new Rect(0f, 0f, 1f, 1f);
				((Graphic)_shine).color = new Color(1f, 1f, 1f, Mathf.Clamp01(s.Shine));
			}
			_active = ((Behaviour)_tiled).enabled || num4 > 0 || ((Behaviour)_shine).enabled || s.Pattern == BarPattern.HpBlocks;
			((Component)_clip).gameObject.SetActive(_active);
			if (!_fillOnly)
			{
				SetClip(1f);
			}
			((Transform)_clip).SetAsLastSibling();
		}

		public void SetMaxHealth(float max)
		{
			if (_s == null || _s.Pattern != BarPattern.HpBlocks)
			{
				_maxHp = max;
			}
			else if (!(Mathf.Abs(max - _maxHp) < 0.5f))
			{
				_maxHp = max;
				LayoutDividers();
			}
		}

		public static float AutoBlock(float maxHp, int maxBlocks, bool fine = false)
		{
			maxBlocks = Mathf.Max(2, maxBlocks);
			if (fine)
			{
				if (maxHp / 25f <= (float)maxBlocks)
				{
					return 25f;
				}
				if (maxHp / 50f <= (float)maxBlocks)
				{
					return 50f;
				}
			}
			float num = 100f;
			for (int i = 0; i < 12; i++)
			{
				if (maxHp / num <= (float)maxBlocks)
				{
					return num;
				}
				if (maxHp / (num * 2.5f) <= (float)maxBlocks)
				{
					return num * 2.5f;
				}
				if (maxHp / (num * 5f) <= (float)maxBlocks)
				{
					return num * 5f;
				}
				num *= 10f;
			}
			return num;
		}

		private int LayoutDividers()
		{
			//IL_0079: 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)
			BarStyle s = _s;
			if (s == null)
			{
				return 0;
			}
			int num = 0;
			Dims(s, out var w, out var h);
			float t = Mathf.Max(s.PatternThickness, 0.5f);
			if (s.Pattern == BarPattern.Segments)
			{
				int num2 = Mathf.Clamp(s.PatternCount, 2, 65);
				num = num2 - 1;
				float num3 = w / (float)num2;
				for (int i = 0; i < num; i++)
				{
					PlaceDivider(i, num3 * (float)(i + 1), t, h, s.PatternColor);
				}
			}
			else if (s.Pattern == BarPattern.HpBlocks && _maxHp > 0f)
			{
				float num4 = ((s.PatternHpPerBlock > 0f) ? s.PatternHpPerBlock : AutoBlock(_maxHp, s.PatternMaxBlocks, s.PatternFineBlocks));
				int num5 = 1;
				while (num < 64)
				{
					float num6 = (float)num5 * num4;
					if (num6 >= _maxHp - 0.01f)
					{
						break;
					}
					PlaceDivider(num, w * num6 / _maxHp, t, h, s.PatternColor);
					num++;
					num5++;
				}
			}
			for (int j = 0; j < _dividers.Count; j++)
			{
				bool flag = j < num;
				if (((Component)_dividers[j]).gameObject.activeSelf != flag)
				{
					((Component)_dividers[j]).gameObject.SetActive(flag);
				}
			}
			return num;
		}

		private void PlaceDivider(int i, float x, float t, float h, Color color)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_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)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			while (_dividers.Count <= i)
			{
				RectTransform rt;
				Image item = UiFactory.Solid("Divider", (Transform)(object)_content, out rt);
				RectTransform obj = rt;
				Vector2 anchorMin = (rt.anchorMax = Vector2.zero);
				obj.anchorMin = anchorMin;
				rt.pivot = Vector2.zero;
				_dividers.Add(item);
			}
			Image val = _dividers[i];
			RectTransform rectTransform = ((Graphic)val).rectTransform;
			rectTransform.sizeDelta = new Vector2(t, h);
			rectTransform.anchoredPosition = new Vector2(x - t * 0.5f, 0f);
			((Graphic)val).color = color;
		}

		public void SetFill(float fraction)
		{
			if (_active && _fillOnly)
			{
				SetClip(fraction);
			}
		}

		private static void Dims(BarStyle s, out float w, out float h)
		{
			bool fillVertical = s.FillVertical;
			w = Mathf.Max(fillVertical ? s.Height : s.Width, 1f);
			h = Mathf.Max(fillVertical ? s.Width : s.Height, 1f);
		}

		private void SetClip(float fraction)
		{
			//IL_000e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01(fraction);
			_clip.anchorMin = Vector2.zero;
			_clip.anchorMax = ((_s != null && _s.FillVertical) ? new Vector2(1f, num) : new Vector2(num, 1f));
			_clip.offsetMin = Vector2.zero;
			_clip.offsetMax = Vector2.zero;
		}
	}
	internal static class PatternTextures
	{
		private static readonly Dictionary<int, Texture2D> Cache = new Dictionary<int, Texture2D>();

		private static Texture2D _shine;

		private static int Key(int kind, float ratio)
		{
			return kind * 1000 + Mathf.Clamp(Mathf.RoundToInt(ratio * 100f), 1, 99);
		}

		private static Texture2D New(int w, int h, string name)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			return new Texture2D(w, h, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)1,
				name = name
			};
		}

		private static float Band(float pos, float period, float ratio)
		{
			float num = Mathf.Clamp(ratio, 0.01f, 0.99f) * period;
			float num2 = Mathf.Repeat(pos, period);
			return Mathf.Clamp01(num - num2 + 0.5f) * Mathf.Clamp01(num2 + 0.5f);
		}

		public static Texture2D Stripes(float ratio)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			int key = Key(1, ratio);
			if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = New(64, 1, "HPBarheim_Stripes");
			Color32[] array = (Color32[])(object)new Color32[64];
			for (int i = 0; i < 64; i++)
			{
				array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Band(i, 64f, ratio) * 255f));
			}
			value.SetPixels32(array);
			value.Apply(false, true);
			return Cache[key] = value;
		}

		public static Texture2D Diagonal(float ratio, bool reverse)
		{
			//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)
			int key = Key(reverse ? 4 : 3, ratio);
			if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = New(64, 64, reverse ? "HPBarheim_DiagonalReverse" : "HPBarheim_Diagonal");
			Color32[] array = (Color32[])(object)new Color32[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					int num = (reverse ? (63 - i) : i);
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Band(j + num, 64f, ratio) * 255f));
				}
			}
			value.SetPixels32(array);
			value.Apply(false, true);
			return Cache[key] = value;
		}

		public static Texture2D Chevrons(float ratio, float slope)
		{
			//IL_00cf: 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)
			slope = Mathf.Clamp(Mathf.Round(slope * 4f) / 4f, 0.25f, 20f);
			int key = Key(5, ratio) * 1000 + Mathf.RoundToInt(slope * 4f);
			if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = New(64, 64, "HPBarheim_Chevrons");
			Color32[] array = (Color32[])(object)new Color32[4096];
			float num = 31.5f;
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float pos = (float)j + Mathf.Abs((float)i - num) * slope;
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Band(pos, 64f, ratio) * 255f));
				}
			}
			value.SetPixels32(array);
			value.Apply(false, true);
			return Cache[key] = value;
		}

		public static Texture2D Diamonds(float ratio)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			int key = Key(6, ratio);
			if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = New(64, 64, "HPBarheim_Diamonds");
			Color32[] array = (Color32[])(object)new Color32[4096];
			float num = 31.5f;
			float num2 = Mathf.Clamp(ratio, 0.1f, 0.9f) * 64f * 0.5f;
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num3 = Mathf.Abs((float)j - num) + Mathf.Abs((float)i - num);
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num2 - num3 + 0.5f) * 255f));
				}
			}
			value.SetPixels32(array);
			value.Apply(false, true);
			return Cache[key] = value;
		}

		public static Texture2D Shine()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_shine != (Object)null)
			{
				return _shine;
			}
			_shine = New(1, 32, "HPBarheim_Shine");
			((Texture)_shine).wrapMode = (TextureWrapMode)1;
			Color32[] array = (Color32[])(object)new Color32[32];
			for (int i = 0; i < 32; i++)
			{
				float num = ((float)i + 0.5f) / 32f;
				float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.45f, 1f, num));
				num2 = num2 * 0.85f + ((num > 0.92f) ? 0.15f : 0f);
				array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num2) * 255f));
			}
			_shine.SetPixels32(array);
			_shine.Apply(false, true);
			return _shine;
		}
	}
	internal sealed class BarStyle
	{
		public float Width;

		public float Height;

		public float OffsetX;

		public float OffsetY;

		public Color Background;

		public Color Hostile;

		public Color Neutral;

		public Color Friendly;

		public bool UseGradient;

		public bool Vertical;

		public bool FillVertical;

		public Color GradientStart;

		public bool Phantom;

		public Color PhantomColor;

		public float PhantomDelay;

		public float PhantomSpeed;

		public float LowThreshold;

		public bool LowPulse;

		public Color LowColor;

		public float BorderThickness;

		public Color BorderColor;

		public float ShadowDistance;

		public float ShadowSoftness;

		public Color ShadowColor;

		public float GlowSize;

		public Color GlowColor;

		public BarPattern Pattern;

		public Color PatternColor;

		public int PatternCount;

		public int PatternMaxBlocks;

		public float PatternHpPerBlock;

		public float PatternSpacing;

		public float PatternThickness;

		public bool PatternFillOnly;

		public bool PatternFineBlocks;

		public float Shine;

		public float Opacity;

		public static BarStyle Normal()
		{
			//IL_004c: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			return new BarStyle
			{
				Width = HPConfig.BarWidth.Value,
				Height = HPConfig.BarHeight.Value,
				OffsetX = HPConfig.BarOffsetX.Value,
				OffsetY = HPConfig.BarOffsetY.Value,
				Background = HPConfig.BarBackgroundColor.Value,
				Hostile = HPConfig.BarHostileColor.Value,
				Neutral = HPConfig.BarNeutralColor.Value,
				Friendly = HPConfig.BarFriendlyColor.Value,
				UseGradient = HPConfig.BarUseGradient.Value,
				Vertical = (HPConfig.BarGradientDirection.Value == GradientDirection.Vertical),
				GradientStart = HPConfig.BarGradientStartColor.Value,
				Phantom = HPConfig.EnablePhantomBar.Value,
				PhantomColor = HPConfig.PhantomColor.Value,
				PhantomDelay = HPConfig.PhantomDelay.Value,
				PhantomSpeed = HPConfig.PhantomSpeed.Value,
				LowThreshold = HPConfig.LowHealthThreshold.Value,
				LowPulse = HPConfig.LowHealthPulse.Value,
				LowColor = HPConfig.LowHealthColor.Value,
				BorderThickness = HPConfig.BarBorderThickness.Value,
				BorderColor = HPConfig.BarBorderColor.Value,
				ShadowDistance = HPConfig.BarShadowDistance.Value,
				ShadowSoftness = HPConfig.BarShadowSoftness.Value,
				ShadowColor = HPConfig.BarShadowColor.Value,
				GlowSize = HPConfig.BarGlowSize.Value,
				GlowColor = HPConfig.BarGlowColor.Value,
				Pattern = HPConfig.BarPatternType.Value,
				PatternColor = HPConfig.BarPatternColor.Value,
				PatternCount = HPConfig.BarPatternSegments.Value,
				PatternMaxBlocks = HPConfig.BarPatternMaxBlocks.Value,
				PatternHpPerBlock = HPConfig.BarPatternHpPerBlock.Value,
				PatternFineBlocks = true,
				PatternSpacing = HPConfig.BarPatternSpacing.Value,
				PatternThickness = HPConfig.BarPatternThickness.Value,
				PatternFillOnly = HPConfig.BarPatternFillOnly.Value,
				Shine = HPConfig.BarShine.Value,
				Opacity = HPConfig.BarOpacity.Value
			};
		}

		public static BarStyle Boss()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			Color value = HPConfig.BossBarFillColor.Value;
			return new BarStyle
			{
				Width = HPConfig.BossBarWidth.Value,
				Height = HPConfig.BossBarHeight.Value,
				OffsetX = 0f,
				OffsetY = 0f,
				Background = HPConfig.BossBarBackgroundColor.Value,
				Hostile = value,
				Neutral = value,
				Friendly = value,
				UseGradient = HPConfig.BossBarUseGradient.Value,
				Vertical = (HPConfig.BossBarGradientDirection.Value == GradientDirection.Vertical),
				GradientStart = HPConfig.BossBarGradientStartColor.Value,
				Phantom = HPConfig.BossBarPhantom.Value,
				PhantomColor = HPConfig.BossBarPhantomColor.Value,
				PhantomDelay = HPConfig.BossBarPhantomDelay.Value,
				PhantomSpeed = HPConfig.BossBarPhantomSpeed.Value,
				LowThreshold = HPConfig.BossBarLowHealthThreshold.Value,
				LowPulse = HPConfig.BossBarLowHealthPulse.Value,
				LowColor = HPConfig.BossBarLowHealthColor.Value,
				BorderThickness = HPConfig.BossBarBorderThickness.Value,
				BorderColor = HPConfig.BossBarBorderColor.Value,
				ShadowDistance = HPConfig.BossBarShadowDistance.Value,
				ShadowSoftness = HPConfig.BossBarShadowSoftness.Value,
				ShadowColor = HPConfig.BossBarShadowColor.Value,
				GlowSize = HPConfig.BossBarGlowSize.Value,
				GlowColor = HPConfig.BossBarGlowColor.Value,
				Pattern = HPConfig.BossBarPatternType.Value,
				PatternColor = HPConfig.BossBarPatternColor.Value,
				PatternCount = HPConfig.BossBarPatternSegments.Value,
				PatternMaxBlocks = HPConfig.BossBarPatternMaxBlocks.Value,
				PatternHpPerBlock = HPConfig.BossBarPatternHpPerBlock.Value,
				PatternSpacing = HPConfig.BossBarPatternSpacing.Value,
				PatternThickness = HPConfig.BossBarPatternThickness.Value,
				PatternFillOnly = HPConfig.BossBarPatternFillOnly.Value,
				Shine = HPConfig.BossBarShine.Value,
				Opacity = HPConfig.BossBarOpacity.Value
			};
		}
	}
	internal sealed class BossBarManager : MonoBehaviour
	{
		private readonly List<BossBarWidget> _active = new List<BossBarWidget>(4);

		private readonly Stack<BossBarWidget> _pool = new Stack<BossBarWidget>(4);

		private readonly List<Character> _candidates = new List<Character>(4);

		private readonly List<float> _dist = new List<float>(4);

		private Canvas _canvas;

		private float _nextVanillaSync;

		private void LateUpdate()
		{
			float time = Time.time;
			bool flag = HPConfig.Enabled.Value && HPConfig.EnableBossBar.Value;
			if (time >= _nextVanillaSync)
			{
				_nextVanillaSync = time + 0.25f;
				VanillaBossHud.Sync(flag && HPConfig.HideVanillaBossHud.Value);
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				ReleaseAll();
				return;
			}
			TMP_FontAsset val = FontProvider.GetBase();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((Object)(object)_canvas == (Object)null)
			{
				_canvas = UiFactory.CreateOverlayCanvas("HPBarheim_BossBars", -45);
			}
			FindBosses(localPlayer, flag);
			for (int i = 0; i < _active.Count; i++)
			{
				_active[i].Wanted = false;
			}
			for (int j = 0; j < _candidates.Count; j++)
			{
				Character c = _candidates[j];
				BossBarWidget bossBarWidget = Find(c);
				if (bossBarWidget == null)
				{
					bossBarWidget = ((_pool.Count > 0) ? _pool.Pop() : new BossBarWidget(((Component)_canvas).transform, val));
					bossBarWidget.Bind(c);
					_active.Add(bossBarWidget);
				}
				bossBarWidget.Wanted = true;
				bossBarWidget.Slot = j;
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			for (int num = _active.Count - 1; num >= 0; num--)
			{
				BossBarWidget bossBarWidget2 = _active[num];
				if (!bossBarWidget2.Tick(unscaledDeltaTime))
				{
					bossBarWidget2.Release();
					_pool.Push(bossBarWidget2);
					_active.RemoveAt(num);
				}
			}
		}

		private void FindBosses(Player player, bool on)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			_candidates.Clear();
			_dist.Clear();
			if (!on)
			{
				return;
			}
			float num = ((HPConfig.BossMaxDistance.Value > 0f) ? HPConfig.BossMaxDistance.Value : VanillaBossHud.VanillaMaxDistance());
			float num2 = num * num;
			bool value = HPConfig.BossShowWhenAlerted.Value;
			int num3 = Mathf.Max(1, HPConfig.BossMaxBars.Value);
			Vector3 position = ((Component)player).transform.position;
			List<Character> allCharacters = Character.GetAllCharacters();
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val = allCharacters[i];
				if ((Object)(object)val == (Object)null || !val.IsBoss() || val.IsDead())
				{
					continue;
				}
				Vector3 val2 = ((Component)val).transform.position - position;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude > num2)
				{
					continue;
				}
				bool flag = val.GetHealth() < val.GetMaxHealth() - 0.01f;
				if (!flag && value)
				{
					BaseAI baseAI = val.GetBaseAI();
					flag = (Object)(object)baseAI != (Object)null && baseAI.IsAlerted();
				}
				if (!flag)
				{
					continue;
				}
				int j;
				for (j = 0; j < _dist.Count && _dist[j] <= sqrMagnitude; j++)
				{
				}
				if (j < num3)
				{
					_candidates.Insert(j, val);
					_dist.Insert(j, sqrMagnitude);
					if (_candidates.Count > num3)
					{
						_candidates.RemoveAt(num3);
						_dist.RemoveAt(num3);
					}
				}
			}
		}

		private BossBarWidget Find(Character c)
		{
			for (int i = 0; i < _active.Count; i++)
			{
				if ((Object)(object)_active[i].Target == (Object)(object)c)
				{
					return _active[i];
				}
			}
			return null;
		}

		private void ReleaseAll()
		{
			for (int i = 0; i < _active.Count; i++)
			{
				_active[i].Release();
				_pool.Push(_active[i]);
			}
			_active.Clear();
		}

		private void OnDestroy()
		{
			if ((Object)(object)_canvas != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_canvas).gameObject);
			}
		}
	}
	internal sealed class BossBarWidget
	{
		private readonly RectTransform _root;

		private readonly CanvasGroup _group;

		private readonly HealthBarView _bar;

		private readonly AilmentBarsView _ailments;

		private readonly TextMeshProUGUI _name;

		private readonly TextMeshProUGUI _hp;

		private static readonly Vector2 TextBox = new Vector2(1200f, 80f);

		public int Slot;

		public bool Wanted;

		private float _alpha;

		private int _layoutVersion = -1;

		private int _lastCur = int.MinValue;

		private int _lastMax = int.MinValue;

		private string _rawName = "";

		public Character Target { get; private set; }

		public BossBarWidget(Transform canvasRoot, TMP_FontAsset font)
		{
			//IL_005e: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			_root = UiFactory.Rect("BossBar", canvasRoot);
			RectTransform root = _root;
			RectTransform root2 = _root;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 1f);
			root2.anchorMax = val;
			root.anchorMin = val;
			_root.pivot = new Vector2(0.5f, 0.5f);
			_root.sizeDelta = Vector2.zero;
			_group = ((Component)_root).gameObject.AddComponent<CanvasGroup>();
			_group.interactable = false;
			_group.blocksRaycasts = false;
			_bar = new HealthBarView((Transform)(object)_root);
			_ailments = new AilmentBarsView((Transform)(object)_root, HPConfig.BossAilment);
			_hp = UiFactory.Text("BossHp", (Transform)(object)_root, font);
			_name = UiFactory.Text("BossName", (Transform)(object)_root, font);
			((Component)_root).gameObject.SetActive(false);
		}

		public void Bind(Character c)
		{
			Target = c;
			Wanted = true;
			_rawName = c.GetHoverName() ?? "";
			_lastCur = (_lastMax = int.MinValue);
			_layoutVersion = -1;
			_ailments.Hide();
			float maxHealth = c.GetMaxHealth();
			_bar.ResetTo((maxHealth > 0f) ? Mathf.Clamp01(c.GetHealth() / maxHealth) : 0f);
			_alpha = 0f;
			_group.alpha = 0f;
			((Component)_root).gameObject.SetActive(true);
		}

		public void Release()
		{
			Target = null;
			Wanted = false;
			((Component)_root).gameObject.SetActive(false);
		}

		public bool Tick(float dt)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (_layoutVersion != HPConfig.Version)
			{
				ApplyLayout();
			}
			float num = 0f - (HPConfig.BossBarOffsetY.Value + HPConfig.BossBarHeight.Value * 0.5f) - (float)Slot * HPConfig.BossBarStackSpacing.Value;
			_root.anchoredPosition = new Vector2(HPConfig.BossBarOffsetX.Value, num);
			Character target = Target;
			if ((Object)(object)target != (Object)null)
			{
				float maxHealth = target.GetMaxHealth();
				float num2 = (target.IsDead() ? 0f : target.GetHealth());
				_bar.SetMaxHealth(maxHealth);
				_bar.Tick((maxHealth > 0f) ? Mathf.Clamp01(num2 / maxHealth) : 0f, HudState.Hostile, dt);
				UpdateHealthText(num2, maxHealth);
				if (target.IsDead())
				{
					_ailments.Hide();
				}
				else
				{
					_ailments.Tick(target, dt);
				}
			}
			float value = HPConfig.BossBarFadeSeconds.Value;
			float num3 = ((Wanted && (Object)(object)target != (Object)null) ? 1f : 0f);
			_alpha = ((value <= 0f) ? num3 : Mathf.MoveTowards(_alpha, num3, dt / value));
			_group.alpha = _alpha;
			return num3 > 0f || _alpha > 0f;
		}

		private void UpdateHealthText(float cur, float max)
		{
			if (!HPConfig.EnableBossHealthText.Value)
			{
				return;
			}
			int num = Mathf.CeilToInt(cur);
			int num2 = Mathf.CeilToInt(max);
			if (num != _lastCur || num2 != _lastMax)
			{
				_lastCur = num;
				_lastMax = num2;
				bool value = HPConfig.BossHealthTextAbbreviate.Value;
				int num3 = ((num2 > 0) ? Mathf.CeilToInt(100f * cur / max) : 0);
				switch (HPConfig.BossHealthTextMode.Value)
				{
				case BossHpTextMode.Current:
					((TMP_Text)_hp).text = TextFx.Abbreviate(num, value);
					break;
				case BossHpTextMode.Percent:
					((TMP_Text)_hp).text = num3 + "%";
					break;
				case BossHpTextMode.CurrentAndPercent:
					((TMP_Text)_hp).text = TextFx.Abbreviate(num, value) + "  (" + num3 + "%)";
					break;
				default:
					((TMP_Text)_hp).text = TextFx.Abbreviate(num, value) + " / " + TextFx.Abbreviate(num2, value);
					break;
				}
			}
		}

		private void ApplyLayout()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			_layoutVersion = HPConfig.Version;
			float barHalfWidth = HPConfig.BossBarWidth.Value * 0.5f;
			_bar.ApplyLayout(BarStyle.Boss());
			_ailments.ApplyLayout(0f, 0f, HPConfig.BossBarWidth.Value, HPConfig.BossBarHeight.Value);
			bool value = HPConfig.EnableBossName.Value;
			((Component)_name).gameObject.SetActive(value);
			if (value)
			{
				TextFx.SetFont(_name, HPConfig.BossNameFont.Value);
				((TMP_Text)_name).fontSize = HPConfig.BossNameFontSize.Value;
				TextFx.SetColor(_name, HPConfig.BossNameUseGradient.Value, HPConfig.BossNameColor.Value, HPConfig.BossNameGradientColorA.Value, HPConfig.BossNameGradientColorB.Value, HPConfig.BossNameGradientDirection.Value);
				((TMP_Text)_name).fontStyle = (FontStyles)HPConfig.BossNameFontStyle.Value;
				((TMP_Text)_name).characterSpacing = HPConfig.BossNameLetterSpacing.Value;
				TextFx.Apply(_name, HPConfig.BossNameOutlineWidth.Value, HPConfig.BossNameOutlineColor.Value, HPConfig.BossNameShadowDistance.Value, HPConfig.BossNameShadowColor.Value);
				((TMP_Text)_name).text = _rawName;
				TextFx.PlaceOnBar(_name, HPConfig.BossNameAlign.Value, HPConfig.BossNameOffsetX.Value, HPConfig.BossNameOffsetY.Value, barHalfWidth, TextBox);
			}
			bool value2 = HPConfig.EnableBossHealthText.Value;
			((Component)_hp).gameObject.SetActive(value2);
			if (value2)
			{
				TextFx.SetFont(_hp, HPConfig.BossHealthTextFont.Value);
				((TMP_Text)_hp).fontSize = HPConfig.BossHealthTextFontSize.Value;
				((Graphic)_hp).color = HPConfig.BossHealthTextColor.Value;
				((TMP_Text)_hp).fontStyle = (FontStyles)0;
				TextFx.Apply(_hp, HPConfig.BossHealthTextOutlineWidth.Value, HPConfig.BossHealthTextOutlineColor.Value, 0f, Color.black);
				TextFx.PlaceOnBar(_hp, HPConfig.BossHealthTextAlign.Value, HPConfig.BossHealthTextOffsetX.Value, HPConfig.BossHealthTextOffsetY.Value, barHalfWidth, TextBox);
				_lastCur = (_lastMax = int.MinValue);
			}
			((Transform)((TMP_Text)_name).rectTransform).SetAsLastSibling();
		}
	}
	internal static class DamageIconSprite
	{
		internal enum IconType
		{
			Blunt,
			Slash,
			Pierce,
			Chop,
			Pickaxe,
			Fire,
			Frost,
			Lightning,
			Poison,
			Spirit
		}

		private abstract class Prim
		{
			public Color32 Color;

			public abstract bool Covers(Vector2 p);
		}

		private sealed class Poly : Prim
		{
			public Vector2[] Pts;

			public override bool Covers(Vector2 p)
			{
				//IL_0027: 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_004a: 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)
				bool flag = false;
				int num = 0;
				int num2 = Pts.Length - 1;
				while (num < Pts.Length)
				{
					if (Pts[num].y > p.y != Pts[num2].y > p.y && p.x < (Pts[num2].x - Pts[num].x) * (p.y - Pts[num].y) / (Pts[num2].y - Pts[num].y) + Pts[num].x)
					{
						flag = !flag;
					}
					num2 = num++;
				}
				return flag;
			}
		}

		private sealed class Circ : Prim
		{
			public Vector2 C;

			public float R;

			public override bool Covers(Vector2 p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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)
				Vector2 val = p - C;
				return ((Vector2)(ref val)).sqrMagnitude <= R * R;
			}
		}

		private sealed class Caps : Prim
		{
			public Vector2 A;

			public Vector2 B;

			public float HalfW;

			public override bool Covers(Vector2 p)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: 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_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_0036: 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_0046: 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_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_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = B - A;
				float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude;
				float num = ((sqrMagnitude > 0.0001f) ? Mathf.Clamp01(Vector2.Dot(p - A, val) / sqrMagnitude) : 0f);
				Vector2 val2 = p - (A + val * num);
				return ((Vector2)(ref val2)).sqrMagnitude <= HalfW * HalfW;
			}
		}

		private const int Size = 64;

		private const float Ref = 24f;

		private const int SS = 4;

		private static readonly Dictionary<IconType, Sprite> _cache = new Dictionary<IconType, Sprite>();

		private static Sprite _overlay;

		private static Sprite _overlayReversed;

		public static Sprite Get(IconType type)
		{
			if (_cache.TryGetValue(type, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = Build(BuildPrims(type), "HPBarheim_Icon_" + type);
			_cache[type] = value;
			return value;
		}

		public static Sprite GetImmuneOverlay(bool reversed)
		{
			if (reversed)
			{
				if ((Object)(object)_overlayReversed == (Object)null)
				{
					_overlayReversed = Build(BuildOverlayPrims(reversed: true), "HPBarheim_ImmuneOverlay_Rev");
				}
				return _overlayReversed;
			}
			if ((Object)(object)_overlay == (Object)null)
			{
				_overlay = Build(BuildOverlayPrims(reversed: false), "HPBarheim_ImmuneOverlay");
			}
			return _overlay;
		}

		private static Vector2 V(float x, float ySvg)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(x, 24f - ySvg);
		}

		private static Poly P(Color32 c, params Vector2[] pts)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return new Poly
			{
				Color = c,
				Pts = pts
			};
		}

		private static Circ C(Color32 c, Vector2 center, float r)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			return new Circ
			{
				Color = c,
				C = center,
				R = r
			};
		}

		private static Caps L(Color32 c, Vector2 a, Vector2 b, float halfW)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0014: 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)
			return new Caps
			{
				Color = c,
				A = a,
				B = b,
				HalfW = halfW
			};
		}

		private static Color32 Col(byte r, byte g, byte b, byte a = byte.MaxValue)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			return new Color32(r, g, b, a);
		}

		private static Sprite Build(List<Prim> prims, string name)
		{
			//IL_0007: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1,
				name = name
			};
			float num = 2.6666667f;
			Color32[] array = (Color32[])(object)new Color32[4096];
			Vector2 p = default(Vector2);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					int num2 = 0;
					float num3 = 0f;
					float num4 = 0f;
					float num5 = 0f;
					for (int k = 0; k < 4; k++)
					{
						for (int l = 0; l < 4; l++)
						{
							((Vector2)(ref p))..ctor(((float)j + ((float)l + 0.5f) / 4f) / num, ((float)i + ((float)k + 0.5f) / 4f) / num);
							bool flag = false;
							Color32 val2 = default(Color32);
							for (int m = 0; m < prims.Count; m++)
							{
								if (prims[m].Covers(p))
								{
									val2 = prims[m].Color;
									flag = true;
								}
							}
							if (flag)
							{
								num2++;
								num3 += (float)(int)val2.r;
								num4 += (float)(int)val2.g;
								num5 += (float)(int)val2.b;
							}
						}
					}
					int num6 = 16;
					if (num2 > 0)
					{
						byte b = (byte)Mathf.RoundToInt(255f * (float)num2 / (float)num6);
						array[i * 64 + j] = new Color32((byte)Mathf.RoundToInt(num3 / (float)num2), (byte)Mathf.RoundToInt(num4 / (float)num2), (byte)Mathf.RoundToInt(num5 / (float)num2), b);
					}
					else
					{
						array[i * 64 + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)0);
					}
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
		}

		private static List<Prim> BuildOverlayPrims(bool reversed)
		{
			//IL_001f: 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_0024: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Vector2 a = (reversed ? V(20f, 4f) : V(4f, 4f));
			Vector2 b = (reversed ? V(4f, 20f) : V(20f, 20f));
			return new List<Prim>
			{
				L(Col(11, 11, 12), a, b, 2.1f),
				L(Col(byte.MaxValue, 77, 77), a, b, 1.2f)
			};
		}

		private static List<Prim> BuildPrims(IconType type)
		{
			return type switch
			{
				IconType.Blunt => Blunt(), 
				IconType.Slash => Slash(), 
				IconType.Pierce => Pierce(), 
				IconType.Chop => Chop(), 
				IconType.Pickaxe => Pickaxe(), 
				IconType.Fire => Fire(), 
				IconType.Frost => Frost(), 
				IconType.Lightning => Lightning(), 
				IconType.Poison => Poison(), 
				IconType.Spirit => Spirit(), 
				_ => new List<Prim>(), 
			};
		}

		private static List<Prim> Blunt()
		{
			//IL_000c: 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_002b: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: 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_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			Color32 c = Col(122, 122, 116);
			Color32 c2 = Col(155, 155, 148);
			Color32 c3 = Col(195, 195, 188);
			Color32 c4 = Col(189, 189, 181);
			List<Prim> list = new List<Prim>();
			list.Add(P(c, V(11f, 13f), V(13f, 13f), V(12.6f, 23f), V(11.4f, 23f)));
			list.Add(C(c2, V(12f, 8f), 5.2f));
			list.Add(C(c3, V(10.3f, 6.3f), 1.5f));
			list.Add(P(c4, V(12f, 0.2f), V(13.6f, 1.8f), V(12f, 3.4f), V(10.4f, 1.8f)));
			list.Add(P(c4, V(4.3f, 5.6f), V(5.9f, 7.2f), V(4.3f, 8.8f), V(2.7f, 7.2f)));
			list.Add(P(c4, V(19.7f, 5.6f), V(21.3f, 7.2f), V(19.7f, 8.8f), V(18.1f, 7.2f)));
			return list;
		}

		private static Vector2 Rot(float x, float y)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Cos((float)Math.PI * -19f / 90f);
			float num2 = Mathf.Sin((float)Math.PI * -19f / 90f);
			float num3 = x - 12f;
			float num4 = y - 12f;
			return V(12f + num3 * num - num4 * num2, 12f + num3 * num2 + num4 * num);
		}

		private static List<Prim> Slash()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			Color32 c = Col(207, 211, 216);
			Color32 c2 = Col(138, 138, 143);
			Color32 c3 = Col(90, 70, 50);
			List<Prim> list = new List<Prim>();
			list.Add(P(c, Rot(12f, 1f), Rot(14f, 5.5f), Rot(14f, 16.5f), Rot(10f, 16.5f), Rot(10f, 5.5f)));
			list.Add(P(c2, Rot(7.2f, 16f), Rot(16.8f, 16f), Rot(16.8f, 18.3f), Rot(7.2f, 18.3f)));
			list.Add(P(c3, Rot(10.5f, 18f), Rot(13.5f, 18f), Rot(13.5f, 23.2f), Rot(10.5f, 23.2f)));
			return list;
		}

		private static List<Prim> Pierce()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Color32 c = Col(138, 122, 99);
			Color32 c2 = Col(185, 195, 201);
			List<Prim> list = new List<Prim>();
			list.Add(P(c, V(11f, 9.5f), V(13f, 9.5f), V(13f, 23f), V(11f, 23f)));
			list.Add(P(c2, V(12f, 1f), V(16f, 10.5f), V(8f, 10.5f)));
			return list;
		}

		private static List<Prim> Chop()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: 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_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: 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_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: 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)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			Color32 c = Col(138, 122, 99);
			Color32 c2 = Col(176, 137, 104);
			List<Prim> list = new List<Prim>();
			list.Add(P(c, V(10.9f, 4f), V(13.1f, 4f), V(13.1f, 23f), V(10.9f, 23f)));
			list.Add(P(c2, V(12f, 3.2f), V(12.52f, 2.93f), V(13.08f, 2.71f), V(13.66f, 2.56f), V(14.27f, 2.46f), V(14.9f, 2.43f), V(15.54f, 2.48f), V(16.18f, 2.59f), V(16.83f, 2.77f), V(17.47f, 3.03f), V(18.1f, 3.37f), V(18.71f, 3.79f), V(19.3f, 4.3f), V(19.74f, 4.76f), V(20.13f, 5.25f), V(20.45f, 5.77f), V(20.7f, 6.3f), V(20.9f, 6.84f), V(21.04f, 7.4f), V(21.11f, 7.97f), V(21.13f, 8.54f), V(21.09f, 9.11f), V(20.98f, 9.68f), V(20.82f, 10.24f), V(20.6f, 10.8f), V(20.01f, 10.54f), V(19.39f, 10.27f), V(18.74f, 9.98f), V(18.06f, 9.68f), V(17.36f, 9.37f), V(16.64f, 9.05f), V(15.9f, 8.72f), V(15.14f, 8.39f), V(14.37f, 8.04f), V(13.59f, 7.7f), V(12.8f, 7.35f), V(12f, 7f)));
			return list;
		}

		private static List<Prim> Pickaxe()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0025: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00f3: 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 refer