Decompiled source of ValheimHUDMaster v1.9.1

ValheimHUDMaster.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GlitnirTimeHUD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Atlas Playbook v0.4.1")]
[assembly: AssemblyProduct("GlitnirTimeHUD")]
[assembly: AssemblyCopyright("Copyright © Atlas Playbook v0.4.1 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a5001452-2cfa-4de4-be18-88fa66ef598e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.andersonmods.valheimhudmaster", "Valheim HUD Master", "1.9.1")]
public class ValheimHUDMaster : BaseUnityPlugin
{
	public enum Categoria
	{
		Vanilla,
		Marketplace,
		EpicMMO
	}

	public enum MoveMode
	{
		Anchor,
		Local,
		NoMove
	}

	public enum PartMoveMode
	{
		Anchor,
		Local
	}

	public struct GroupPartSetup
	{
		public string caminho;

		public PartMoveMode modo;

		public GroupPartSetup(string caminho, PartMoveMode modo)
		{
			this.caminho = caminho;
			this.modo = modo;
		}
	}

	private interface IEditableHudElement
	{
		Categoria Categoria { get; }

		MoveMode Modo { get; }

		bool OriginalSalvo { get; }

		string ModoDescricao { get; }

		ConfigEntry<float> OffsetX { get; }

		ConfigEntry<float> OffsetY { get; }

		ConfigEntry<float> Escala { get; }

		ConfigEntry<float> EscalaX { get; }

		ConfigEntry<float> EscalaY { get; }

		ConfigEntry<float> Rotacao { get; }

		ConfigEntry<bool> Visivel { get; }

		ConfigEntry<float> Opacidade { get; }

		void CapturarOriginal();

		void Aplicar();

		void Resetar();
	}

	private class HudElement : IEditableHudElement
	{
		private ValheimHUDMaster plugin;

		public string nome;

		public string caminho;

		public bool vanilla;

		public Categoria categoria;

		public MoveMode modo;

		public RectTransform rt;

		public Vector2 originalAnchorMin;

		public Vector2 originalAnchorMax;

		public Vector3 originalLocalPosition;

		public Vector3 originalScale;

		public Quaternion originalRot;

		public bool originalSalvo = false;

		public ConfigEntry<float> offsetX;

		public ConfigEntry<float> offsetY;

		public ConfigEntry<float> escala;

		public ConfigEntry<float> escalaX;

		public ConfigEntry<float> escalaY;

		public ConfigEntry<float> rotacao;

		public ConfigEntry<bool> visivel;

		public ConfigEntry<float> opacidade;

		public Categoria Categoria => categoria;

		public MoveMode Modo => modo;

		public bool OriginalSalvo => originalSalvo;

		public string ModoDescricao => modo.ToString();

		public ConfigEntry<float> OffsetX => offsetX;

		public ConfigEntry<float> OffsetY => offsetY;

		public ConfigEntry<float> Escala => escala;

		public ConfigEntry<float> EscalaX => escalaX;

		public ConfigEntry<float> EscalaY => escalaY;

		public ConfigEntry<float> Rotacao => rotacao;

		public ConfigEntry<bool> Visivel => visivel;

		public ConfigEntry<float> Opacidade => opacidade;

		public HudElement(ValheimHUDMaster plugin, string nome, string caminho, bool vanilla, Categoria categoria, MoveMode modo)
		{
			this.plugin = plugin;
			this.nome = nome;
			this.caminho = caminho;
			this.vanilla = vanilla;
			this.categoria = categoria;
			this.modo = modo;
			string text = "HUD - " + nome;
			offsetX = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "OffsetX", 0f, "Offset horizontal.");
			offsetY = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "OffsetY", 0f, "Offset vertical.");
			escala = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Escala", 1f, "Escala geral.");
			escalaX = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "EscalaX", 1f, "Escala horizontal.");
			escalaY = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "EscalaY", 1f, "Escala vertical.");
			rotacao = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Rotacao", 0f, "Rotacao.");
			visivel = ((BaseUnityPlugin)plugin).Config.Bind<bool>(text, "Visivel", true, "Elemento visivel.");
			opacidade = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Opacidade", 100f, "Opacidade em porcentagem.");
		}

		public void CapturarOriginal()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_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_0096: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if (originalSalvo)
			{
				return;
			}
			Transform val = plugin.BuscarTransform(caminho, vanilla, categoria);
			if (!((Object)(object)val == (Object)null))
			{
				rt = ((Component)val).GetComponent<RectTransform>();
				if (!((Object)(object)rt == (Object)null))
				{
					originalAnchorMin = rt.anchorMin;
					originalAnchorMax = rt.anchorMax;
					originalLocalPosition = ((Transform)rt).localPosition;
					originalScale = ((Transform)rt).localScale;
					originalRot = ((Transform)rt).localRotation;
					originalSalvo = true;
					((BaseUnityPlugin)plugin).Logger.LogInfo((object)("[HUD MASTER] Encontrado: " + nome));
				}
			}
		}

		public void Aplicar()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if (!originalSalvo || (Object)(object)rt == (Object)null)
			{
				return;
			}
			AplicarOpacidade(((Component)rt).gameObject, visivel.Value, opacidade.Value);
			if (visivel.Value)
			{
				if (modo == MoveMode.Anchor)
				{
					Vector2 val = default(Vector2);
					((Vector2)(ref val))..ctor(offsetX.Value / (float)Screen.width, offsetY.Value / (float)Screen.height);
					rt.anchorMin = originalAnchorMin + val;
					rt.anchorMax = originalAnchorMax + val;
				}
				else if (modo == MoveMode.Local)
				{
					((Transform)rt).localPosition = originalLocalPosition + new Vector3(offsetX.Value, offsetY.Value, 0f);
				}
				((Transform)rt).localScale = new Vector3(originalScale.x * escala.Value * escalaX.Value, originalScale.y * escala.Value * escalaY.Value, originalScale.z);
				((Transform)rt).localRotation = Quaternion.Euler(0f, 0f, rotacao.Value) * originalRot;
			}
		}

		public void Resetar()
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			offsetX.Value = 0f;
			offsetY.Value = 0f;
			escala.Value = 1f;
			escalaX.Value = 1f;
			escalaY.Value = 1f;
			rotacao.Value = 0f;
			visivel.Value = true;
			opacidade.Value = 100f;
			if ((Object)(object)rt != (Object)null)
			{
				AplicarOpacidade(((Component)rt).gameObject, visivel: true, 100f);
				rt.anchorMin = originalAnchorMin;
				rt.anchorMax = originalAnchorMax;
				((Transform)rt).localPosition = originalLocalPosition;
				((Transform)rt).localScale = originalScale;
				((Transform)rt).localRotation = originalRot;
			}
		}
	}

	private class HudGroup : IEditableHudElement
	{
		private class GroupPart
		{
			public RectTransform rt;

			public PartMoveMode modo;

			public Vector2 originalAnchorMin;

			public Vector2 originalAnchorMax;

			public Vector3 originalLocalPosition;

			public Vector3 originalScale;

			public Quaternion originalRot;
		}

		private ValheimHUDMaster plugin;

		public string nome;

		public Categoria categoria;

		public bool usaEspacamento;

		private GroupPartSetup[] setups;

		private List<GroupPart> partes = new List<GroupPart>();

		private bool originalSalvo = false;

		private ConfigEntry<float> offsetX;

		private ConfigEntry<float> offsetY;

		private ConfigEntry<float> escala;

		private ConfigEntry<float> escalaX;

		private ConfigEntry<float> escalaY;

		private ConfigEntry<float> rotacao;

		private ConfigEntry<float> espacamento;

		private ConfigEntry<bool> visivel;

		private ConfigEntry<float> opacidade;

		public Categoria Categoria => categoria;

		public MoveMode Modo => MoveMode.Local;

		public bool OriginalSalvo => originalSalvo;

		public string ModoDescricao => usaEspacamento ? "Grupo + Espacamento" : "Grupo";

		public bool UsaEspacamento => usaEspacamento;

		public ConfigEntry<float> OffsetX => offsetX;

		public ConfigEntry<float> OffsetY => offsetY;

		public ConfigEntry<float> Escala => escala;

		public ConfigEntry<float> EscalaX => escalaX;

		public ConfigEntry<float> EscalaY => escalaY;

		public ConfigEntry<float> Rotacao => rotacao;

		public ConfigEntry<float> Espacamento => espacamento;

		public ConfigEntry<bool> Visivel => visivel;

		public ConfigEntry<float> Opacidade => opacidade;

		public HudGroup(ValheimHUDMaster plugin, string nome, Categoria categoria, GroupPartSetup[] setups, bool usaEspacamento)
		{
			this.plugin = plugin;
			this.nome = nome;
			this.categoria = categoria;
			this.setups = setups;
			this.usaEspacamento = usaEspacamento;
			string text = "HUD - " + nome;
			offsetX = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "OffsetX", 0f, "Offset horizontal.");
			offsetY = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "OffsetY", 0f, "Offset vertical.");
			escala = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Escala", 1f, "Escala geral.");
			escalaX = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "EscalaX", 1f, "Escala horizontal.");
			escalaY = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "EscalaY", 1f, "Escala vertical.");
			rotacao = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Rotacao", 0f, "Rotacao.");
			espacamento = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Espacamento", 1f, "Espacamento.");
			visivel = ((BaseUnityPlugin)plugin).Config.Bind<bool>(text, "Visivel", true, "Grupo visivel.");
			opacidade = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Opacidade", 100f, "Opacidade em porcentagem.");
		}

		public void CapturarOriginal()
		{
			//IL_00ae: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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)
			if (originalSalvo || (Object)(object)Hud.instance == (Object)null)
			{
				return;
			}
			partes.Clear();
			GroupPartSetup[] array = setups;
			for (int i = 0; i < array.Length; i++)
			{
				GroupPartSetup groupPartSetup = array[i];
				Transform val = plugin.BuscarTransform(groupPartSetup.caminho, vanilla: true, Categoria.Vanilla);
				if (!((Object)(object)val == (Object)null))
				{
					RectTransform component = ((Component)val).GetComponent<RectTransform>();
					if (!((Object)(object)component == (Object)null))
					{
						partes.Add(new GroupPart
						{
							rt = component,
							modo = groupPartSetup.modo,
							originalAnchorMin = component.anchorMin,
							originalAnchorMax = component.anchorMax,
							originalLocalPosition = ((Transform)component).localPosition,
							originalScale = ((Transform)component).localScale,
							originalRot = ((Transform)component).localRotation
						});
					}
				}
			}
			if (partes.Count != 0)
			{
				originalSalvo = true;
				((BaseUnityPlugin)plugin).Logger.LogInfo((object)("[HUD MASTER] Grupo encontrado: " + nome + " partes=" + partes.Count));
			}
		}

		public void Aplicar()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			if (!originalSalvo)
			{
				return;
			}
			foreach (GroupPart parte in partes)
			{
				if ((Object)(object)parte.rt != (Object)null)
				{
					AplicarOpacidade(((Component)parte.rt).gameObject, visivel.Value, opacidade.Value);
				}
			}
			if (!visivel.Value)
			{
				return;
			}
			Vector3 val = Vector3.zero;
			foreach (GroupPart parte2 in partes)
			{
				val += parte2.originalLocalPosition;
			}
			val /= (float)partes.Count;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(offsetX.Value / (float)Screen.width, offsetY.Value / (float)Screen.height);
			foreach (GroupPart parte3 in partes)
			{
				Vector3 val3 = parte3.originalLocalPosition - val;
				if (usaEspacamento)
				{
					val3 *= espacamento.Value;
				}
				if (parte3.modo == PartMoveMode.Anchor)
				{
					parte3.rt.anchorMin = parte3.originalAnchorMin + val2;
					parte3.rt.anchorMax = parte3.originalAnchorMax + val2;
				}
				else
				{
					((Transform)parte3.rt).localPosition = val + val3 + new Vector3(offsetX.Value, offsetY.Value, 0f);
				}
				((Transform)parte3.rt).localScale = new Vector3(parte3.originalScale.x * escala.Value * escalaX.Value, parte3.originalScale.y * escala.Value * escalaY.Value, parte3.originalScale.z);
				((Transform)parte3.rt).localRotation = Quaternion.Euler(0f, 0f, rotacao.Value) * parte3.originalRot;
			}
		}

		public Rect? ObterRectTela()
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			if (!originalSalvo)
			{
				return null;
			}
			bool flag = false;
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			foreach (GroupPart parte in partes)
			{
				if ((Object)(object)parte.rt == (Object)null)
				{
					continue;
				}
				Vector3[] array = (Vector3[])(object)new Vector3[4];
				parte.rt.GetWorldCorners(array);
				for (int i = 0; i < 4; i++)
				{
					float x = array[i].x;
					float y = array[i].y;
					if (!flag)
					{
						num = x;
						num2 = y;
						num3 = x;
						num4 = y;
						flag = true;
					}
					else
					{
						num = Mathf.Min(num, x);
						num2 = Mathf.Min(num2, y);
						num3 = Mathf.Max(num3, x);
						num4 = Mathf.Max(num4, y);
					}
				}
			}
			if (!flag)
			{
				return null;
			}
			float num5 = Mathf.Max(Mathf.Abs(num3 - num), 24f);
			float num6 = Mathf.Max(Mathf.Abs(num4 - num2), 24f);
			return new Rect(num, (float)Screen.height - num4, num5, num6);
		}

		public void Resetar()
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			offsetX.Value = 0f;
			offsetY.Value = 0f;
			escala.Value = 1f;
			escalaX.Value = 1f;
			escalaY.Value = 1f;
			rotacao.Value = 0f;
			espacamento.Value = 1f;
			visivel.Value = true;
			opacidade.Value = 100f;
			foreach (GroupPart parte in partes)
			{
				if (!((Object)(object)parte.rt == (Object)null))
				{
					AplicarOpacidade(((Component)parte.rt).gameObject, visivel: true, 100f);
					parte.rt.anchorMin = parte.originalAnchorMin;
					parte.rt.anchorMax = parte.originalAnchorMax;
					((Transform)parte.rt).localPosition = parte.originalLocalPosition;
					((Transform)parte.rt).localScale = parte.originalScale;
					((Transform)parte.rt).localRotation = parte.originalRot;
				}
			}
		}
	}

	private Rect menuRect = new Rect(30f, 80f, 520f, 760f);

	private Vector2 scrollElementos = Vector2.zero;

	private bool mostrarMenu = false;

	private bool categoriaVanilla = true;

	private bool categoriaMarketplace = false;

	private bool categoriaEpicMMO = false;

	private ConfigEntry<KeyCode> teclaEditor;

	private ConfigEntry<float> tamanhoIconesEditor;

	private ConfigEntry<bool> mostrarMarketplace;

	private ConfigEntry<bool> mostrarEpicMMO;

	private ConfigEntry<bool> separarComida;

	private bool editarMovimento = false;

	private bool arrastando = false;

	private bool arrastandoCentro = false;

	private Vector2 ultimoMouseCentro = Vector2.zero;

	private bool redimensionandoCanto = false;

	private Vector2 ultimoMouseResize = Vector2.zero;

	private Vector2 direcaoResizeCanto = Vector2.zero;

	private bool redimensionandoLateral = false;

	private Vector2 ultimoMouseResizeLateral = Vector2.zero;

	private int tipoResizeLateral = 0;

	private bool rotacionandoVisual = false;

	private float anguloMouseInicial = 0f;

	private float rotacaoInicialElemento = 0f;

	private bool hoverCaixa = false;

	private bool hoverHandle = false;

	private Texture2D texMove;

	private Texture2D texRotate;

	private Texture2D texScaleCorner;

	private Texture2D texScaleX;

	private Texture2D texScaleY;

	private Texture2D texCenter;

	private Texture2D texOutline;

	private bool visualEditor = true;

	private Vector2 ultimoMouse;

	private string elementoAtual = "Stamina";

	private Dictionary<string, IEditableHudElement> elementos = new Dictionary<string, IEditableHudElement>();

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[HUD MASTER] Inicializando...");
		teclaEditor = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controles", "TeclaEditor", (KeyCode)288, "Tecla do editor HUD.");
		tamanhoIconesEditor = ((BaseUnityPlugin)this).Config.Bind<float>("Visual Editor", "TamanhoIcones", 24f, "Tamanho dos icones/handles do editor visual.");
		mostrarMarketplace = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtros", "MostrarMarketplace", false, "Mostra elementos Marketplace.");
		mostrarEpicMMO = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtros", "MostrarEpicMMO", false, "Mostra elementos Epic MMO.");
		separarComida = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD - Comida", "SepararElementos", false, "Permite mover garfo separado.");
		RegistrarElemento("Stamina", "hudroot/staminapanel", vanilla: true, Categoria.Vanilla, MoveMode.Anchor);
		RegistrarGrupo("Vida", Categoria.Vanilla, new GroupPartSetup[2]
		{
			new GroupPartSetup("hudroot/healthpanel/Health", PartMoveMode.Local),
			new GroupPartSetup("hudroot/healthpanel/healthicon", PartMoveMode.Local)
		}, usaEspacamento: true);
		RegistrarComida();
		RegistrarElemento("Eitr/Ether", "hudroot/eitrpanel", vanilla: true, Categoria.Vanilla, MoveMode.Anchor);
		RegistrarElemento("Hotbar/Atalhos", "hudroot/HotKeyBar", vanilla: true, Categoria.Vanilla, MoveMode.Anchor);
		RegistrarElemento("Minimapa", "hudroot/MiniMap/small", vanilla: true, Categoria.Vanilla, MoveMode.Anchor);
		RegistrarElemento("Status/Buffs", "hudroot/StatusEffects", vanilla: true, Categoria.Vanilla, MoveMode.Anchor);
		RegistrarElemento("Market - Marketplace", "BACKGROUND", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Market - Quests", "QuestPanel", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Market - Trader", "Trader", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Market - Leaderboard", "MarketplaceLeaderboardUI(Clone)", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Market - NPC Dialogue", "NPCDialogueUI(Clone)", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Market - NPC Config", "MAIN", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Market - Mail", "MailBox", vanilla: false, Categoria.Marketplace, MoveMode.NoMove);
		RegistrarElemento("Market - Open Mail", "OpenMail", vanilla: false, Categoria.Marketplace, MoveMode.NoMove);
		RegistrarElemento("Market - Notificacao Email", "UnreadMailNofitication", vanilla: false, Categoria.Marketplace, MoveMode.Anchor);
		RegistrarElemento("Epic MMO - Painel Geral", "EpicHudPanelCanvas(Clone)/EpicHudPanel", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Background", "EpicHudPanelCanvas(Clone)/EpicHudPanel/Background", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - XP", "EpicHudPanelCanvas(Clone)/EpicHudPanel/Container/Exp", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - HP", "EpicHudPanelCanvas(Clone)/EpicHudPanel/Container/Hp", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Stamina", "EpicHudPanelCanvas(Clone)/EpicHudPanel/Container/Stamina", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Eitr", "EpicHudPanelCanvas(Clone)/EpicHudPanel/Container/Eitr", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Botoes Menu", "LevelHud(Clone)/Canvas/NavigatePanel/Buttons", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Painel Navegacao", "LevelHud(Clone)/Canvas/NavigatePanel", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Painel Atributos", "LevelHud(Clone)/Canvas/PointPanel", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		RegistrarElemento("Epic MMO - Lista Amigos", "LevelHud(Clone)/Canvas/FriendList", vanilla: false, Categoria.EpicMMO, MoveMode.NoMove);
		CarregarAssets();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[HUD MASTER] Inicializado.");
	}

	private void RegistrarComida()
	{
		RegistrarGrupo("Comida", Categoria.Vanilla, new GroupPartSetup[4]
		{
			new GroupPartSetup("hudroot/healthpanel/food0", PartMoveMode.Local),
			new GroupPartSetup("hudroot/healthpanel/food1", PartMoveMode.Local),
			new GroupPartSetup("hudroot/healthpanel/food2", PartMoveMode.Local),
			new GroupPartSetup("hudroot/healthpanel/foodicon", PartMoveMode.Local)
		}, usaEspacamento: true);
	}

	private void Update()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)FejdStartup.instance != (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null)
		{
			return;
		}
		if (Input.GetKeyDown(teclaEditor.Value))
		{
			mostrarMenu = !mostrarMenu;
		}
		foreach (IEditableHudElement value in elementos.Values)
		{
			if (DeveMostrar(value))
			{
				value.CapturarOriginal();
				value.Aplicar();
			}
		}
	}

	private void OnGUI()
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)FejdStartup.instance != (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Hud.instance == (Object)null) && mostrarMenu)
		{
			if (editarMovimento)
			{
				ProcessarArraste();
			}
			((Rect)(ref menuRect)).height = Mathf.Clamp(((Rect)(ref menuRect)).height, 520f, (float)Screen.height * 0.92f);
			menuRect = GUI.Window(777777, menuRect, new WindowFunction(DesenharMenu), "Valheim HUD Master");
			DesenharVisualEditor();
		}
	}

	private void DesenharVisualEditor()
	{
		//IL_005e: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: 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_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		if (!visualEditor)
		{
			return;
		}
		IEditableHudElement editableHudElement = Atual();
		if (editableHudElement == null || !editableHudElement.OriginalSalvo)
		{
			return;
		}
		Rect? val = ObterRectTela(editableHudElement);
		if (!val.HasValue)
		{
			return;
		}
		Rect value = val.Value;
		if (!(((Rect)(ref value)).width < 8f) && !(((Rect)(ref value)).height < 8f))
		{
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, 0.07f);
			GUI.Box(value, "");
			GUI.color = Color.white;
			DesenharLinha(new Rect(((Rect)(ref value)).x, ((Rect)(ref value)).y, ((Rect)(ref value)).width, 2f));
			DesenharLinha(new Rect(((Rect)(ref value)).x, ((Rect)(ref value)).yMax - 2f, ((Rect)(ref value)).width, 2f));
			DesenharLinha(new Rect(((Rect)(ref value)).x, ((Rect)(ref value)).y, 2f, ((Rect)(ref value)).height));
			DesenharLinha(new Rect(((Rect)(ref value)).xMax - 2f, ((Rect)(ref value)).y, 2f, ((Rect)(ref value)).height));
			float tamanho = Mathf.Clamp(tamanhoIconesEditor.Value, 12f, 80f);
			float tamanho2 = Mathf.Clamp(tamanhoIconesEditor.Value * 0.58f, 8f, 48f);
			DesenharHandleCanto(((Rect)(ref value)).xMin, ((Rect)(ref value)).yMin, tamanho, 180f);
			DesenharHandleCanto(((Rect)(ref value)).xMax, ((Rect)(ref value)).yMin, tamanho, 270f);
			DesenharHandleCanto(((Rect)(ref value)).xMax, ((Rect)(ref value)).yMax, tamanho, 0f);
			DesenharHandleCanto(((Rect)(ref value)).xMin, ((Rect)(ref value)).yMax, tamanho, 90f);
			DesenharHandleLateral(((Rect)(ref value)).center.x, ((Rect)(ref value)).yMin, tamanho2);
			DesenharHandleLateral(((Rect)(ref value)).xMin, ((Rect)(ref value)).center.y, tamanho2);
			DesenharHandleLateral(((Rect)(ref value)).xMax, ((Rect)(ref value)).center.y, tamanho2);
			DesenharHandleLateral(((Rect)(ref value)).center.x, ((Rect)(ref value)).yMax, tamanho2);
			float num = Mathf.Clamp(tamanhoIconesEditor.Value * 1.15f, 16f, 90f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref value)).center.x - num * 0.5f, ((Rect)(ref value)).yMin - num - 14f, num, num);
			DesenharHandleRotacao(val2);
			float num2 = Mathf.Clamp(tamanhoIconesEditor.Value * 1.15f, 14f, 90f);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(((Rect)(ref value)).center.x - num2 * 0.5f, ((Rect)(ref value)).center.y - num2 * 0.5f, num2, num2);
			Vector2 val4 = ((Event.current != null) ? Event.current.mousePosition : Vector2.zero);
			GUI.color = (Color)(((Rect)(ref val3)).Contains(val4) ? new Color(1f, 0.78f, 0.25f, 1f) : Color.white);
			if ((Object)(object)texMove != (Object)null)
			{
				GUI.DrawTexture(val3, (Texture)(object)texMove, (ScaleMode)2, true);
			}
			else
			{
				GUI.Box(val3, "+");
			}
			bool flag = ProcessarRotacaoVisual(value, val2, editableHudElement);
			if (!flag)
			{
				flag = ProcessarResizeCantos(value, editableHudElement);
			}
			if (!flag)
			{
				flag = ProcessarResizeLaterais(value, editableHudElement);
			}
			if (!flag)
			{
				ProcessarMoverPelaCaixa(value, editableHudElement);
			}
			GUI.color = new Color(1f, 1f, 1f, 0.95f);
			GUI.Label(new Rect(((Rect)(ref value)).x, ((Rect)(ref value)).y - 20f, Mathf.Max(160f, ((Rect)(ref value)).width), 20f), elementoAtual);
			GUI.color = color;
		}
	}

	private Rect? ObterRectTela(IEditableHudElement atual)
	{
		if (atual is HudElement hudElement)
		{
			return RectTransformParaTela(hudElement.rt);
		}
		if (atual is HudGroup hudGroup)
		{
			return hudGroup.ObterRectTela();
		}
		return null;
	}

	private Rect? RectTransformParaTela(RectTransform rt)
	{
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rt == (Object)null)
		{
			return null;
		}
		bool achou = false;
		float xMin = 0f;
		float yMin = 0f;
		float xMax = 0f;
		float yMax = 0f;
		RectTransform[] componentsInChildren = ((Component)rt).GetComponentsInChildren<RectTransform>(true);
		RectTransform[] array = componentsInChildren;
		foreach (RectTransform val in array)
		{
			if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy && RectTransformTemVisualVisivel(val))
			{
				AdicionarCornersTela(val, ref achou, ref xMin, ref yMin, ref xMax, ref yMax);
			}
		}
		if (!achou)
		{
			AdicionarCornersTela(rt, ref achou, ref xMin, ref yMin, ref xMax, ref yMax);
		}
		if (!achou)
		{
			return null;
		}
		float num = Mathf.Max(Mathf.Abs(xMax - xMin), 24f);
		float num2 = Mathf.Max(Mathf.Abs(yMax - yMin), 24f);
		return new Rect(xMin, (float)Screen.height - yMax, num, num2);
	}

	private bool RectTransformTemVisualVisivel(RectTransform rt)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rt == (Object)null)
		{
			return false;
		}
		Graphic component = ((Component)rt).GetComponent<Graphic>();
		if ((Object)(object)component != (Object)null)
		{
			if (!((Behaviour)component).enabled)
			{
				return false;
			}
			if (component.color.a <= 0.01f)
			{
				return false;
			}
			return true;
		}
		CanvasRenderer component2 = ((Component)rt).GetComponent<CanvasRenderer>();
		if ((Object)(object)component2 != (Object)null && component2.GetAlpha() > 0.01f)
		{
			return true;
		}
		return false;
	}

	private void AdicionarCornersTela(RectTransform rt, ref bool achou, ref float xMin, ref float yMin, ref float xMax, ref float yMax)
	{
		if ((Object)(object)rt == (Object)null)
		{
			return;
		}
		Vector3[] array = (Vector3[])(object)new Vector3[4];
		rt.GetWorldCorners(array);
		for (int i = 0; i < 4; i++)
		{
			float x = array[i].x;
			float y = array[i].y;
			if (!achou)
			{
				xMin = x;
				yMin = y;
				xMax = x;
				yMax = y;
				achou = true;
			}
			else
			{
				xMin = Mathf.Min(xMin, x);
				yMin = Mathf.Min(yMin, y);
				xMax = Mathf.Max(xMax, x);
				yMax = Mathf.Max(yMax, y);
			}
		}
	}

	private void DesenharLinha(Rect r)
	{
		//IL_0024: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		GUI.color = (Color)(hoverCaixa ? new Color(1f, 0.78f, 0.25f, 1f) : Color.white);
		GUI.Box(r, "");
	}

	private void DesenharTexturaRotacionada(Rect rect, Texture2D tex, float angulo)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0039: 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)
		if ((Object)(object)tex == (Object)null)
		{
			GUI.Box(rect, "");
			return;
		}
		Matrix4x4 matrix = GUI.matrix;
		GUIUtility.RotateAroundPivot(angulo, ((Rect)(ref rect)).center);
		GUI.DrawTexture(rect, (Texture)(object)tex, (ScaleMode)2, true);
		GUI.matrix = matrix;
	}

	private void DesenharHandleCanto(float x, float y, float tamanho, float rotacao)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_005a: 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_008c: 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)
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(x - tamanho * 0.5f, y - tamanho * 0.5f, tamanho, tamanho);
		Event current = Event.current;
		Vector2 val2 = ((current != null) ? current.mousePosition : Vector2.zero);
		GUI.color = (Color)(((Rect)(ref val)).Contains(val2) ? new Color(1f, 0.78f, 0.25f, 1f) : Color.white);
		if ((Object)(object)texScaleCorner != (Object)null)
		{
			DesenharTexturaRotacionada(val, texScaleCorner, rotacao);
		}
		else
		{
			GUI.Box(val, "");
		}
	}

	private void DesenharHandleLateral(float x, float y, float tamanho)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_005a: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(x - tamanho * 0.5f, y - tamanho * 0.5f, tamanho, tamanho);
		Event current = Event.current;
		Vector2 val2 = ((current != null) ? current.mousePosition : Vector2.zero);
		GUI.color = (Color)(((Rect)(ref val)).Contains(val2) ? new Color(1f, 0.78f, 0.25f, 1f) : Color.white);
		GUI.Box(val, "");
	}

	private void DesenharHandleRotacao(Rect r)
	{
		//IL_0012: 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_0017: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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)
		Event current = Event.current;
		Vector2 val = ((current != null) ? current.mousePosition : Vector2.zero);
		GUI.color = (Color)((((Rect)(ref r)).Contains(val) || rotacionandoVisual) ? new Color(1f, 0.78f, 0.25f, 1f) : Color.white);
		if ((Object)(object)texRotate != (Object)null)
		{
			GUI.DrawTexture(r, (Texture)(object)texRotate, (ScaleMode)2, true);
		}
		else
		{
			GUI.Box(r, "⟳");
		}
	}

	private bool MouseSobreAlgumHandle(Rect r, Vector2 mouse)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_00d7: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: 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_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp(tamanhoIconesEditor.Value, 12f, 80f);
		Rect[] array = (Rect[])(object)new Rect[8]
		{
			new Rect(((Rect)(ref r)).xMin - num * 0.5f, ((Rect)(ref r)).yMin - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).center.x - num * 0.5f, ((Rect)(ref r)).yMin - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).xMax - num * 0.5f, ((Rect)(ref r)).yMin - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).xMin - num * 0.5f, ((Rect)(ref r)).center.y - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).xMax - num * 0.5f, ((Rect)(ref r)).center.y - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).xMin - num * 0.5f, ((Rect)(ref r)).yMax - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).center.x - num * 0.5f, ((Rect)(ref r)).yMax - num * 0.5f, num, num),
			new Rect(((Rect)(ref r)).xMax - num * 0.5f, ((Rect)(ref r)).yMax - num * 0.5f, num, num)
		};
		Rect[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			Rect val = array2[i];
			if (((Rect)(ref val)).Contains(mouse))
			{
				return true;
			}
		}
		return false;
	}

	private bool ProcessarRotacaoVisual(Rect box, Rect rotateRect, IEditableHudElement atual)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Invalid comparison between Unknown and I4
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Invalid comparison between Unknown and I4
		//IL_00e2: 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)
		if (atual == null)
		{
			return false;
		}
		if (!atual.OriginalSalvo)
		{
			return false;
		}
		Event current = Event.current;
		if (current == null)
		{
			return false;
		}
		Vector2 mousePosition = current.mousePosition;
		bool flag = ((Rect)(ref rotateRect)).Contains(mousePosition);
		if ((int)current.type == 0 && current.button == 0 && flag)
		{
			rotacionandoVisual = true;
			anguloMouseInicial = CalcularAnguloMouse(((Rect)(ref box)).center, mousePosition);
			rotacaoInicialElemento = atual.Rotacao.Value;
			current.Use();
			return true;
		}
		if ((int)current.type == 1)
		{
			rotacionandoVisual = false;
			return false;
		}
		if (rotacionandoVisual && (int)current.type == 3)
		{
			float num = CalcularAnguloMouse(((Rect)(ref box)).center, mousePosition);
			float num2 = Mathf.DeltaAngle(anguloMouseInicial, num);
			atual.Rotacao.Value = NormalizarAngulo(rotacaoInicialElemento + num2);
			atual.Aplicar();
			current.Use();
			return true;
		}
		return rotacionandoVisual;
	}

	private float CalcularAnguloMouse(Vector2 centro, Vector2 mouse)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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)
		Vector2 val = mouse - centro;
		return Mathf.Atan2(val.y, val.x) * 57.29578f;
	}

	private float NormalizarAngulo(float angulo)
	{
		while (angulo > 180f)
		{
			angulo -= 360f;
		}
		while (angulo < -180f)
		{
			angulo += 360f;
		}
		return angulo;
	}

	private Vector2 EixoLocalX(IEditableHudElement atual)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		float num = atual.Rotacao.Value * ((float)Math.PI / 180f);
		Vector2 val = new Vector2(Mathf.Cos(num), 0f - Mathf.Sin(num));
		return ((Vector2)(ref val)).normalized;
	}

	private Vector2 EixoLocalY(IEditableHudElement atual)
	{
		//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)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		float num = atual.Rotacao.Value * ((float)Math.PI / 180f);
		Vector2 val = new Vector2(Mathf.Sin(num), Mathf.Cos(num));
		return ((Vector2)(ref val)).normalized;
	}

	private bool ProcessarResizeCantos(Rect r, IEditableHudElement atual)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: 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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Invalid comparison between Unknown and I4
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Invalid comparison between Unknown and I4
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		if (atual == null)
		{
			return false;
		}
		if (!atual.OriginalSalvo)
		{
			return false;
		}
		Event current = Event.current;
		if (current == null)
		{
			return false;
		}
		Vector2 mousePosition = current.mousePosition;
		float num = Mathf.Clamp(tamanhoIconesEditor.Value, 12f, 80f);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(((Rect)(ref r)).xMin - num * 0.5f, ((Rect)(ref r)).yMin - num * 0.5f, num, num);
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(((Rect)(ref r)).xMax - num * 0.5f, ((Rect)(ref r)).yMin - num * 0.5f, num, num);
		Rect val3 = default(Rect);
		((Rect)(ref val3))..ctor(((Rect)(ref r)).xMin - num * 0.5f, ((Rect)(ref r)).yMax - num * 0.5f, num, num);
		Rect val4 = default(Rect);
		((Rect)(ref val4))..ctor(((Rect)(ref r)).xMax - num * 0.5f, ((Rect)(ref r)).yMax - num * 0.5f, num, num);
		bool flag = ((Rect)(ref val)).Contains(mousePosition);
		bool flag2 = ((Rect)(ref val2)).Contains(mousePosition);
		bool flag3 = ((Rect)(ref val3)).Contains(mousePosition);
		bool flag4 = ((Rect)(ref val4)).Contains(mousePosition);
		bool flag5 = flag || flag2 || flag3 || flag4;
		if ((int)current.type == 0 && current.button == 0 && flag5)
		{
			redimensionandoCanto = true;
			ultimoMouseResize = mousePosition;
			Vector2 val5 = EixoLocalX(atual);
			Vector2 val6 = EixoLocalY(atual);
			Vector2 val7;
			if (flag)
			{
				val7 = -val5 - val6;
				direcaoResizeCanto = ((Vector2)(ref val7)).normalized;
			}
			else if (flag2)
			{
				val7 = val5 - val6;
				direcaoResizeCanto = ((Vector2)(ref val7)).normalized;
			}
			else if (flag4)
			{
				val7 = val5 + val6;
				direcaoResizeCanto = ((Vector2)(ref val7)).normalized;
			}
			else if (flag3)
			{
				val7 = -val5 + val6;
				direcaoResizeCanto = ((Vector2)(ref val7)).normalized;
			}
			current.Use();
			return true;
		}
		if ((int)current.type == 1)
		{
			redimensionandoCanto = false;
			direcaoResizeCanto = Vector2.zero;
			return false;
		}
		if (redimensionandoCanto && (int)current.type == 3)
		{
			Vector2 val8 = mousePosition - ultimoMouseResize;
			ultimoMouseResize = mousePosition;
			float num2 = Vector2.Dot(val8, direcaoResizeCanto);
			float num3 = num2 * 0.01f;
			atual.Escala.Value = Mathf.Clamp(atual.Escala.Value + num3, 0.2f, 3f);
			atual.Aplicar();
			current.Use();
			return true;
		}
		return redimensionandoCanto;
	}

	private bool ProcessarResizeLaterais(Rect r, IEditableHudElement atual)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: 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_01d4: Invalid comparison between Unknown and I4
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Invalid comparison between Unknown and I4
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		if (atual == null)
		{
			return false;
		}
		if (!atual.OriginalSalvo)
		{
			return false;
		}
		Event current = Event.current;
		if (current == null)
		{
			return false;
		}
		Vector2 mousePosition = current.mousePosition;
		float num = Mathf.Clamp(tamanhoIconesEditor.Value * 0.58f, 8f, 48f);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(((Rect)(ref r)).center.x - num * 0.5f, ((Rect)(ref r)).yMin - num * 0.5f, num, num);
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(((Rect)(ref r)).center.x - num * 0.5f, ((Rect)(ref r)).yMax - num * 0.5f, num, num);
		Rect val3 = default(Rect);
		((Rect)(ref val3))..ctor(((Rect)(ref r)).xMin - num * 0.5f, ((Rect)(ref r)).center.y - num * 0.5f, num, num);
		Rect val4 = default(Rect);
		((Rect)(ref val4))..ctor(((Rect)(ref r)).xMax - num * 0.5f, ((Rect)(ref r)).center.y - num * 0.5f, num, num);
		bool flag = ((Rect)(ref val)).Contains(mousePosition);
		bool flag2 = ((Rect)(ref val2)).Contains(mousePosition);
		bool flag3 = ((Rect)(ref val3)).Contains(mousePosition);
		bool flag4 = ((Rect)(ref val4)).Contains(mousePosition);
		bool flag5 = flag || flag2 || flag3 || flag4;
		if ((int)current.type == 0 && current.button == 0 && flag5)
		{
			redimensionandoLateral = true;
			ultimoMouseResizeLateral = mousePosition;
			if (flag3)
			{
				tipoResizeLateral = -1;
			}
			else if (flag4)
			{
				tipoResizeLateral = 1;
			}
			else if (flag)
			{
				tipoResizeLateral = -2;
			}
			else if (flag2)
			{
				tipoResizeLateral = 2;
			}
			current.Use();
			return true;
		}
		if ((int)current.type == 1)
		{
			redimensionandoLateral = false;
			tipoResizeLateral = 0;
			return false;
		}
		if (redimensionandoLateral && (int)current.type == 3)
		{
			Vector2 val5 = mousePosition - ultimoMouseResizeLateral;
			ultimoMouseResizeLateral = mousePosition;
			Vector2 val6 = EixoLocalX(atual);
			Vector2 val7 = EixoLocalY(atual);
			if (tipoResizeLateral == -1)
			{
				float num2 = Vector2.Dot(val5, -val6);
				atual.EscalaX.Value = Mathf.Clamp(atual.EscalaX.Value + num2 * 0.01f, 0.2f, 3f);
			}
			else if (tipoResizeLateral == 1)
			{
				float num3 = Vector2.Dot(val5, val6);
				atual.EscalaX.Value = Mathf.Clamp(atual.EscalaX.Value + num3 * 0.01f, 0.2f, 3f);
			}
			else if (tipoResizeLateral == -2)
			{
				float num4 = Vector2.Dot(val5, -val7);
				atual.EscalaY.Value = Mathf.Clamp(atual.EscalaY.Value + num4 * 0.01f, 0.2f, 3f);
			}
			else if (tipoResizeLateral == 2)
			{
				float num5 = Vector2.Dot(val5, val7);
				atual.EscalaY.Value = Mathf.Clamp(atual.EscalaY.Value + num5 * 0.01f, 0.2f, 3f);
			}
			atual.Aplicar();
			current.Use();
			return true;
		}
		return redimensionandoLateral;
	}

	private void ProcessarMoverPelaCaixa(Rect caixaRect, IEditableHudElement atual)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Invalid comparison between Unknown and I4
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Invalid comparison between Unknown and I4
		//IL_00c6: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		if (atual == null || !atual.OriginalSalvo || atual.Modo == MoveMode.NoMove)
		{
			return;
		}
		Event current = Event.current;
		if (current != null)
		{
			Vector2 mousePosition = current.mousePosition;
			bool flag = ((Rect)(ref caixaRect)).Contains(mousePosition);
			if ((int)current.type == 0 && current.button == 0 && flag)
			{
				arrastandoCentro = true;
				ultimoMouseCentro = mousePosition;
				current.Use();
			}
			else if ((int)current.type == 1)
			{
				arrastandoCentro = false;
			}
			else if (arrastandoCentro && (int)current.type == 3)
			{
				Vector2 val = mousePosition - ultimoMouseCentro;
				ultimoMouseCentro = mousePosition;
				ConfigEntry<float> offsetX = atual.OffsetX;
				offsetX.Value += val.x;
				ConfigEntry<float> offsetY = atual.OffsetY;
				offsetY.Value -= val.y;
				atual.Aplicar();
				current.Use();
			}
		}
	}

	private void RegistrarElemento(string nome, string caminho, bool vanilla, Categoria categoria, MoveMode modo)
	{
		elementos[nome] = new HudElement(this, nome, caminho, vanilla, categoria, modo);
	}

	private void RegistrarGrupo(string nome, Categoria categoria, GroupPartSetup[] partes, bool usaEspacamento)
	{
		elementos[nome] = new HudGroup(this, nome, categoria, partes, usaEspacamento);
	}

	private bool DeveMostrar(IEditableHudElement e)
	{
		return true;
	}

	private IEditableHudElement Atual()
	{
		if (!elementos.ContainsKey(elementoAtual) || !DeveMostrar(elementos[elementoAtual]))
		{
			foreach (KeyValuePair<string, IEditableHudElement> elemento in elementos)
			{
				if (DeveMostrar(elemento.Value))
				{
					elementoAtual = elemento.Key;
					break;
				}
			}
		}
		return elementos[elementoAtual];
	}

	private void ProcessarArraste()
	{
		//IL_0033: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Invalid comparison between Unknown and I4
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Invalid comparison between Unknown and I4
		//IL_0084: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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)
		IEditableHudElement editableHudElement = Atual();
		if (editableHudElement.OriginalSalvo && editableHudElement.Modo != MoveMode.NoMove)
		{
			Event current = Event.current;
			if ((int)current.type == 0 && current.button == 0)
			{
				arrastando = true;
				ultimoMouse = current.mousePosition;
				current.Use();
			}
			if (arrastando && (int)current.type == 3)
			{
				Vector2 val = current.mousePosition - ultimoMouse;
				ConfigEntry<float> offsetX = editableHudElement.OffsetX;
				offsetX.Value += val.x;
				ConfigEntry<float> offsetY = editableHudElement.OffsetY;
				offsetY.Value -= val.y;
				ultimoMouse = current.mousePosition;
				current.Use();
			}
			if ((int)current.type == 1)
			{
				arrastando = false;
			}
		}
	}

	private void DesenharMenu(int id)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		if (GUI.Button(new Rect(((Rect)(ref menuRect)).width - 32f, 5f, 26f, 22f), "X"))
		{
			mostrarMenu = false;
			return;
		}
		GUILayout.Space(22f);
		GUILayout.Label("Valheim HUD Master 1.9.1", Array.Empty<GUILayoutOption>());
		GUILayout.Space(6f);
		scrollElementos = GUILayout.BeginScrollView(scrollElementos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(((Rect)(ref menuRect)).height - 360f) });
		DesenharCategoria("Vanilla", Categoria.Vanilla, ref categoriaVanilla);
		DesenharCategoria("Marketplace", Categoria.Marketplace, ref categoriaMarketplace);
		DesenharCategoria("Epic MMO", Categoria.EpicMMO, ref categoriaEpicMMO);
		GUILayout.Space(10f);
		DesenharEditorElemento();
		GUILayout.EndScrollView();
		GUILayout.Space(10f);
		DesenharBotoes();
		GUI.DragWindow();
	}

	private void DesenharCategoria(string titulo, Categoria categoria, ref bool aberta)
	{
		string text = (aberta ? "▼ " : "▶ ");
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button(text + titulo, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
		{
			aberta = !aberta;
		}
		if (GUILayout.Button("↻", (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(34f),
			GUILayout.Height(26f)
		}))
		{
			ResetarCategoria(categoria);
		}
		GUILayout.EndHorizontal();
		if (!aberta)
		{
			return;
		}
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		foreach (KeyValuePair<string, IEditableHudElement> elemento in elementos)
		{
			if (elemento.Value.Categoria == categoria && GUILayout.Toggle(elementoAtual == elemento.Key, elemento.Key, Array.Empty<GUILayoutOption>()))
			{
				elementoAtual = elemento.Key;
			}
		}
		GUILayout.EndVertical();
	}

	private void ResetarCategoria(Categoria categoria)
	{
		foreach (IEditableHudElement value in elementos.Values)
		{
			if (value.Categoria == categoria)
			{
				value.Resetar();
			}
		}
		((BaseUnityPlugin)this).Config.Save();
		((BaseUnityPlugin)this).Logger.LogInfo((object)("[HUD MASTER] Categoria resetada: " + categoria));
	}

	private void DesenharEditorElemento()
	{
		IEditableHudElement editableHudElement = Atual();
		GUILayout.Label("Editando: " + elementoAtual, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Modo: " + editableHudElement.ModoDescricao, Array.Empty<GUILayoutOption>());
		if (!editableHudElement.OriginalSalvo)
		{
			GUILayout.Label("Aguardando elemento aparecer...", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Se for UI de mod, abra a janela correspondente.", Array.Empty<GUILayoutOption>());
			return;
		}
		editableHudElement.Visivel.Value = GUILayout.Toggle(editableHudElement.Visivel.Value, "Elemento visivel", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Opacidade: " + editableHudElement.Opacidade.Value.ToString("0") + "%", Array.Empty<GUILayoutOption>());
		editableHudElement.Opacidade.Value = GUILayout.HorizontalSlider(editableHudElement.Opacidade.Value, 0f, 100f, Array.Empty<GUILayoutOption>());
		if (editableHudElement.Modo != MoveMode.NoMove)
		{
			editarMovimento = GUILayout.Toggle(editarMovimento, "ATIVAR MODO MOVER COM MOUSE", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Offset X: " + editableHudElement.OffsetX.Value.ToString("0"), Array.Empty<GUILayoutOption>());
			GUILayout.Label("Offset Y: " + editableHudElement.OffsetY.Value.ToString("0"), Array.Empty<GUILayoutOption>());
		}
		else
		{
			GUILayout.Label("Este elemento usa movimento nativo.", Array.Empty<GUILayoutOption>());
			GUILayout.Label("HUD Master altera apenas tamanho, rotacao e opacidade.", Array.Empty<GUILayoutOption>());
		}
		GUILayout.Space(8f);
		GUILayout.Label("Tamanho geral: " + editableHudElement.Escala.Value.ToString("0.00"), Array.Empty<GUILayoutOption>());
		editableHudElement.Escala.Value = GUILayout.HorizontalSlider(editableHudElement.Escala.Value, 0.2f, 3f, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Largura X: " + editableHudElement.EscalaX.Value.ToString("0.00"), Array.Empty<GUILayoutOption>());
		editableHudElement.EscalaX.Value = GUILayout.HorizontalSlider(editableHudElement.EscalaX.Value, 0.2f, 3f, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Altura Y: " + editableHudElement.EscalaY.Value.ToString("0.00"), Array.Empty<GUILayoutOption>());
		editableHudElement.EscalaY.Value = GUILayout.HorizontalSlider(editableHudElement.EscalaY.Value, 0.2f, 3f, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Rotacao: " + editableHudElement.Rotacao.Value.ToString("0"), Array.Empty<GUILayoutOption>());
		editableHudElement.Rotacao.Value = GUILayout.HorizontalSlider(editableHudElement.Rotacao.Value, -180f, 180f, Array.Empty<GUILayoutOption>());
		GUILayout.Space(8f);
		GUILayout.Label("Tamanho dos icones do editor: " + tamanhoIconesEditor.Value.ToString("0"), Array.Empty<GUILayoutOption>());
		tamanhoIconesEditor.Value = GUILayout.HorizontalSlider(tamanhoIconesEditor.Value, 12f, 80f, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Aplica em: quinas, laterais e icone central.", Array.Empty<GUILayoutOption>());
		if (editableHudElement is HudGroup hudGroup && hudGroup.UsaEspacamento)
		{
			GUILayout.Label("Espacamento: " + hudGroup.Espacamento.Value.ToString("0.00"), Array.Empty<GUILayoutOption>());
			hudGroup.Espacamento.Value = GUILayout.HorizontalSlider(hudGroup.Espacamento.Value, 0.5f, 3f, Array.Empty<GUILayoutOption>());
		}
	}

	private void DesenharBotoes()
	{
		//IL_0144: 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)
		IEditableHudElement editableHudElement = Atual();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("SALVAR LAYOUT", Array.Empty<GUILayoutOption>()))
		{
			((BaseUnityPlugin)this).Config.Save();
		}
		if (GUILayout.Button("RESETAR ATUAL", Array.Empty<GUILayoutOption>()))
		{
			editableHudElement.Resetar();
			((BaseUnityPlugin)this).Config.Save();
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("RESETAR TUDO", Array.Empty<GUILayoutOption>()))
		{
			foreach (IEditableHudElement value2 in elementos.Values)
			{
				value2.Resetar();
			}
			((BaseUnityPlugin)this).Config.Save();
		}
		GUILayout.Space(6f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("BACKUP CFG", Array.Empty<GUILayoutOption>()))
		{
			BackupCFG();
		}
		if (GUILayout.Button("LOAD CFG", Array.Empty<GUILayoutOption>()))
		{
			LoadCFG();
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("ABRIR PASTA CFG", Array.Empty<GUILayoutOption>()))
		{
			AbrirPastaHUD();
		}
		GUILayout.Space(6f);
		KeyCode value = teclaEditor.Value;
		GUILayout.Label(((object)(KeyCode)(ref value)).ToString() + " abre/fecha editor.  ↻ reseta uma categoria.", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Visual Editor: resize usa eixo local rotacionado.", Array.Empty<GUILayoutOption>());
	}

	private void BackupCFG()
	{
		string text = PastaHUD();
		if (!Directory.Exists(text))
		{
			Directory.CreateDirectory(text);
		}
		string text2 = Path.Combine(text, "MyHUD.cfg");
		File.Copy(((BaseUnityPlugin)this).Config.ConfigFilePath, text2, overwrite: true);
		((BaseUnityPlugin)this).Logger.LogInfo((object)("[HUD MASTER] Backup CFG salvo em: " + text2));
	}

	private void LoadCFG()
	{
		string path = PastaHUD();
		string text = Path.Combine(path, "MyHUD.cfg");
		if (!File.Exists(text))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"[HUD MASTER] MyHUD.cfg nao encontrado.");
			return;
		}
		File.Copy(text, ((BaseUnityPlugin)this).Config.ConfigFilePath, overwrite: true);
		((BaseUnityPlugin)this).Config.Reload();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[HUD MASTER] CFG carregado.");
	}

	private void AbrirPastaHUD()
	{
		string text = PastaHUD();
		if (!Directory.Exists(text))
		{
			Directory.CreateDirectory(text);
		}
		Process.Start("explorer.exe", text);
	}

	private string PastaHUD()
	{
		return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "ValheimHUDMaster");
	}

	private void CarregarAssets()
	{
		string path = Path.Combine(Paths.PluginPath, "AndersonMods-ValheimHUDMaster", "assets");
		texMove = CarregarPNG(Path.Combine(path, "handle_move.png"));
		texScaleCorner = CarregarPNG(Path.Combine(path, "handle_scale_corner.png"));
		texRotate = CarregarPNG(Path.Combine(path, "handle_rotate.png"));
		texOutline = CarregarPNG(Path.Combine(path, "selection_outline.png"));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[HUD MASTER] Assets visuais principais carregados.");
	}

	private Texture2D CarregarPNG(string caminho)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		if (!File.Exists(caminho))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[HUD MASTER] PNG nao encontrado: " + caminho));
			return null;
		}
		try
		{
			byte[] array = File.ReadAllBytes(caminho);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false);
			Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule");
			if (type == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[HUD MASTER] ImageConversionModule nao encontrado via reflection.");
				return null;
			}
			MethodInfo method = type.GetMethod("LoadImage", new Type[3]
			{
				typeof(Texture2D),
				typeof(byte[]),
				typeof(bool)
			});
			if (method == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[HUD MASTER] Metodo ImageConversion.LoadImage nao encontrado.");
				return null;
			}
			object obj = method.Invoke(null, new object[3] { val, array, false });
			if (obj is bool && !(bool)obj)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[HUD MASTER] LoadImage retornou false.");
				return null;
			}
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			return val;
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[HUD MASTER] Erro carregando PNG: " + ex.Message));
			return null;
		}
	}

	private Transform BuscarTransform(string caminho, bool vanilla, Categoria categoria)
	{
		if (vanilla)
		{
			if ((Object)(object)Hud.instance == (Object)null)
			{
				return null;
			}
			return ((Component)Hud.instance).transform.Find(caminho);
		}
		GameObject val = GameObject.Find(caminho);
		if ((Object)(object)val != (Object)null)
		{
			return val.transform;
		}
		return null;
	}

	private static void AplicarOpacidade(GameObject go, bool visivel, float opacidadePercent)
	{
		if (!((Object)(object)go == (Object)null))
		{
			float alpha = (visivel ? Mathf.Clamp01(opacidadePercent / 100f) : 0f);
			CanvasGroup val = go.GetComponent<CanvasGroup>();
			if ((Object)(object)val == (Object)null)
			{
				val = go.AddComponent<CanvasGroup>();
			}
			val.alpha = alpha;
			val.interactable = visivel;
			val.blocksRaycasts = visivel;
		}
	}
}