Decompiled source of Enchantments Viewer v0.2.0

OutwardEnchantmentsViewer.dll

Decompiled a week 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;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using OutwardEnchantmentsViewer.Enchantments;
using OutwardEnchantmentsViewer.Managers;
using OutwardEnchantmentsViewer.UI;
using OutwardEnchantmentsViewer.Utility.Enums;
using OutwardEnchantmentsViewer.Utility.Fixers;
using OutwardEnchantmentsViewer.Utility.Helpers;
using SideLoader;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardEnchantmentsViewer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardEnchanmentsViewe")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace OutwardEnchantmentsViewer
{
	[BepInPlugin("gymmed.outwardenchantmentsviewer", "Outward Enchantments Viewer", "0.2.0")]
	public class OutwardEnchantmentsViewer : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ItemDetailsDisplay), "OnScrollDownPressed")]
		public class Patch_OnScrollDownPressed
		{
			private static bool Prefix(ItemDetailsDisplay __instance)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.m_movingScrollview)
				{
					return false;
				}
				Rect rect;
				if (__instance.m_viewPortSize == 0f)
				{
					RectTransform component = ((Component)((Component)__instance).transform.Find("ItemDetails/Stats/Scroll View/Viewport")).GetComponent<RectTransform>();
					if ((Object)(object)component == (Object)null)
					{
						SL.Log(prefix + " ItemDetailsDisplay@OnScrollDownPressed missing ViewPort for ItemDetailsDisplay");
						return true;
					}
					rect = component.rect;
					__instance.m_viewPortSize = ((Rect)(ref rect)).height;
				}
				float viewPortSize = __instance.m_viewPortSize;
				rect = __instance.m_contentScrollView.content.rect;
				float num = viewPortSize / ((Rect)(ref rect)).height;
				__instance.m_targetScrollPos = Mathf.Clamp(__instance.m_contentScrollView.verticalNormalizedPosition - num, 0f, 1f);
				__instance.m_movingScrollview = true;
				((Selectable)__instance.m_btnScrollDown).interactable = false;
				((Selectable)__instance.m_btnScrollUp).interactable = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(ItemDetailsDisplay), "OnScrollUpPressed")]
		public class Patch_OnScrollUpPressed
		{
			private static bool Prefix(ItemDetailsDisplay __instance)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.m_movingScrollview)
				{
					return false;
				}
				Rect rect;
				if (__instance.m_viewPortSize == 0f)
				{
					RectTransform component = ((Component)((Component)__instance).transform.Find("ItemDetails/Stats/Scroll View/Viewport")).GetComponent<RectTransform>();
					if ((Object)(object)component == (Object)null)
					{
						SL.Log(prefix + " ItemDetailsDisplay@OnScrollUpPressed missing ViewPort for ItemDetailsDisplay");
						return true;
					}
					rect = component.rect;
					__instance.m_viewPortSize = ((Rect)(ref rect)).height;
				}
				float viewPortSize = __instance.m_viewPortSize;
				rect = __instance.m_contentScrollView.content.rect;
				float num = viewPortSize / ((Rect)(ref rect)).height;
				__instance.m_targetScrollPos = Mathf.Clamp(__instance.m_contentScrollView.verticalNormalizedPosition + num, 0f, 1f);
				__instance.m_movingScrollview = true;
				((Selectable)__instance.m_btnScrollDown).interactable = false;
				((Selectable)__instance.m_btnScrollUp).interactable = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(ResourcesPrefabManager), "Load")]
		public class ResourcesPrefabManager_Load
		{
			private static void Postfix(ResourcesPrefabManager __instance)
			{
				string filePath = Path.Combine(XmlSerializerHelper.GetProjectLocation(), "customEnchantmentsDescriptions.xml");
				CustomEnchantmentsManager.Instance.LoadEnchantmentDictionaryFromXml(filePath);
				EnchantmentsHelper.FixFilterRecipe();
			}
		}

		[HarmonyPatch(typeof(ItemDetailsDisplay))]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class ItemDetailsDisplay_AwakeInit
		{
			[HarmonyPostfix]
			private static void Postfix(ItemDetailsDisplay __instance)
			{
				try
				{
					new ItemDescriptionScrollFixer(__instance);
					ItemDisplayManager.Instance.TryCreateSection(__instance);
				}
				catch (Exception ex)
				{
					SL.Log(prefix + " ItemDetailsDisplay@StartInit error: " + ex.Message);
				}
			}
		}

		[HarmonyPatch(typeof(ItemDetailsDisplay))]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class ItemDetailsDisplay_RefreshDetailsPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ItemDetailsDisplay __instance)
			{
				try
				{
					ItemDisplay itemDisplay = __instance.itemDisplay;
					Item val = ((itemDisplay != null) ? itemDisplay.RefItem : null);
					ItemDisplayManager.Instance.ShowOriginalDescription(__instance);
					Character localCharacter = ((UIElement)__instance).LocalCharacter;
					CharacterInventory val2 = ((localCharacter != null) ? localCharacter.Inventory : null);
					if (!Object.op_Implicit((Object)(object)val2))
					{
						return;
					}
					if (ShowDescriptionsOnlyForInventory.Value && (Object)(object)val.m_lastParentItemContainer != (Object)null && val.m_lastParentItemContainer is MerchantPouch)
					{
						ItemDisplayManager.Instance.HideDescription(__instance);
						ItemDisplayManager.Instance.HideDisabledDescription(__instance);
					}
					else if (!(val is Equipment))
					{
						EnchantmentRecipeItem val3 = (EnchantmentRecipeItem)(object)((val is EnchantmentRecipeItem) ? val : null);
						if (val3 != null)
						{
							if (!ShowEnchantmentDescriptions.Value)
							{
								ItemDisplayManager.Instance.HideDescription(__instance);
								ItemDisplayManager.Instance.HideDisabledDescription(__instance);
							}
							else
							{
								ItemDescriptionsManager.Instance.SetEnchantmentsDescription(val3, val2, __instance);
								ItemDisplayManager.Instance.HideDisabledDescription(__instance);
							}
						}
						else
						{
							ItemDisplayManager.Instance.HideDescription(__instance);
							ItemDisplayManager.Instance.HideDisabledDescription(__instance);
						}
					}
					else if (!ShowEquipmentDescriptions.Value || val.IsNonEnchantable)
					{
						ItemDisplayManager.Instance.HideDescription(__instance);
						ItemDisplayManager.Instance.HideDisabledDescription(__instance);
					}
					else
					{
						ItemDescriptionsManager.Instance.SetEquipmentsEnchantmentsDescription(val, val2, __instance);
					}
				}
				catch (Exception ex)
				{
					SL.Log(prefix + " ItemDetailsDisplay@RefreshDetails error: " + ex.Message);
				}
			}
		}

		public const string GUID = "gymmed.outwardenchantmentsviewer";

		public const string NAME = "Outward Enchantments Viewer";

		public const string VERSION = "0.2.0";

		public static string prefix = "[gymmed-Enchantments-Viewer]";

		public static ConfigEntry<bool> ShowEnchantmentDescriptions;

		public static ConfigEntry<bool> ShowEquipmentDescriptions;

		public static ConfigEntry<bool> ShowAllAvailableEnchantmentsCountForEquipment;

		public static ConfigEntry<bool> ShowMissingEnchantmentsForEquipment;

		public static ConfigEntry<bool> ShowDescriptionsOnlyForInventory;

		public static ManualLogSource Log { get; private set; }

		public static OutwardEnchantmentsViewer Instance { get; private set; }

		internal void Awake()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogMessage((object)"Hello world from Outward Enchantments Viewer 0.2.0!");
			ShowEnchantmentDescriptions = ((BaseUnityPlugin)this).Config.Bind<bool>("Enchantments Descriptions", "ShowEnchantmentDescriptions", true, "Show detailed descriptions for enchantments?");
			ShowEquipmentDescriptions = ((BaseUnityPlugin)this).Config.Bind<bool>("Equipment Descriptions", "ShowEquipmentEnchantmentsDescriptions", true, "Show enchantments for equipment?");
			ShowAllAvailableEnchantmentsCountForEquipment = ((BaseUnityPlugin)this).Config.Bind<bool>("Equipment Descriptions Header", "ShowAllAvailableEnchantmentsCountForEquipment", true, "Show all available enchantments count for equipment?");
			ShowMissingEnchantmentsForEquipment = ((BaseUnityPlugin)this).Config.Bind<bool>("Equipment Descriptions Body", "ShowMissingEnchantmentsForEquipment", true, "Show missing enchantments for equipment?");
			ShowDescriptionsOnlyForInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Show Descriptions in Panels", "ShowDescriptionsOnlyForInventory", false, "Show descriptions only for items in inventory?");
			new Harmony("gymmed.outwardenchantmentsviewer").PatchAll();
		}

		internal void Update()
		{
		}
	}
}
namespace OutwardEnchantmentsViewer.Utility.Helpers
{
	public class EnchantmentInformationHelper
	{
		public static string GetDamageListDescription(Enchantment enchantment)
		{
			string text = "";
			if (enchantment.DamageBonus.Count < 1)
			{
				return text;
			}
			int num = enchantment.DamageBonus.Count - 1;
			DamageType damageType = enchantment.DamageBonus[0];
			text += GetDamageDescription(damageType, fullGrowthWords: true);
			for (int i = 1; i < num; i++)
			{
				damageType = enchantment.DamageBonus[i];
				text = text + ", " + GetDamageDescription(damageType);
			}
			if (num > 0)
			{
				damageType = enchantment.DamageBonus[num];
				text = text + " and " + GetDamageDescription(damageType);
			}
			return text + "\n\n";
		}

		private static string GetDamageDescription(DamageType damageType, bool fullGrowthWords = false)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			string arg = "";
			if (fullGrowthWords)
			{
				arg = "Lose ";
				if (damageType.Damage > 0f)
				{
					arg = "Gain +";
				}
			}
			else if (damageType.Damage > 0f)
			{
				arg = "+";
			}
			return $"{arg}{damageType.Damage} flat {damageType.Type} damage";
		}

		public static string GetModifiersListDescriptions(Enchantment enchantment)
		{
			string text = "";
			if (enchantment.DamageModifier.Count < 1)
			{
				return text;
			}
			int num = enchantment.DamageModifier.Count - 1;
			DamageType damageType = enchantment.DamageModifier[0];
			text += GetModifierDescription(damageType, fullGrowthWords: true);
			for (int i = 1; i < num; i++)
			{
				damageType = enchantment.DamageModifier[i];
				text = text + ", " + GetModifierDescription(damageType);
			}
			if (num > 0)
			{
				damageType = enchantment.DamageModifier[num];
				text = text + " and " + GetModifierDescription(damageType);
			}
			return text + "\n\n";
		}

		private static string GetModifierDescription(DamageType damageType, bool fullGrowthWords = false)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			string arg = "";
			if (fullGrowthWords)
			{
				arg = "Lose ";
				if (damageType.Damage > 0f)
				{
					arg = "Gain +";
				}
			}
			else if (damageType.Damage > 0f)
			{
				arg = "+";
			}
			return $"{arg}{damageType.Damage}% {damageType.Type} Damage Bonus";
		}

		public static string GetAdditionalDamagesDescription(Enchantment enchantment)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			if (enchantment.AdditionalDamages.Count() < 1)
			{
				return text;
			}
			AdditionalDamage[] additionalDamages = enchantment.AdditionalDamages;
			foreach (AdditionalDamage val in additionalDamages)
			{
				string arg = "Removes ";
				if (val.ConversionRatio > 0f)
				{
					arg = "Adds +";
				}
				string arg2 = ((int)Math.Round(val.ConversionRatio * 100f, 0)).ToString();
				text = text + $"{arg}{arg2}% of the existing weapon's {val.SourceDamageType}" + $" damage as {val.BonusDamageType} damage \n\n";
			}
			return text;
		}

		public static string GetStatModificationsDescription(Enchantment enchantment)
		{
			string text = "";
			if (enchantment.StatModifications.Count < 1)
			{
				return text;
			}
			int num = enchantment.StatModifications.Count - 1;
			StatModification statModification = enchantment.StatModifications[0];
			text += GetStatModificationDescription(statModification, fullGrowthWords: true);
			for (int i = 1; i < num; i++)
			{
				statModification = enchantment.StatModifications[i];
				text = text + ", " + GetStatModificationDescription(statModification);
			}
			if (num > 0)
			{
				statModification = enchantment.StatModifications[num];
				text = text + " and " + GetStatModificationDescription(statModification);
			}
			return text + "\n\n";
		}

		private static string GetStatModificationDescription(StatModification statModification, bool fullGrowthWords = false)
		{
			string text = "";
			string text2 = Regex.Replace(((object)(Stat)(ref statModification.Name)).ToString(), "(?<!^)([A-Z])", " $1");
			if (fullGrowthWords)
			{
				text = "Removes ";
				if (statModification.Value > 0f)
				{
					text = "Adds +";
				}
			}
			else if (statModification.Value > 0f)
			{
				text = "+";
			}
			string text3 = ((((object)(BonusType)(ref statModification.Type)).ToString() == "Modifier") ? "% " : (" " + ((object)(BonusType)(ref statModification.Type)).ToString() + " "));
			return text + statModification.Value + text3 + text2;
		}

		public static string GetElementalResistancesDescription(Enchantment enchantment)
		{
			string text = "";
			if (enchantment.ElementalResistances.Count < 1)
			{
				return text;
			}
			int num = enchantment.ElementalResistances.Count - 1;
			DamageType damageType = enchantment.ElementalResistances[0];
			text += GetElementalResistanceDescription(damageType, fullGrowthWords: true);
			for (int i = 1; i < num; i++)
			{
				damageType = enchantment.ElementalResistances[i];
				text = text + ", " + GetElementalResistanceDescription(damageType);
			}
			if (num > 0)
			{
				damageType = enchantment.ElementalResistances[num];
				text = text + " and " + GetElementalResistanceDescription(damageType);
			}
			return text + "\n\n";
		}

		private static string GetElementalResistanceDescription(DamageType damageType, bool fullGrowthWords = false)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			string arg = "";
			if (fullGrowthWords)
			{
				arg = "Removes ";
				if (damageType.Damage > 0f)
				{
					arg = "Adds +";
				}
			}
			else if (damageType.Damage > 0f)
			{
				arg = "+";
			}
			return $"{arg}{damageType.Damage}% {damageType.Type} resistance";
		}

		public static string GetEffectsDescription(Enchantment enchantment)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			if (enchantment.Effects.Count() < 1)
			{
				return text;
			}
			GenericHelper.SplitDerivedClasses<Effect, AddStatusEffectBuildUp>(enchantment.Effects, out var remainingArray, out var derivedArray);
			text += GetAddStatusEffectBuildUpDescription(derivedArray);
			GenericHelper.SplitDerivedClasses<Effect, ShootEnchantmentBlast>(remainingArray, out remainingArray, out var derivedArray2);
			ShootEnchantmentBlast[] array = derivedArray2;
			foreach (ShootEnchantmentBlast val in array)
			{
				string text2 = text;
				Blast baseBlast = ((ShootBlast)val).BaseBlast;
				text = text2 + $"Weapon deals an AoE {((baseBlast != null) ? ((Component)baseBlast).GetComponentInChildren<WeaponDamage>()?.OverrideDType : null)} \"Blast\" with " + $"{val.DamageMultiplier}x damage multiplier (based on Weapon's total base damage) \n\n";
			}
			GenericHelper.SplitDerivedClasses<Effect, AffectStatusEffectBuildUpResistance>(remainingArray, out remainingArray, out var derivedArray3);
			text += GetAffectStatusEffectBuildUpResistancesDescription(derivedArray3);
			GenericHelper.SplitDerivedClasses<Effect, AddStatusEffect>(remainingArray, out remainingArray, out var derivedArray4);
			text += GetAddStatusEffectsDescription(derivedArray4);
			Effect[] array2 = remainingArray;
			foreach (Effect val2 in array2)
			{
				text += $"Type: {((object)val2).GetType()}";
			}
			return text + "\n";
		}

		private static string GetAddStatusEffectBuildUpDescription(AddStatusEffectBuildUp[] derivedStatusEffects)
		{
			string text = "";
			if (derivedStatusEffects.Length < 1)
			{
				return text;
			}
			int num = derivedStatusEffects.Length - 1;
			AddStatusEffectBuildUp val = derivedStatusEffects[0];
			text = text + "Weapon now inflicts " + val.Status.StatusName + " " + $"({val.BuildUpValue}% buildup)";
			for (int i = 1; i < num; i++)
			{
				val = derivedStatusEffects[i];
				text = text + ", " + val.Status.StatusName + " " + $"({val.BuildUpValue}% buildup)";
			}
			if (num > 0)
			{
				val = derivedStatusEffects[num];
				text = text + " and " + val.Status.StatusName + " " + $"({val.BuildUpValue}% buildup) \n\n";
			}
			return text;
		}

		private static string GetAffectStatusEffectBuildUpResistancesDescription(AffectStatusEffectBuildUpResistance[] derivedStatusResistances)
		{
			string text = "";
			if (derivedStatusResistances.Length < 1)
			{
				return text;
			}
			int num = derivedStatusResistances.Length - 1;
			AffectStatusEffectBuildUpResistance val = derivedStatusResistances[0];
			text = text + "Euipment now provides " + val.StatusEffect.StatusName + " " + $"({val.RealValue}% buildup) resistance";
			for (int i = 0; i < num; i++)
			{
				val = derivedStatusResistances[i];
				text = text + ", " + val.StatusEffect.StatusName + " " + $"({val.RealValue}% buildup) resistance";
			}
			if (num > 0)
			{
				val = derivedStatusResistances[num];
				text = text + " and " + val.StatusEffect.StatusName + " " + $"({val.RealValue}% buildup) resistance \n";
			}
			return text;
		}

		private static string GetAddStatusEffectsDescription(AddStatusEffect[] derivedAddStatusEffect)
		{
			string text = "";
			if (derivedAddStatusEffect.Length < 1)
			{
				return text;
			}
			int num = derivedAddStatusEffect.Length - 1;
			AddStatusEffect val = null;
			string text2 = "";
			for (int i = 0; i < derivedAddStatusEffect.Length; i++)
			{
				val = derivedAddStatusEffect[i];
				text2 = ((val.ChancesToContract <= 0) ? "" : "+");
				text = ((i != 0) ? ((i != num) ? (text + ", " + val.Status.StatusName + " " + $"({text2}{val.ChancesToContract})") : (text + " and " + val.Status.StatusName + " " + $"({text2}{val.ChancesToContract}) \n")) : (text + "Euipment now contracts " + val.Status.StatusName + " " + $"({text2}{val.ChancesToContract})"));
			}
			return text;
		}
	}
	public class EnchantmentsHelper
	{
		public static string GetEnchantmentArmorIngrediantType(EnchantmentRecipe recipe)
		{
			//IL_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			IngredientData[] compatibleEquipments = recipe.CompatibleEquipments.CompatibleEquipments;
			foreach (IngredientData val in compatibleEquipments)
			{
				Item specificIngredient = val.SpecificIngredient;
				Armor val2 = (Armor)(object)((specificIngredient is Armor) ? specificIngredient : null);
				if (val2 != null)
				{
					return ((object)(EquipmentSlotIDs)(ref ((Equipment)val2).EquipSlot)).ToString();
				}
				Item specificIngredient2 = val.SpecificIngredient;
				Weapon val3 = (Weapon)(object)((specificIngredient2 is Weapon) ? specificIngredient2 : null);
				if (val3 != null)
				{
					return ((Item)val3).TypeDisplay.ToString();
				}
			}
			return "";
		}

		public static string GetEnchantmentDescription(EnchantmentRecipeItem enchantmentItem)
		{
			return ((Item)enchantmentItem).Name + " \n";
		}

		public static string GetEnchantmentsDescriptions(List<EnchantmentRecipeData> enchantmentRecipesDatas)
		{
			string text = "";
			foreach (EnchantmentRecipeData enchantmentRecipesData in enchantmentRecipesDatas)
			{
				text += GetEnchantmentDescription(enchantmentRecipesData.item);
			}
			return text;
		}

		public static string GetEnchantmentsDescriptions(List<EnchantmentRecipe> enchantmentRecipes)
		{
			string text = "";
			foreach (EnchantmentRecipe enchantmentRecipe in enchantmentRecipes)
			{
				Enchantment enchantmentPrefab = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(enchantmentRecipe.RecipeID);
				text = text + "Enchanting: " + enchantmentPrefab.Name + " \n";
			}
			return text;
		}

		public static List<EnchantmentRecipeData> GetAvailableEnchantmentRecipeDatasInInventory(Item item, CharacterInventory inventory)
		{
			List<EnchantmentRecipeItem> allItemsOfType = ItemHelpers.GetAllItemsOfType<EnchantmentRecipeItem>(ItemHelpers.GetUniqueItemsInInventory(inventory));
			List<EnchantmentRecipeData> list = new List<EnchantmentRecipeData>();
			foreach (EnchantmentRecipeItem item2 in allItemsOfType)
			{
				EnchantmentRecipe[] recipes = item2.Recipes;
				foreach (EnchantmentRecipe val in recipes)
				{
					if (val.GetHasMatchingEquipment(item))
					{
						list.Add(new EnchantmentRecipeData(item2, val));
					}
				}
			}
			return list;
		}

		public static List<EnchantmentRecipeItem> GetAvailableEnchantmentRecipeItemsInInventory(Item item, CharacterInventory inventory)
		{
			List<EnchantmentRecipeItem> allItemsOfType = ItemHelpers.GetAllItemsOfType<EnchantmentRecipeItem>(ItemHelpers.GetUniqueItemsInInventory(inventory));
			List<EnchantmentRecipeItem> list = new List<EnchantmentRecipeItem>();
			foreach (EnchantmentRecipeItem item2 in allItemsOfType)
			{
				EnchantmentRecipe[] recipes = item2.Recipes;
				for (int i = 0; i < recipes.Length; i++)
				{
					if (recipes[i].GetHasMatchingEquipment(item))
					{
						list.Add(item2);
					}
				}
			}
			return list;
		}

		public static List<EnchantmentRecipe> GetAvailableEnchantmentRecipies(Item item)
		{
			List<EnchantmentRecipe> enchantmentRecipes = RecipeManager.Instance.GetEnchantmentRecipes();
			List<EnchantmentRecipe> list = new List<EnchantmentRecipe>();
			foreach (EnchantmentRecipe item2 in enchantmentRecipes)
			{
				if (item2.GetHasMatchingEquipment(item))
				{
					list.Add(item2);
				}
			}
			return list;
		}

		public static List<EnchantmentRecipe> GetMissingEnchantments(List<EnchantmentRecipe> availableEnchantments, List<EnchantmentRecipe> haveEnchantments)
		{
			List<EnchantmentRecipe> list = new List<EnchantmentRecipe>();
			bool flag = false;
			foreach (EnchantmentRecipe availableEnchantment in availableEnchantments)
			{
				foreach (EnchantmentRecipe haveEnchantment in haveEnchantments)
				{
					if (availableEnchantment.RecipeID == haveEnchantment.RecipeID)
					{
						flag = true;
					}
				}
				if (flag)
				{
					flag = false;
				}
				else
				{
					list.Add(availableEnchantment);
				}
			}
			return list;
		}

		public static void FixFilterRecipe()
		{
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab("5800047");
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return;
			}
			EnchantmentRecipeItem val = (EnchantmentRecipeItem)(object)((itemPrefab is EnchantmentRecipeItem) ? itemPrefab : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				_ = val.Recipes;
				EnchantmentRecipe enchantmentRecipeForID = RecipeManager.Instance.GetEnchantmentRecipeForID(52);
				EnchantmentRecipe enchantmentRecipeForID2 = RecipeManager.Instance.GetEnchantmentRecipeForID(53);
				EnchantmentRecipe enchantmentRecipeForID3 = RecipeManager.Instance.GetEnchantmentRecipeForID(54);
				if (!((Object)(object)enchantmentRecipeForID == (Object)null) && !((Object)(object)enchantmentRecipeForID2 == (Object)null) && !((Object)(object)enchantmentRecipeForID3 == (Object)null))
				{
					EnchantmentRecipe[] recipes = (EnchantmentRecipe[])(object)new EnchantmentRecipe[3] { enchantmentRecipeForID, enchantmentRecipeForID2, enchantmentRecipeForID3 };
					val.Recipes = recipes;
				}
			}
		}
	}
	public class GenericHelper
	{
		public static void SplitDerivedClasses<TBase, TDerived>(TBase[] sourceArray, out TBase[] remainingArray, out TDerived[] derivedArray)
		{
			List<TDerived> list = new List<TDerived>();
			List<TBase> list2 = new List<TBase>();
			foreach (TBase val in sourceArray)
			{
				if (val is TDerived)
				{
					object obj = val;
					TDerived item = (TDerived)((obj is TDerived) ? obj : null);
					list.Add(item);
				}
				else
				{
					list2.Add(val);
				}
			}
			derivedArray = list.ToArray();
			remainingArray = list2.ToArray();
		}

		public static int CountDerivedClassesInArray<T>(T[] array, Type TypeToCount)
		{
			int num = 0;
			for (int i = 0; i < array.Length; i++)
			{
				T val = array[i];
				if (val != null && TypeToCount.IsAssignableFrom(val.GetType()))
				{
					num++;
				}
			}
			return num;
		}

		public static int CountDerivedClassesInList<T>(List<T> list, Type TypeToCount)
		{
			int num = 0;
			foreach (T item in list)
			{
				if (item != null && TypeToCount.IsAssignableFrom(item.GetType()))
				{
					num++;
				}
			}
			return num;
		}

		public static void TryCleaningGameObjectWithNames(Transform parent, string[] elementNames)
		{
			foreach (string elementName in elementNames)
			{
				TryCleaningGameObjectWithName(parent, elementName);
			}
		}

		public static void TryCleaningGameObjectWithName(Transform parent, string elementName)
		{
			Transform val = parent.Find(elementName);
			if (Object.op_Implicit((Object)(object)val))
			{
				Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
			}
		}

		public bool HasParentWithHiddenItemDetails(Transform targetTransform, string[] names)
		{
			while ((Object)(object)targetTransform != (Object)null)
			{
				if (Array.Exists(names, (string name) => ((Object)targetTransform).name == name))
				{
					return true;
				}
				targetTransform = targetTransform.parent;
			}
			return false;
		}
	}
	public class ItemHelpers
	{
		public static List<T> GetAllItemsOfType<T>(List<Item> items) where T : Item
		{
			List<T> list = new List<T>();
			foreach (Item item in items)
			{
				T val = (T)(object)((item is T) ? item : null);
				if (val != null)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static List<Item> GetUniqueItemsInInventory(CharacterInventory inventory)
		{
			ItemContainer pouch = inventory.Pouch;
			List<Item> first = ((pouch != null) ? pouch.GetContainedItems() : null);
			List<Item> second = new List<Item>();
			if (inventory.HasABag)
			{
				second = ((ItemContainer)inventory.EquippedBag.Container).GetContainedItems();
			}
			return first.Union(second).ToList();
		}
	}
	public class XmlSerializerHelper
	{
		public static string GetProjectLocation()
		{
			return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}

		public static T DeserializeXML<T>(string filePath)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
			using FileStream stream = new FileStream(filePath, FileMode.Open);
			return (T)xmlSerializer.Deserialize(stream);
		}
	}
}
namespace OutwardEnchantmentsViewer.Utility.Fixers
{
	public class ItemDescriptionScrollFixer
	{
		private ItemDetailsDisplay _itemDetailsDisplay;

		private Button _btnScrollUpButton;

		private Button _btnScrollDownButton;

		private ScrollRect _scrollView;

		private RectTransform _viewport;

		public Button BtnScrollUpButton
		{
			get
			{
				return _btnScrollUpButton;
			}
			set
			{
				_btnScrollUpButton = value;
			}
		}

		public Button BtnScrollDownButton
		{
			get
			{
				return _btnScrollDownButton;
			}
			set
			{
				_btnScrollDownButton = value;
			}
		}

		public ScrollRect ScrollView
		{
			get
			{
				return _scrollView;
			}
			set
			{
				_scrollView = value;
			}
		}

		public RectTransform Viewport
		{
			get
			{
				return _viewport;
			}
			set
			{
				_viewport = value;
			}
		}

		public ItemDetailsDisplay ItemDetailsDisplay
		{
			get
			{
				return _itemDetailsDisplay;
			}
			set
			{
				_itemDetailsDisplay = value;
			}
		}

		public ItemDescriptionScrollFixer(ItemDetailsDisplay itemDetailsDisplay)
		{
			ItemDetailsDisplay = itemDetailsDisplay;
			CreateFixer(itemDetailsDisplay);
		}

		public void CreateFixer(ItemDetailsDisplay itemDetailsDisplay)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			Transform val = ((Component)itemDetailsDisplay).transform.Find("ItemDetails/");
			if (Object.op_Implicit((Object)(object)val))
			{
				Transform obj = val.Find("btnScrollUp");
				BtnScrollUpButton = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
				Transform obj2 = val.Find("btnScrollDown");
				BtnScrollDownButton = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
				Transform obj3 = val.Find("Stats/Scroll View");
				ScrollView = ((obj3 != null) ? ((Component)obj3).GetComponent<ScrollRect>() : null);
				ScrollRect scrollView = ScrollView;
				Viewport = ((scrollView != null) ? scrollView.viewport : null);
				if (Object.op_Implicit((Object)(object)BtnScrollDownButton) && Object.op_Implicit((Object)(object)BtnScrollUpButton) && Object.op_Implicit((Object)(object)ScrollView) && Object.op_Implicit((Object)(object)Viewport))
				{
					((UnityEventBase)BtnScrollUpButton.onClick).RemoveAllListeners();
					((UnityEventBase)BtnScrollDownButton.onClick).RemoveAllListeners();
					BtnScrollDownButton.onClick = new ButtonClickedEvent();
					BtnScrollUpButton.onClick = new ButtonClickedEvent();
					((UnityEvent)((Component)BtnScrollUpButton).GetComponent<Button>().onClick).AddListener(new UnityAction(ScrollUp));
					((UnityEvent)((Component)BtnScrollDownButton).GetComponent<Button>().onClick).AddListener(new UnityAction(ScrollDown));
				}
			}
		}

		private void ScrollUp()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = Viewport.rect;
			float height = ((Rect)(ref rect)).height;
			rect = ScrollView.content.rect;
			float num = height / ((Rect)(ref rect)).height;
			ScrollView.verticalNormalizedPosition = Mathf.Clamp(ScrollView.verticalNormalizedPosition + num, 0f, 1f);
		}

		private void ScrollDown()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = Viewport.rect;
			float height = ((Rect)(ref rect)).height;
			rect = ScrollView.content.rect;
			float num = height / ((Rect)(ref rect)).height;
			ScrollView.verticalNormalizedPosition = Mathf.Clamp(ScrollView.verticalNormalizedPosition - num, 0f, 1f);
		}
	}
}
namespace OutwardEnchantmentsViewer.Utility.Enums
{
	public enum CustomEnchantmentsDescriptions
	{
		AngelLight = 20,
		BlazeBlue = 21,
		CopperFlame = 19,
		SanguineFlame = 18
	}
	public static class CustomEnchantmentsDescriptionsExtensions
	{
		public static readonly Dictionary<CustomEnchantmentsDescriptions, string> CustomEnchantmentRecipesDescriptions = new Dictionary<CustomEnchantmentsDescriptions, string>
		{
			{
				CustomEnchantmentsDescriptions.AngelLight,
				"Changes the color of the lantern to white and effects of Flamethrower to Electric. \n\nLantern can no longer be refueled, however it passively gains fuel when equipped but not lit."
			},
			{
				CustomEnchantmentsDescriptions.BlazeBlue,
				"Changes the color of the lantern to blue and effects of Flamethrower to Frost. \n\nLantern can no longer be refueled, however it passively gains fuel when equipped but not lit."
			},
			{
				CustomEnchantmentsDescriptions.CopperFlame,
				"Changes the color of the lantern to green and effects of Flamethrower to Rust. \n\nLantern can no longer be refueled, however it passively gains fuel when equipped but not lit."
			},
			{
				CustomEnchantmentsDescriptions.SanguineFlame,
				"Changes the color of the lantern to Red and effects of Flamethrower to Decay. \n\nLantern can no longer be refueled, however it passively gains fuel when equipped but not lit."
			}
		};

		public static string GetDescription(this CustomEnchantmentsDescriptions enchantmentEnum)
		{
			return CustomEnchantmentRecipesDescriptions[enchantmentEnum];
		}

		public static string GetDescription(int recipeID)
		{
			string value = "";
			if (Enum.IsDefined(typeof(CustomEnchantmentsDescriptions), recipeID))
			{
				CustomEnchantmentRecipesDescriptions.TryGetValue((CustomEnchantmentsDescriptions)recipeID, out value);
				return value;
			}
			return value;
		}
	}
	public enum StatColor
	{
		Default,
		Disabled,
		Health,
		Stamina,
		Mana,
		Needs,
		Corruption,
		StatusEffect,
		StatusCures,
		Enchantment
	}
	public static class StatColorExtensions
	{
		public static readonly Dictionary<StatColor, Color> Colors = new Dictionary<StatColor, Color>
		{
			{
				StatColor.Default,
				new Color(0.8627f, 0.8627f, 0.8627f, 1f)
			},
			{
				StatColor.Disabled,
				new Color(0.5882f, 0.5882f, 0.5882f, 1f)
			},
			{
				StatColor.Health,
				new Color(0.765f, 0.522f, 0.525f, 1f)
			},
			{
				StatColor.Stamina,
				new Color(0.827f, 0.757f, 0.584f, 1f)
			},
			{
				StatColor.Mana,
				new Color(0.529f, 0.702f, 0.816f, 1f)
			},
			{
				StatColor.Needs,
				new Color(0.584f, 0.761f, 0.522f, 1f)
			},
			{
				StatColor.Corruption,
				new Color(0.655f, 0.647f, 0.282f, 1f)
			},
			{
				StatColor.StatusEffect,
				new Color(0.78f, 1f, 0.702f, 1f)
			},
			{
				StatColor.StatusCures,
				new Color(1f, 0.702f, 0.706f, 1f)
			},
			{
				StatColor.Enchantment,
				new Color(0.961f, 0.157f, 0.569f, 1f)
			}
		};

		public static Color GetColor(this StatColor stat)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Colors[stat];
		}
	}
}
namespace OutwardEnchantmentsViewer.UI
{
	public class AdditionalTextContainer
	{
		private List<Transform> _additionalTexts = new List<Transform>();

		private Transform _additionalTextsContainer;

		public List<Transform> AdditionalTexts
		{
			get
			{
				return _additionalTexts;
			}
			set
			{
				_additionalTexts = value;
			}
		}

		public Transform AdditionalTextsContainer
		{
			get
			{
				return _additionalTextsContainer;
			}
			set
			{
				_additionalTextsContainer = value;
			}
		}

		public void ShowAdditionalTextsContainer()
		{
			((Component)AdditionalTextsContainer).gameObject.SetActive(true);
		}

		public void HideAdditionalTextsContainer()
		{
			((Component)AdditionalTextsContainer).gameObject.SetActive(false);
		}
	}
	public class ItemDisplaySection
	{
		private Transform _separator;

		private Transform _description;

		private Transform _disabledDescription;

		private Transform _originalSeparator;

		private Transform _originalDescription;

		private Text _descriptionText;

		private Text _disabledDescriptionText;

		private Row _headerRow;

		public Transform Separator
		{
			get
			{
				return _separator;
			}
			set
			{
				_separator = value;
			}
		}

		public Transform Description
		{
			get
			{
				return _description;
			}
			set
			{
				_description = value;
			}
		}

		public Text DescriptionText
		{
			get
			{
				return _descriptionText;
			}
			set
			{
				_descriptionText = value;
			}
		}

		public Text DisabledDescriptionText
		{
			get
			{
				return _disabledDescriptionText;
			}
			set
			{
				_disabledDescriptionText = value;
			}
		}

		public Row HeaderRow
		{
			get
			{
				return _headerRow;
			}
			set
			{
				_headerRow = value;
			}
		}

		public Transform OriginalSeparator
		{
			get
			{
				return _originalSeparator;
			}
			set
			{
				_originalSeparator = value;
			}
		}

		public Transform OriginalDescription
		{
			get
			{
				return _originalDescription;
			}
			set
			{
				_originalDescription = value;
			}
		}

		public Transform DisabledDescription
		{
			get
			{
				return _disabledDescription;
			}
			set
			{
				_disabledDescription = value;
			}
		}

		public ItemDisplaySection(ItemDetailsDisplay itemDetailsDisplay)
		{
			CreateSection(itemDetailsDisplay);
			HideDescription();
		}

		public void ShowDescription()
		{
			((Component)Separator).gameObject.SetActive(true);
			((Component)Description).gameObject.SetActive(true);
			HeaderRow.GameObject.SetActive(true);
		}

		public void HideDescription()
		{
			((Component)Separator).gameObject.SetActive(false);
			((Component)Description).gameObject.SetActive(false);
			HeaderRow.GameObject.SetActive(false);
		}

		public void ShowDisabledDescription()
		{
			((Component)DisabledDescription).gameObject.SetActive(true);
		}

		public void HideDisabledDescription()
		{
			((Component)DisabledDescription).gameObject.SetActive(false);
		}

		public void ShowOriginalDescription()
		{
			((Component)OriginalSeparator).gameObject.SetActive(true);
			((Component)OriginalDescription).gameObject.SetActive(true);
		}

		public void HideOriginalDescription()
		{
			((Component)OriginalSeparator).gameObject.SetActive(false);
			((Component)OriginalDescription).gameObject.SetActive(false);
		}

		public void SetHeaderText(string leftText = null, string rightText = null)
		{
			if (HeaderRow != null)
			{
				if (leftText != null)
				{
					HeaderRow.ChangeLeftText(leftText);
				}
				if (rightText != null)
				{
					HeaderRow.ChangeRightText(rightText);
				}
			}
		}

		public void SetDescriptiontext(string text)
		{
			if (Object.op_Implicit((Object)(object)DescriptionText))
			{
				DescriptionText.text = text;
			}
		}

		public void SetDisabledDescriptiontext(string text)
		{
			if (Object.op_Implicit((Object)(object)DisabledDescriptionText))
			{
				DisabledDescriptionText.text = text;
			}
		}

		private void CreateSection(ItemDetailsDisplay itemDetailsDisplay)
		{
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)itemDetailsDisplay).transform.Find("ItemDetails/Stats/Scroll View/Viewport");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			OriginalSeparator = val.Find("Content/Separator");
			OriginalDescription = val.Find("Content/Description");
			if (!Object.op_Implicit((Object)(object)OriginalSeparator) || !Object.op_Implicit((Object)(object)OriginalDescription))
			{
				return;
			}
			Separator = Object.Instantiate<Transform>(OriginalSeparator, OriginalSeparator.parent);
			Transform obj = OriginalDescription.Find("lblDescription");
			object textFont;
			if (obj == null)
			{
				textFont = null;
			}
			else
			{
				Text component = ((Component)obj).GetComponent<Text>();
				textFont = ((component != null) ? component.font : null);
			}
			Row.TextFont = (Font)textFont;
			HeaderRow = new Row(OriginalSeparator.parent);
			Description = Object.Instantiate<Transform>(OriginalDescription, OriginalDescription.parent);
			DisabledDescription = Object.Instantiate<Transform>(OriginalDescription, OriginalDescription.parent);
			((Object)Separator).name = "gymmed-Separator";
			((Object)Description).name = "gymmed-Description";
			((Object)DisabledDescription).name = "gymmed-Disabled-Description";
			HeaderRow.GameObject.SetActive(false);
			Transform val2 = Description.Find("lblDescription");
			if (Object.op_Implicit((Object)(object)val2))
			{
				Transform val3 = DisabledDescription.Find("lblDescription");
				if (Object.op_Implicit((Object)(object)val3))
				{
					DescriptionText = ((Component)val2).GetComponent<Text>();
					DisabledDescriptionText = ((Component)val3).GetComponent<Text>();
					((Graphic)DisabledDescriptionText).color = StatColor.Disabled.GetColor();
				}
			}
		}
	}
	public class Row
	{
		private Text _rightText;

		private Text _leftText;

		private GameObject _gameObject;

		public static Font TextFont;

		public Text RightText
		{
			get
			{
				return _rightText;
			}
			set
			{
				_rightText = value;
			}
		}

		public Text LeftText
		{
			get
			{
				return _leftText;
			}
			set
			{
				_leftText = value;
			}
		}

		public GameObject GameObject
		{
			get
			{
				return _gameObject;
			}
			set
			{
				_gameObject = value;
			}
		}

		public Row(Transform parentTransform)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			GameObject = new GameObject("gymmed-Row");
			((Transform)GameObject.AddComponent<RectTransform>()).SetParent(parentTransform, false);
			HorizontalLayoutGroup obj = GameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj).childAlignment = (TextAnchor)6;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
			GameObject val = CreateTextChild("LeftText", "Left Side", GameObject.transform, (TextAnchor)6);
			LeftText = val.GetComponent<Text>();
			GameObject val2 = CreateTextChild("RightText", "Right Side", GameObject.transform, (TextAnchor)8);
			RightText = val2.GetComponent<Text>();
		}

		public void ChangeRightText(string text)
		{
			RightText.text = text;
		}

		public void ChangeLeftText(string text)
		{
			LeftText.text = text;
		}

		private GameObject CreateTextChild(string name, string textValue, Transform parent, TextAnchor anchor = 4, bool isFlexible = false)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_002a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00d2: Expected O, but got Unknown
			GameObject val = new GameObject("gymmed-" + name + "-container");
			((Transform)val.AddComponent<RectTransform>()).SetParent(parent, false);
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj).childAlignment = anchor;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			GameObject val2 = new GameObject(name);
			((Transform)val2.AddComponent<RectTransform>()).SetParent(val.transform, false);
			Text obj2 = val2.AddComponent<Text>();
			obj2.text = textValue;
			obj2.alignment = anchor;
			obj2.font = (Object.op_Implicit((Object)(object)TextFont) ? TextFont : Resources.GetBuiltinResource<Font>("Ariel.tff"));
			obj2.fontSize = 19;
			((Graphic)obj2).color = StatColor.Enchantment.GetColor();
			obj2.horizontalOverflow = (HorizontalWrapMode)1;
			obj2.verticalOverflow = (VerticalWrapMode)1;
			LayoutElement val3 = val2.AddComponent<LayoutElement>();
			val3.minWidth = 50f;
			if (!isFlexible)
			{
				val3.flexibleWidth = 0f;
				return val2;
			}
			val3.flexibleWidth = 1f;
			return val2;
		}
	}
}
namespace OutwardEnchantmentsViewer.Managers
{
	public class CustomEnchantmentsManager
	{
		private static CustomEnchantmentsManager _instance;

		private Dictionary<int, EnchantmentDescription> _enchantmentsDictionary;

		public static CustomEnchantmentsManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new CustomEnchantmentsManager();
				}
				return _instance;
			}
		}

		public Dictionary<int, EnchantmentDescription> EnchantmentsDictionary
		{
			get
			{
				return _enchantmentsDictionary;
			}
			set
			{
				_enchantmentsDictionary = value;
			}
		}

		private CustomEnchantmentsManager()
		{
		}

		public EnchantmentDescription TryGetDescription(int RecipeID)
		{
			if (EnchantmentsDictionary == null)
			{
				return null;
			}
			EnchantmentsDictionary.TryGetValue(RecipeID, out var value);
			return value;
		}

		public void LoadEnchantmentDictionaryFromXml(string filePath)
		{
			try
			{
				EnchantmentDescriptionsControllerJson enchantmentDescriptionsControllerJson = XmlSerializerHelper.DeserializeXML<EnchantmentDescriptionsControllerJson>(filePath);
				if (enchantmentDescriptionsControllerJson != null && enchantmentDescriptionsControllerJson.enchantments != null && enchantmentDescriptionsControllerJson.enchantments.Count >= 1)
				{
					Dictionary<int, EnchantmentDescription> enchantmentsDictionary = enchantmentDescriptionsControllerJson.ToDictionary();
					EnchantmentsDictionary = enchantmentsDictionary;
				}
			}
			catch (Exception ex)
			{
				SL.Log(OutwardEnchantmentsViewer.prefix + " CustomEnchantmentsManager@LoadEnchantmentDictionaryFromXml error:" + ex.Message + "!");
			}
		}
	}
	public class ItemDescriptionsManager
	{
		private static ItemDescriptionsManager _instance;

		public static ItemDescriptionsManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new ItemDescriptionsManager();
				}
				return _instance;
			}
		}

		private ItemDescriptionsManager()
		{
		}

		public void SetEquipmentsEnchantmentsDescription(Item item, CharacterInventory inventory, ItemDetailsDisplay itemDetailsDisplay)
		{
			List<EnchantmentRecipe> availableEnchantmentRecipies = EnchantmentsHelper.GetAvailableEnchantmentRecipies(item);
			List<EnchantmentRecipeData> availableEnchantmentRecipeDatasInInventory = EnchantmentsHelper.GetAvailableEnchantmentRecipeDatasInInventory(item, inventory);
			List<EnchantmentRecipe> list = availableEnchantmentRecipeDatasInInventory.Select((EnchantmentRecipeData data) => data.enchantmentRecipe).ToList();
			string enchantmentsDescriptions = EnchantmentsHelper.GetEnchantmentsDescriptions(availableEnchantmentRecipeDatasInInventory);
			string leftText = "Unlocked Enchantments";
			string text = list.Count.ToString();
			if (OutwardEnchantmentsViewer.ShowAllAvailableEnchantmentsCountForEquipment.Value)
			{
				text = $"{text}/{availableEnchantmentRecipies.Count}";
			}
			ItemDisplayManager.Instance.SetHeaderText(itemDetailsDisplay, leftText, text);
			ItemDisplayManager.Instance.SetDescriptionText(itemDetailsDisplay, enchantmentsDescriptions);
			ItemDisplayManager.Instance.ShowDescription(itemDetailsDisplay, string.IsNullOrEmpty(item.Description));
			if (!OutwardEnchantmentsViewer.ShowMissingEnchantmentsForEquipment.Value)
			{
				ItemDisplayManager.Instance.HideDisabledDescription(itemDetailsDisplay);
				return;
			}
			List<EnchantmentRecipe> missingEnchantments = EnchantmentsHelper.GetMissingEnchantments(availableEnchantmentRecipies, list);
			string enchantmentsDescriptions2 = EnchantmentsHelper.GetEnchantmentsDescriptions(missingEnchantments);
			if (missingEnchantments.Count > 0)
			{
				ItemDisplayManager.Instance.SetDisabledDescriptionText(itemDetailsDisplay, enchantmentsDescriptions2);
				ItemDisplayManager.Instance.ShowDisabledDescription(itemDetailsDisplay);
			}
			else
			{
				ItemDisplayManager.Instance.HideDisabledDescription(itemDetailsDisplay);
			}
		}

		public void SetEnchantmentsDescription(EnchantmentRecipeItem item, CharacterInventory inventory, ItemDetailsDisplay itemDetailsDisplay)
		{
			try
			{
				string text = "";
				EnchantmentRecipe[] recipes = item.Recipes;
				foreach (EnchantmentRecipe val in recipes)
				{
					Enchantment enchantmentPrefab = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(val.RecipeID);
					if ((Object)(object)enchantmentPrefab == (Object)null)
					{
						return;
					}
					text += GetEnchantmentInformation(enchantmentPrefab, val);
				}
				ItemDisplayManager.Instance.SetHeaderText(itemDetailsDisplay, "Enchantment Properties", "");
				ItemDisplayManager.Instance.SetDescriptionText(itemDetailsDisplay, text);
				ItemDisplayManager.Instance.ShowDescription(itemDetailsDisplay);
			}
			catch (Exception ex)
			{
				SL.Log(OutwardEnchantmentsViewer.prefix + " ItemDescriptionsManager@SetEnchantmentsDescription error: " + ex.Message);
			}
		}

		public string GetEnchantmentRecipeEquipmentName(EnchantmentRecipe recipe)
		{
			string text = "";
			string enchantmentArmorIngrediantType = EnchantmentsHelper.GetEnchantmentArmorIngrediantType(recipe);
			if (!string.IsNullOrEmpty(enchantmentArmorIngrediantType))
			{
				text = text + enchantmentArmorIngrediantType + "\n";
			}
			return text;
		}

		public string GetDynamicEnchantmentInformationSection(Enchantment enchantment, EnchantmentRecipe recipe)
		{
			return string.Concat("" + GetEnchantmentRecipeEquipmentName(recipe), GetDynamicEnchantmentInformation(enchantment));
		}

		public string GetEnchantmentInformation(Enchantment enchantment, EnchantmentRecipe recipe)
		{
			try
			{
				EnchantmentDescription enchantmentDescription = CustomEnchantmentsManager.Instance.TryGetDescription(recipe.RecipeID);
				if (enchantmentDescription == null)
				{
					return GetDynamicEnchantmentInformationSection(enchantment, recipe);
				}
				if (enchantmentDescription.overwrite)
				{
					return enchantmentDescription.description;
				}
				return string.Concat("" + GetDynamicEnchantmentInformationSection(enchantment, recipe), enchantmentDescription.description);
			}
			catch (Exception ex)
			{
				SL.Log(OutwardEnchantmentsViewer.prefix + " ItemDescriptionsManager@GetEnchantmentInformation error: " + ex.Message);
				return "Error";
			}
		}

		public string GetDynamicEnchantmentInformation(Enchantment enchantment)
		{
			string text = "";
			text += EnchantmentInformationHelper.GetDamageListDescription(enchantment);
			text += EnchantmentInformationHelper.GetModifiersListDescriptions(enchantment);
			text += EnchantmentInformationHelper.GetAdditionalDamagesDescription(enchantment);
			text += EnchantmentInformationHelper.GetEffectsDescription(enchantment);
			text += EnchantmentInformationHelper.GetStatModificationsDescription(enchantment);
			text += EnchantmentInformationHelper.GetElementalResistancesDescription(enchantment);
			if (enchantment.GlobalStatusResistance > 0f)
			{
				text = text + "Global Status Resistance " + enchantment.GlobalStatusResistance + " \n\n";
			}
			if (enchantment.HealthAbsorbRatio > 0f)
			{
				text = text + "Gain +" + enchantment.HealthAbsorbRatio + "x Health Leech (damage dealth will restore " + enchantment.HealthAbsorbRatio + "x the damage as Health) \n\n";
			}
			if (enchantment.Indestructible)
			{
				text += "Provides indestructibility \n";
			}
			if (enchantment.ManaAbsorbRatio > 0f)
			{
				text = text + "Gain +" + enchantment.ManaAbsorbRatio + "x Mana Leech (damage dealth will restore " + enchantment.ManaAbsorbRatio + "x the damage as Mana) \n\n";
			}
			if (enchantment.StaminaAbsorbRatio > 0f)
			{
				text = text + "Gain +" + enchantment.StaminaAbsorbRatio + "x Stamina Leech (damage dealth will restore " + enchantment.StaminaAbsorbRatio + "x the damage as Stamina) \n\n";
			}
			if (enchantment.TrackDamageRatio > 0f)
			{
				text = text + "Track Damage Ratio " + enchantment.TrackDamageRatio + " \n\n";
			}
			return text + CustomEnchantmentsDescriptionsExtensions.GetDescription(((EffectPreset)enchantment).PresetID);
		}
	}
	public class ItemDisplayManager
	{
		private Dictionary<ItemDetailsDisplay, ItemDisplaySection> _dictionaryDisplaySections = new Dictionary<ItemDetailsDisplay, ItemDisplaySection>();

		private static ItemDisplayManager _instance;

		public static ItemDisplayManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new ItemDisplayManager();
				}
				return _instance;
			}
		}

		public Dictionary<ItemDetailsDisplay, ItemDisplaySection> DictionaryDisplaySections
		{
			get
			{
				return _dictionaryDisplaySections;
			}
			set
			{
				_dictionaryDisplaySections = value;
			}
		}

		private ItemDisplayManager()
		{
		}

		public void TryCreateSection(ItemDetailsDisplay itemDetailsDisplay)
		{
			DictionaryDisplaySections.TryGetValue(itemDetailsDisplay, out var value);
			if (value == null)
			{
				DictionaryDisplaySections.Add(itemDetailsDisplay, new ItemDisplaySection(itemDetailsDisplay));
			}
		}

		public void ShowDescription(ItemDetailsDisplay itemDetailsDisplay, bool hideOrginalDescription = false)
		{
			ItemDisplaySection itemDisplaySection = GetItemDisplaySection(itemDetailsDisplay);
			itemDisplaySection.ShowDescription();
			if (hideOrginalDescription)
			{
				itemDisplaySection.HideOriginalDescription();
			}
		}

		public void ShowDisabledDescription(ItemDetailsDisplay itemDetailsDisplay)
		{
			GetItemDisplaySection(itemDetailsDisplay).ShowDisabledDescription();
		}

		public void HideDisabledDescription(ItemDetailsDisplay itemDetailsDisplay)
		{
			GetItemDisplaySection(itemDetailsDisplay).HideDisabledDescription();
		}

		public void ShowOriginalDescription(ItemDetailsDisplay itemDetailsDisplay)
		{
			GetItemDisplaySection(itemDetailsDisplay).ShowOriginalDescription();
		}

		public void HideOriginalDescription(ItemDetailsDisplay itemDetailsDisplay)
		{
			GetItemDisplaySection(itemDetailsDisplay).HideOriginalDescription();
		}

		public void HideDescription(ItemDetailsDisplay itemDetailsDisplay)
		{
			GetItemDisplaySection(itemDetailsDisplay).HideDescription();
		}

		public void SetDescriptionText(ItemDetailsDisplay itemDetailsDisplay, string text)
		{
			GetItemDisplaySection(itemDetailsDisplay).SetDescriptiontext(text);
		}

		public void SetDisabledDescriptionText(ItemDetailsDisplay itemDetailsDisplay, string text)
		{
			GetItemDisplaySection(itemDetailsDisplay).SetDisabledDescriptiontext(text);
		}

		public void SetHeaderText(ItemDetailsDisplay itemDetailsDisplay, string leftText, string rightText)
		{
			GetItemDisplaySection(itemDetailsDisplay).SetHeaderText(leftText, rightText);
		}

		public ItemDisplaySection GetItemDisplaySection(ItemDetailsDisplay itemDetailsDisplay)
		{
			DictionaryDisplaySections.TryGetValue(itemDetailsDisplay, out var value);
			if (value == null)
			{
				throw new Exception("Tried to retrieve missing itemDetailsDisplay from dictionary!");
			}
			return value;
		}
	}
}
namespace OutwardEnchantmentsViewer.Enchantments
{
	[Serializable]
	public class EnchantmentDescription
	{
		[XmlElement("overwrite")]
		public bool overwrite { get; set; }

		[XmlElement("description")]
		public string description { get; set; }
	}
	[Serializable]
	[XmlRoot("root")]
	public class EnchantmentDescriptionsControllerJson
	{
		[XmlArray("enchantments")]
		[XmlArrayItem("enchantment")]
		public List<EnchantmentEntryJson> enchantments { get; set; }

		public Dictionary<int, EnchantmentDescription> ToDictionary()
		{
			Dictionary<int, EnchantmentDescription> dictionary = new Dictionary<int, EnchantmentDescription>();
			foreach (EnchantmentEntryJson enchantment in enchantments)
			{
				dictionary[enchantment.id] = enchantment.data;
			}
			return dictionary;
		}
	}
	[Serializable]
	public class EnchantmentEntryJson
	{
		[XmlElement("id")]
		public int id { get; set; }

		[XmlElement("data")]
		public EnchantmentDescription data { get; set; }
	}
	public class EnchantmentRecipeData
	{
		public EnchantmentRecipeItem item;

		public EnchantmentRecipe enchantmentRecipe;

		public EnchantmentRecipeData(EnchantmentRecipeItem item, EnchantmentRecipe enchantmentRecipe)
		{
			this.item = item;
			this.enchantmentRecipe = enchantmentRecipe;
		}
	}
}