Decompiled source of CleanHud v0.1.0

plugins/CleanHud.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("CleanHud")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CleanHud")]
[assembly: AssemblyTitle("CleanHud")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace CleanHud
{
	internal static class CleanHudUi
	{
		private const float BarGap = 9f;

		private const float FoodGap = 10f;

		private const float StatusGapX = 10f;

		private const float StatusGapY = 6f;

		private static RectTransform _container;

		private static RectTransform _vitals;

		private static RectTransform _foodRow;

		private static RectTransform _statusRoot;

		private static Bar _health;

		private static Bar _stamina;

		private static Bar _eitr;

		private const float PowerGap = 18f;

		private static readonly FoodSlot[] Food = new FoodSlot[3];

		private static PowerSlot _power;

		private static readonly List<StatusTile> Tiles = new List<StatusTile>();

		private static readonly List<StatusEffect> Effects = new List<StatusEffect>();

		private static RectTransform _vanillaStatusRoot;

		private static readonly List<CanvasGroup> VanillaVitals = new List<CanvasGroup>();

		private static CanvasGroup _vanillaStatus;

		private static CanvasGroup _vanillaPower;

		private static readonly List<CanvasGroup> CenterStamina = new List<CanvasGroup>();

		private static readonly List<CanvasGroup> CenterEitr = new List<CanvasGroup>();

		private static int _vitalsLayoutKey = -1;

		private static int _statusLayoutKey = -1;

		private static float _vitalsHeight;

		public static bool VanillaVitalsHidden { get; private set; }

		public static void Build(Hud hud)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			Destroy();
			Theme.LoadFonts(hud);
			_container = Theme.Rect("CleanHud", hud.m_rootObject.transform);
			Theme.Stretch(_container);
			((Transform)_container).SetAsLastSibling();
			Waypoints.Build(_container);
			_vitals = Theme.Rect("Vitals", (Transform)(object)_container);
			_foodRow = Theme.Rect("FoodRow", (Transform)(object)_vitals);
			for (int i = 0; i < Food.Length; i++)
			{
				Food[i] = new FoodSlot((Transform)(object)_foodRow, i);
			}
			_power = new PowerSlot((Transform)(object)_foodRow);
			_health = new Bar((Transform)(object)_vitals, "Health", Theme.Health, 16f, lowWarning: true);
			_stamina = new Bar((Transform)(object)_vitals, "Stamina", Theme.Stamina, 11f, lowWarning: false);
			_eitr = new Bar((Transform)(object)_vitals, "Eitr", Theme.Eitr, 11f, lowWarning: false);
			_vanillaStatusRoot = hud.m_statusEffectListRoot;
			_statusRoot = Theme.Rect("StatusEffects", (Transform)(object)_container);
			CollectVanillaVitals(hud);
			_vanillaStatus = (((Object)(object)hud.m_statusEffectListRoot != (Object)null) ? GetGroup(((Component)hud.m_statusEffectListRoot).gameObject) : null);
			_vanillaPower = (((Object)(object)hud.m_gpRoot != (Object)null) ? GetGroup(((Component)hud.m_gpRoot).gameObject) : null);
			CollectChildren(hud.m_staminaBar2Root, CenterStamina);
			CollectChildren(hud.m_eitrBarRoot, CenterEitr);
			if ((Object)(object)hud.m_healthPanel != (Object)null)
			{
				Restyle.Dump("vanilla health panel", (Transform)(object)hud.m_healthPanel, 3);
			}
			ManualLogSource log = Plugin.Log;
			string name = ((Object)hud.m_rootObject).name;
			Rect rect = _container.rect;
			log.LogInfo((object)$"Clean HUD built under '{name}' (rect: {((Rect)(ref rect)).size}).");
		}

		public static void Destroy()
		{
			SetVanillaVisible(VanillaVitals, visible: true);
			if ((Object)(object)_vanillaStatus != (Object)null)
			{
				SetVanillaVisible(_vanillaStatus, visible: true);
			}
			if ((Object)(object)_vanillaPower != (Object)null)
			{
				SetVanillaVisible(_vanillaPower, visible: true);
			}
			SetVanillaVisible(CenterStamina, visible: true);
			SetVanillaVisible(CenterEitr, visible: true);
			CenterStamina.Clear();
			CenterEitr.Clear();
			VanillaVitals.Clear();
			_vanillaStatus = null;
			_vanillaPower = null;
			VanillaVitalsHidden = false;
			Waypoints.Destroy();
			if ((Object)(object)_statusRoot != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_statusRoot).gameObject);
			}
			if ((Object)(object)_container != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_container).gameObject);
			}
			_statusRoot = null;
			_container = null;
			Tiles.Clear();
			_vitalsLayoutKey = -1;
			_statusLayoutKey = -1;
		}

		public static void Refresh(float dt)
		{
			if ((Object)(object)_container == (Object)null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			bool flag = ModConfig.Enabled.Value && (Object)(object)localPlayer != (Object)null;
			bool flag2 = flag && ModConfig.ShowVitals.Value;
			bool flag3 = flag && ModConfig.ShowStatusBar.Value;
			VanillaVitalsHidden = flag2 && ModConfig.HideVanillaVitals.Value;
			SetVanillaVisible(VanillaVitals, !VanillaVitalsHidden);
			if ((Object)(object)_vanillaStatus != (Object)null)
			{
				SetVanillaVisible(_vanillaStatus, !flag3 || !ModConfig.HideVanillaStatus.Value);
			}
			if ((Object)(object)_vanillaPower != (Object)null)
			{
				SetVanillaVisible(_vanillaPower, !VanillaVitalsHidden || !ModConfig.ShowForsakenPower.Value);
			}
			SetVanillaVisible(CenterStamina, !flag || !ModConfig.HideCenterStamina.Value);
			SetVanillaVisible(CenterEitr, !flag || !ModConfig.HideCenterEitr.Value);
			SetActive((Component)(object)_container, flag);
			SetActive((Component)(object)_statusRoot, flag3);
			if (flag)
			{
				SetActive((Component)(object)_vitals, flag2);
				if (flag2)
				{
					RefreshVitals(localPlayer, dt);
				}
				if (flag3)
				{
					RefreshStatus(localPlayer);
				}
				Waypoints.Refresh(localPlayer);
			}
		}

		private static void RefreshVitals(Player player, float dt)
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			float maxEitr = ((Character)player).GetMaxEitr();
			bool flag = maxEitr > 0f;
			bool value = ModConfig.ShowFood.Value;
			bool value2 = ModConfig.ShowFoodStats.Value;
			float value3 = ModConfig.VitalsWidth.Value;
			StatusEffect val = null;
			float cooldown = 0f;
			if (ModConfig.ShowForsakenPower.Value)
			{
				player.GetGuardianPowerHUD(ref val, ref cooldown);
			}
			bool flag2 = (Object)(object)val != (Object)null;
			int num = (flag ? 1 : 0) | (value ? 2 : 0) | (value2 ? 4 : 0) | (flag2 ? 8 : 0) | (Mathf.RoundToInt(value3) << 4);
			if (num != _vitalsLayoutKey)
			{
				_vitalsLayoutKey = num;
				LayoutVitals(value3, flag, value, value2, flag2);
			}
			if (flag2)
			{
				_power.Set(val, cooldown);
			}
			float value4 = ModConfig.Scale.Value;
			((Transform)_vitals).localScale = new Vector3(value4, value4, 1f);
			_vitals.anchoredPosition = ModConfig.VitalsOffset.Value;
			_health.Set(((Character)player).GetHealth(), ((Character)player).GetMaxHealth(), dt);
			_stamina.Set(player.GetStamina(), ((Character)player).GetMaxStamina(), dt);
			if (flag)
			{
				_eitr.Set(player.GetEitr(), maxEitr, dt);
			}
			if (value)
			{
				List<Food> foods = player.GetFoods();
				for (int i = 0; i < Food.Length; i++)
				{
					Food[i].Set((i < foods.Count) ? foods[i] : null);
				}
			}
		}

		private static void LayoutVitals(float width, bool eitr, bool food, bool stats, bool power)
		{
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_009c: 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_00be: 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_0121: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			float y = 0f;
			bool flag = food || power;
			SetActive((Component)(object)_foodRow, flag);
			if (flag)
			{
				float num = 17f + (stats ? 13f : 0f) + 4f;
				Row(_foodRow, 44f, num + 6f);
				for (int i = 0; i < Food.Length; i++)
				{
					SetActive((Component)(object)Food[i].Root, food);
					Theme.Place(Food[i].Root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2((float)i * 54f, 0f), new Vector2(44f, 44f));
				}
				float num2 = (food ? ((float)Food.Length * 54f - 10f + 18f) : 0f);
				Theme.Place(_power.Root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num2, 0f), new Vector2(44f, 44f));
			}
			SetActive((Component)(object)_power.Root, power);
			Row(_health.Root, _health.Height, 9f);
			Row(_stamina.Root, _stamina.Height, 9f);
			SetActive((Component)(object)_eitr.Root, eitr);
			if (eitr)
			{
				Row(_eitr.Root, _eitr.Height, 9f);
			}
			_vitalsHeight = 0f - y - 9f;
			Theme.Place(_vitals, Vector2.zero, Vector2.zero, ModConfig.VitalsOffset.Value, new Vector2(width + 140f, _vitalsHeight));
			_statusLayoutKey = -1;
			void Row(RectTransform rt, float h, float gapAfter)
			{
				//IL_000b: 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_002a: 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)
				Theme.Place(rt, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, y), new Vector2(width, h));
				y -= h + gapAfter;
			}
		}

		private static void RefreshStatus(Player player)
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			Effects.Clear();
			((Character)player).GetSEMan().GetHUDStatusEffects(Effects);
			while (Tiles.Count < Effects.Count)
			{
				Tiles.Add(new StatusTile((Transform)(object)_statusRoot));
			}
			for (int i = 0; i < Tiles.Count; i++)
			{
				bool flag = i < Effects.Count;
				SetActive((Component)(object)Tiles[i].Root, flag);
				if (flag)
				{
					Tiles[i].Set(Effects[i]);
				}
			}
			StatusPlacement value = ModConfig.StatusPosition.Value;
			int num = Mathf.Max(1, ModConfig.StatusPerRow.Value);
			bool value2 = ModConfig.StatusShowNames.Value;
			int num2 = Effects.Count | (num << 8) | ((int)value << 16) | ((value2 ? 1 : 0) << 20) | ((ModConfig.ShowVitals.Value ? 1 : 0) << 21);
			if (num2 != _statusLayoutKey)
			{
				_statusLayoutKey = num2;
				LayoutStatus(value, num, value2);
			}
			float value3 = ModConfig.Scale.Value;
			((Transform)_statusRoot).localScale = new Vector3(value3, value3, 1f);
			if (value == StatusPlacement.AboveVitals)
			{
				_statusRoot.anchoredPosition = AboveVitalsPosition();
			}
		}

		private static void LayoutStatus(StatusPlacement placement, int perRow, bool names)
		{
			//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_0099: 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_00e6: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			float num = 50f;
			float num2 = 17f + (names ? 13f : 0f);
			float num3 = 40f + num2 + 6f;
			int count = Effects.Count;
			Vector2 pivot = default(Vector2);
			switch (placement)
			{
			case StatusPlacement.TopCenter:
				((Vector2)(ref pivot))..ctor(0.5f, 1f);
				if ((Object)(object)((Transform)_statusRoot).parent != (Object)(object)_container)
				{
					((Transform)_statusRoot).SetParent((Transform)(object)_container, false);
				}
				Theme.Place(_statusRoot, new Vector2(0.5f, 1f), pivot, new Vector2(0f, -24f), Vector2.zero);
				break;
			case StatusPlacement.AboveVitals:
				((Vector2)(ref pivot))..ctor(0f, 0f);
				if ((Object)(object)((Transform)_statusRoot).parent != (Object)(object)_container)
				{
					((Transform)_statusRoot).SetParent((Transform)(object)_container, false);
				}
				Theme.Place(_statusRoot, Vector2.zero, pivot, AboveVitalsPosition(), Vector2.zero);
				break;
			default:
				((Vector2)(ref pivot))..ctor(1f, 1f);
				PlaceAtVanillaStatus();
				break;
			}
			int num4 = Mathf.Max(1, (count + perRow - 1) / perRow);
			Vector2 pos = default(Vector2);
			for (int i = 0; i < count; i++)
			{
				int num5 = i / perRow;
				int num6 = i % perRow;
				switch (placement)
				{
				case StatusPlacement.TopCenter:
				{
					float num7 = (float)Mathf.Min(perRow, count - num5 * perRow) * num - 10f;
					((Vector2)(ref pos))..ctor((0f - num7) * 0.5f + (float)num6 * num + 20f, (float)(-num5) * num3);
					break;
				}
				case StatusPlacement.AboveVitals:
					((Vector2)(ref pos))..ctor((float)num6 * num, (float)(num4 - 1 - num5) * num3 + num2);
					break;
				default:
					((Vector2)(ref pos))..ctor((float)(-num6) * num, (float)(-num5) * num3);
					break;
				}
				Theme.Place(Tiles[i].Root, Vector2.zero, pivot, pos, new Vector2(40f, 40f));
			}
		}

		private static Vector2 AboveVitalsPosition()
		{
			//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_0019: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Vector2 value = ModConfig.VitalsOffset.Value;
			if (!ModConfig.ShowVitals.Value)
			{
				return value;
			}
			return value + new Vector2(0f, (_vitalsHeight + 14f) * ModConfig.Scale.Value);
		}

		private static void PlaceAtVanillaStatus()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00d7: 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_003f: 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_0053: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			RectTransform vanillaStatusRoot = _vanillaStatusRoot;
			if ((Object)(object)vanillaStatusRoot == (Object)null)
			{
				if ((Object)(object)((Transform)_statusRoot).parent != (Object)(object)_container)
				{
					((Transform)_statusRoot).SetParent((Transform)(object)_container, false);
				}
				Theme.Place(_statusRoot, Vector2.one, Vector2.one, new Vector2(-24f, -260f), Vector2.zero);
				return;
			}
			if ((Object)(object)((Transform)_statusRoot).parent != (Object)(object)((Transform)vanillaStatusRoot).parent)
			{
				((Transform)_statusRoot).SetParent(((Transform)vanillaStatusRoot).parent, false);
			}
			((Transform)_statusRoot).SetSiblingIndex(((Transform)vanillaStatusRoot).GetSiblingIndex() + 1);
			_statusRoot.anchorMin = vanillaStatusRoot.anchorMin;
			_statusRoot.anchorMax = vanillaStatusRoot.anchorMax;
			_statusRoot.pivot = new Vector2(1f, 1f);
			_statusRoot.anchoredPosition = vanillaStatusRoot.anchoredPosition + new Vector2(-4f, (ModConfig.ShowClock.Value && ModConfig.RestyleMinimap.Value) ? (-18f) : 0f);
			_statusRoot.sizeDelta = Vector2.zero;
		}

		private static void CollectVanillaVitals(Hud hud)
		{
			Add((Component)(object)hud.m_healthPanel);
			Add((Component)(object)hud.m_foodBarRoot);
			Add((Component)(object)hud.m_foodBaseBar);
			Add((Component)(object)hud.m_foodIcon);
			Add((Component)(object)hud.m_foodText);
			if (hud.m_foodBars != null)
			{
				Image[] foodBars = hud.m_foodBars;
				for (int i = 0; i < foodBars.Length; i++)
				{
					Add((Component)(object)foodBars[i]);
				}
			}
			if (hud.m_foodIcons != null)
			{
				Image[] foodBars = hud.m_foodIcons;
				for (int i = 0; i < foodBars.Length; i++)
				{
					Add((Component)(object)foodBars[i]);
				}
			}
			if (hud.m_foodTime != null)
			{
				TMP_Text[] foodTime = hud.m_foodTime;
				for (int i = 0; i < foodTime.Length; i++)
				{
					Add((Component)(object)foodTime[i]);
				}
			}
			static void Add(Component c)
			{
				if ((Object)(object)c != (Object)null)
				{
					VanillaVitals.Add(GetGroup(c.gameObject));
				}
			}
		}

		private static void CollectChildren(RectTransform root, List<CanvasGroup> into)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			foreach (Transform item in (Transform)root)
			{
				Transform val = item;
				into.Add(GetGroup(((Component)val).gameObject));
			}
		}

		private static CanvasGroup GetGroup(GameObject go)
		{
			CanvasGroup component = go.GetComponent<CanvasGroup>();
			if (!((Object)(object)component != (Object)null))
			{
				return go.AddComponent<CanvasGroup>();
			}
			return component;
		}

		private static void SetVanillaVisible(List<CanvasGroup> groups, bool visible)
		{
			foreach (CanvasGroup group in groups)
			{
				SetVanillaVisible(group, visible);
			}
		}

		private static void SetVanillaVisible(CanvasGroup g, bool visible)
		{
			if (!((Object)(object)g == (Object)null))
			{
				float num = (visible ? 1f : 0f);
				if (g.alpha != num)
				{
					g.alpha = num;
					g.blocksRaycasts = visible;
				}
			}
		}

		private static void SetActive(Component c, bool active)
		{
			if (c.gameObject.activeSelf != active)
			{
				c.gameObject.SetActive(active);
			}
		}
	}
	internal static class HotbarStyle
	{
		private static readonly HashSet<string> Known = new HashSet<string> { "binding", "icon", "durability", "amount", "equiped", "queued", "selected" };

		private static readonly Dictionary<GameObject, Restyle> Styled = new Dictionary<GameObject, Restyle>();

		private static readonly List<GameObject> Dead = new List<GameObject>();

		private static bool _dumped;

		public static void Update(HotkeyBar bar)
		{
			if (!ModConfig.Enabled.Value || !ModConfig.RestyleHotbar.Value)
			{
				if (Styled.Count > 0)
				{
					UndoAll();
				}
				return;
			}
			foreach (ElementData element in bar.m_elements)
			{
				if (!((Object)(object)element.m_go == (Object)null) && !Styled.ContainsKey(element.m_go))
				{
					if (!_dumped)
					{
						_dumped = true;
						Restyle.Dump("hotbar slot", element.m_go.transform);
					}
					Styled[element.m_go] = Style(element.m_go);
				}
			}
			if (Styled.Count <= bar.m_elements.Count)
			{
				return;
			}
			Dead.Clear();
			foreach (GameObject key in Styled.Keys)
			{
				if ((Object)(object)key == (Object)null)
				{
					Dead.Add(key);
				}
			}
			foreach (GameObject item in Dead)
			{
				Styled.Remove(item);
			}
		}

		public static void UndoAll()
		{
			foreach (KeyValuePair<GameObject, Restyle> item in Styled)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Value.Undo();
				}
			}
			Styled.Clear();
		}

		private static Restyle Style(GameObject go)
		{
			//IL_0024: 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_0069: Expected O, but got Unknown
			//IL_00fd: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			Restyle restyle = new Restyle();
			Transform transform = go.transform;
			Image component = go.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				restyle.Image(component, Theme.WoodSprite, Theme.Wood, (Type)1);
			}
			else
			{
				((Component)restyle.Track<Image>(Theme.WoodPanel("CleanWood", transform))).transform.SetAsFirstSibling();
			}
			foreach (Transform item in transform)
			{
				Transform val = item;
				if (!Known.Contains(((Object)val).name))
				{
					Image component2 = ((Component)val).GetComponent<Image>();
					if ((Object)(object)component2 != (Object)null)
					{
						restyle.Hide((Behaviour)(object)component2);
					}
				}
			}
			((Component)restyle.Track<Image>(Theme.RimOverlay(transform, 0.8f))).transform.SetSiblingIndex(1);
			StyleImages(restyle, transform.Find("equiped"), Theme.Rounded, new Color(1f, 0.76f, 0.32f, 0.32f), 1.6f);
			StyleImages(restyle, transform.Find("queued"), Theme.Rounded, new Color(0.82f, 0.64f, 0.36f, 0.2f), 1.6f);
			StyleImages(restyle, transform.Find("selected"), Theme.Rounded, new Color(1f, 0.95f, 0.8f, 0.3f), 1.6f);
			Transform val2 = transform.Find("durability");
			if ((Object)(object)val2 != (Object)null)
			{
				GuiBar gui = ((Component)val2).GetComponent<GuiBar>();
				Image val3 = (((Object)(object)gui != (Object)null && (Object)(object)gui.m_bar != (Object)null) ? ((Component)gui.m_bar).GetComponent<Image>() : null);
				Image[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Image>(true);
				foreach (Image val4 in componentsInChildren)
				{
					if ((Object)(object)val4 != (Object)(object)val3)
					{
						restyle.Image(val4, null, Theme.Track, (Type)0);
					}
				}
				if ((Object)(object)val3 != (Object)null)
				{
					restyle.Image(val3, Theme.Gradient, Theme.Durability, (Type)0);
					Color original = gui.m_originalColor;
					restyle.Do(delegate
					{
						//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)
						gui.m_originalColor = Theme.Durability;
					}, delegate
					{
						//IL_001f: 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)
						if ((Object)(object)gui != (Object)null)
						{
							gui.m_originalColor = original;
						}
					});
				}
			}
			Transform obj = transform.Find("binding");
			restyle.Text((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null, title: true, 0f, Theme.Bronze);
			Transform obj2 = transform.Find("amount");
			restyle.Text((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null, title: false, 0f, Theme.Text);
			return restyle;
		}

		private static void StyleImages(Restyle r, Transform t, Sprite sprite, Color color, float ppu)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)t == (Object)null))
			{
				Image[] componentsInChildren = ((Component)t).GetComponentsInChildren<Image>(true);
				foreach (Image img in componentsInChildren)
				{
					r.Image(img, sprite, color, (Type)1, ppu);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Hud))]
	internal static class HudPatches
	{
		private static bool _refreshErrorLogged;

		private static bool _hotbarErrorLogged;

		private static bool _minimapErrorLogged;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(Hud __instance)
		{
			try
			{
				CleanHudUi.Build(__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Could not build the clean HUD, vanilla HUD stays as is: " + ex));
				CleanHudUi.Destroy();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void UpdatePostfix()
		{
			try
			{
				CleanHudUi.Refresh(Time.deltaTime);
			}
			catch (Exception ex)
			{
				if (!_refreshErrorLogged)
				{
					_refreshErrorLogged = true;
					Plugin.Log.LogError((object)("Clean HUD refresh failed, switching back to vanilla: " + ex));
					CleanHudUi.Destroy();
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateStamina")]
		private static void StaminaPostfix(Hud __instance, Player player)
		{
			if (PercentOn() && !((Object)(object)__instance.m_staminaText == (Object)null))
			{
				__instance.m_staminaText.text = WithPercent(player.GetStamina(), ((Character)player).GetMaxStamina(), " ");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateEitr")]
		private static void EitrPostfix(Hud __instance, Player player)
		{
			if (PercentOn() && !((Object)(object)__instance.m_eitrText == (Object)null) && !(((Character)player).GetMaxEitr() <= 0f))
			{
				__instance.m_eitrText.text = WithPercent(player.GetEitr(), ((Character)player).GetMaxEitr(), " ");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateHealth")]
		private static void HealthPostfix(Hud __instance, Player player)
		{
			if (PercentOn() && !CleanHudUi.VanillaVitalsHidden && !((Object)(object)__instance.m_healthText == (Object)null))
			{
				__instance.m_healthText.text = WithPercent(((Character)player).GetHealth(), ((Character)player).GetMaxHealth(), "\n");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
		private static void HotbarPostfix(HotkeyBar __instance)
		{
			try
			{
				HotbarStyle.Update(__instance);
			}
			catch (Exception ex)
			{
				if (!_hotbarErrorLogged)
				{
					_hotbarErrorLogged = true;
					Plugin.Log.LogError((object)("Hotbar restyle failed, leaving it vanilla: " + ex));
					HotbarStyle.UndoAll();
					ModConfig.RestyleHotbar.Value = false;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Minimap), "Update")]
		private static void MinimapPostfix(Minimap __instance)
		{
			try
			{
				Waypoints.HandleMapInput(__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Persistent pin toggle failed: " + ex));
			}
			try
			{
				MinimapStyle.Update(__instance);
			}
			catch (Exception ex2)
			{
				if (!_minimapErrorLogged)
				{
					_minimapErrorLogged = true;
					Plugin.Log.LogError((object)("Minimap restyle failed, leaving it vanilla: " + ex2));
					MinimapStyle.Undo();
					ModConfig.RestyleMinimap.Value = false;
				}
			}
		}

		private static bool PercentOn()
		{
			if (ModConfig.Enabled.Value)
			{
				return ModConfig.PercentOnVanillaBars.Value;
			}
			return false;
		}

		private static string WithPercent(float cur, float max, string separator)
		{
			return Mathf.CeilToInt(cur) + separator + "<size=65%><alpha=#B0>" + Bar.Percent(cur, max) + "%";
		}
	}
	internal static class MinimapStyle
	{
		private static Restyle _style;

		private static Minimap _styledFor;

		private static TMP_Text _clock;

		private static RectTransform _plaque;

		private static int _lastMinute = -1;

		private static bool _dumped;

		public static void Update(Minimap map)
		{
			int num;
			if (ModConfig.Enabled.Value && ModConfig.RestyleMinimap.Value)
			{
				num = (((Object)(object)map.m_mapImageSmall != (Object)null) ? 1 : 0);
				if (num != 0 && !((Object)(object)_styledFor != (Object)(object)map))
				{
					goto IL_003c;
				}
			}
			else
			{
				num = 0;
			}
			Undo();
			goto IL_003c;
			IL_003c:
			if (num == 0)
			{
				return;
			}
			if (_style == null)
			{
				if (!_dumped)
				{
					_dumped = true;
					Restyle.Dump("small minimap", ((Object)(object)map.m_smallRoot != (Object)null) ? map.m_smallRoot.transform : null, 5);
				}
				_style = Apply(map);
				_styledFor = map;
			}
			UpdateClock();
		}

		public static void Undo()
		{
			_style?.Undo();
			_style = null;
			_styledFor = null;
			_clock = null;
			_plaque = null;
			_lastMinute = -1;
		}

		private static Restyle Apply(Minimap map)
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: 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)
			Restyle restyle = new Restyle();
			RectTransform rectTransform = ((Graphic)map.m_mapImageSmall).rectTransform;
			Transform parent = ((Transform)rectTransform).parent;
			List<Transform> list = new List<Transform>
			{
				(Transform)(object)rectTransform,
				(Transform)(object)map.m_pinRootSmall,
				(Transform)(object)map.m_pinNameRootSmall,
				(Transform)(object)map.m_smallMarker,
				(Transform)(object)map.m_smallShipMarker,
				(Transform)(object)map.m_windMarker
			};
			if ((Object)(object)map.m_biomeNameSmall != (Object)null)
			{
				list.Add(map.m_biomeNameSmall.transform);
			}
			Image[] componentsInChildren = map.m_smallRoot.GetComponentsInChildren<Image>(true);
			foreach (Image val in componentsInChildren)
			{
				if (!IsUnderAny(((Component)val).transform, list) && !((Object)(object)((Component)val).GetComponent<Mask>() != (Object)null))
				{
					restyle.Hide((Behaviour)(object)val);
				}
			}
			int siblingIndex = ((Transform)rectTransform).GetSiblingIndex();
			Image obj = restyle.Track<Image>(Theme.Image("CleanMapWood", parent, Theme.WoodSprite, Theme.Wood, (Type)1));
			Theme.Match(((Graphic)obj).rectTransform, rectTransform, 7f);
			((Component)obj).transform.SetSiblingIndex(siblingIndex);
			Image val2 = restyle.Track<Image>(Theme.Image("CleanMapRim", parent, Theme.Rim, Color.white, (Type)1, 0.8f));
			Theme.Match(((Graphic)val2).rectTransform, rectTransform, 7f);
			((Component)val2).transform.SetSiblingIndex(((Transform)rectTransform).GetSiblingIndex() + 1);
			if ((Object)(object)map.m_biomeNameSmall != (Object)null)
			{
				restyle.Text(map.m_biomeNameSmall, title: true, 0f, Theme.Text);
			}
			if (ModConfig.ShowClock.Value)
			{
				RectTransform val3 = restyle.Track<RectTransform>(Theme.Rect("CleanMapOverlay", parent));
				Theme.Match(val3, rectTransform, 7f);
				((Transform)val3).SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
				_plaque = Theme.Rect("Plaque", (Transform)(object)val3);
				Theme.Place(_plaque, new Vector2(0.5f, 0f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(150f, 24f));
				Theme.WoodPanel("Wood", (Transform)(object)_plaque);
				Theme.RimOverlay((Transform)(object)_plaque, 0.6f);
				_clock = Theme.Label("Clock", (Transform)(object)_plaque, 15f, (TextAlignmentOptions)514, Theme.Text, title: true);
				Theme.Stretch(_clock.rectTransform, 6f, 6f, 0f, 1f);
			}
			return restyle;
		}

		private static void UpdateClock()
		{
			if ((Object)(object)_clock == (Object)null)
			{
				return;
			}
			EnvMan instance = EnvMan.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				int num = Mathf.FloorToInt(instance.GetDayFraction() * 24f * 60f) % 1440;
				if (num != _lastMinute)
				{
					_lastMinute = num;
					_clock.text = "Day " + instance.GetDay() + "  <color=#c9a46a>·</color>  " + (num / 60).ToString("00") + ":" + (num % 60).ToString("00");
				}
			}
		}

		private static bool IsUnderAny(Transform t, List<Transform> roots)
		{
			foreach (Transform root in roots)
			{
				if ((Object)(object)root != (Object)null && ((Object)(object)t == (Object)(object)root || t.IsChildOf(root)))
				{
					return true;
				}
			}
			return false;
		}
	}
	internal enum VitalsText
	{
		ValueAndPercent,
		Percent,
		Value
	}
	internal enum StatusPlacement
	{
		TopRight,
		TopCenter,
		AboveVitals
	}
	internal static class ModConfig
	{
		private sealed class PinTypeList
		{
			private string _parsed;

			private readonly HashSet<PinType> _types = new HashSet<PinType>();

			public bool Contains(string raw, PinType type)
			{
				//IL_0076: 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)
				if (raw != _parsed)
				{
					_parsed = raw;
					_types.Clear();
					string[] array = raw.Split(new char[1] { ',' });
					foreach (string text in array)
					{
						try
						{
							_types.Add((PinType)Enum.Parse(typeof(PinType), text.Trim(), ignoreCase: true));
						}
						catch (ArgumentException)
						{
						}
					}
				}
				return _types.Contains(type);
			}
		}

		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<KeyCode> ToggleKey;

		public static ConfigEntry<float> Scale;

		public static ConfigEntry<bool> DumpUiHierarchy;

		public static ConfigEntry<bool> ShowVitals;

		public static ConfigEntry<bool> HideVanillaVitals;

		public static ConfigEntry<VitalsText> TextMode;

		public static ConfigEntry<Vector2> VitalsOffset;

		public static ConfigEntry<float> VitalsWidth;

		public static ConfigEntry<bool> ShowFood;

		public static ConfigEntry<bool> ShowFoodStats;

		public static ConfigEntry<float> FoodWarnSeconds;

		public static ConfigEntry<bool> ShowForsakenPower;

		public static ConfigEntry<bool> ShowStatusBar;

		public static ConfigEntry<bool> HideVanillaStatus;

		public static ConfigEntry<StatusPlacement> StatusPosition;

		public static ConfigEntry<int> StatusPerRow;

		public static ConfigEntry<bool> StatusShowNames;

		public static ConfigEntry<bool> PercentOnVanillaBars;

		public static ConfigEntry<bool> HideCenterStamina;

		public static ConfigEntry<bool> HideCenterEitr;

		public static ConfigEntry<bool> RestyleHotbar;

		public static ConfigEntry<bool> RestyleMinimap;

		public static ConfigEntry<bool> ShowClock;

		public static ConfigEntry<bool> ShowWaypoints;

		public static ConfigEntry<string> FarPinTypes;

		public static ConfigEntry<string> SightPinTypes;

		public static ConfigEntry<float> SightMaxDistance;

		public static ConfigEntry<float> ReachedDistance;

		public static ConfigEntry<bool> RememberReached;

		public static ConfigEntry<int> WaypointMaxShown;

		public static ConfigEntry<bool> RemoveReachedPins;

		public static ConfigEntry<string> PersistentPrefix;

		public static ConfigEntry<KeyCode> PersistentToggleKey;

		public static ConfigEntry<float> PersistentHideRadius;

		public static ConfigEntry<bool> WaypointNames;

		public static ConfigEntry<bool> WaypointDistance;

		public static ConfigEntry<bool> WaypointHideChecked;

		public static ConfigEntry<bool> WaypointEdge;

		public static ConfigEntry<float> WaypointAimedAlpha;

		public static ConfigEntry<float> WaypointOpacity;

		private static readonly PinTypeList FarTypes = new PinTypeList();

		private static readonly PinTypeList SightTypes = new PinTypeList();

		public static void Bind(ConfigFile cfg)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Expected O, but got Unknown
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Expected O, but got Unknown
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Expected O, but got Unknown
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Expected O, but got Unknown
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Expected O, but got Unknown
			Enabled = cfg.Bind<bool>("1 - General", "Enabled", true, "Use the clean HUD. Off = plain vanilla HUD.");
			ToggleKey = cfg.Bind<KeyCode>("1 - General", "ToggleKey", (KeyCode)289, "Switch between the clean HUD and vanilla in-game.");
			Scale = cfg.Bind<float>("1 - General", "Scale", 1f, new ConfigDescription("Size of every clean HUD element.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			DumpUiHierarchy = cfg.Bind<bool>("1 - General", "DumpUiHierarchy", true, "Write the vanilla hotbar / minimap / health panel layout to LogOutput.log once per session (helps tune the restyle).");
			ShowVitals = cfg.Bind<bool>("2 - Vitals", "Show", true, "Show the health / stamina / eitr bars.");
			HideVanillaVitals = cfg.Bind<bool>("2 - Vitals", "HideVanilla", true, "Hide the vanilla health circle and food bars while the clean bars are shown. The stamina bar near the crosshair stays.");
			TextMode = cfg.Bind<VitalsText>("2 - Vitals", "TextMode", VitalsText.ValueAndPercent, "What to print next to each bar.");
			VitalsOffset = cfg.Bind<Vector2>("2 - Vitals", "Offset", new Vector2(32f, 32f), "Distance from the bottom-left corner, in HUD pixels.");
			VitalsWidth = cfg.Bind<float>("2 - Vitals", "Width", 240f, new ConfigDescription("Length of the bars (the numbers sit to the right of them).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(140f, 480f), Array.Empty<object>()));
			ShowFood = cfg.Bind<bool>("3 - Food", "Show", true, "Show food tiles with countdown timers above the bars.");
			ShowFoodStats = cfg.Bind<bool>("3 - Food", "ShowStats", false, "Show the health / stamina / eitr each food gives under its timer.");
			FoodWarnSeconds = cfg.Bind<float>("3 - Food", "WarnSeconds", 60f, new ConfigDescription("Timer turns red below this many seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>()));
			ShowForsakenPower = cfg.Bind<bool>("3 - Food", "ShowForsakenPower", true, "Show your forsaken power as a tile after the food (cooldown or Ready). The vanilla power panel is hidden while the clean vitals are on.");
			ShowStatusBar = cfg.Bind<bool>("4 - Status Effects", "Show", true, "Show the clean status effect bar.");
			HideVanillaStatus = cfg.Bind<bool>("4 - Status Effects", "HideVanilla", true, "Hide the vanilla status effect icons while the clean bar is shown.");
			StatusPosition = cfg.Bind<StatusPlacement>("4 - Status Effects", "Placement", StatusPlacement.TopRight, "Where the status effect bar goes.");
			StatusPerRow = cfg.Bind<int>("4 - Status Effects", "PerRow", 8, new ConfigDescription("Icons per row before wrapping.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
			StatusShowNames = cfg.Bind<bool>("4 - Status Effects", "ShowNames", false, "Print each effect's name under its timer.");
			PercentOnVanillaBars = cfg.Bind<bool>("5 - Vanilla", "PercentOnBars", true, "Add a percentage to the vanilla stamina and eitr bars (and the health circle when it is visible).");
			HideCenterStamina = cfg.Bind<bool>("5 - Vanilla", "HideCenterStamina", true, "Hide the small stamina bar that pops up in the middle of the screen while running or attacking (the clean bar shows stamina).");
			HideCenterEitr = cfg.Bind<bool>("5 - Vanilla", "HideCenterEitr", false, "Hide the small eitr bar that pops up in the middle of the screen while casting.");
			RestyleHotbar = cfg.Bind<bool>("6 - Hotbar", "Restyle", true, "Give the hotbar slots the clean look.");
			RestyleMinimap = cfg.Bind<bool>("7 - Minimap", "Restyle", true, "Replace the minimap's frame with the clean look.");
			ShowClock = cfg.Bind<bool>("7 - Minimap", "ShowClock", true, "Show the day number and time of day on the minimap.");
			ShowWaypoints = cfg.Bind<bool>("8 - Waypoints", "Show", true, "Show map pins as markers in the world.");
			FarPinTypes = cfg.Bind<string>("8 - Waypoints", "FarPinTypes", "Icon0,Icon1,Icon2,Icon3,Icon4,Death", "Pin types shown at any distance. Icon0-Icon4 are the pins you place. Each one disappears once you reach it or remove the pin.");
			SightPinTypes = cfg.Bind<string>("8 - Waypoints", "LineOfSightPinTypes", "Boss,Hildir1,Hildir2,Hildir3", "Pin types shown only while you have a clear line of sight to them (bosses, Hildir's chests).");
			SightMaxDistance = cfg.Bind<float>("8 - Waypoints", "LineOfSightMaxDistance", 200f, new ConfigDescription("Line-of-sight pins farther than this are hidden (meters). Terrain beyond ~200 m isn't loaded, so sight can't be checked there.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 500f), Array.Empty<object>()));
			ReachedDistance = cfg.Bind<float>("8 - Waypoints", "ReachedDistance", 10f, new ConfigDescription("Walking this close to a normal pin counts as reaching it (meters).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f), Array.Empty<object>()));
			RemoveReachedPins = cfg.Bind<bool>("8 - Waypoints", "RemoveReachedPins", true, "Delete a normal (non-persistent) pin from the map when you reach it. Off = only its marker goes away.");
			PersistentPrefix = cfg.Bind<string>("8 - Waypoints", "PersistentPrefix", "*", "Pins whose name starts with this are persistent: never removed, their marker only hides while you stand on them.");
			PersistentToggleKey = cfg.Bind<KeyCode>("8 - Waypoints", "PersistentToggleKey", (KeyCode)112, "On the big map, hover a pin and press this to make it persistent (or normal again).");
			PersistentHideRadius = cfg.Bind<float>("8 - Waypoints", "PersistentHideRadius", 3f, new ConfigDescription("A persistent pin's marker hides while you're this close, and comes back when you walk away (meters).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			RememberReached = cfg.Bind<bool>("8 - Waypoints", "RememberReached", true, "Remember reached pins between sessions (per world), so their markers stay gone.");
			WaypointMaxShown = cfg.Bind<int>("8 - Waypoints", "MaxShown", 5, new ConfigDescription("At most this many markers on screen at once; the nearest ones win. Death markers don't count toward this and always show. Permanent pins (bed, players, events) never show.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), Array.Empty<object>()));
			WaypointNames = cfg.Bind<bool>("8 - Waypoints", "ShowNames", true, "Show the pin's name.");
			WaypointDistance = cfg.Bind<bool>("8 - Waypoints", "ShowDistance", true, "Show how far away the pin is.");
			WaypointHideChecked = cfg.Bind<bool>("8 - Waypoints", "HideChecked", true, "Don't show pins you crossed out on the map.");
			WaypointEdge = cfg.Bind<bool>("8 - Waypoints", "EdgeIndicators", true, "Keep off-screen pins pinned to the screen edge so you know which way to turn.");
			WaypointAimedAlpha = cfg.Bind<float>("8 - Waypoints", "AimedOpacity", 0.08f, new ConfigDescription("Opacity of a marker when you look straight at it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			WaypointOpacity = cfg.Bind<float>("8 - Waypoints", "Opacity", 0.9f, new ConfigDescription("Opacity of markers you are not looking at.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
		}

		public static bool IsFarPin(PinType type)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return FarTypes.Contains(FarPinTypes.Value, type);
		}

		public static bool IsSightPin(PinType type)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return SightTypes.Contains(SightPinTypes.Value, type);
		}
	}
	[BepInPlugin("com.cleanhud.valheim", "Clean HUD", "0.1.0")]
	[BepInProcess("valheim.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "com.cleanhud.valheim";

		public const string ModName = "Clean HUD";

		public const string ModVersion = "0.1.0";

		internal static ManualLogSource Log;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ModConfig.Bind(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("com.cleanhud.valheim");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			Log.LogInfo((object)"Clean HUD 0.1.0 loaded (client-side only).");
		}

		private void Update()
		{
			//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_000b: 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)
			KeyCode value = ModConfig.ToggleKey.Value;
			if ((int)value != 0 && ZInput.GetKeyDown(value, false) && !UiBlocksInput())
			{
				ModConfig.Enabled.Value = !ModConfig.Enabled.Value;
			}
		}

		private void OnDestroy()
		{
			CleanHudUi.Destroy();
			HotbarStyle.UndoAll();
			MinimapStyle.Undo();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static bool UiBlocksInput()
		{
			if ((!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !Menu.IsVisible())
			{
				return TextInput.IsVisible();
			}
			return true;
		}
	}
	internal sealed class Restyle
	{
		private readonly List<Action> _undo = new List<Action>();

		public void Image(Image img, Sprite sprite, Color color, Type type = (Type)1, float ppu = 1f)
		{
			//IL_0045: 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_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_009b: 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)
			if ((Object)(object)img == (Object)null)
			{
				return;
			}
			Sprite s = img.sprite;
			Sprite o = img.overrideSprite;
			Type t = img.type;
			Color c = ((Graphic)img).color;
			float p = img.pixelsPerUnitMultiplier;
			_undo.Add(delegate
			{
				//IL_0038: 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)
				if (!((Object)(object)img == (Object)null))
				{
					img.sprite = s;
					img.overrideSprite = o;
					img.type = t;
					((Graphic)img).color = c;
					img.pixelsPerUnitMultiplier = p;
				}
			});
			img.overrideSprite = null;
			Theme.Style(img, sprite, color, type, ppu);
		}

		public void Hide(Behaviour b)
		{
			if ((Object)(object)b == (Object)null || !b.enabled)
			{
				return;
			}
			_undo.Add(delegate
			{
				if ((Object)(object)b != (Object)null)
				{
					b.enabled = true;
				}
			});
			b.enabled = false;
		}

		public void Text(TMP_Text t, bool title, float size, Color color)
		{
			//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_009d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)t == (Object)null)
			{
				return;
			}
			TMP_FontAsset f = t.font;
			Material m = t.fontSharedMaterial;
			float s = t.fontSize;
			Color c = ((Graphic)t).color;
			_undo.Add(delegate
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)t == (Object)null))
				{
					t.font = f;
					t.fontSharedMaterial = m;
					t.fontSize = s;
					((Graphic)t).color = c;
				}
			});
			Theme.ApplyFont(t, title);
			if (size > 0f)
			{
				t.fontSize = size;
			}
			((Graphic)t).color = color;
		}

		public void Do(Action apply, Action undo)
		{
			apply();
			_undo.Add(undo);
		}

		public T Track<T>(T created) where T : Component
		{
			if ((Object)(object)created != (Object)null)
			{
				_undo.Add(delegate
				{
					if ((Object)(object)created != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)created).gameObject);
					}
				});
			}
			return created;
		}

		public void Undo()
		{
			for (int num = _undo.Count - 1; num >= 0; num--)
			{
				try
				{
					_undo[num]();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Restyle undo failed: " + ex.Message));
				}
			}
			_undo.Clear();
		}

		public static void Dump(string title, Transform root, int maxDepth = 6)
		{
			if (!((Object)(object)root == (Object)null) && ModConfig.DumpUiHierarchy.Value)
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("UI layout of ").Append(title).Append(":\n");
				DumpNode(stringBuilder, root, 0, maxDepth);
				Plugin.Log.LogInfo((object)stringBuilder.ToString());
			}
		}

		private static void DumpNode(StringBuilder sb, Transform t, int depth, int maxDepth)
		{
			//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_006d: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			sb.Append(' ', depth * 2).Append(((Object)t).name);
			if (!((Component)t).gameObject.activeSelf)
			{
				sb.Append(" (inactive)");
			}
			RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null);
			if (val != null)
			{
				StringBuilder stringBuilder = sb.Append(" [");
				Rect rect = val.rect;
				StringBuilder stringBuilder2 = stringBuilder.Append(((Rect)(ref rect)).width.ToString("0")).Append('x');
				rect = val.rect;
				stringBuilder2.Append(((Rect)(ref rect)).height.ToString("0")).Append(']');
			}
			Component[] components = ((Component)t).GetComponents<Component>();
			foreach (Component val2 in components)
			{
				if (!((Object)(object)val2 == (Object)null) && !(val2 is Transform))
				{
					sb.Append(' ').Append(((object)val2).GetType().Name);
					Image val3 = (Image)(object)((val2 is Image) ? val2 : null);
					if (val3 != null && (Object)(object)val3.sprite != (Object)null)
					{
						sb.Append('(').Append(((Object)val3.sprite).name).Append(')');
					}
				}
			}
			sb.Append('\n');
			if (depth >= maxDepth)
			{
				return;
			}
			foreach (Transform item in t)
			{
				Transform t2 = item;
				DumpNode(sb, t2, depth + 1, maxDepth);
			}
		}
	}
	internal static class Theme
	{
		public static readonly Color Wood = new Color(1f, 1f, 1f, 0.92f);

		public static readonly Color Track = new Color(0.05f, 0.035f, 0.025f, 0.92f);

		public static readonly Color Bronze = new Color(0.82f, 0.64f, 0.36f, 1f);

		public static readonly Color Text = new Color(0.96f, 0.89f, 0.72f, 1f);

		public static readonly Color TextDim = new Color(0.76f, 0.67f, 0.52f, 1f);

		public static readonly Color Warn = new Color(1f, 0.74f, 0.3f, 1f);

		public static readonly Color Danger = new Color(0.96f, 0.33f, 0.24f, 1f);

		public static readonly Color Shade = new Color(0.03f, 0.02f, 0.01f, 0.62f);

		public static readonly Color Health = new Color(0.72f, 0.14f, 0.11f, 1f);

		public static readonly Color Stamina = new Color(0.88f, 0.64f, 0.18f, 1f);

		public static readonly Color Eitr = new Color(0.38f, 0.46f, 0.9f, 1f);

		public static readonly Color Durability = new Color(0.5f, 0.72f, 0.3f, 1f);

		public static readonly Color Trail = new Color(1f, 0.88f, 0.64f, 0.5f);

		public const string HealthHex = "#e2705e";

		public const string StaminaHex = "#f2c45a";

		public const string EitrHex = "#8e9cff";

		private static Sprite _rounded;

		private static Sprite _rim;

		private static Sprite _wood;

		private static Sprite _gradient;

		private static Sprite _solid;

		private static Sprite _disc;

		private static TMP_FontAsset _body;

		private static TMP_FontAsset _title;

		private static Material _bodyMaterial;

		public static Sprite Rounded
		{
			get
			{
				if (!((Object)(object)_rounded != (Object)null))
				{
					return _rounded = MakeRounded();
				}
				return _rounded;
			}
		}

		public static Sprite Rim
		{
			get
			{
				if (!((Object)(object)_rim != (Object)null))
				{
					return _rim = MakeRim();
				}
				return _rim;
			}
		}

		public static Sprite WoodSprite
		{
			get
			{
				if (!((Object)(object)_wood != (Object)null))
				{
					return _wood = MakeWood();
				}
				return _wood;
			}
		}

		public static Sprite Gradient
		{
			get
			{
				if (!((Object)(object)_gradient != (Object)null))
				{
					return _gradient = MakeGradient();
				}
				return _gradient;
			}
		}

		public static Sprite Solid
		{
			get
			{
				if (!((Object)(object)_solid != (Object)null))
				{
					return _solid = MakeSolid();
				}
				return _solid;
			}
		}

		public static Sprite Disc
		{
			get
			{
				if (!((Object)(object)_disc != (Object)null))
				{
					return _disc = MakeDisc();
				}
				return _disc;
			}
		}

		public static void LoadFonts(Hud hud)
		{
			TMP_Text val = (((Object)(object)hud.m_staminaText != (Object)null) ? hud.m_staminaText : hud.m_healthText);
			if ((Object)(object)val != (Object)null)
			{
				_body = val.font;
				_bodyMaterial = val.fontSharedMaterial;
			}
			if ((Object)(object)_title == (Object)null)
			{
				TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				foreach (TMP_FontAsset val2 in array)
				{
					string text = ((Object)val2).name.ToLowerInvariant();
					if (text.Contains("norse"))
					{
						_title = val2;
						if (text.Contains("bold"))
						{
							break;
						}
					}
				}
			}
			if ((Object)(object)_title == (Object)null)
			{
				_title = _body;
			}
		}

		public static RectTransform Rect(string name, Transform parent)
		{
			//IL_0014: 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_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_003d: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) })
			{
				layer = ((Component)parent).gameObject.layer
			}.transform;
			((Transform)val).SetParent(parent, false);
			return val;
		}

		public static Image Image(string name, Transform parent, Sprite sprite, Color color, Type type = (Type)1, float ppuMultiplier = 1f)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)Rect(name, parent)).gameObject.AddComponent<Image>();
			((Graphic)obj).raycastTarget = false;
			Style(obj, sprite, color, type, ppuMultiplier);
			return obj;
		}

		public static void Style(Image img, Sprite sprite, Color color, Type type = (Type)1, float ppuMultiplier = 1f)
		{
			//IL_0008: 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)
			img.sprite = sprite;
			img.type = type;
			((Graphic)img).color = color;
			img.pixelsPerUnitMultiplier = ppuMultiplier;
		}

		public static Image Flat(string name, Transform parent, Color color)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)Rect(name, parent)).gameObject.AddComponent<Image>();
			((Graphic)obj).raycastTarget = false;
			((Graphic)obj).color = color;
			return obj;
		}

		public static Image WoodPanel(string name, Transform parent)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Image obj = Image(name, parent, WoodSprite, Wood, (Type)1);
			Stretch(((Graphic)obj).rectTransform);
			return obj;
		}

		public static Image RimOverlay(Transform parent, float thickness = 1f, float outset = 0f)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Image obj = Image("Rim", parent, Rim, Color.white, (Type)1, 1f / Mathf.Max(0.1f, thickness));
			Stretch(((Graphic)obj).rectTransform, 0f - outset, 0f - outset, 0f - outset, 0f - outset);
			return obj;
		}

		public static TMP_Text Label(string name, Transform parent, float size, TextAlignmentOptions align, Color color, bool title = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = ((Component)Rect(name, parent)).gameObject.AddComponent<TextMeshProUGUI>();
			ApplyFont((TMP_Text)(object)obj, title);
			((TMP_Text)obj).fontSize = size;
			((TMP_Text)obj).alignment = align;
			((Graphic)obj).color = color;
			((TMP_Text)obj).richText = true;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((Graphic)obj).raycastTarget = false;
			return (TMP_Text)(object)obj;
		}

		public static void ApplyFont(TMP_Text t, bool title)
		{
			if (title && (Object)(object)_title != (Object)null)
			{
				t.font = _title;
				if ((Object)(object)_title == (Object)(object)_body && (Object)(object)_bodyMaterial != (Object)null)
				{
					t.fontSharedMaterial = _bodyMaterial;
				}
			}
			else if ((Object)(object)_body != (Object)null)
			{
				t.font = _body;
				if ((Object)(object)_bodyMaterial != (Object)null)
				{
					t.fontSharedMaterial = _bodyMaterial;
				}
			}
		}

		public static void Place(RectTransform rt, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size)
		{
			//IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = anchor;
			rt.anchorMax = anchor;
			rt.pivot = pivot;
			rt.anchoredPosition = pos;
			rt.sizeDelta = size;
		}

		public static void Stretch(RectTransform rt, float left = 0f, float right = 0f, float top = 0f, float bottom = 0f)
		{
			//IL_0001: 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_0021: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.pivot = new Vector2(0.5f, 0.5f);
			rt.offsetMin = new Vector2(left, bottom);
			rt.offsetMax = new Vector2(0f - right, 0f - top);
		}

		public static void Match(RectTransform rt, RectTransform other, float margin)
		{
			//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_001a: 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_002d: 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_003e: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = other.anchorMin;
			rt.anchorMax = other.anchorMax;
			rt.pivot = other.pivot;
			rt.offsetMin = other.offsetMin - new Vector2(margin, margin);
			rt.offsetMax = other.offsetMax + new Vector2(margin, margin);
		}

		public static string Time(float seconds)
		{
			int num = Mathf.Max(0, Mathf.CeilToInt(seconds));
			if (num < 60)
			{
				return num + "s";
			}
			if (num < 3600)
			{
				return num / 60 + ":" + (num % 60).ToString("00");
			}
			return num / 3600 + ":" + (num / 60 % 60).ToString("00") + ":" + (num % 60).ToString("00");
		}

		public static float Pulse(float speed)
		{
			return 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * speed);
		}

		private static Texture2D NewTexture(string name, int w, int h)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return new Texture2D(w, h, (TextureFormat)4, false)
			{
				name = "CleanHud_" + name,
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1
			};
		}

		private static Sprite Finish(Texture2D tex, Color32[] px, float border)
		{
			//IL_0028: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			tex.SetPixels32(px);
			tex.Apply(false, true);
			return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(border, border, border, border));
		}

		private static float RoundedCoverage(int x, int y, int size, float r)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp((float)x + 0.5f, r, (float)size - r);
			float num2 = Mathf.Clamp((float)y + 0.5f, r, (float)size - r);
			float num3 = Vector2.Distance(new Vector2((float)x + 0.5f, (float)y + 0.5f), new Vector2(num, num2));
			return Mathf.Clamp01(r - num3 + 0.5f);
		}

		private static float EdgeDepth(int x, int y, int size, float r)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)x + 0.5f;
			float num2 = (float)y + 0.5f;
			float num3 = Mathf.Clamp(num, r, (float)size - r);
			float num4 = Mathf.Clamp(num2, r, (float)size - r);
			if (num3 != num && num4 != num2)
			{
				return r - Vector2.Distance(new Vector2(num, num2), new Vector2(num3, num4));
			}
			return Mathf.Min(Mathf.Min(num, (float)size - num), Mathf.Min(num2, (float)size - num2));
		}

		private static Sprite MakeRounded()
		{
			//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)
			Texture2D tex = NewTexture("Rounded", 32, 32);
			Color32[] array = (Color32[])(object)new Color32[1024];
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					array[i * 32 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(RoundedCoverage(j, i, 32, 10f) * 255f));
				}
			}
			return Finish(tex, array, 10f);
		}

		private static Sprite MakeRim()
		{
			//IL_00c3: 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)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			Texture2D tex = NewTexture("Rim", 32, 32);
			Color32[] array = (Color32[])(object)new Color32[1024];
			Color val = default(Color);
			((Color)(ref val))..ctor(0.06f, 0.04f, 0.02f, 1f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.9f, 0.73f, 0.43f, 1f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.47f, 0.33f, 0.16f, 1f);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(0f, 0f, 0f, 0.55f);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = RoundedCoverage(j, i, 32, 4f);
					float num2 = EdgeDepth(j, i, 32, 4f);
					Color val5;
					if (num2 < 1f)
					{
						val5 = val;
					}
					else if (num2 < 3f)
					{
						val5 = Color.Lerp(val3, val2, (float)i / 31f);
						if (num2 < 1.8f)
						{
							val5 = Color.Lerp(val5, Color.white, 0.12f);
						}
					}
					else
					{
						val5 = ((!(num2 < 4.5f)) ? Color.clear : Color.Lerp(val4, Color.clear, (num2 - 3f) / 1.5f));
					}
					val5.a *= num;
					array[i * 32 + j] = Color32.op_Implicit(val5);
				}
			}
			return Finish(tex, array, 6f);
		}

		private static Sprite MakeWood()
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00c1: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D tex = NewTexture("Wood", 64, 64);
			Color32[] array = (Color32[])(object)new Color32[4096];
			Color val = default(Color);
			((Color)(ref val))..ctor(0.1f, 0.07f, 0.045f, 1f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.2f, 0.14f, 0.09f, 1f);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = Mathf.PerlinNoise((float)j * 0.035f + 3.1f, (float)i * 0.42f + 7.7f);
					float num2 = Mathf.PerlinNoise((float)j * 0.15f + 11f, (float)i * 1.6f) * 0.25f;
					Color val3 = Color.Lerp(val, val2, Mathf.Clamp01(num * 0.85f + num2));
					float num3 = Mathf.Clamp01(EdgeDepth(j, i, 64, 4f) / 10f);
					val3 = Color.Lerp(val3 * 0.65f, val3, num3);
					val3.a = RoundedCoverage(j, i, 64, 4f);
					array[i * 64 + j] = Color32.op_Implicit(val3);
				}
			}
			return Finish(tex, array, 8f);
		}

		private static Sprite MakeGradient()
		{
			//IL_0096: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D tex = NewTexture("Gradient", 4, 32);
			Color32[] array = (Color32[])(object)new Color32[128];
			Color val = default(Color);
			for (int i = 0; i < 32; i++)
			{
				float num = (float)i / 31f;
				float num2 = Mathf.Lerp(0.58f, 1f, Mathf.SmoothStep(0f, 1f, num));
				if (i >= 29)
				{
					num2 = 1f;
				}
				if ((float)i >= 17.6f && i < 29)
				{
					num2 = Mathf.Min(1f, num2 + 0.05f);
				}
				((Color)(ref val))..ctor(num2, num2, num2, 1f);
				for (int j = 0; j < 4; j++)
				{
					array[i * 4 + j] = Color32.op_Implicit(val);
				}
			}
			return Finish(tex, array, 0f);
		}

		private static Sprite MakeSolid()
		{
			//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)
			Texture2D tex = NewTexture("Solid", 4, 4);
			Color32[] array = (Color32[])(object)new Color32[16];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
			}
			return Finish(tex, array, 0f);
		}

		private static Sprite MakeDisc()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			Texture2D tex = NewTexture("Disc", 64, 64);
			Color32[] array = (Color32[])(object)new Color32[4096];
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(32f, 32f);
			float num = 31.5f;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.12f, 0.08f, 0.05f, 0.92f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.92f, 0.75f, 0.45f, 1f);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(0.45f, 0.31f, 0.15f, 1f);
			Color val5 = default(Color);
			((Color)(ref val5))..ctor(0.05f, 0.03f, 0.02f, 1f);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num2 = num - Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), val);
					Color val6 = ((!(num2 < 0f)) ? ((!(num2 < 2f)) ? ((!(num2 < 6f)) ? ((!(num2 < 8f)) ? val2 : Color.Lerp(new Color(0f, 0f, 0f, 0.9f), val2, (num2 - 6f) / 2f)) : Color.Lerp(val4, val3, (float)i / 63f)) : val5) : Color.clear);
					val6.a *= Mathf.Clamp01(num2 + 0.5f);
					array[i * 64 + j] = Color32.op_Implicit(val6);
				}
			}
			return Finish(tex, array, 0f);
		}
	}
	internal static class Waypoints
	{
		private struct Candidate
		{
			public PinData Pin;

			public Vector3 World;

			public float Distance;

			public bool Sight;

			public bool Persistent;
		}

		private const float MarkerLift = 1.6f;

		private static RectTransform _layer;

		private static Canvas _canvas;

		private static readonly List<WaypointMarker> Pool = new List<WaypointMarker>();

		private static readonly Dictionary<PinData, float> Heights = new Dictionary<PinData, float>();

		private static readonly List<Candidate> Candidates = new List<Candidate>();

		private static readonly List<PinData> ToRemove = new List<PinData>();

		private static readonly HashSet<PinData> Armed = new HashSet<PinData>();

		private static readonly HashSet<string> Reached = new HashSet<string>();

		private static long _world = long.MinValue;

		private static int _sightMask = -1;

		private static string ReachedFile => Path.Combine(Paths.ConfigPath, "com.cleanhud.valheim.reached.txt");

		public static void Build(RectTransform container)
		{
			_layer = Theme.Rect("Waypoints", (Transform)(object)container);
			Theme.Stretch(_layer);
			((Transform)_layer).SetAsFirstSibling();
			_canvas = ((Component)container).GetComponentInParent<Canvas>();
			if ((Object)(object)_canvas != (Object)null)
			{
				_canvas = _canvas.rootCanvas;
			}
			Pool.Clear();
			Heights.Clear();
		}

		public static void Destroy()
		{
			_layer = null;
			_canvas = null;
			Pool.Clear();
			Heights.Clear();
		}

		public static void Refresh(Player player)
		{
			//IL_006a: 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_008a: 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_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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_0156: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Invalid comparison between Unknown and I4
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: 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_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Invalid comparison between Unknown and I4
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: 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_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: 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_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_layer == (Object)null)
			{
				return;
			}
			Minimap instance = Minimap.instance;
			Camera mainCamera = Utils.GetMainCamera();
			if (!ModConfig.ShowWaypoints.Value || !((Object)(object)instance != (Object)null) || !((Object)(object)mainCamera != (Object)null) || Minimap.IsOpen() || InventoryGui.IsVisible())
			{
				HideFrom(0);
				return;
			}
			LoadReachedForWorld();
			Camera val = (((Object)(object)_canvas == (Object)null || (int)_canvas.renderMode == 0) ? null : _canvas.worldCamera);
			Vector3 position = ((Component)player).transform.position;
			float num = (float)Screen.height / 1080f;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
			float num2 = 46f * num;
			Vector2 val3 = val2 - new Vector2(num2, num2);
			float value = ModConfig.Scale.Value;
			int num3 = 0;
			Candidates.Clear();
			foreach (PinData pin2 in instance.m_pins)
			{
				if (pin2.m_checked && ModConfig.WaypointHideChecked.Value)
				{
					continue;
				}
				bool flag = ModConfig.IsFarPin(pin2.m_type);
				bool flag2 = !flag && ModConfig.IsSightPin(pin2.m_type);
				if (!flag && !flag2)
				{
					continue;
				}
				Vector3 val4 = WorldPosition(pin2, position);
				float num4 = Vector3.Distance(position, val4);
				bool flag3 = false;
				if (flag)
				{
					float num5 = FlatDistance(position, pin2.m_pos);
					float value2 = ModConfig.ReachedDistance.Value;
					if (num5 > value2 * 2f)
					{
						Armed.Add(pin2);
					}
					bool flag4 = Armed.Contains(pin2);
					flag3 = IsPersistent(pin2);
					if (flag3)
					{
						if (num5 <= ModConfig.PersistentHideRadius.Value)
						{
							continue;
						}
					}
					else
					{
						string text = Key(pin2);
						if (Reached.Contains(text))
						{
							continue;
						}
						if (flag4 && num5 <= value2)
						{
							if ((int)pin2.m_type != 4 && ModConfig.RemoveReachedPins.Value)
							{
								ToRemove.Add(pin2);
							}
							else
							{
								MarkReached(text);
							}
							continue;
						}
					}
				}
				else if (num4 > ModConfig.SightMaxDistance.Value || !HasLineOfSight(((Component)mainCamera).transform.position, val4))
				{
					continue;
				}
				Candidates.Add(new Candidate
				{
					Pin = pin2,
					World = val4,
					Distance = num4,
					Sight = flag2,
					Persistent = flag3
				});
			}
			if (ToRemove.Count > 0)
			{
				foreach (PinData item in ToRemove)
				{
					string text2 = DisplayName(item);
					instance.RemovePin(item);
					Armed.Remove(item);
					Heights.Remove(item);
					MessageHud instance2 = MessageHud.instance;
					if (instance2 != null)
					{
						instance2.ShowMessage((MessageType)1, string.IsNullOrEmpty(text2) ? "Waypoint reached" : ("Reached " + text2), 0, (Sprite)null, false, true);
					}
				}
				ToRemove.Clear();
			}
			Candidates.Sort((Candidate a, Candidate b) => a.Distance.CompareTo(b.Distance));
			int value3 = ModConfig.WaypointMaxShown.Value;
			int num6 = 0;
			Vector2 anchoredPosition = default(Vector2);
			for (int num7 = 0; num7 < Candidates.Count; num7++)
			{
				PinData pin = Candidates[num7].Pin;
				if ((int)pin.m_type != 4)
				{
					if (num6 >= value3)
					{
						continue;
					}
					num6++;
				}
				Vector3 world = Candidates[num7].World;
				float distance = Candidates[num7].Distance;
				bool sight = Candidates[num7].Sight;
				bool persistent = Candidates[num7].Persistent;
				Vector3 val5 = mainCamera.WorldToScreenPoint(world);
				bool num8 = val5.z < 0f;
				Vector2 val6 = new Vector2(val5.x, val5.y) - val2;
				if (num8)
				{
					val6 = -val6;
				}
				bool flag5 = num8 || Mathf.Abs(val6.x) > val3.x || Mathf.Abs(val6.y) > val3.y;
				if (flag5)
				{
					if (sight || !ModConfig.WaypointEdge.Value)
					{
						continue;
					}
					if (((Vector2)(ref val6)).sqrMagnitude < 1f)
					{
						val6 = Vector2.down;
					}
					float num9 = Mathf.Min(val3.x / Mathf.Max(0.001f, Mathf.Abs(val6.x)), val3.y / Mathf.Max(0.001f, Mathf.Abs(val6.y)));
					val6 *= num9;
				}
				if (num3 == Pool.Count)
				{
					Pool.Add(new WaypointMarker((Transform)(object)_layer));
				}
				WaypointMarker waypointMarker = Pool[num3++];
				if (!((Component)waypointMarker.Root).gameObject.activeSelf)
				{
					((Component)waypointMarker.Root).gameObject.SetActive(true);
				}
				RectTransformUtility.ScreenPointToLocalPointInRectangle(_layer, val2 + val6, val, ref anchoredPosition);
				waypointMarker.Root.anchoredPosition = anchoredPosition;
				((Transform)waypointMarker.Root).localScale = new Vector3(value, value, 1f);
				waypointMarker.Group.alpha = (flag5 ? (ModConfig.WaypointOpacity.Value * 0.6f) : AimFade(((Vector2)(ref val6)).magnitude, num));
				waypointMarker.Set(pin, DisplayName(pin), persistent, distance, flag5);
			}
			HideFrom(num3);
		}

		public static bool IsPersistent(PinData pin)
		{
			string value = ModConfig.PersistentPrefix.Value;
			if (!string.IsNullOrEmpty(value) && pin.m_name != null)
			{
				return pin.m_name.TrimStart(Array.Empty<char>()).StartsWith(value, StringComparison.Ordinal);
			}
			return false;
		}

		public static string DisplayName(PinData pin)
		{
			string text = pin.m_name ?? "";
			string value = ModConfig.PersistentPrefix.Value;
			if (!string.IsNullOrEmpty(value))
			{
				string text2 = text.TrimStart(Array.Empty<char>());
				if (text2.StartsWith(value, StringComparison.Ordinal))
				{
					text = text2.Substring(value.Length).TrimStart(Array.Empty<char>());
				}
			}
			if (text.Length == 0)
			{
				return "";
			}
			if (Localization.instance == null)
			{
				return text;
			}
			return Localization.instance.Localize(text);
		}

		public static void HandleMapInput(Minimap map)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: 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_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_007d: Unknown result type (might be due to invalid IL or missing references)
			KeyCode value = ModConfig.PersistentToggleKey.Value;
			if (!ModConfig.Enabled.Value || !ModConfig.ShowWaypoints.Value || (int)value == 0 || (int)map.m_mode != 2 || !ZInput.GetKeyDown(value, false) || ((Object)(object)map.m_nameInput != (Object)null && ((TMP_InputField)map.m_nameInput).isFocused) || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()))
			{
				return;
			}
			Vector3 val = map.ScreenToWorldPoint(ZInput.pointerPosition);
			PinData closestPin = map.GetClosestPin(val, map.PinInteractRadius, true);
			if (closestPin == null)
			{
				return;
			}
			string value2 = ModConfig.PersistentPrefix.Value;
			if (!string.IsNullOrEmpty(value2))
			{
				bool flag = !IsPersistent(closestPin);
				string text = (closestPin.m_name ?? "").TrimStart(Array.Empty<char>());
				if (!flag)
				{
					text = text.Substring(value2.Length).TrimStart(Array.Empty<char>());
				}
				closestPin.m_name = (flag ? (value2 + text) : text);
				PinNameData namePinData = closestPin.m_NamePinData;
				TMP_Text val2 = ((namePinData != null) ? namePinData.PinNameText : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.text = Localization.instance.Localize(closestPin.m_name);
				}
				map.m_pinUpdateRequired = true;
				Armed.Remove(closestPin);
				string text2 = DisplayName(closestPin);
				MessageHud instance = MessageHud.instance;
				if (instance != null)
				{
					instance.ShowMessage((MessageType)2, (string.IsNullOrEmpty(text2) ? "Pin" : text2) + (flag ? ": persistent" : ": normal (removed when reached)"), 0, (Sprite)null, false, true);
				}
			}
		}

		private static float AimFade(float fromCenter, float uiScale)
		{
			float num = Mathf.InverseLerp(30f * uiScale, 170f * uiScale, fromCenter);
			return Mathf.Lerp(ModConfig.WaypointAimedAlpha.Value, ModConfig.WaypointOpacity.Value, Mathf.SmoothStep(0f, 1f, num));
		}

		private static bool HasLineOfSight(Vector3 from, Vector3 to)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if (_sightMask == -1)
			{
				_sightMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "terrain", "piece", "Default_small" });
			}
			Vector3 val = to - from;
			float magnitude = ((Vector3)(ref val)).magnitude;
			float num = magnitude - 6f;
			if (num <= 0f)
			{
				return true;
			}
			return !Physics.Raycast(from, val / magnitude, num, _sightMask, (QueryTriggerInteraction)1);
		}

		private static Vector3 WorldPosition(PinData pin, Vector3 me)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0051: 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_009f: 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_0091: 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_00b3: 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)
			Vector3 pos = pin.m_pos;
			if (Mathf.Abs(pos.y) > 0.01f)
			{
				return pos + Vector3.up * 1.6f;
			}
			if (Heights.TryGetValue(pin, out var value))
			{
				return new Vector3(pos.x, value + 1.6f, pos.z);
			}
			ZoneSystem instance = ZoneSystem.instance;
			float num = default(float);
			if (!((Object)(object)instance != (Object)null) || !instance.GetGroundHeight(pos, ref num))
			{
				num = ((WorldGenerator.instance == null) ? me.y : WorldGenerator.instance.GetHeight(pos.x, pos.z));
			}
			else
			{
				Heights[pin] = num;
			}
			return new Vector3(pos.x, num + 1.6f, pos.z);
		}

		private static float FlatDistance(Vector3 a, Vector3 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			float num = a.x - b.x;
			float num2 = a.z - b.z;
			return Mathf.Sqrt(num * num + num2 * num2);
		}

		private static string Key(PinData pin)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			return (int)pin.m_type + "|" + Mathf.RoundToInt(pin.m_pos.x) + "|" + Mathf.RoundToInt(pin.m_pos.z) + "|" + pin.m_name;
		}

		private static void MarkReached(string key)
		{
			if (!Reached.Add(key) || !ModConfig.RememberReached.Value || _world == long.MinValue)
			{
				return;
			}
			try
			{
				File.AppendAllText(ReachedFile, _world + "\t" + key + "\n");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not save reached waypoint: " + ex.Message));
			}
		}

		private static void LoadReachedForWorld()
		{
			long num = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorldUID() : 0);
			if (num == _world)
			{
				return;
			}
			_world = num;
			Reached.Clear();
			Heights.Clear();
			Armed.Clear();
			if (!ModConfig.RememberReached.Value || !File.Exists(ReachedFile))
			{
				return;
			}
			try
			{
				string text = num + "\t";
				string[] array = File.ReadAllLines(ReachedFile);
				foreach (string text2 in array)
				{
					if (text2.StartsWith(text, StringComparison.Ordinal))
					{
						Reached.Add(text2.Substring(text.Length));
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not read reached waypoints: " + ex.Message));
			}
		}

		private static void HideFrom(int index)
		{
			for (int i = index; i < Pool.Count; i++)
			{
				if (((Component)Pool[i].Root).gameObject.activeSelf)
				{
					((Component)Pool[i].Root).gameObject.SetActive(false);
				}
			}
		}
	}
	internal sealed class Bar
	{
		public const float ValueWidth = 140f;

		public readonly RectTransform Root;

		public readonly float Height;

		private readonly RectTransform _fill;

		private readonly RectTransform _trail;

		private readonly Image _fillImage;

		private readonly TMP_Text _value;

		private readonly Color _color;

		private readonly bool _lowWarning;

		private float _trailFrac = 1f;

		private int _lastCur = -1;

		private int _lastMax = -1;

		private VitalsText _lastMode;

		public Bar(Transform parent, string name, Color color, float height, bool lowWarning)
		{
			//IL_0028: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			Height = height;
			_color = color;
			_lowWarning = lowWarning;
			Root = Theme.Rect(name, parent);
			RectTransform val = Theme.Rect("Inner", (Transform)(object)Root);
			Theme.Stretch(val, 2f, 2f, 2f, 2f);
			Theme.Stretch(((Graphic)Theme.Flat("Track", (Transform)(object)val, Theme.Track)).rectTransform);
			_trail = ((Graphic)Theme.Flat("Trail", (Transform)(object)val, Theme.Trail)).rectTransform;
			_fillImage = Theme.Image("Fill", (Transform)(object)val, Theme.Gradient, color, (Type)0);
			_fill = ((Graphic)_fillImage).rectTransform;
			SetFrac(_trail, 1f);
			SetFrac(_fill, 1f);
			Theme.RimOverlay((Transform)(object)Root, (height >= 14f) ? 0.7f : 0.55f);
			_value = Theme.Label("Value", (Transform)(object)Root, (height >= 14f) ? 17f : 14f, (TextAlignmentOptions)4097, Color.Lerp(color, Theme.Text, 0.7f), title: true);
			Theme.Place(_value.rectTransform, new Vector2(1f, 0.5f), new Vector2(0f, 0.5f), new Vector2(10f, 1f), new Vector2(140f, 22f));
		}

		public void Set(float cur, float max, float dt)
		{
			//IL_0071: 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_008d: 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)
			float num = ((max > 0f) ? Mathf.Clamp01(cur / max) : 0f);
			SetFrac(_fill, num);
			_trailFrac = ((num >= _trailFrac) ? num : Mathf.MoveTowards(_trailFrac, num, dt * 0.6f));
			SetFrac(_trail, _trailFrac);
			((Graphic)_fillImage).color = ((_lowWarning && num < 0.25f) ? Color.Lerp(_color, new Color(1f, 0.55f, 0.4f), Theme.Pulse(7f) * 0.5f) : _color);
			int num2 = Mathf.CeilToInt(cur);
			int num3 = Mathf.CeilToInt(max);
			VitalsText value = ModConfig.TextMode.Value;
			if (num2 != _lastCur || num3 != _lastMax || value != _lastMode)
			{
				_lastCur = num2;
				_lastMax = num3;
				_lastMode = value;
				int num4 = Percent(cur, max);
				switch (value)
				{
				case VitalsText.Percent:
					_value.text = num4 + "%";
					return;
				case VitalsText.Value:
					_value.text = num2 + "<alpha=#88> / " + num3;
					return;
				}
				_value.text = num2 + "<alpha=#88> / " + num3 + "  <alpha=#BB><size=80%>" + num4 + "%";
			}
		}

		public static int Percent(float cur, float max)
		{
			if (max <= 0f)
			{
				return 0;
			}
			if (cur >= max)
			{
				return 100;
			}
			return Mathf.Clamp(Mathf.FloorToInt(cur / max * 100f), (cur > 0f) ? 1 : 0, 99);
		}

		private static void SetFrac(RectTransform rt, float f)
		{
			//IL_0001: 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_0027: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = new Vector2(f, 1f);
			rt.pivot = new Vector2(0f, 0.5f);
			rt.offsetMin = Vector2.zero;
			rt.offsetMax = Vector2.zero;
		}
	}
	internal sealed class IconTile
	{
		public const float TimeHeight = 17f;

		public const float SubHeight = 13f;

		public readonly RectTransform Root;

		public readonly float Size;

		public readonly Image Glow;

		public readonly Image Icon;

		public readonly Image Sweep;

		public readonly TMP_Text Time;

		public readonly TMP_Text Sub;

		private int _lastSecond = int.MinValue;

		public IconTile(Transform parent, string name, float size)
		{
			//IL_002d: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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_01ce: 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_01ff: