Decompiled source of Mayheim v2.0.21

plugins\ValheimMMO.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using ValheimMMO.Cities;
using ValheimMMO.Config;
using ValheimMMO.Drops;
using ValheimMMO.Dungeons;
using ValheimMMO.Factions;
using ValheimMMO.Food;
using ValheimMMO.Hunger;
using ValheimMMO.Hunts;
using ValheimMMO.InventorySlots;
using ValheimMMO.Items;
using ValheimMMO.Merchant;
using ValheimMMO.Network;
using ValheimMMO.Progression;
using ValheimMMO.Pvp;
using ValheimMMO.Quests;
using ValheimMMO.Social;
using ValheimMMO.Testing;
using ValheimMMO.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ValheimMMO")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.25.97.0")]
[assembly: AssemblyInformationalVersion("0.25.97")]
[assembly: AssemblyProduct("ValheimMMO")]
[assembly: AssemblyTitle("ValheimMMO")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.25.97.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ValheimMMO
{
	[BepInPlugin("com.lucas.valheimmmo", "Mayheim", "2.0.21")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginId = "com.lucas.valheimmmo";

		public const string PluginName = "Mayheim";

		public const string PluginVersion = "2.0.21";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private Harmony _harmony;

		internal static readonly List<string> PatchesComFalha = new List<string>();

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			ModConfig.Bind(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<MmoUI>();
			((Component)this).gameObject.AddComponent<MerchantSellUI>();
			((Component)this).gameObject.AddComponent<QuestNpcUI>();
			((Component)this).gameObject.AddComponent<QuestTracker>();
			((Component)this).gameObject.AddComponent<GroupHud>();
			((Component)this).gameObject.AddComponent<FactionUI>();
			_harmony = new Harmony("com.lucas.valheimmmo");
			PatchIsolated();
			VilaTests.Registrar();
			DescobreTests.Registrar();
			ModTests.Registrar();
			EventoTests.Registrar();
			BotTests.Registrar();
			MercadorTests.Registrar();
			MedidaTests.Registrar();
			InteriorTests.Registrar();
			CofreTests.Registrar();
			ComidaTests.Registrar();
			TeleporteTests.Registrar();
			DropsDumpTests.Registrar();
			LootTests.Registrar();
			LocationDumpTests.Registrar();
			RestauroTests.Registrar();
			TrapacaTests.Registrar();
			Log.LogInfo((object)"Mayheim v2.0.21 carregado.");
		}

		private void PatchIsolated()
		{
			int num = 0;
			PatchesComFalha.Clear();
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Plugin).Assembly);
			foreach (Type type in typesFromAssembly)
			{
				if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0)
				{
					try
					{
						_harmony.CreateClassProcessor(type).Patch();
						num++;
					}
					catch (Exception ex)
					{
						PatchesComFalha.Add(type.FullName + ": " + ex.Message);
						Log.LogError((object)("Falha ao aplicar patch " + type.FullName + ": " + ex.Message));
					}
				}
			}
			int count = PatchesComFalha.Count;
			Log.LogInfo((object)($"Patches aplicados: {num} classes" + ((count > 0) ? $", {count} com falha (ver acima)" : ".")));
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace ValheimMMO.UI
{
	internal static class CharacterButton
	{
		private static Button _button;

		private static InventoryGui _gui;

		internal static void Ensure(InventoryGui gui)
		{
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: 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_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: 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_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_info == (Object)null)
			{
				return;
			}
			if ((Object)(object)_gui != (Object)(object)gui)
			{
				_gui = gui;
				_button = null;
			}
			if ((Object)(object)_button != (Object)null)
			{
				return;
			}
			Button val = null;
			Button val2 = null;
			Button[] componentsInChildren = ((Component)gui.m_info).GetComponentsInChildren<Button>(true);
			foreach (Button val3 in componentsInChildren)
			{
				if ((Object)(object)((Component)val3).transform.parent != (Object)(object)gui.m_info && (Object)(object)((Component)val3).transform.parent.parent != (Object)(object)gui.m_info)
				{
					continue;
				}
				val2 = val3;
				for (int j = 0; j < ((UnityEventBase)val3.onClick).GetPersistentEventCount(); j++)
				{
					if (((UnityEventBase)val3.onClick).GetPersistentMethodName(j) == "OnOpenSkills")
					{
						val = val3;
						break;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				val = val2;
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent, false);
			((Object)val4).name = "MmoCharacterButton";
			_button = val4.GetComponent<Button>();
			_button.onClick = new ButtonClickedEvent();
			((UnityEvent)_button.onClick).AddListener(new UnityAction(Toggle));
			RectTransform component = val4.GetComponent<RectTransform>();
			RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
			Transform parent = ((Component)val).transform.parent;
			List<RectTransform> list = new List<RectTransform>();
			Selectable[] componentsInChildren2 = ((Component)parent).GetComponentsInChildren<Selectable>(true);
			foreach (Selectable val5 in componentsInChildren2)
			{
				if ((Object)(object)((Component)val5).transform.parent == (Object)(object)parent && (Object)(object)((Component)val5).gameObject != (Object)(object)val4 && ((Component)val5).gameObject.activeSelf)
				{
					list.Add(((Component)val5).GetComponent<RectTransform>());
				}
			}
			list.Sort((RectTransform a, RectTransform b) => a.anchoredPosition.x.CompareTo(b.anchoredPosition.x));
			if (list.Count >= 2)
			{
				float x = list[0].anchoredPosition.x;
				float x2 = list[list.Count - 1].anchoredPosition.x;
				float num = (x2 - x) / (float)list.Count;
				for (int num2 = 0; num2 < list.Count; num2++)
				{
					list[num2].anchoredPosition = new Vector2(x + num * (float)num2, list[num2].anchoredPosition.y);
				}
				component.anchoredPosition = new Vector2(x2, component2.anchoredPosition.y);
			}
			else
			{
				component.anchoredPosition = component2.anchoredPosition + new Vector2(96f, 0f);
			}
			Image componentInChildren = val4.GetComponentInChildren<Image>(true);
			ObjectDB instance = ObjectDB.instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				GameObject itemPrefab = instance.GetItemPrefab("HelmetBronze");
				obj = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_icons);
			}
			Sprite[] array = (Sprite[])obj;
			if ((Object)(object)componentInChildren != (Object)null && array != null && array.Length != 0 && (Object)(object)array[0] != (Object)null)
			{
				Image val6 = componentInChildren;
				Image[] componentsInChildren3 = val4.GetComponentsInChildren<Image>(true);
				foreach (Image val7 in componentsInChildren3)
				{
					Rect rect = ((Graphic)val7).rectTransform.rect;
					float width = ((Rect)(ref rect)).width;
					rect = ((Graphic)val6).rectTransform.rect;
					if (width < ((Rect)(ref rect)).width)
					{
						val6 = val7;
					}
				}
				val6.sprite = array[0];
				((Graphic)val6).color = Color.white;
			}
			UITooltip val8 = val4.GetComponent<UITooltip>() ?? val4.GetComponentInChildren<UITooltip>(true);
			if ((Object)(object)val8 != (Object)null)
			{
				val8.m_text = "Personagem: level, atributos, especializacao, grupo e cla";
				val8.m_topic = "Personagem";
			}
			val4.SetActive(true);
		}

		private static void Toggle()
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				if (ModConfig.UnityUiPanel.Value)
				{
					CharacterDialog.Toggle();
				}
				else
				{
					MmoUI.PanelOpen = !MmoUI.PanelOpen;
				}
			}
		}

		internal static void Reset()
		{
			_button = null;
			_gui = null;
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Show")]
	internal static class InventoryGui_Show_CharacterButtonPatch
	{
		private static void Postfix(InventoryGui __instance)
		{
			try
			{
				CharacterButton.Ensure(__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[UI] botao Personagem: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "OnDestroy")]
	internal static class InventoryGui_OnDestroy_CharacterButtonPatch
	{
		private static void Postfix()
		{
			CharacterButton.Reset();
		}
	}
	internal static class CharacterDialog
	{
		private sealed class TextReceiverCb : TextReceiver
		{
			private readonly Action<string> _cb;

			private readonly string _init;

			public TextReceiverCb(string init, Action<string> cb)
			{
				_init = init;
				_cb = cb;
			}

			public string GetText()
			{
				return _init ?? "";
			}

			public void SetText(string text)
			{
				_cb?.Invoke(text);
			}
		}

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

			public static UnityAction <>9__32_0;

			public static UnityAction <>9__49_2;

			public static Action<string> <>9__51_6;

			public static UnityAction <>9__51_1;

			public static Action<string> <>9__51_7;

			public static UnityAction <>9__51_2;

			public static UnityAction <>9__51_3;

			public static UnityAction <>9__51_0;

			internal void <Ensure>b__32_0()
			{
				Close();
			}

			internal void <BuildGroup>b__49_2()
			{
				Group.Leave();
				Rebuild(keepScroll: true);
			}

			internal void <BuildClan>b__51_1()
			{
				TextInput instance = TextInput.instance;
				if (instance != null)
				{
					instance.RequestText((TextReceiver)(object)new TextReceiverCb(_clanName, delegate(string t)
					{
						_clanName = t?.Trim();
						ReopenSoon();
					}), "Nome do cla", Mathf.Clamp(ModConfig.ClanNameMax.Value, 3, 32));
				}
			}

			internal void <BuildClan>b__51_6(string t)
			{
				_clanName = t?.Trim();
				ReopenSoon();
			}

			internal void <BuildClan>b__51_2()
			{
				TextInput instance = TextInput.instance;
				if (instance != null)
				{
					instance.RequestText((TextReceiver)(object)new TextReceiverCb(_clanTag, delegate(string t)
					{
						_clanTag = t?.Trim().ToUpperInvariant();
						ReopenSoon();
					}), "Tag do cla (2-4 letras)", Mathf.Clamp(ModConfig.ClanTagMax.Value, 2, 6));
				}
			}

			internal void <BuildClan>b__51_7(string t)
			{
				_clanTag = t?.Trim().ToUpperInvariant();
				ReopenSoon();
			}

			internal void <BuildClan>b__51_3()
			{
				Clan.Create(_clanName, _clanTag);
				Rebuild(keepScroll: true);
			}

			internal void <BuildClan>b__51_0()
			{
				if (!_clanConfirmLeave)
				{
					_clanConfirmLeave = true;
				}
				else
				{
					Clan.Leave();
					_clanConfirmLeave = false;
				}
				Rebuild(keepScroll: true);
			}
		}

		private static GameObject _root;

		private static InventoryGui _gui;

		private static RectTransform _content;

		private static ScrollRect _scroll;

		private static TMP_Text _fontSource;

		private static Image _bkgSource;

		private static Button _btnTemplate;

		private static Button _upTemplate;

		private static Button _downTemplate;

		private static readonly List<Button> _tabButtons = new List<Button>();

		private static int _tab;

		private static float _refreshT;

		private static string _clanName;

		private static string _clanTag;

		private static bool _clanConfirmLeave;

		private static readonly Color Gold = new Color(1f, 0.72f, 0.3f);

		private static readonly Color Muted = new Color(0.75f, 0.7f, 0.6f);

		private static readonly Color Bonus = new Color(1f, 0.62f, 0.2f);

		private static readonly Color TextC = new Color(0.98f, 0.95f, 0.88f);

		private static readonly Color Good = new Color(0.62f, 0.9f, 0.62f);

		private static readonly Color Bad = new Color(0.9f, 0.4f, 0.35f);

		private const float W = 700f;

		private const float H = 760f;

		private static float _reopenAt = -1f;

		private static string _lastSignature;

		internal static bool IsOpen
		{
			get
			{
				if ((Object)(object)_root != (Object)null)
				{
					return _root.activeSelf;
				}
				return false;
			}
		}

		internal static void Toggle()
		{
			if (IsOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}

		internal static void Open()
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)InventoryGui.instance == (Object)null)
			{
				return;
			}
			if (!InventoryGui.IsVisible())
			{
				InventoryGui.instance.Show((Container)null, 1);
			}
			Ensure();
			if ((Object)(object)_root == (Object)null)
			{
				return;
			}
			_root.SetActive(true);
			_root.transform.SetAsLastSibling();
			MmoUI.PanelOpen = true;
			try
			{
				Rebuild();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"[UI] erro ao montar o painel de personagem: {arg}");
				Close();
			}
		}

		internal static void Close()
		{
			if ((Object)(object)_root != (Object)null)
			{
				_root.SetActive(false);
			}
			MmoUI.PanelOpen = false;
		}

		internal static void OnInventoryHidden()
		{
			if (IsOpen)
			{
				Close();
			}
		}

		internal static void ReopenSoon()
		{
			_reopenAt = Time.time + 0.15f;
		}

		internal static void Tick(float dt)
		{
			if (_reopenAt > 0f && Time.time >= _reopenAt && !TextInput.IsVisible())
			{
				_reopenAt = -1f;
				_tab = 4;
				Open();
			}
			else
			{
				if (!IsOpen)
				{
					return;
				}
				if ((Object)(object)Player.m_localPlayer == (Object)null || !InventoryGui.IsVisible())
				{
					Close();
					return;
				}
				if (ZInput.GetKeyDown((KeyCode)27, true))
				{
					Close();
					return;
				}
				_refreshT += dt;
				if (_refreshT >= 0.5f)
				{
					_refreshT = 0f;
					if (Signature(Player.m_localPlayer) != _lastSignature)
					{
						Rebuild(keepScroll: true);
					}
				}
			}
		}

		private static void Ensure()
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0127: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: 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_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: 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_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Expected O, but got Unknown
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: 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_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)_gui != (Object)(object)instance)
			{
				_root = null;
				_gui = instance;
			}
			if ((Object)(object)_root != (Object)null)
			{
				return;
			}
			Transform val = (((Object)(object)instance.m_inventoryRoot != (Object)null) ? instance.m_inventoryRoot : ((Component)instance).transform);
			object bkgSource;
			if (!((Object)(object)instance.m_player != (Object)null))
			{
				bkgSource = null;
			}
			else
			{
				Transform obj = ((Transform)instance.m_player).Find("Bkg");
				bkgSource = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			}
			_bkgSource = (Image)bkgSource;
			_fontSource = (((Object)(object)instance.m_textsDialog != (Object)null && (Object)(object)instance.m_textsDialog.m_textAreaTopic != (Object)null) ? instance.m_textsDialog.m_textAreaTopic : ((Component)instance).GetComponentInChildren<TMP_Text>(true));
			_btnTemplate = instance.m_tabCraft;
			_upTemplate = instance.m_qualityLevelUp;
			_downTemplate = instance.m_qualityLevelDown;
			_root = new GameObject("MmoCharacterDialog", new Type[1] { typeof(RectTransform) });
			_root.transform.SetParent(val, false);
			RectTransform component = _root.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			component.anchorMax = val2;
			component.anchorMin = val2;
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(700f, 760f);
			component.anchoredPosition = new Vector2(0f, -10f);
			Image val3 = Image(_root.transform, "Bkg");
			Stretch(((Graphic)val3).rectTransform);
			if ((Object)(object)_bkgSource != (Object)null)
			{
				val3.sprite = _bkgSource.sprite;
				((Graphic)val3).material = ((Graphic)_bkgSource).material;
				((Graphic)val3).color = ((Graphic)_bkgSource).color;
				val3.type = _bkgSource.type;
				val3.pixelsPerUnitMultiplier = _bkgSource.pixelsPerUnitMultiplier;
			}
			else
			{
				((Graphic)val3).color = new Color(0.16f, 0.11f, 0.07f, 0.96f);
			}
			((Graphic)val3).raycastTarget = true;
			RectTransform rectTransform = Text(_root.transform, "PERSONAGEM", 26f, Gold, (TextAlignmentOptions)514).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 1f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 1f);
			rectTransform.anchoredPosition = new Vector2(0f, -18f);
			rectTransform.sizeDelta = new Vector2(-40f, 34f);
			Transform transform = _root.transform;
			object obj2 = <>c.<>9__32_0;
			if (obj2 == null)
			{
				UnityAction val4 = delegate
				{
					Close();
				};
				<>c.<>9__32_0 = val4;
				obj2 = (object)val4;
			}
			RectTransform component2 = ((Component)Btn(transform, "X", (UnityAction)obj2, 34f, 30f)).GetComponent<RectTransform>();
			((Vector2)(ref val2))..ctor(1f, 1f);
			component2.anchorMax = val2;
			component2.anchorMin = val2;
			component2.pivot = new Vector2(1f, 1f);
			component2.anchoredPosition = new Vector2(-16f, -14f);
			GameObject val5 = new GameObject("Scroll", new Type[4]
			{
				typeof(RectTransform),
				typeof(ScrollRect),
				typeof(RectMask2D),
				typeof(Image)
			});
			val5.transform.SetParent(_root.transform, false);
			RectTransform component3 = val5.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.offsetMin = new Vector2(28f, 26f);
			component3.offsetMax = new Vector2(-28f, -60f);
			((Graphic)val5.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.001f);
			_scroll = val5.GetComponent<ScrollRect>();
			_scroll.horizontal = false;
			_scroll.vertical = true;
			_scroll.movementType = (MovementType)2;
			_scroll.scrollSensitivity = 40f;
			GameObject val6 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val6.transform.SetParent(val5.transform, false);
			_content = val6.GetComponent<RectTransform>();
			_content.anchorMin = new Vector2(0f, 1f);
			_content.anchorMax = new Vector2(1f, 1f);
			_content.pivot = new Vector2(0.5f, 1f);
			_content.offsetMin = Vector2.zero;
			_content.offsetMax = Vector2.zero;
			VerticalLayoutGroup component4 = val6.GetComponent<VerticalLayoutGroup>();
			((LayoutGroup)component4).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component4).spacing = 4f;
			((LayoutGroup)component4).padding = new RectOffset(4, 4, 4, 12);
			val6.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			_scroll.content = _content;
			_scroll.viewport = component3;
		}

		private static void Stretch(RectTransform r)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			r.anchorMin = Vector2.zero;
			r.anchorMax = Vector2.one;
			r.offsetMin = Vector2.zero;
			r.offsetMax = Vector2.zero;
		}

		private static Image Image(Transform parent, string name)
		{
			//IL_0021: 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)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			Image component = val.GetComponent<Image>();
			((Graphic)component).raycastTarget = false;
			return component;
		}

		private static TMP_Text Text(Transform parent, string text, float size, Color color, TextAlignmentOptions align = (TextAlignmentOptions)513, float width = 0f, float height = 0f)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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)
			GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)_fontSource != (Object)null)
			{
				((TMP_Text)val2).font = _fontSource.font;
				((TMP_Text)val2).fontSharedMaterial = _fontSource.fontSharedMaterial;
			}
			((TMP_Text)val2).fontSize = size;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).richText = true;
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((Graphic)val2).raycastTarget = false;
			LayoutElement val3 = val.AddComponent<LayoutElement>();
			if (width > 0f)
			{
				val3.preferredWidth = width;
				val3.minWidth = width;
				val3.flexibleWidth = 0f;
			}
			else
			{
				val3.flexibleWidth = 1f;
			}
			if (height > 0f)
			{
				val3.preferredHeight = height;
			}
			return (TMP_Text)(object)val2;
		}

		private static Button Btn(Transform parent, string label, UnityAction onClick, float w, float h, Button template = null)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			template = template ?? _btnTemplate;
			GameObject val;
			if ((Object)(object)template != (Object)null)
			{
				val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false);
				TMP_Text[] componentsInChildren = val.GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text obj in componentsInChildren)
				{
					obj.text = label;
					obj.textWrappingMode = (TextWrappingModes)0;
					obj.overflowMode = (TextOverflowModes)0;
					obj.fontSize = Mathf.Min(obj.fontSize, 16f);
				}
				UITooltip component = val.GetComponent<UITooltip>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_text = "";
					component.m_topic = "";
				}
			}
			else
			{
				val = new GameObject("Btn", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Button)
				});
				val.transform.SetParent(parent, false);
				((Graphic)val.GetComponent<Image>()).color = new Color(0.3f, 0.22f, 0.14f, 1f);
				Stretch(Text(val.transform, label, 14f, TextC, (TextAlignmentOptions)514).rectTransform);
			}
			((Object)val).name = "Btn_" + label;
			val.SetActive(true);
			Button component2 = val.GetComponent<Button>();
			component2.onClick = new ButtonClickedEvent();
			((UnityEvent)component2.onClick).AddListener(onClick);
			((Selectable)component2).interactable = true;
			val.GetComponent<RectTransform>().sizeDelta = new Vector2(w, h);
			LayoutElement obj2 = val.GetComponent<LayoutElement>() ?? val.AddComponent<LayoutElement>();
			obj2.preferredWidth = w;
			obj2.minWidth = w;
			obj2.preferredHeight = h;
			obj2.minHeight = h;
			obj2.flexibleWidth = 0f;
			return component2;
		}

		private static RectTransform Row(Transform parent, float h, float spacing = 8f)
		{
			//IL_0032: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Row", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>();
			((LayoutGroup)component).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component).spacing = spacing;
			LayoutElement component2 = val.GetComponent<LayoutElement>();
			component2.preferredHeight = h;
			component2.minHeight = h;
			component2.flexibleWidth = 1f;
			return val.GetComponent<RectTransform>();
		}

		private static void Space(Transform parent, float h)
		{
			//IL_0025: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Space", new Type[2]
			{
				typeof(RectTransform),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			val.GetComponent<LayoutElement>().preferredHeight = h;
			val.GetComponent<LayoutElement>().minHeight = h;
		}

		private static void Separator(Transform parent)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Image obj = Image(parent, "Sep");
			((Graphic)obj).color = new Color(1f, 0.85f, 0.55f, 0.35f);
			LayoutElement obj2 = ((Component)obj).gameObject.AddComponent<LayoutElement>();
			obj2.preferredHeight = 2f;
			obj2.minHeight = 2f;
			obj2.flexibleWidth = 1f;
		}

		private static void Bar(Transform parent, float pct, string label, Color fill)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			Image obj = Image(parent, "Bar");
			((Graphic)obj).color = new Color(0f, 0f, 0f, 0.55f);
			LayoutElement obj2 = ((Component)obj).gameObject.AddComponent<LayoutElement>();
			obj2.preferredHeight = 22f;
			obj2.minHeight = 22f;
			obj2.flexibleWidth = 1f;
			Image obj3 = Image(((Component)obj).transform, "Fill");
			((Graphic)obj3).color = fill;
			RectTransform rectTransform = ((Graphic)obj3).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(Mathf.Clamp01(pct), 1f);
			rectTransform.offsetMin = new Vector2(2f, 2f);
			rectTransform.offsetMax = new Vector2(-2f, -2f);
			TMP_Text obj4 = Text(((Component)obj).transform, label, 13f, Color.white, (TextAlignmentOptions)514);
			Stretch(obj4.rectTransform);
			Object.Destroy((Object)(object)((Component)obj4).GetComponent<LayoutElement>());
		}

		private static void Clear()
		{
			if (!((Object)(object)_content == (Object)null))
			{
				for (int num = ((Transform)_content).childCount - 1; num >= 0; num--)
				{
					Object.DestroyImmediate((Object)(object)((Component)((Transform)_content).GetChild(num)).gameObject);
				}
			}
		}

		private static string Signature(Player player)
		{
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			PlayerProgress playerProgress = PlayerProgress.Get(player);
			if (playerProgress == null)
			{
				return "";
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(_tab).Append('|').Append(playerProgress.Level)
				.Append('|')
				.Append(playerProgress.Xp)
				.Append('|')
				.Append(playerProgress.SpentPoints)
				.Append('|')
				.Append(playerProgress.UnspentPoints);
			int[] spent = playerProgress.Spent;
			foreach (int value in spent)
			{
				stringBuilder.Append(',').Append(value);
			}
			stringBuilder.Append('|').Append(Titles.ActiveId(player)).Append('|')
				.Append(Titles.Earned(player).Count);
			stringBuilder.Append('|').Append(Group.Members.Count).Append('|')
				.Append(Group.Invites.Count)
				.Append('|')
				.Append(Group.LeaderUid);
			foreach (Group.Member member in Group.Members)
			{
				Player val = Group.FindPlayer(member.Uid);
				stringBuilder.Append(',').Append(member.Uid).Append(':')
					.Append(((Object)(object)val != (Object)null) ? Mathf.RoundToInt(((Character)val).GetHealth()) : (-1));
			}
			stringBuilder.Append('|').Append(Group.Invitable().Count);
			Clan.Info mine = Clan.Mine;
			stringBuilder.Append('|').Append(mine?.Id ?? 0).Append('|')
				.Append(mine?.Xp ?? 0)
				.Append('|')
				.Append(mine?.Bank ?? 0)
				.Append('|')
				.Append(mine?.Members.Count ?? 0)
				.Append('|')
				.Append(Clan.Invites.Count)
				.Append('|')
				.Append(Clan.LastMessage);
			if (mine != null)
			{
				foreach (var member2 in mine.Members)
				{
					stringBuilder.Append(',').Append(member2.uid).Append(Clan.IsOnline(member2.uid) ? 'o' : 'x');
				}
				stringBuilder.Append('|').Append(Clan.Invitable().Count);
			}
			Specialization specialization = (ModConfig.SpecEnabled.Value ? Specialization.Get(player) : null);
			if (specialization != null)
			{
				stringBuilder.Append('|').Append(specialization.Available(player)).Append('|')
					.Append(specialization.SpentTotal);
				Skills skills = ((Character)player).GetSkills();
				SkillType[] allowed = Specialization.Allowed;
				foreach (SkillType val2 in allowed)
				{
					stringBuilder.Append(',').Append(Mathf.RoundToInt(skills.GetSkill(val2).m_level));
				}
			}
			stringBuilder.Append('|').Append(_clanName).Append('|')
				.Append(_clanTag)
				.Append('|')
				.Append(_clanConfirmLeave);
			return stringBuilder.ToString();
		}

		private static void SetTab(int tab)
		{
			_tab = tab;
			Rebuild();
		}

		internal static void Rebuild(bool keepScroll = false)
		{
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Expected O, but got Unknown
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: 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_04bf: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen || (Object)(object)_content == (Object)null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			PlayerProgress playerProgress = PlayerProgress.Get(localPlayer);
			if ((Object)(object)localPlayer == (Object)null || playerProgress == null)
			{
				return;
			}
			float num = ((keepScroll && (Object)(object)_scroll != (Object)null) ? _scroll.verticalNormalizedPosition : 1f);
			Clear();
			_lastSignature = Signature(localPlayer);
			bool flag = playerProgress.Level >= ModConfig.MaxLevel.Value;
			RectTransform parent = Row((Transform)(object)_content, 30f);
			string text = ((ValheimMMO.Factions.Factions.Enabled && ValheimMMO.Factions.Factions.Mine > 0) ? (ValheimMMO.Factions.Factions.Tag(ValheimMMO.Factions.Factions.Mine) + " ") : "");
			string text2 = ((Clan.Enabled && Clan.Mine != null) ? ("<color=#F2C766>[" + Clan.Mine.Tag + "]</color> ") : "");
			string text3 = Titles.ActiveName(localPlayer);
			Text((Transform)(object)parent, text + text2 + "<b>" + localPlayer.GetPlayerName() + "</b>" + ((text3 != null) ? ("  <color=#C9A6FF>" + text3 + "</color>") : ""), 18f, TextC, (TextAlignmentOptions)513);
			Text((Transform)(object)parent, $"<b>Level {playerProgress.Level}</b>" + (flag ? "" : $" <size=13><color=#{ColorUtility.ToHtmlStringRGB(Muted)}>/ {ModConfig.MaxLevel.Value}</color></size>"), 22f, Gold, (TextAlignmentOptions)516, 200f);
			float num2 = (flag ? 1f : playerProgress.LevelProgress);
			Bar((Transform)(object)_content, num2, flag ? "LEVEL MAXIMO" : $"{playerProgress.Xp} / {playerProgress.XpForNextLevel} XP  ({num2 * 100f:0}%)", new Color(0.35f, 0.5f, 0.9f, 0.95f));
			Space((Transform)(object)_content, 6f);
			Specialization specialization = (ModConfig.SpecEnabled.Value ? Specialization.Get(localPlayer) : null);
			int num3 = playerProgress.TotalPoints - playerProgress.SpentPoints;
			int num4 = specialization?.Available(localPlayer) ?? 0;
			List<(int, string)> list = new List<(int, string)> { (0, (num3 > 0) ? $"Atributos ({num3})" : "Atributos") };
			if (specialization != null)
			{
				list.Add((1, (num4 > 0) ? $"Especializacao ({num4})" : "Especializacao"));
			}
			if (ModConfig.GroupEnabled.Value)
			{
				list.Add((3, (Group.Invites.Count > 0) ? "Grupo (!)" : (Group.InGroup ? $"Grupo ({Group.Members.Count})" : "Grupo")));
			}
			if (Clan.Enabled)
			{
				list.Add((4, (Clan.Invites.Count > 0) ? "Cla (!)" : ((Clan.Mine != null) ? ("Cla [" + Clan.Mine.Tag + "]") : "Cla")));
			}
			bool flag2 = false;
			foreach (var item in list)
			{
				if (item.Item1 == _tab)
				{
					flag2 = true;
				}
			}
			if (!flag2)
			{
				_tab = 0;
			}
			RectTransform parent2 = Row((Transform)(object)_content, 34f, 6f);
			float w = (644f - 6f * (float)(list.Count - 1)) / (float)list.Count;
			foreach (var item2 in list)
			{
				int id = item2.Item1;
				Button val = Btn((Transform)(object)parent2, item2.Item2, (UnityAction)delegate
				{
					SetTab(id);
				}, w, 32f);
				Image val2 = ((Component)val).GetComponent<Image>() ?? ((Component)val).GetComponentInChildren<Image>();
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = (Color)((id == _tab) ? Color.white : new Color(0.7f, 0.7f, 0.7f, 0.85f));
				}
				TMP_Text[] componentsInChildren = ((Component)val).GetComponentsInChildren<TMP_Text>();
				for (int num5 = 0; num5 < componentsInChildren.Length; num5++)
				{
					((Graphic)componentsInChildren[num5]).color = ((id == _tab) ? Gold : TextC);
				}
			}
			Space((Transform)(object)_content, 6f);
			Separator((Transform)(object)_content);
			Space((Transform)(object)_content, 6f);
			switch (_tab)
			{
			case 1:
				BuildSpecialization(localPlayer, playerProgress, specialization);
				break;
			case 3:
				BuildGroup(localPlayer);
				break;
			case 4:
				BuildClan(localPlayer);
				break;
			default:
				BuildAttributes(localPlayer, playerProgress, specialization);
				break;
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(_content);
			if ((Object)(object)_scroll != (Object)null)
			{
				_scroll.verticalNormalizedPosition = (keepScroll ? num : 1f);
			}
		}

		private static string M(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGB(c);
		}

		private static void BuildAttributes(Player player, PlayerProgress prog, Specialization spec)
		{
			//IL_0050: 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_007a: 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_00d6: 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_010f: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Expected O, but got Unknown
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_06de: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Expected O, but got Unknown
			//IL_0717: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			int unspentPoints = prog.UnspentPoints;
			Text((Transform)(object)_content, (unspentPoints > 0) ? string.Format("<color=#{0}><b>{1}</b></color> ponto{2} para distribuir", M(Gold), unspentPoints, (unspentPoints == 1) ? "" : "s") : ("<color=#" + M(Muted) + ">Nenhum ponto disponivel</color>"), 15f, TextC, (TextAlignmentOptions)513);
			Space((Transform)(object)_content, 2f);
			RectTransform parent = Row((Transform)(object)_content, 18f);
			Text((Transform)(object)parent, "<color=#" + M(Muted) + ">ATRIBUTO</color>", 11f, TextC, (TextAlignmentOptions)513, 170f);
			Text((Transform)(object)parent, "<color=#" + M(Muted) + ">PONTOS</color>", 11f, TextC, (TextAlignmentOptions)514, 60f);
			Text((Transform)(object)parent, "", 11f, TextC, (TextAlignmentOptions)513, 84f);
			Text((Transform)(object)parent, "<color=#" + M(Muted) + ">ITENS</color>", 11f, TextC, (TextAlignmentOptions)514, 60f);
			Text((Transform)(object)parent, "<color=#" + M(Muted) + ">EFEITO</color>", 11f, TextC, (TextAlignmentOptions)516);
			prog.ComputeStats(player, out var hp, out var stamina, out var eitr);
			float maxCarryWeight = player.GetMaxCarryWeight();
			int[] array = ItemBonuses.TotalEquipped((Humanoid)(object)player);
			Attr[] all = AttrInfo.All;
			foreach (Attr attr in all)
			{
				int num = (int)attr;
				Attr a = attr;
				RectTransform parent2 = Row((Transform)(object)_content, 34f);
				Text((Transform)(object)parent2, "<b>" + AttrInfo.DisplayName(attr) + "</b>", 16f, TextC, (TextAlignmentOptions)513, 170f);
				Text((Transform)(object)parent2, $"<b>{prog.Spent[num]}</b>", 18f, Gold, (TextAlignmentOptions)514, 60f);
				((Selectable)Btn((Transform)(object)parent2, "+", (UnityAction)delegate
				{
					prog.TrySpend(a, player);
					MmoUI.RefreshStats(player);
					Rebuild(keepScroll: true);
				}, 38f, 28f, _upTemplate)).interactable = unspentPoints > 0;
				((Selectable)Btn((Transform)(object)parent2, "-", (UnityAction)delegate
				{
					if (!prog.TryRefund(a, player, out var reason2))
					{
						((Character)player).Message((MessageType)2, reason2, 0, (Sprite)null, false);
					}
					else
					{
						MmoUI.RefreshStats(player);
					}
					Rebuild(keepScroll: true);
				}, 38f, 28f, _downTemplate)).interactable = prog.Spent[num] > 0 && ModConfig.RespecEnabled.Value;
				Text((Transform)(object)parent2, (array[num] > 0) ? $"<color=#{M(Bonus)}>+{array[num]}</color>" : ("<color=#" + M(Muted) + ">-</color>"), 15f, TextC, (TextAlignmentOptions)514, 60f);
				Text((Transform)(object)parent2, "<color=#" + M(Muted) + ">" + AttrInfo.Effect(attr) + "</color>  <b>" + MmoUI.ValueForPublic(attr, hp, stamina, eitr, maxCarryWeight) + "</b>", 15f, TextC, (TextAlignmentOptions)516);
			}
			Space((Transform)(object)_content, 8f);
			Separator((Transform)(object)_content);
			Space((Transform)(object)_content, 6f);
			string reason;
			bool flag = PlayerProgress.CanRespec(player, out reason);
			((Selectable)Btn((Transform)(object)_content, "Redistribuir todos os pontos", (UnityAction)delegate
			{
				if (prog.RespecAll(player, out var reason2))
				{
					spec?.Reset(player, out var _);
					MmoUI.RefreshStats(player);
					((Character)player).Message((MessageType)2, "Pontos redistribuidos", 0, (Sprite)null, false);
				}
				else
				{
					((Character)player).Message((MessageType)2, reason2, 0, (Sprite)null, false);
				}
				Rebuild(keepScroll: true);
			}, 640f, 30f)).interactable = ModConfig.RespecEnabled.Value && (prog.SpentPoints > 0 || (spec != null && spec.SpentTotal > 0)) && flag;
			if (!flag && ModConfig.RespecEnabled.Value)
			{
				Text((Transform)(object)_content, "<i><color=#" + M(Muted) + ">" + reason + "</color></i>", 12f, TextC, (TextAlignmentOptions)513);
			}
			if (ModConfig.PvpEnabled.Value)
			{
				float num2 = Karma.Local(player);
				Text((Transform)(object)_content, string.Format("<color=#{0}>Karma {1:0.0} · {2}</color>", (num2 >= ModConfig.WantedThreshold.Value) ? "E04A3A" : M(Muted), num2, Karma.StatusName(num2)), 12f, TextC, (TextAlignmentOptions)513);
			}
			Space((Transform)(object)_content, 8f);
			Separator((Transform)(object)_content);
			Space((Transform)(object)_content, 6f);
			List<Titles.Def> list = Titles.Earned(player);
			string text = Titles.ActiveId(player);
			Text((Transform)(object)_content, $"<b>Titulos</b>  <size=12><color=#{M(Muted)}>{list.Count}/{Titles.Defs.Length} · clique para usar como titulo ativo</color></size>", 16f, TextC, (TextAlignmentOptions)513);
			Dictionary<string, long> arg = Titles.Stats(player);
			Titles.Def[] defs = Titles.Defs;
			foreach (Titles.Def def in defs)
			{
				long num3 = def.Value(arg, prog.Level);
				bool flag2 = num3 >= def.Goal;
				bool active = def.Id == text;
				Titles.Def d = def;
				RectTransform parent3 = Row((Transform)(object)_content, 30f);
				((Selectable)Btn((Transform)(object)parent3, (active ? "★ " : "") + def.Name, (UnityAction)delegate
				{
					Titles.SetActive(player, active ? "" : d.Id);
					Rebuild(keepScroll: true);
				}, 240f, 26f)).interactable = flag2;
				Text((Transform)(object)parent3, $"<color=#{(flag2 ? M(Gold) : M(Muted))}>{Math.Min(num3, def.Goal)}/{def.Goal} {def.How}</color>", 13f, TextC, (TextAlignmentOptions)513);
			}
		}

		private static void BuildSpecialization(Player player, PlayerProgress prog, Specialization spec)
		{
			//IL_0066: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: 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_0275: 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_02b6: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Expected O, but got Unknown
			if (spec == null)
			{
				return;
			}
			int num = spec.Available(player);
			int num2 = Specialization.TotalPointsFor(prog.Level);
			int value = ModConfig.SpecLevelsPerPoint.Value;
			int num3 = (prog.Level / value + 1) * value;
			Text((Transform)(object)_content, $"<b>Especializacao</b>  <size=12><color=#{M(Muted)}>{num} de {num2} ponto(s) · 1 a cada {value} levels · +{ModConfig.SpecSkillPerPoint.Value:0} na skill por ponto" + ((num3 <= ModConfig.MaxLevel.Value) ? $" · proximo no level {num3}" : "") + "</color></size>", 15f, TextC, (TextAlignmentOptions)513);
			Space((Transform)(object)_content, 4f);
			Skills skills = ((Character)player).GetSkills();
			SkillType[] allowed = Specialization.Allowed;
			foreach (SkillType val in allowed)
			{
				SkillType st = val;
				float level = skills.GetSkill(val).m_level;
				float num4 = spec.BonusFor(val);
				float num5 = Mathf.Min(100f, level + num4);
				RectTransform parent = Row((Transform)(object)_content, 30f);
				Text((Transform)(object)parent, Specialization.Name(val), 15f, TextC, (TextAlignmentOptions)513, 190f);
				Text((Transform)(object)parent, $"<color=#{M(Muted)}>treinado {level:0}</color>" + ((num4 > 0f) ? $"  <color=#{M(Bonus)}>+{num4:0}</color>" : "") + $"  <color=#{M(Gold)}>= {num5:0}</color>", 14f, TextC, (TextAlignmentOptions)513, 260f);
				int num6 = spec.PointsIn(val);
				Text((Transform)(object)parent, (num6 > 0) ? $"<color=#{M(Muted)}>{num6} pt</color>" : "", 13f, TextC, (TextAlignmentOptions)516);
				((Selectable)Btn((Transform)(object)parent, "+", (UnityAction)delegate
				{
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					if (!spec.Spend(player, st, out var reason))
					{
						((Character)player).Message((MessageType)2, reason, 0, (Sprite)null, false);
					}
					Rebuild(keepScroll: true);
				}, 38f, 28f, _upTemplate)).interactable = num > 0 && num5 < 100f;
				((Selectable)Btn((Transform)(object)parent, "-", (UnityAction)delegate
				{
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					if (!spec.Refund(player, st, out var reason))
					{
						((Character)player).Message((MessageType)2, reason, 0, (Sprite)null, false);
					}
					Rebuild(keepScroll: true);
				}, 38f, 28f, _downTemplate)).interactable = num6 > 0 && ModConfig.RespecEnabled.Value;
			}
			Space((Transform)(object)_content, 6f);
			Text((Transform)(object)_content, "<color=#" + M(Muted) + ">O bonus entra no calculo de dano, bloqueio e stamina como nivel de skill. A tela de habilidades do jogo mostra so o treinado.</color>", 12f, TextC, (TextAlignmentOptions)513);
		}

		private static void BuildGroup(Player player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_013e: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: 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)
			//IL_0348: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: 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_02e5: Expected O, but got Unknown
			Text((Transform)(object)_content, "<b>Grupo</b>  <size=12><color=#" + M(Muted) + ">" + (Group.InGroup ? $"{Group.Members.Count} membro(s) · XP compartilhado a ate {ModConfig.XpNearbyRadius.Value:0} m" : "sem grupo") + "</color></size>", 16f, TextC, (TextAlignmentOptions)513);
			Space((Transform)(object)_content, 4f);
			foreach (Group.Invite item in new List<Group.Invite>(Group.Invites))
			{
				Group.Invite i = item;
				RectTransform parent = Row((Transform)(object)_content, 30f);
				Text((Transform)(object)parent, "Convite de <b>" + item.FromName + "</b>", 14f, TextC, (TextAlignmentOptions)513, 320f);
				Btn((Transform)(object)parent, "Aceitar", (UnityAction)delegate
				{
					Group.Accept(i);
					Rebuild(keepScroll: true);
				}, 100f, 26f);
				Btn((Transform)(object)parent, "Recusar", (UnityAction)delegate
				{
					Group.Decline(i);
					Rebuild(keepScroll: true);
				}, 100f, 26f);
			}
			if (Group.InGroup)
			{
				foreach (Group.Member item2 in new List<Group.Member>(Group.Members))
				{
					Group.Member mm = item2;
					RectTransform parent2 = Row((Transform)(object)_content, 30f);
					string text = ((item2.Uid == Group.LeaderUid) ? "★ " : "");
					string text2 = ((item2.Uid == Group.MyUid) ? (" <color=#" + M(Muted) + ">(voce)</color>") : "");
					Player val = Group.FindPlayer(item2.Uid);
					string text3 = (((Object)(object)val != (Object)null) ? $" <color=#{M(Good)}>{((Character)val).GetHealth():0}/{((Character)val).GetMaxHealth():0}</color>" : (" <color=#" + M(Muted) + ">longe</color>"));
					Text((Transform)(object)parent2, text + item2.Name + text2 + text3, 15f, TextC, (TextAlignmentOptions)513);
					if (Group.IsLeader && item2.Uid != Group.MyUid)
					{
						Btn((Transform)(object)parent2, "Remover", (UnityAction)delegate
						{
							Group.Kick(mm);
							Rebuild(keepScroll: true);
						}, 100f, 26f);
					}
				}
				RectTransform parent3 = Row((Transform)(object)_content, 30f);
				string label = (Group.IsLeader ? "Desfazer grupo" : "Sair do grupo");
				object obj = <>c.<>9__49_2;
				if (obj == null)
				{
					UnityAction val2 = delegate
					{
						Group.Leave();
						Rebuild(keepScroll: true);
					};
					<>c.<>9__49_2 = val2;
					obj = (object)val2;
				}
				Btn((Transform)(object)parent3, label, (UnityAction)obj, 170f, 26f);
				Space((Transform)(object)_content, 6f);
			}
			List<Player> list = Group.Invitable();
			Text((Transform)(object)_content, $"<b>Convidar</b>  <size=12><color=#{M(Muted)}>jogadores a ate {ModConfig.GroupInviteRange.Value:0} m</color></size>", 15f, TextC, (TextAlignmentOptions)513);
			if (list.Count == 0)
			{
				Text((Transform)(object)_content, "<color=#" + M(Muted) + ">Ninguem por perto.</color>", 13f, TextC, (TextAlignmentOptions)513);
			}
			foreach (Player item3 in list)
			{
				Player pp = item3;
				RectTransform parent4 = Row((Transform)(object)_content, 30f);
				Text((Transform)(object)parent4, $"{item3.GetPlayerName()}  <color=#{M(Muted)}>{Vector3.Distance(((Component)item3).transform.position, ((Component)player).transform.position):0} m</color>", 15f, TextC, (TextAlignmentOptions)513);
				((Selectable)Btn((Transform)(object)parent4, "Convidar", (UnityAction)delegate
				{
					string text4 = Group.SendInvite(pp);
					if (text4 != null)
					{
						((Character)player).Message((MessageType)1, text4, 0, (Sprite)null, false);
					}
					Rebuild(keepScroll: true);
				}, 110f, 26f)).interactable = !Group.InGroup || Group.IsLeader;
			}
		}

		private static void BuildClan(Player player)
		{
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: 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_0189: 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_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Expected O, but got Unknown
			//IL_05f7: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: 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_01f9: Expected O, but got Unknown
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a21: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0905: Unknown result type (might be due to invalid IL or missing references)
			//IL_0811: Unknown result type (might be due to invalid IL or missing references)
			//IL_0805: Unknown result type (might be due to invalid IL or missing references)
			//IL_0931: Unknown result type (might be due to invalid IL or missing references)
			//IL_094a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a58: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected O, but got Unknown
			//IL_0856: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e3: Expected O, but got Unknown
			//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac7: Expected O, but got Unknown
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a1: Expected O, but got Unknown
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: 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_03ac: Unknown result type (might be due to invalid IL or missing references)
			Clan.Info mine = Clan.Mine;
			string lastMessage = Clan.LastMessage;
			if (mine == null)
			{
				Text((Transform)(object)_content, $"Um cla e <b>permanente</b>: nome e tag ao lado do nome de todos os membros, cofre de ouro e chat com <b>/c</b>. Membros do mesmo cla nao se ferem. Ate {ModConfig.ClanMaxMembers.Value} membros.", 13f, TextC, (TextAlignmentOptions)513);
				Space((Transform)(object)_content, 6f);
				if (Clan.Invites.Count > 0)
				{
					Text((Transform)(object)_content, "<b>Convites</b>", 15f, TextC, (TextAlignmentOptions)513);
					Clan.Invite[] array = Clan.Invites.ToArray();
					foreach (Clan.Invite invite in array)
					{
						Clan.Invite i2 = invite;
						RectTransform parent = Row((Transform)(object)_content, 30f);
						Text((Transform)(object)parent, invite.FromName + " convidou voce para <b>" + invite.ClanName + "</b>", 14f, TextC, (TextAlignmentOptions)513);
						Btn((Transform)(object)parent, "Aceitar", (UnityAction)delegate
						{
							Clan.Accept(i2);
							Rebuild(keepScroll: true);
						}, 100f, 26f);
						Btn((Transform)(object)parent, "Recusar", (UnityAction)delegate
						{
							Clan.Invites.Remove(i2);
							Rebuild(keepScroll: true);
						}, 100f, 26f);
					}
					Space((Transform)(object)_content, 6f);
				}
				Text((Transform)(object)_content, "<b>Fundar um cla</b>", 15f, TextC, (TextAlignmentOptions)513);
				RectTransform parent2 = Row((Transform)(object)_content, 32f);
				string label = (string.IsNullOrEmpty(_clanName) ? "Nome do cla..." : ("Nome: " + _clanName));
				object obj = <>c.<>9__51_1;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						TextInput instance = TextInput.instance;
						if (instance != null)
						{
							instance.RequestText((TextReceiver)(object)new TextReceiverCb(_clanName, delegate(string t)
							{
								_clanName = t?.Trim();
								ReopenSoon();
							}), "Nome do cla", Mathf.Clamp(ModConfig.ClanNameMax.Value, 3, 32));
						}
					};
					<>c.<>9__51_1 = val;
					obj = (object)val;
				}
				Btn((Transform)(object)parent2, label, (UnityAction)obj, 360f, 28f);
				string label2 = (string.IsNullOrEmpty(_clanTag) ? "Tag..." : ("Tag: " + _clanTag));
				object obj2 = <>c.<>9__51_2;
				if (obj2 == null)
				{
					UnityAction val2 = delegate
					{
						TextInput instance = TextInput.instance;
						if (instance != null)
						{
							instance.RequestText((TextReceiver)(object)new TextReceiverCb(_clanTag, delegate(string t)
							{
								_clanTag = t?.Trim().ToUpperInvariant();
								ReopenSoon();
							}), "Tag do cla (2-4 letras)", Mathf.Clamp(ModConfig.ClanTagMax.Value, 2, 6));
						}
					};
					<>c.<>9__51_2 = val2;
					obj2 = (object)val2;
				}
				Btn((Transform)(object)parent2, label2, (UnityAction)obj2, 160f, 28f);
				string why;
				bool flag = Clan.ValidName(_clanName, out why);
				string why2;
				bool flag2 = Clan.ValidTag(_clanTag, out why2);
				RectTransform content = _content;
				string label3 = "Fundar " + (flag ? _clanName : "") + " " + (flag2 ? ("[" + _clanTag + "]") : "");
				object obj3 = <>c.<>9__51_3;
				if (obj3 == null)
				{
					UnityAction val3 = delegate
					{
						Clan.Create(_clanName, _clanTag);
						Rebuild(keepScroll: true);
					};
					<>c.<>9__51_3 = val3;
					obj3 = (object)val3;
				}
				((Selectable)Btn((Transform)(object)content, label3, (UnityAction)obj3, 640f, 30f)).interactable = flag && flag2;
				if (!string.IsNullOrEmpty(_clanName) && !flag)
				{
					Text((Transform)(object)_content, "<color=#" + M(Muted) + ">" + why + "</color>", 12f, TextC, (TextAlignmentOptions)513);
				}
				if (!string.IsNullOrEmpty(_clanTag) && !flag2)
				{
					Text((Transform)(object)_content, "<color=#" + M(Muted) + ">" + why2 + "</color>", 12f, TextC, (TextAlignmentOptions)513);
				}
				if (!string.IsNullOrEmpty(lastMessage))
				{
					Text((Transform)(object)_content, "<color=#" + M(Gold) + ">" + lastMessage + "</color>", 12f, TextC, (TextAlignmentOptions)513);
				}
				return;
			}
			long myUid = Clan.MyUid;
			bool flag3 = mine.IsLeader(myUid);
			Text((Transform)(object)_content, "<b>" + mine.Name + "</b> <color=#" + M(Gold) + ">[" + mine.Tag + "]</color>", 20f, TextC, (TextAlignmentOptions)513);
			Text((Transform)(object)_content, $"Fundado no dia {mine.CreatedDay} · {mine.Members.Count} membro(s)", 13f, TextC, (TextAlignmentOptions)513);
			Text((Transform)(object)_content, $"Cofre: <b>{mine.Bank}</b> moedas", 15f, TextC, (TextAlignmentOptions)513);
			RectTransform parent3 = Row((Transform)(object)_content, 30f);
			Text((Transform)(object)parent3, "Depositar:", 13f, TextC, (TextAlignmentOptions)513, 100f);
			int[] array2 = new int[3] { 50, 200, 1000 };
			foreach (int num in array2)
			{
				int vv = num;
				Btn((Transform)(object)parent3, $"+{num}", (UnityAction)delegate
				{
					Clan.Deposit(vv);
					Rebuild(keepScroll: true);
				}, 90f, 26f);
			}
			if (flag3)
			{
				RectTransform parent4 = Row((Transform)(object)_content, 30f);
				Text((Transform)(object)parent4, "Sacar:", 13f, TextC, (TextAlignmentOptions)513, 100f);
				array2 = new int[3] { 50, 200, 1000 };
				foreach (int num2 in array2)
				{
					int vv2 = num2;
					((Selectable)Btn((Transform)(object)parent4, $"-{num2}", (UnityAction)delegate
					{
						Clan.Withdraw(vv2);
						Rebuild(keepScroll: true);
					}, 90f, 26f)).interactable = mine.Bank >= num2;
				}
			}
			if (!string.IsNullOrEmpty(lastMessage))
			{
				Text((Transform)(object)_content, "<color=#" + M(Muted) + ">" + lastMessage + "</color>", 12f, TextC, (TextAlignmentOptions)513);
			}
			Space((Transform)(object)_content, 6f);
			Separator((Transform)(object)_content);
			Space((Transform)(object)_content, 4f);
			Text((Transform)(object)_content, $"<b>Membros</b>  <size=12><color=#{M(Muted)}>{mine.Members.Count}/{ModConfig.ClanMaxMembers.Value}</color></size>", 15f, TextC, (TextAlignmentOptions)513);
			foreach (var member in mine.Members)
			{
				(long uid, string name) mm = member;
				RectTransform parent5 = Row((Transform)(object)_content, 28f);
				bool flag4 = Clan.IsOnline(member.uid);
				string text = ((member.uid == mine.LeaderUid) ? (" <color=#" + M(Gold) + ">(lider)</color>") : "");
				Text((Transform)(object)parent5, "<color=#" + (flag4 ? M(Good) : M(Muted)) + ">●</color> " + member.name + text + ((member.uid == myUid) ? " (voce)" : ""), 14f, TextC, (TextAlignmentOptions)513);
				if (flag3 && member.uid != myUid)
				{
					Btn((Transform)(object)parent5, "Expulsar", (UnityAction)delegate
					{
						Clan.Kick(mm.uid);
						Rebuild(keepScroll: true);
					}, 100f, 24f);
				}
			}
			if (flag3)
			{
				Space((Transform)(object)_content, 4f);
				List<Player> list = Clan.Invitable();
				Text((Transform)(object)_content, $"<b>Convidar</b>  <size=12><color=#{M(Muted)}>jogadores a ate {ModConfig.GroupInviteRange.Value:0} m</color></size>", 15f, TextC, (TextAlignmentOptions)513);
				if (list.Count == 0)
				{
					Text((Transform)(object)_content, "<color=#" + M(Muted) + ">Ninguem por perto.</color>", 13f, TextC, (TextAlignmentOptions)513);
				}
				foreach (Player item in list)
				{
					Player pp = item;
					RectTransform parent6 = Row((Transform)(object)_content, 28f);
					Text((Transform)(object)parent6, item.GetPlayerName(), 14f, TextC, (TextAlignmentOptions)513);
					Btn((Transform)(object)parent6, "Convidar", (UnityAction)delegate
					{
						Clan.SendInvite(pp);
						Rebuild(keepScroll: true);
					}, 100f, 24f);
				}
			}
			Space((Transform)(object)_content, 8f);
			Text((Transform)(object)_content, "<color=#" + M(Muted) + ">Chat do cla: digite <b>/c mensagem</b> no chat. " + (flag3 ? "Se o lider sair, a lideranca passa ao membro mais antigo." : "") + "</color>", 12f, TextC, (TextAlignmentOptions)513);
			Space((Transform)(object)_content, 4f);
			RectTransform parent7 = Row((Transform)(object)_content, 30f);
			string label4 = (_clanConfirmLeave ? "CONFIRMAR: sair do cla" : "Sair do cla");
			object obj4 = <>c.<>9__51_0;
			if (obj4 == null)
			{
				UnityAction val4 = delegate
				{
					if (!_clanConfirmLeave)
					{
						_clanConfirmLeave = true;
					}
					else
					{
						Clan.Leave();
						_clanConfirmLeave = false;
					}
					Rebuild(keepScroll: true);
				};
				<>c.<>9__51_0 = val4;
				obj4 = (object)val4;
			}
			Btn((Transform)(object)parent7, label4, (UnityAction)obj4, 220f, 26f);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Hide")]
	internal static class InventoryGui_Hide_CharacterDialogPatch
	{
		private static void Postfix()
		{
			CharacterDialog.OnInventoryHidden();
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	internal static class GameCamera_UpdateMouseCapture_Patch
	{
		private static void Postfix()
		{
			if (QuestNpcUI.IsOpen || MmoUI.PanelOpen || FactionUI.IsOpen)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}
	}
	internal static class GameUi
	{
		public sealed class Window
		{
			public GameObject Root;

			public RectTransform Content;

			public ScrollRect Scroll;

			public TMP_Text Title;

			public Action<Transform> OnBuild;

			public Func<string> Signature;

			public Action OnClose;

			private string _lastSig;

			private float _t;

			public bool IsOpen
			{
				get
				{
					if ((Object)(object)Root != (Object)null)
					{
						return Root.activeSelf;
					}
					return false;
				}
			}

			public Window(string name, string title, float w, float h, Vector2 anchor, Vector2 anchoredPos, bool scroll = true)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Expected O, but got Unknown
				//IL_00ad: 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_00b0: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: 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_0160: 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_018a: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Expected O, but got Unknown
				//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0204: Unknown result type (might be due to invalid IL or missing references)
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0270: Unknown result type (might be due to invalid IL or missing references)
				//IL_0276: Expected O, but got Unknown
				//IL_029f: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02de: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0317: Unknown result type (might be due to invalid IL or missing references)
				//IL_0397: Unknown result type (might be due to invalid IL or missing references)
				//IL_039d: Expected O, but got Unknown
				//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e5: 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_040f: Unknown result type (might be due to invalid IL or missing references)
				//IL_041f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0462: Unknown result type (might be due to invalid IL or missing references)
				//IL_046c: Expected O, but got Unknown
				Transform val = Root();
				if (!((Object)(object)val == (Object)null))
				{
					Root = new GameObject(name, new Type[1] { typeof(RectTransform) });
					Root.transform.SetParent(val, false);
					Plugin.Log.LogInfo((object)("[UI] janela " + name + " criada sob '" + ((Object)val).name + "' (" + ((val is RectTransform) ? "RectTransform" : "Transform") + ")."));
					RectTransform component = Root.GetComponent<RectTransform>();
					Vector2 val2 = (component.anchorMin = (component.anchorMax = anchor));
					component.pivot = anchor;
					component.sizeDelta = new Vector2(w, h);
					component.anchoredPosition = anchoredPos;
					Image obj = Image(Root.transform, "Bkg");
					Stretch(((Graphic)obj).rectTransform);
					ApplyBackground(obj);
					Title = Text(Root.transform, title, 24f, Gold, (TextAlignmentOptions)514);
					RectTransform rectTransform = Title.rectTransform;
					rectTransform.anchorMin = new Vector2(0f, 1f);
					rectTransform.anchorMax = new Vector2(1f, 1f);
					rectTransform.pivot = new Vector2(0.5f, 1f);
					rectTransform.anchoredPosition = new Vector2(0f, -16f);
					rectTransform.sizeDelta = new Vector2(-60f, 32f);
					Object.Destroy((Object)(object)((Component)Title).GetComponent<LayoutElement>());
					Button obj2 = Btn(Root.transform, "X", (UnityAction)delegate
					{
						Close();
					}, 34f, 30f);
					RectTransform component2 = ((Component)obj2).GetComponent<RectTransform>();
					((Vector2)(ref val2))..ctor(1f, 1f);
					component2.anchorMax = val2;
					component2.anchorMin = val2;
					component2.pivot = new Vector2(1f, 1f);
					component2.anchoredPosition = new Vector2(-14f, -12f);
					Object.Destroy((Object)(object)((Component)obj2).GetComponent<LayoutElement>());
					GameObject val5 = new GameObject("Scroll", new Type[3]
					{
						typeof(RectTransform),
						typeof(Image),
						typeof(RectMask2D)
					});
					val5.transform.SetParent(Root.transform, false);
					RectTransform component3 = val5.GetComponent<RectTransform>();
					component3.anchorMin = new Vector2(0f, 0f);
					component3.anchorMax = new Vector2(1f, 1f);
					component3.pivot = new Vector2(0.5f, 1f);
					component3.offsetMin = new Vector2(26f, 24f);
					component3.offsetMax = new Vector2(-26f, -56f);
					((Graphic)val5.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.001f);
					if (scroll)
					{
						Scroll = val5.AddComponent<ScrollRect>();
						Scroll.horizontal = false;
						Scroll.vertical = true;
						Scroll.movementType = (MovementType)2;
						Scroll.scrollSensitivity = 40f;
					}
					GameObject val6 = new GameObject("Content", new Type[3]
					{
						typeof(RectTransform),
						typeof(VerticalLayoutGroup),
						typeof(ContentSizeFitter)
					});
					val6.transform.SetParent(val5.transform, false);
					Content = val6.GetComponent<RectTransform>();
					Content.anchorMin = new Vector2(0f, 1f);
					Content.anchorMax = new Vector2(1f, 1f);
					Content.pivot = new Vector2(0.5f, 1f);
					Content.offsetMin = Vector2.zero;
					Content.offsetMax = Vector2.zero;
					VerticalLayoutGroup component4 = val6.GetComponent<VerticalLayoutGroup>();
					((LayoutGroup)component4).childAlignment = (TextAnchor)0;
					((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = true;
					((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true;
					((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false;
					((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = true;
					((HorizontalOrVerticalLayoutGroup)component4).spacing = 4f;
					((LayoutGroup)component4).padding = new RectOffset(4, 4, 4, 12);
					val6.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
					if ((Object)(object)Scroll != (Object)null)
					{
						Scroll.content = Content;
						Scroll.viewport = component3;
					}
					Root.SetActive(false);
				}
			}

			public void Open()
			{
				if (!((Object)(object)Root == (Object)null))
				{
					Root.SetActive(true);
					Root.transform.SetAsLastSibling();
					_lastSig = null;
					Build(keepScroll: false);
				}
			}

			public void Close()
			{
				if (!((Object)(object)Root == (Object)null) && Root.activeSelf)
				{
					Root.SetActive(false);
					OnClose?.Invoke();
				}
			}

			public void Build(bool keepScroll = true)
			{
				//IL_00a5: 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)
				if (!((Object)(object)Root == (Object)null) && !((Object)(object)Content == (Object)null) && OnBuild != null)
				{
					float num = ((keepScroll && (Object)(object)Scroll != (Object)null) ? Scroll.verticalNormalizedPosition : 1f);
					for (int num2 = ((Transform)Content).childCount - 1; num2 >= 0; num2--)
					{
						Object.DestroyImmediate((Object)(object)((Component)((Transform)Content).GetChild(num2)).gameObject);
					}
					try
					{
						OnBuild((Transform)(object)Content);
					}
					catch (Exception ex)
					{
						Text((Transform)(object)Content, "<color=#" + H(Bad) + ">Erro ao montar a janela: " + ex.Message + "</color>", 12f, TextC, (TextAlignmentOptions)513);
						Plugin.Log.LogWarning((object)$"[UI] {((Object)Root).name}: {ex}");
					}
					_lastSig = Signature?.Invoke();
					LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
					if ((Object)(object)Scroll != (Object)null)
					{
						Scroll.verticalNormalizedPosition = (keepScroll ? num : 1f);
					}
				}
			}

			public void Tick(float dt)
			{
				if (!IsOpen)
				{
					return;
				}
				if (ZInput.GetKeyDown((KeyCode)27, true))
				{
					Close();
					return;
				}
				_t += dt;
				if (!(_t < 0.5f))
				{
					_t = 0f;
					if (Signature != null && Signature() != _lastSig)
					{
						Build();
					}
				}
			}
		}

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

		public static readonly Color Muted = new Color(0.75f, 0.7f, 0.6f);

		public static readonly Color Bonus = new Color(1f, 0.62f, 0.2f);

		public static readonly Color TextC = new Color(0.98f, 0.95f, 0.88f);

		public static readonly Color Good = new Color(0.62f, 0.9f, 0.62f);

		public static readonly Color Bad = new Color(0.9f, 0.4f, 0.35f);

		public static readonly Color Purple = new Color(0.79f, 0.65f, 1f);

		private static TMP_Text _fontSource;

		private static Image _bkgSource;

		private static Button _btnTemplate;

		private static Button _upTemplate;

		private static Button _downTemplate;

		public static string H(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGB(c);
		}

		private static void EnsureSources()
		{
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if ((Object)(object)_fontSource == (Object)null || !Object.op_Implicit((Object)(object)_fontSource))
			{
				_fontSource = (((Object)(object)instance.m_textsDialog != (Object)null && (Object)(object)instance.m_textsDialog.m_textAreaTopic != (Object)null) ? instance.m_textsDialog.m_textAreaTopic : ((Component)instance).GetComponentInChildren<TMP_Text>(true));
			}
			if ((Object)(object)_bkgSource == (Object)null || !Object.op_Implicit((Object)(object)_bkgSource))
			{
				object bkgSource;
				if (!((Object)(object)instance.m_player != (Object)null))
				{
					bkgSource = null;
				}
				else
				{
					Transform obj = ((Transform)instance.m_player).Find("Bkg");
					bkgSource = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				}
				_bkgSource = (Image)bkgSource;
			}
			if ((Object)(object)_btnTemplate == (Object)null || !Object.op_Implicit((Object)(object)_btnTemplate))
			{
				_btnTemplate = instance.m_tabCraft;
			}
			if ((Object)(object)_upTemplate == (Object)null || !Object.op_Implicit((Object)(object)_upTemplate))
			{
				_upTemplate = instance.m_qualityLevelUp;
			}
			if ((Object)(object)_downTemplate == (Object)null || !Object.op_Implicit((Object)(object)_downTemplate))
			{
				_downTemplate = instance.m_qualityLevelDown;
			}
		}

		public static Transform Root()
		{
			if ((Object)(object)InventoryGui.instance != (Object)null && ((Component)InventoryGui.instance).transform is RectTransform)
			{
				return ((Component)InventoryGui.instance).transform;
			}
			if ((Object)(object)Hud.instance != (Object)null && (Object)(object)Hud.instance.m_rootObject != (Object)null)
			{
				return Hud.instance.m_rootObject.transform;
			}
			return null;
		}

		public static void ApplyBackground(Image img, float alpha = 1f)
		{
			//IL_008f: 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_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_0071: Unknown result type (might be due to invalid IL or missing references)
			EnsureSources();
			((Graphic)img).raycastTarget = true;
			if ((Object)(object)_bkgSource != (Object)null)
			{
				img.sprite = _bkgSource.sprite;
				((Graphic)img).material = ((Graphic)_bkgSource).material;
				img.type = _bkgSource.type;
				img.pixelsPerUnitMultiplier = _bkgSource.pixelsPerUnitMultiplier;
				Color color = ((Graphic)_bkgSource).color;
				color.a *= alpha;
				((Graphic)img).color = color;
			}
			else
			{
				((Graphic)img).color = new Color(0.16f, 0.11f, 0.07f, 0.96f * alpha);
			}
		}

		public static void Stretch(RectTransform r)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			r.anchorMin = Vector2.zero;
			r.anchorMax = Vector2.one;
			r.offsetMin = Vector2.zero;
			r.offsetMax = Vector2.zero;
		}

		public static Image Image(Transform parent, string name)
		{
			//IL_0021: 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)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			Image component = val.GetComponent<Image>();
			((Graphic)component).raycastTarget = false;
			return component;
		}

		public static TMP_Text Text(Transform parent, string text, float size, Color color, TextAlignmentOptions align = (TextAlignmentOptions)513, float width = 0f, float height = 0f)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			EnsureSources();
			GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)_fontSource != (Object)null)
			{
				((TMP_Text)val2).font = _fontSource.font;
				((TMP_Text)val2).fontSharedMaterial = _fontSource.fontSharedMaterial;
			}
			((TMP_Text)val2).fontSize = size;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			((TMP_Text)val2).text = text ?? "";
			((TMP_Text)val2).richText = true;
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((Graphic)val2).raycastTarget = false;
			LayoutElement val3 = val.AddComponent<LayoutElement>();
			if (width > 0f)
			{
				val3.preferredWidth = width;
				val3.minWidth = width;
				val3.flexibleWidth = 0f;
			}
			else
			{
				val3.flexibleWidth = 1f;
			}
			if (height > 0f)
			{
				val3.preferredHeight = height;
			}
			return (TMP_Text)(object)val2;
		}

		public static Button Btn(Transform parent, string label, UnityAction onClick, float w, float h, Button template = null)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_0103: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			EnsureSources();
			template = template ?? _btnTemplate;
			GameObject val;
			if ((Object)(object)template != (Object)null)
			{
				val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false);
				TMP_Text[] componentsInChildren = val.GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text obj in componentsInChildren)
				{
					obj.text = label;
					obj.textWrappingMode = (TextWrappingModes)0;
					obj.overflowMode = (TextOverflowModes)0;
					obj.fontSize = Mathf.Min(obj.fontSize, 16f);
				}
				UITooltip component = val.GetComponent<UITooltip>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_text = "";
					component.m_topic = "";
				}
			}
			else
			{
				val = new GameObject("Btn", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Button)
				});
				val.transform.SetParent(parent, false);
				((Graphic)val.GetComponent<Image>()).color = new Color(0.3f, 0.22f, 0.14f, 1f);
				Stretch(Text(val.transform, label, 14f, TextC, (TextAlignmentOptions)514).rectTransform);
			}
			((Object)val).name = "Btn_" + label;
			val.SetActive(true);
			Button component2 = val.GetComponent<Button>();
			component2.onClick = new ButtonClickedEvent();
			if (onClick != null)
			{
				((UnityEvent)component2.onClick).AddListener(onClick);
			}
			((Selectable)component2).interactable = true;
			val.GetComponent<RectTransform>().sizeDelta = new Vector2(w, h);
			LayoutElement obj2 = val.GetComponent<LayoutElement>() ?? val.AddComponent<LayoutElement>();
			obj2.preferredWidth = w;
			obj2.minWidth = w;
			obj2.preferredHeight = h;
			obj2.minHeight = h;
			obj2.flexibleWidth = 0f;
			return component2;
		}

		public static Button UpBtn(Transform parent, UnityAction onClick, float w = 38f, float h = 28f)
		{
			EnsureSources();
			return Btn(parent, "+", onClick, w, h, _upTemplate);
		}

		public static Button DownBtn(Transform parent, UnityAction onClick, float w = 38f, float h = 28f)
		{
			EnsureSources();
			return Btn(parent, "-", onClick, w, h, _downTemplate);
		}

		public static void TabLook(Button b, bool active)
		{
			//IL_0039: 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_005b: 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)
			Image val = ((Component)b).GetComponent<Image>() ?? ((Component)b).GetComponentInChildren<Image>();
			if ((Object)(object)val != (Object)null)
			{
				((Graphic)val).color = (Color)(active ? Color.white : new Color(0.7f, 0.7f, 0.7f, 0.85f));
			}
			TMP_Text[] componentsInChildren = ((Component)b).GetComponentsInChildren<TMP_Text>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Graphic)componentsInChildren[i]).color = (active ? Gold : TextC);
			}
		}

		public static RectTransform Row(Transform parent, float h, float spacing = 8f, TextAnchor align = (TextAnchor)3)
		{
			//IL_0032: 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_0044: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Row", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>();
			((LayoutGroup)component).childAlignment = align;
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component).spacing = spacing;
			LayoutElement component2 = val.GetComponent<LayoutElement>();
			component2.preferredHeight = h;
			component2.minHeight = h;
			component2.flexibleWidth = 1f;
			return val.GetComponent<RectTransform>();
		}

		public static RectTransform Column(Transform parent, float spacing = 4f)
		{
			//IL_0032: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Col", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			VerticalLayoutGroup component = val.GetComponent<VerticalLayoutGroup>();
			((LayoutGroup)component).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component).spacing = spacing;
			val.GetComponent<LayoutElement>().flexibleWidth = 1f;
			return val.GetComponent<RectTransform>();
		}

		public static void Space(Transform parent, float h)
		{
			//IL_0025: 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)
			GameObject val = new GameObject("Space", new Type[2]
			{
				typeof(RectTransform),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			LayoutElement component = val.GetComponent<LayoutElement>();
			component.preferredHeight = h;
			component.minHeight = h;
		}

		public static void Flex(Transform parent)
		{
			//IL_0025: 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)
			GameObject val = new GameObject("Flex", new Type[2]
			{
				typeof(RectTransform),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			val.GetComponent<LayoutElement>().flexibleWidth = 1f;
		}

		public static void Separator(Transform parent)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Image obj = Image(parent, "Sep");
			((Graphic)obj).color = new Color(1f, 0.85f, 0.55f, 0.35f);
			LayoutElement obj2 = ((Component)obj).gameObject.AddComponent<LayoutElement>();
			obj2.preferredHeight = 2f;
			obj2.minHeight = 2f;
			obj2.flexibleWidth = 1f;
		}

		public static void Bar(Transform parent, float pct, string label, Color fill, float h = 22f)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			Image val = Image(parent, "Bar");
			((Graphic)val).color = new Color(0f, 0f, 0f, 0.55f);
			LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.preferredHeight = h;
			obj.minHeight = h;
			obj.flexibleWidth = 1f;
			Image obj2 = Image(((Component)val).transform, "Fill");
			((Graphic)obj2).color = fill;
			RectTransform rectTransform = ((Graphic)obj2).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(Mathf.Clamp01(pct), 1f);
			rectTransform.offsetMin = new Vector2(2f, 2f);
			rectTransform.offsetMax = new Vector2(-2f, -2f);
			if (!string.IsNullOrEmpty(label))
			{
				TMP_Text obj3 = Text(((Component)val).transform, label, Mathf.Max(10f, h - 9f), Color.white, (TextAlignmentOptions)514);
				Stretch(obj3.rectTransform);
				Object.Destroy((Object)(object)((Component)obj3).GetComponent<LayoutElement>());
			}
		}

		public static Image Icon(Transform parent, Sprite sprite, float size)
		{
			Image obj = Image(parent, "Icon");
			obj.sprite = sprite;
			obj.preserveAspect = true;
			((Behaviour)obj).enabled = (Object)(object)sprite != (Object)null;
			LayoutElement obj2 = ((Component)obj).gameObject.AddComponent<LayoutElement>();
			obj2.preferredWidth = size;
			obj2.minWidth = size;
			obj2.preferredHeight = size;
			obj2.minHeight = size;
			obj2.flexibleWidth = 0f;
			return obj;
		}

		public static Sprite IconOf(ItemData item)
		{
			try
			{
				return (item != null) ? item.GetIcon() : null;
			}
			catch
			{
				return null;
			}
		}

		public static Sprite IconOf(SharedData sh)
		{
			if (sh?.m_icons == null || sh.m_icons.Length == 0)
			{
				return null;
			}
			return sh.m_icons[0];
		}

		public static string ItemName(ItemData item)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			string text = Localization.instance.Localize(item.m_shared.m_name);
			string text2 = ((item.m_shared.m_maxQuality > 1) ? $" <size=11><color=#{H(Muted)}>q{item.m_quality}</color></size>" : "");
			string text3 = ((item.m_stack > 1) ? $" <color=#{H(Muted)}>x{item.m_stack}</color>" : "");
			return text + text2 + text3;
		}
	}
	internal sealed class ClonedBar
	{
		public GameObject Root;

		public RectTransform Rect;

		public GuiBar[] Bars;

		public TMP_Text Text;

		public Animator Animator;

		public bool Alive => (Object)(object)Root != (Object)null;

		public static ClonedBar From(RectTransform source, string name, bool fixedText)
		{
			//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_00c5: 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_00dc: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)source == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, ((Transform)source).parent);
			((Object)val).name = name;
			ClonedBar clonedBar = new ClonedBar
			{
				Root = val,
				Rect = val.GetComponent<RectTransform>(),
				Bars = val.GetComponentsInChildren<GuiBar>(true),
				Text = val.GetComponentInChildren<TMP_Text>(true),
				Animator = (val.GetComponent<Animator>() ?? val.GetComponentInChildren<Animator>(true))
			};
			if ((Object)(object)clonedBar.Text != (Object)null && fixedText)
			{
				TMP_Text text = clonedBar.Text;
				text.enableAutoSizing = false;
				text.fontSize = 15f;
				text.textWrappingMode = (TextWrappingModes)0;
				text.overflowMode = (TextOverflowModes)0;
				text.alignment = (TextAlignmentOptions)514;
				((Graphic)text).color = Color.white;
				text.fontStyle = (FontStyles)(text.fontStyle | 1);
				RectTransform rectTrans