Decompiled source of Transmog v3.0.0

Transmog.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Transmog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Transmog")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace Transmog;

public static class Configs
{
	public static ConfigEntry<KeyboardShortcut> HotKeyOpenTransmogPanel;

	public static ConfigEntry<KeyboardShortcut> HotKeyToggleTransmog;

	public static ConfigEntry<string> PanelAnchor;

	public static ConfigEntry<Vector2> PanelPosition;

	public static ConfigEntry<bool> NeverHideAlsoAppliesToWeapons;

	public static void SetupConfigs(ConfigFile config)
	{
		//IL_002d: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		AcceptableValueList<string> val = new AcceptableValueList<string>(TransmogUI.Anchors.Keys.ToArray());
		HotKeyOpenTransmogPanel = config.Bind<KeyboardShortcut>("General", GenerateConfigKey("HotKeyOpenTransmogPanel"), new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), "Hotkey to open the transmog panel. Make sure your inventory is open before using the hotkey. Examples: Q, C, LeftShift + Q, LeftShift + Alpha1, LeftAlt + F1. It is recommended that you use a configuration manager mod to easily change the hotkey in-game.");
		HotKeyToggleTransmog = config.Bind<KeyboardShortcut>("General", GenerateConfigKey("HotKeyToggleTransmog"), new KeyboardShortcut((KeyCode)61, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Hotkey to switch the transmog on and off. Examples: Q, C, LeftShift + Q, LeftShift + Alpha1, LeftAlt + F1. It is recommended that you use a configuration manager mod to easily change the hotkey in-game.");
		PanelAnchor = config.Bind<string>("General", GenerateConfigKey("PanelAnchor"), "Middle-center", new ConfigDescription("Defines the starting point of the transmog panel.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
		PanelPosition = config.Bind<Vector2>("General", GenerateConfigKey("PanelPosition"), new Vector2(0f, 0f), "Defines the starting position of the transmog panel.");
		NeverHideAlsoAppliesToWeapons = config.Bind<bool>("Mechanics", GenerateConfigKey("NeverHideAlsoAppliesToWeapons"), false, "The option to never hide a shield will also apply to weapons.");
		PanelAnchor.SettingChanged += PanelSettingsChanged;
		PanelPosition.SettingChanged += PanelSettingsChanged;
	}

	public static string GenerateConfigKey(string key)
	{
		return GenerateConfigKey(key, null);
	}

	public static string GenerateConfigKey(string key, string unit)
	{
		key = string.Concat(key.Select((char x) => char.IsUpper(x) ? (" " + x) : x.ToString())).TrimStart(new char[1] { ' ' });
		if (!string.IsNullOrEmpty(unit))
		{
			key += $" ({unit})";
		}
		return key;
	}

	private static void PanelSettingsChanged(object sender, EventArgs e)
	{
		bool activeSelf = TransmogUI.Panel.activeSelf;
		TransmogUI.Awake();
		if (activeSelf)
		{
			TransmogUI.OpenMenu();
		}
	}
}
public static class Helper
{
	private static Dictionary<string, string> languages;

	public static string GetModFolder()
	{
		if (Paths.PluginPath != null)
		{
			DirectoryInfo directoryInfo = new DirectoryInfo(Paths.PluginPath);
			if (directoryInfo.Exists)
			{
				string[] files = Directory.GetFiles(directoryInfo.FullName, string.Format("{0}.dll", "Transmog"), SearchOption.AllDirectories);
				if (files.Any())
				{
					string directoryName = Path.GetDirectoryName(files.First());
					if (!string.IsNullOrEmpty(directoryName))
					{
						return directoryName;
					}
				}
			}
		}
		return null;
	}

	public static Dictionary<string, string> GetLanguages()
	{
		if (languages == null)
		{
			languages = new Dictionary<string, string>
			{
				{ "AB", "Abenaki" },
				{ "BG", "Bulgarian" },
				{ "CS", "Czech" },
				{ "DA", "Danish" },
				{ "DE", "German" },
				{ "EL", "Greek" },
				{ "EN", "English" },
				{ "ES", "Spanish" },
				{ "FI", "Finnish" },
				{ "FR", "French" },
				{ "HI", "Hindi" },
				{ "HR", "Croatian" },
				{ "HU", "Hungarian" },
				{ "IS", "Icelandic" },
				{ "IT", "Italian" },
				{ "JA", "Japanese" },
				{ "KA", "Georgian" },
				{ "KO", "Korean" },
				{ "LT", "Lithuanian" },
				{ "LV", "Latvian" },
				{ "ML", "Macedonian" },
				{ "NL", "Dutch" },
				{ "NO", "Norwegian" },
				{ "PL", "Polish" },
				{ "PT-BR", "Portuguese_Brazilian" },
				{ "PT-EU", "Portuguese_European" },
				{ "RO", "Romanian" },
				{ "RU", "Russian" },
				{ "SE", "Swedish" },
				{ "SK", "Slovak" },
				{ "SR", "Serbian" },
				{ "TH", "Thai" },
				{ "TR", "Turkish" },
				{ "UK", "Ukrainian" },
				{ "ZH-CN", "Chinese" },
				{ "ZH-TW", "Chinese_Trad" }
			};
		}
		return languages;
	}
}
public class TransmogItem
{
	public string ItemLabel;

	public ItemType ItemType;

	public AnimationState? ItemAnim;

	public SkillType? ItemSkill;

	public string ItemName;

	public int ItemVariant;

	public bool CanBeHidden;

	public bool Hidden;

	public bool NeverHide;

	public TransmogItem(string itemLabel, ItemType itemType, AnimationState? itemAnim = null, SkillType? itemSkill = null, bool canBeHidden = false)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		ItemType = itemType;
		ItemAnim = itemAnim;
		ItemSkill = itemSkill;
		ItemLabel = itemLabel;
		CanBeHidden = canBeHidden;
		ItemName = string.Empty;
	}
}
public enum ItemCategory
{
	HELMET,
	CHEST,
	LEGS,
	SHOULDER,
	UTILITY,
	TRINKET,
	SHIELD,
	BOW,
	CROSSBOW,
	STAFF_ELEMENTAL,
	STAFF_BLOOD,
	ONE_HANDED_KNIFE,
	ONE_HANDED_AXE,
	ONE_HANDED_CLUB,
	ONE_HANDED_SWORD,
	TWO_HANDED_AXE,
	TWO_HANDED_CLUB,
	TWO_HANDED_SWORD,
	DUAL_KNIFE,
	DUAL_AXE,
	FISTS,
	SPEAR,
	POLEARM,
	PICKAXE
}
[BepInPlugin("Transmog", "Transmog", "3.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class Transmog : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "OnSpawned")]
	public class Player_OnSpawned_Patch
	{
		public static void Postfix(Player __instance)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && __instance.m_customData.ContainsKey("Alpus-Transmog"))
			{
				LoadData(new ZPackage(__instance.m_customData["Alpus-Transmog"]));
				((Humanoid)Player.m_localPlayer).SetupVisEquipment(((Humanoid)Player.m_localPlayer).m_visEquipment, false);
			}
		}
	}

	[HarmonyPatch(typeof(Player), "Update")]
	public class Player_Update_Patch
	{
		public static void Postfix(Player __instance)
		{
			//IL_002a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			KeyboardShortcut value = Configs.HotKeyOpenTransmogPanel.Value;
			if (((KeyboardShortcut)(ref value)).Modifiers.Count() == 0)
			{
				value = Configs.HotKeyOpenTransmogPanel.Value;
				if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey))
				{
					goto IL_006b;
				}
			}
			value = Configs.HotKeyOpenTransmogPanel.Value;
			if (((KeyboardShortcut)(ref value)).IsUp())
			{
				goto IL_006b;
			}
			goto IL_0086;
			IL_0086:
			value = Configs.HotKeyToggleTransmog.Value;
			if (((KeyboardShortcut)(ref value)).Modifiers.Count() == 0)
			{
				value = Configs.HotKeyToggleTransmog.Value;
				if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey))
				{
					goto IL_00cc;
				}
			}
			value = Configs.HotKeyToggleTransmog.Value;
			if (!((KeyboardShortcut)(ref value)).IsUp())
			{
				return;
			}
			goto IL_00cc;
			IL_006b:
			if (TakeInput() && InventoryGui.IsVisible())
			{
				TransmogUI.ToggleMenu();
			}
			goto IL_0086;
			IL_00cc:
			if (TakeInput())
			{
				TransmogEnabled = !TransmogEnabled;
				((Humanoid)Player.m_localPlayer).SetupVisEquipment(((Humanoid)Player.m_localPlayer).m_visEquipment, false);
				SaveData();
				((Character)__instance).Message((MessageType)1, string.Format("Transmog = {0}.", TransmogEnabled ? "on" : "off"), 0, (Sprite)null);
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGrid), "OnLeftClick")]
	public static class InventoryGrid_OnLeftClick_Patch
	{
		public static bool Prefix(InventoryGrid __instance, UIInputHandler clickHandler)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (TransmogUI.Panel.activeSelf)
			{
				Vector2i buttonPos = __instance.GetButtonPos(((Component)clickHandler).gameObject);
				ItemData itemDrop = __instance.m_inventory.GetItemAt(buttonPos.x, buttonPos.y);
				if (itemDrop != null)
				{
					KeyValuePair<ItemCategory, TransmogItem> keyValuePair = TransmogItems.FirstOrDefault((KeyValuePair<ItemCategory, TransmogItem> x) => x.Value.ItemType == itemDrop.m_shared.m_itemType && (!x.Value.ItemSkill.HasValue || x.Value.ItemSkill == (SkillType?)itemDrop.m_shared.m_skillType) && (!x.Value.ItemAnim.HasValue || x.Value.ItemAnim == (AnimationState?)itemDrop.m_shared.m_animationState));
					if (!keyValuePair.Equals(default(KeyValuePair<ItemCategory, TransmogItem>)))
					{
						UpdateTransmog(keyValuePair.Key, ((Object)itemDrop.m_dropPrefab).name, itemDrop.m_variant, false, itemDrop.GetIcon());
					}
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "Hide")]
	public static class InventoryGui_Show_Patch
	{
		public static void Postfix()
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				TransmogUI.CloseMenu();
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "EquipItem")]
	public static class Humanoid_EquipItem_Patch
	{
		public static void Postfix(Humanoid __instance, ItemData item)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && item != null)
			{
				if ((int)item.m_shared.m_itemType == 5)
				{
					lastEquippedShield = item;
				}
				else if ((int)item.m_shared.m_itemType == 3)
				{
					lastEquippedWeapon = item;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "SetupVisEquipment")]
	public static class Humanoid_SetupVisEquipment_Patch
	{
		public static void Prefix(Humanoid __instance, VisEquipment visEq)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Invalid comparison between Unknown and I4
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Invalid comparison between Unknown and I4
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Invalid comparison between Unknown and I4
			if (!TransmogEnabled || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject || !TransmogItems[ItemCategory.SHIELD].NeverHide)
			{
				return;
			}
			if (((Humanoid)Player.m_localPlayer).m_hiddenLeftItem == null && (((Humanoid)Player.m_localPlayer).m_leftItem == null || (int)((Humanoid)Player.m_localPlayer).m_leftItem.m_shared.m_itemType != 5) && lastEquippedShield != null)
			{
				Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
				if (inventory != null && inventory.ContainsItem(lastEquippedShield))
				{
					((Humanoid)Player.m_localPlayer).m_hiddenLeftItem = lastEquippedShield;
				}
				else
				{
					lastEquippedShield = null;
				}
			}
			if (Configs.NeverHideAlsoAppliesToWeapons.Value && ((Humanoid)Player.m_localPlayer).m_hiddenRightItem == null && (((Humanoid)Player.m_localPlayer).m_hiddenLeftItem == null || (int)((Humanoid)Player.m_localPlayer).m_hiddenLeftItem.m_shared.m_itemType == 15 || !((Humanoid)Player.m_localPlayer).m_hiddenLeftItem.IsWeapon()) && (((Humanoid)Player.m_localPlayer).m_rightItem == null || (int)((Humanoid)Player.m_localPlayer).m_rightItem.m_shared.m_itemType != 3) && (((Humanoid)Player.m_localPlayer).m_leftItem == null || (int)((Humanoid)Player.m_localPlayer).m_leftItem.m_shared.m_itemType != 5) && lastEquippedWeapon != null)
			{
				Inventory inventory2 = ((Humanoid)Player.m_localPlayer).GetInventory();
				if (inventory2 != null && inventory2.ContainsItem(lastEquippedWeapon))
				{
					((Humanoid)Player.m_localPlayer).m_hiddenRightItem = lastEquippedWeapon;
				}
				else
				{
					lastEquippedWeapon = null;
				}
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetHelmetItem")]
	public static class VisEquipment_SetHelmetItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && (TransmogItems[ItemCategory.HELMET].ItemName != string.Empty || TransmogItems[ItemCategory.HELMET].Hidden) && ((Humanoid)Player.m_localPlayer).m_helmetItem != null)
			{
				name = ((!TransmogItems[ItemCategory.HELMET].Hidden) ? TransmogItems[ItemCategory.HELMET].ItemName : string.Empty);
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetChestItem")]
	public static class VisEquipment_SetChestItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && (TransmogItems[ItemCategory.CHEST].ItemName != string.Empty || TransmogItems[ItemCategory.CHEST].Hidden) && ((Humanoid)Player.m_localPlayer).m_chestItem != null)
			{
				name = ((!TransmogItems[ItemCategory.CHEST].Hidden) ? TransmogItems[ItemCategory.CHEST].ItemName : string.Empty);
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetLegItem")]
	public static class VisEquipment_SetLegItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && (TransmogItems[ItemCategory.LEGS].ItemName != string.Empty || TransmogItems[ItemCategory.LEGS].Hidden) && ((Humanoid)Player.m_localPlayer).m_legItem != null)
			{
				name = ((!TransmogItems[ItemCategory.LEGS].Hidden) ? TransmogItems[ItemCategory.LEGS].ItemName : string.Empty);
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetUtilityItem")]
	public static class VisEquipment_SetUtilityItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && (TransmogItems[ItemCategory.UTILITY].ItemName != string.Empty || TransmogItems[ItemCategory.UTILITY].Hidden) && ((Humanoid)Player.m_localPlayer).m_utilityItem != null)
			{
				name = ((!TransmogItems[ItemCategory.UTILITY].Hidden) ? TransmogItems[ItemCategory.UTILITY].ItemName : string.Empty);
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetTrinketItem")]
	public static class VisEquipment_SetTrinketItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && (TransmogItems[ItemCategory.TRINKET].ItemName != string.Empty || TransmogItems[ItemCategory.TRINKET].Hidden) && ((Humanoid)Player.m_localPlayer).m_trinketItem != null)
			{
				name = ((!TransmogItems[ItemCategory.TRINKET].Hidden) ? TransmogItems[ItemCategory.TRINKET].ItemName : string.Empty);
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetShoulderItem")]
	public static class VisEquipment_SetShoulderItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name, ref int variant)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && (TransmogItems[ItemCategory.SHOULDER].ItemName != string.Empty || TransmogItems[ItemCategory.SHOULDER].Hidden) && ((Humanoid)Player.m_localPlayer).m_shoulderItem != null)
			{
				name = ((!TransmogItems[ItemCategory.SHOULDER].Hidden) ? TransmogItems[ItemCategory.SHOULDER].ItemName : string.Empty);
				variant = TransmogItems[ItemCategory.SHOULDER].ItemVariant;
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetLeftItem")]
	public static class VisEquipment_SetLeftItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name, ref int variant)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && ((Humanoid)Player.m_localPlayer).m_leftItem != null)
			{
				KeyValuePair<ItemCategory, TransmogItem> keyValuePair = TransmogItems.FirstOrDefault((KeyValuePair<ItemCategory, TransmogItem> x) => x.Value.ItemType == ((Humanoid)Player.m_localPlayer).m_leftItem.m_shared.m_itemType && (!x.Value.ItemSkill.HasValue || x.Value.ItemSkill == (SkillType?)((Humanoid)Player.m_localPlayer).m_leftItem.m_shared.m_skillType) && (!x.Value.ItemAnim.HasValue || x.Value.ItemAnim == (AnimationState?)((Humanoid)Player.m_localPlayer).m_leftItem.m_shared.m_animationState));
				if (!keyValuePair.Equals(default(KeyValuePair<ItemCategory, TransmogItem>)) && keyValuePair.Value.ItemName != string.Empty)
				{
					name = keyValuePair.Value.ItemName;
					variant = keyValuePair.Value.ItemVariant;
				}
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetRightItem")]
	public static class VisEquipment_SetRightItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && ((Humanoid)Player.m_localPlayer).m_rightItem != null)
			{
				KeyValuePair<ItemCategory, TransmogItem> keyValuePair = TransmogItems.FirstOrDefault((KeyValuePair<ItemCategory, TransmogItem> x) => x.Value.ItemType == ((Humanoid)Player.m_localPlayer).m_rightItem.m_shared.m_itemType && (!x.Value.ItemSkill.HasValue || x.Value.ItemSkill == (SkillType?)((Humanoid)Player.m_localPlayer).m_rightItem.m_shared.m_skillType) && (!x.Value.ItemAnim.HasValue || x.Value.ItemAnim == (AnimationState?)((Humanoid)Player.m_localPlayer).m_rightItem.m_shared.m_animationState));
				if (!keyValuePair.Equals(default(KeyValuePair<ItemCategory, TransmogItem>)) && keyValuePair.Value.ItemName != string.Empty)
				{
					name = keyValuePair.Value.ItemName;
				}
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetLeftBackItem")]
	public static class VisEquipment_SetLeftBackItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name, ref int variant)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && ((Humanoid)Player.m_localPlayer).m_hiddenLeftItem != null)
			{
				KeyValuePair<ItemCategory, TransmogItem> keyValuePair = TransmogItems.FirstOrDefault((KeyValuePair<ItemCategory, TransmogItem> x) => x.Value.ItemType == ((Humanoid)Player.m_localPlayer).m_hiddenLeftItem.m_shared.m_itemType && (!x.Value.ItemSkill.HasValue || x.Value.ItemSkill == (SkillType?)((Humanoid)Player.m_localPlayer).m_hiddenLeftItem.m_shared.m_skillType) && (!x.Value.ItemAnim.HasValue || x.Value.ItemAnim == (AnimationState?)((Humanoid)Player.m_localPlayer).m_hiddenLeftItem.m_shared.m_animationState));
				if (!keyValuePair.Equals(default(KeyValuePair<ItemCategory, TransmogItem>)) && keyValuePair.Value.ItemName != string.Empty)
				{
					name = keyValuePair.Value.ItemName;
					variant = keyValuePair.Value.ItemVariant;
				}
			}
		}
	}

	[HarmonyPatch(typeof(VisEquipment), "SetRightBackItem")]
	public static class VisEquipment_SetRightBackItem_Patch
	{
		public static void Prefix(VisEquipment __instance, ref string name)
		{
			if (TransmogEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Component)__instance).gameObject != (Object)(object)((Component)Player.m_localPlayer).gameObject) && ((Humanoid)Player.m_localPlayer).m_hiddenRightItem != null)
			{
				KeyValuePair<ItemCategory, TransmogItem> keyValuePair = TransmogItems.FirstOrDefault((KeyValuePair<ItemCategory, TransmogItem> x) => x.Value.ItemType == ((Humanoid)Player.m_localPlayer).m_hiddenRightItem.m_shared.m_itemType && (!x.Value.ItemSkill.HasValue || x.Value.ItemSkill == (SkillType?)((Humanoid)Player.m_localPlayer).m_hiddenRightItem.m_shared.m_skillType) && (!x.Value.ItemAnim.HasValue || x.Value.ItemAnim == (AnimationState?)((Humanoid)Player.m_localPlayer).m_hiddenRightItem.m_shared.m_animationState));
				if (!keyValuePair.Equals(default(KeyValuePair<ItemCategory, TransmogItem>)) && keyValuePair.Value.ItemName != string.Empty)
				{
					name = keyValuePair.Value.ItemName;
				}
			}
		}
	}

	public const string PluginGUID = "Transmog";

	public const string PluginName = "Transmog";

	public const string PluginVersion = "3.0.0";

	public const string SaveDataVersion = "4.0";

	public const string CustomDataKey = "Alpus-Transmog";

	public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

	public static Dictionary<ItemCategory, TransmogItem> TransmogItems;

	private static ItemData lastEquippedShield;

	private static ItemData lastEquippedWeapon;

	private static bool TransmogEnabled = true;

	private static Harmony harmony;

	private void Awake()
	{
		Configs.SetupConfigs(((BaseUnityPlugin)this).Config);
		GUIManager.OnCustomGUIAvailable += AddTransmogUI;
		LocalizationManager.OnLocalizationAdded += OnLocalizationLoaded;
		harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Transmog");
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
	}

	private void AddTransmogUI()
	{
		TransmogUI.Awake();
	}

	private void OnLocalizationLoaded()
	{
		if (Localization.TryTranslate("$transmog_title").StartsWith("[") && Localization.TryTranslate("$transmog_title").EndsWith("]"))
		{
			Logger.LogWarning((object)"Could not load localization/translation files. Attempting to load files from the root folder as a work-around due to a bug with the Thunderstore mod manager...");
			string[] array = new string[1] { "manifest.json" };
			string[] files = Directory.GetFiles(Helper.GetModFolder(), "*.json");
			string[] array2 = files;
			foreach (string text in array2)
			{
				bool flag = true;
				string[] array3 = array;
				foreach (string value in array3)
				{
					if (text.EndsWith(value))
					{
						flag = false;
						break;
					}
				}
				if (!flag)
				{
					continue;
				}
				foreach (KeyValuePair<string, string> language in Helper.GetLanguages())
				{
					if (text.Contains($"{language.Key}-"))
					{
						Localization.AddJsonFile(language.Value, File.ReadAllText(text));
						Logger.LogInfo((object)$"Loaded localization file: {text} ({language.Value})");
						break;
					}
				}
			}
		}
		SetupTransmogItems();
	}

	private void SetupTransmogItems()
	{
		TransmogItems = new Dictionary<ItemCategory, TransmogItem>
		{
			{
				ItemCategory.HELMET,
				new TransmogItem(Localization.TryTranslate("$transmog_category_helmet"), (ItemType)6, null, null, canBeHidden: true)
			},
			{
				ItemCategory.CHEST,
				new TransmogItem(Localization.TryTranslate("$transmog_category_chest"), (ItemType)7, null, null, canBeHidden: true)
			},
			{
				ItemCategory.LEGS,
				new TransmogItem(Localization.TryTranslate("$transmog_category_legs"), (ItemType)11, null, null, canBeHidden: true)
			},
			{
				ItemCategory.SHOULDER,
				new TransmogItem(Localization.TryTranslate("$transmog_category_shoulder"), (ItemType)17, null, null, canBeHidden: true)
			},
			{
				ItemCategory.UTILITY,
				new TransmogItem(Localization.TryTranslate("$transmog_category_utility"), (ItemType)18, null, null, canBeHidden: true)
			},
			{
				ItemCategory.TRINKET,
				new TransmogItem(Localization.TryTranslate("$transmog_category_trinket"), (ItemType)24, null, null, canBeHidden: true)
			},
			{
				ItemCategory.SHIELD,
				new TransmogItem(Localization.TryTranslate("$transmog_category_shield"), (ItemType)5, (AnimationState)4, (SkillType)6)
			},
			{
				ItemCategory.FISTS,
				new TransmogItem(Localization.TryTranslate("$transmog_category_fists"), (ItemType)14, (AnimationState)0, (SkillType)11)
			},
			{
				ItemCategory.BOW,
				new TransmogItem(Localization.TryTranslate("$transmog_category_bow"), (ItemType)4, (AnimationState)3, (SkillType)8)
			},
			{
				ItemCategory.CROSSBOW,
				new TransmogItem(Localization.TryTranslate("$transmog_category_crossbow"), (ItemType)4, (AnimationState)10, (SkillType)14)
			},
			{
				ItemCategory.STAFF_ELEMENTAL,
				new TransmogItem(Localization.TryTranslate("$transmog_category_staff_elemental"), (ItemType)14, (AnimationState)12, (SkillType)9)
			},
			{
				ItemCategory.STAFF_BLOOD,
				new TransmogItem(Localization.TryTranslate("$transmog_category_staff_blood"), (ItemType)14, (AnimationState)12, (SkillType)10)
			},
			{
				ItemCategory.ONE_HANDED_KNIFE,
				new TransmogItem(Localization.TryTranslate("$transmog_category_one_handed_knife"), (ItemType)3, (AnimationState)0, (SkillType)11)
			},
			{
				ItemCategory.ONE_HANDED_AXE,
				new TransmogItem(Localization.TryTranslate("$transmog_category_one_handed_axe"), (ItemType)3, (AnimationState)1, (SkillType)7)
			},
			{
				ItemCategory.ONE_HANDED_CLUB,
				new TransmogItem(Localization.TryTranslate("$transmog_category_one_handed_club"), (ItemType)3, (AnimationState)1, (SkillType)3)
			},
			{
				ItemCategory.ONE_HANDED_SWORD,
				new TransmogItem(Localization.TryTranslate("$transmog_category_one_handed_sword"), (ItemType)3, (AnimationState)1, (SkillType)1)
			},
			{
				ItemCategory.DUAL_KNIFE,
				new TransmogItem(Localization.TryTranslate("$transmog_category_dual_knife"), (ItemType)14, (AnimationState)11, (SkillType)2)
			},
			{
				ItemCategory.TWO_HANDED_AXE,
				new TransmogItem(Localization.TryTranslate("$transmog_category_two_handed_axe"), (ItemType)14, (AnimationState)8, (SkillType)7)
			},
			{
				ItemCategory.TWO_HANDED_CLUB,
				new TransmogItem(Localization.TryTranslate("$transmog_category_two_handed_club"), (ItemType)14, (AnimationState)2, (SkillType)3)
			},
			{
				ItemCategory.TWO_HANDED_SWORD,
				new TransmogItem(Localization.TryTranslate("$transmog_category_two_handed_sword"), (ItemType)14, (AnimationState)13, (SkillType)1)
			},
			{
				ItemCategory.DUAL_AXE,
				new TransmogItem(Localization.TryTranslate("$transmog_category_dual_axe"), (ItemType)14, (AnimationState)15, (SkillType)7)
			},
			{
				ItemCategory.SPEAR,
				new TransmogItem(Localization.TryTranslate("$transmog_category_spear"), (ItemType)3, (AnimationState)1, (SkillType)5)
			},
			{
				ItemCategory.POLEARM,
				new TransmogItem(Localization.TryTranslate("$transmog_category_polearm"), (ItemType)14, (AnimationState)7, (SkillType)4)
			},
			{
				ItemCategory.PICKAXE,
				new TransmogItem(Localization.TryTranslate("$transmog_category_pickaxe"), (ItemType)14, (AnimationState)2, (SkillType)12)
			}
		};
	}

	private static void SaveData()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ZPackage val = new ZPackage();
		val.Write("4.0");
		val.Write(TransmogEnabled);
		val.Write(TransmogItems.Count);
		foreach (KeyValuePair<ItemCategory, TransmogItem> transmogItem in TransmogItems)
		{
			val.Write(transmogItem.Key.ToString());
			val.Write(transmogItem.Value.ItemName);
			val.Write(transmogItem.Value.ItemVariant);
			if (transmogItem.Value.CanBeHidden)
			{
				val.Write(transmogItem.Value.Hidden);
			}
			else if (transmogItem.Key == ItemCategory.SHIELD)
			{
				val.Write(transmogItem.Value.NeverHide);
			}
		}
		if (Player.m_localPlayer.m_customData.ContainsKey("Alpus-Transmog"))
		{
			Player.m_localPlayer.m_customData["Alpus-Transmog"] = val.GetBase64();
		}
		else
		{
			Player.m_localPlayer.m_customData.Add("Alpus-Transmog", val.GetBase64());
		}
		Logger.LogInfo((object)"Transmog data saved successfuly!");
	}

	private static void LoadData(ZPackage package)
	{
		Logger.LogInfo((object)"Loading transmog data...");
		string text = package.ReadString();
		if (!(text == "3.0") && !(text == "4.0"))
		{
			return;
		}
		TransmogEnabled = package.ReadBool();
		int num = package.ReadInt();
		for (int i = 0; i < num; i++)
		{
			if (Enum.TryParse<ItemCategory>(package.ReadString(), out var result))
			{
				if (TransmogItems.ContainsKey(result))
				{
					TransmogItems[result].ItemName = package.ReadString();
					TransmogItems[result].ItemVariant = package.ReadInt();
					if (TransmogItems[result].CanBeHidden)
					{
						TransmogItems[result].Hidden = package.ReadBool();
					}
					else if (result == ItemCategory.SHIELD && text == "4.0")
					{
						TransmogItems[result].NeverHide = package.ReadBool();
					}
					continue;
				}
				Logger.LogError((object)$"Could not find item category '{result}'. Aborting the loading.");
				break;
			}
			Logger.LogWarning((object)$"Could not parse item category '{result}'. Aborting the loading.");
			break;
		}
		TransmogUI.UpdateItemGrid();
		Logger.LogInfo((object)"Transmog data loading completed.");
	}

	public static bool TakeInput()
	{
		bool result = (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible() && !StoreGui.IsVisible() && !Menu.IsVisible() && (!Object.op_Implicit((Object)(object)TextViewer.instance) || !TextViewer.instance.IsVisible()) && !Minimap.IsOpen() && !GameCamera.InFreeFly() && !PlayerCustomizaton.IsBarberGuiVisible();
		if (((Character)Player.m_localPlayer).IsDead() || ((Character)Player.m_localPlayer).InCutscene() || ((Character)Player.m_localPlayer).IsTeleporting())
		{
			result = false;
		}
		return result;
	}

	public static void UpdateTransmog(ItemCategory itemCategory, string itemName, int itemVariant, bool? hidden = null, Sprite sprite = null)
	{
		TransmogItems[itemCategory].ItemName = itemName;
		TransmogItems[itemCategory].ItemVariant = itemVariant;
		if (hidden.HasValue)
		{
			TransmogItems[itemCategory].Hidden = hidden.Value;
		}
		TransmogUI.UpdateItemGrid(itemCategory, sprite ?? TransmogUI.GetItemIcon(itemName));
		((Humanoid)Player.m_localPlayer).SetupVisEquipment(((Humanoid)Player.m_localPlayer).m_visEquipment, false);
		SaveData();
	}

	public static void UpdateTransmog(ItemCategory itemCategory, bool toggleIsOn)
	{
		if (TransmogItems[itemCategory].CanBeHidden)
		{
			TransmogItems[itemCategory].Hidden = toggleIsOn;
		}
		else if (itemCategory == ItemCategory.SHIELD)
		{
			TransmogItems[itemCategory].NeverHide = toggleIsOn;
		}
		((Humanoid)Player.m_localPlayer).SetupVisEquipment(((Humanoid)Player.m_localPlayer).m_visEquipment, false);
		SaveData();
	}
}
public class TransmogUI
{
	public class ItemGridProperties
	{
		public Image Image;

		public Toggle Toggle;

		public ItemGridProperties(Image image, Toggle toggle)
		{
			Image = image;
			Toggle = toggle;
		}
	}

	public static readonly Dictionary<string, Vector2> Anchors = new Dictionary<string, Vector2>
	{
		{
			"Upper-left",
			new Vector2(0f, 1f)
		},
		{
			"Upper-mid",
			new Vector2(0.5f, 1f)
		},
		{
			"Upper-right",
			new Vector2(1f, 1f)
		},
		{
			"Middle-left",
			new Vector2(0f, 0.5f)
		},
		{
			"Middle-center",
			new Vector2(0.5f, 0.5f)
		},
		{
			"Middle-right",
			new Vector2(1f, 0.5f)
		},
		{
			"Lower-left",
			new Vector2(0f, 0f)
		},
		{
			"Lower-center",
			new Vector2(0.5f, 0f)
		},
		{
			"Lower-right",
			new Vector2(1f, 0f)
		}
	};

	private static Dictionary<ItemCategory, ItemGridProperties> ItemGrid;

	public static Sprite DefaultItemIcon;

	public static GameObject Panel;

	public static void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		Scene scene = GUIManager.CustomGUIBack.scene;
		if (!(((Scene)(ref scene)).name != "main"))
		{
			BuildMenu();
		}
	}

	public static void OpenMenu()
	{
		GameObject panel = Panel;
		if (panel != null)
		{
			panel.SetActive(true);
		}
	}

	public static void CloseMenu()
	{
		GameObject panel = Panel;
		if (panel != null)
		{
			panel.SetActive(false);
		}
	}

	public static void ToggleMenu()
	{
		if (!((Object)(object)Panel == (Object)null))
		{
			if (!Panel.activeSelf)
			{
				OpenMenu();
			}
			else
			{
				CloseMenu();
			}
		}
	}

	public static void UpdateItemGrid()
	{
		foreach (KeyValuePair<ItemCategory, ItemGridProperties> item in ItemGrid)
		{
			TransmogItem transmogItem = Transmog.TransmogItems[item.Key];
			item.Value.Image.sprite = GetItemIcon(transmogItem.ItemName) ?? DefaultItemIcon;
			if ((Object)(object)item.Value.Toggle != (Object)null)
			{
				item.Value.Toggle.isOn = transmogItem.Hidden || transmogItem.NeverHide;
			}
		}
	}

	public static void UpdateItemGrid(ItemCategory itemCategory, Sprite sprite)
	{
		ItemGrid[itemCategory].Image.sprite = sprite;
		if ((Object)(object)ItemGrid[itemCategory].Toggle != (Object)null)
		{
			TransmogItem transmogItem = Transmog.TransmogItems[itemCategory];
			ItemGrid[itemCategory].Toggle.isOn = transmogItem.Hidden || transmogItem.NeverHide;
		}
	}

	public static Sprite GetItemIcon(string prefab)
	{
		Sprite val = null;
		if (!string.IsNullOrEmpty(prefab))
		{
			GameObject prefab2 = ZNetScene.instance.GetPrefab(prefab);
			if ((Object)(object)prefab2 != (Object)null)
			{
				ItemDrop component = prefab2.GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null)
				{
					val = component.m_itemData.GetIcon();
				}
			}
		}
		return val ?? DefaultItemIcon;
	}

	private static Image CreateItemFrame(ItemCategory itemCategory, Sprite sprite, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 position, Color color, float width, float height)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Image", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = anchorMin;
		component.anchorMax = anchorMax;
		component.pivot = pivot;
		component.SetSizeWithCurrentAnchors((Axis)0, width);
		component.SetSizeWithCurrentAnchors((Axis)1, height);
		Image component2 = val.GetComponent<Image>();
		component2.sprite = sprite;
		((Graphic)component2).color = color;
		Button val2 = val.AddComponent<Button>();
		((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
		{
			ResetItem(itemCategory);
		});
		val.transform.SetParent(Panel.transform);
		component.anchoredPosition = position;
		return component2;
	}

	private static void BuildMenu()
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: 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_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Expected O, but got Unknown
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: 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_0355: 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_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: 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_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0416: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0537: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Unknown result type (might be due to invalid IL or missing references)
		//IL_056b: Unknown result type (might be due to invalid IL or missing references)
		//IL_057c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Panel != (Object)null && (Object)(object)Panel.gameObject != (Object)null)
		{
			Object.Destroy((Object)(object)Panel.gameObject);
		}
		DefaultItemIcon = GetItemIcon("Wisp");
		float num = 1008f;
		float num2 = 740f;
		float num3 = 24f;
		Panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, Anchors[Configs.PanelAnchor.Value], Anchors[Configs.PanelAnchor.Value], Configs.PanelPosition.Value, num, num2, true);
		GameObject val = GUIManager.Instance.CreateText(Transmog.Localization.TryTranslate("$transmog_title"), Panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f - num3), GUIManager.Instance.AveriaSerifBold, 24, GUIManager.Instance.ValheimOrange, true, Color.black, num - num3 * 2f, 100f, false);
		val.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 1f);
		val.GetComponent<Text>().alignment = (TextAnchor)1;
		GameObject val2 = GUIManager.Instance.CreateText(Transmog.Localization.TryTranslate("$transmog_instructions"), Panel.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num3, num3 - 96f), GUIManager.Instance.AveriaSerif, 16, Color.white, false, Color.black, num - num3 * 2f, 64f, false);
		val2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
		GameObject val3 = GUIManager.Instance.CreateButton("X", Panel.transform, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-25f, -25f), 40f, 40f);
		((UnityEvent)val3.GetComponent<Button>().onClick).AddListener(new UnityAction(CloseMenu));
		float num4 = 64f;
		float num5 = 64f;
		float num6 = 240f;
		float num7 = 96f;
		float num8 = num3;
		float num9 = num3 + 140f;
		ItemGrid = new Dictionary<ItemCategory, ItemGridProperties>();
		foreach (KeyValuePair<ItemCategory, TransmogItem> transmogItem in Transmog.TransmogItems)
		{
			GameObject val4 = GUIManager.Instance.CreateButton(string.Empty, Panel.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num8, 0f - num9), num4, num5);
			val4.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
			Image image = CreateItemFrame(transmogItem.Key, DefaultItemIcon, Panel.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num8, 0f - num9), new Color(1f, 1f, 1f, 0.75f), num4, num5);
			GameObject val5 = GUIManager.Instance.CreateText(transmogItem.Value.ItemLabel, Panel.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num8 + num4 + 8f, 0f - num9 - 8f - ((!transmogItem.Value.CanBeHidden && transmogItem.Key != ItemCategory.SHIELD) ? 14f : 0f)), GUIManager.Instance.AveriaSerif, 16, Color.white, false, Color.black, num6, 32f, false);
			val5.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
			Toggle val6 = null;
			if (transmogItem.Value.CanBeHidden || transmogItem.Key == ItemCategory.SHIELD)
			{
				GameObject val7 = GUIManager.Instance.CreateToggle(Panel.transform, 20f, 20f);
				RectTransform component = val7.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0f, 1f);
				component.anchorMax = new Vector2(0f, 1f);
				component.pivot = new Vector2(0f, 1f);
				component.anchoredPosition = new Vector2(num8 + num4 + 8f, 0f - num9 - 34f);
				val6 = val7.GetComponent<Toggle>();
				val6.isOn = false;
				GameObject val8 = GUIManager.Instance.CreateText(string.Empty, Panel.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num8 + num4 + 8f + 28f, 0f - num9 - 34f - 1f), GUIManager.Instance.AveriaSerif, 16, Color.white, false, Color.black, num6, 32f, false);
				Text component2 = val8.GetComponent<Text>();
				if (transmogItem.Value.CanBeHidden)
				{
					component2.text = Transmog.Localization.TryTranslate("$transmog_hide");
				}
				else
				{
					component2.text = Transmog.Localization.TryTranslate("$transmog_never_hide");
				}
				val8.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
			}
			num8 += num6;
			if (num8 + num6 + num3 > num)
			{
				num9 += num7;
				num8 = num3;
			}
			ItemGrid.Add(transmogItem.Key, new ItemGridProperties(image, val6));
			((UnityEvent<bool>)(object)val6?.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				CheckboxToggled(transmogItem.Key);
			});
		}
		Panel.SetActive(false);
	}

	private static void ResetItem(ItemCategory itemCategory)
	{
		Transmog.UpdateTransmog(itemCategory, string.Empty, 0, false);
	}

	private static void CheckboxToggled(ItemCategory itemCategory)
	{
		Transmog.UpdateTransmog(itemCategory, ItemGrid[itemCategory].Toggle.isOn);
	}
}