Decompiled source of WearableWard v1.0.9

WearableWard.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using WearableWard.Functions;
using WearableWard.Utils;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: Guid("194FEFC6-7A62-4D86-A47C-3B4D8D6768B5")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("WearableWard")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/WearableWard/")]
[assembly: AssemblyTitle("WearableWard")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("1.0.9")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.9.0")]
[module: <1fb707ad-eb6b-4e61-bdee-2a77e68876bf>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<1b4c2275-a76b-4309-92f9-ba9ae9b6fedd>Embedded]
	internal sealed class <1b4c2275-a76b-4309-92f9-ba9ae9b6fedd>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[<1b4c2275-a76b-4309-92f9-ba9ae9b6fedd>Embedded]
	[CompilerGenerated]
	internal sealed class <1fb707ad-eb6b-4e61-bdee-2a77e68876bf>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <1fb707ad-eb6b-4e61-bdee-2a77e68876bf>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WearableWard
{
	[BepInPlugin("blacks7ar.WearableWard", "WearableWard", "1.0.9")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "blacks7ar.WearableWard";

		public const string modName = "WearableWard";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.9";

		public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/WearableWard/";

		private static string configFileName = "blacks7ar.WearableWard.cfg";

		private static string configFileFullPath;

		public static readonly ManualLogSource WWLogger;

		private static readonly Harmony _harmony;

		private static readonly ConfigSync _configSync;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<Toggle> _enableDebug;

		public static ConfigEntry<Toggle> _repairable;

		private static AssetBundle _shieldBundle;

		public static GameObject _lowTier;

		public static GameObject _midTier;

		public static GameObject _highTier;

		public static GameObject _legendaryTier;

		public static GameObject _epicTier;

		public static GameObject _godTier;

		public static Plugin _Instance;

		public ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedConfig = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			_configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedConfig;
			return val2;
		}

		private void ConfigWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, configFileName);
			fileSystemWatcher.Changed += OnConfigChanged;
			fileSystemWatcher.Created += OnConfigChanged;
			fileSystemWatcher.Renamed += OnConfigChanged;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void OnConfigChanged(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(configFileFullPath))
			{
				return;
			}
			try
			{
				Logging.LogDebug("OnConfigChanged called..");
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				Logging.LogError("There was an issue loading your " + configFileName);
				Logging.LogError("Please check your config entries for spelling and format!");
			}
		}

		public void Awake()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			_Instance = this;
			Localizer.Load();
			_shieldBundle = GetAssetBundleFromResources("shieldbundle");
			_lowTier = _shieldBundle.LoadAsset<GameObject>("BWW_ShieldWard_LowTier");
			_midTier = _shieldBundle.LoadAsset<GameObject>("BWW_ShieldWard_MidTier");
			_highTier = _shieldBundle.LoadAsset<GameObject>("BWW_ShieldWard_HighTier");
			_legendaryTier = _shieldBundle.LoadAsset<GameObject>("BWW_ShieldWard_LegendaryTier");
			_epicTier = _shieldBundle.LoadAsset<GameObject>("BWW_ShieldWard_EpicTier");
			_godTier = _shieldBundle.LoadAsset<GameObject>("BWW_ShieldWard_GodTier");
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_enableDebug = config("2- General", "Damage Debug", Toggle.Off, new ConfigDescription("For debugging purposes.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_repairable = config("2- General", "Repairable", Toggle.Off, new ConfigDescription("If On, shield ward will be repairable and won't break if durability reaches to 0", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigSetup.Init();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			ConfigWatcher();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string x) => x.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		static Plugin()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			configFileFullPath = configPath + directorySeparatorChar + configFileName;
			WWLogger = Logger.CreateLogSource("WearableWard");
			_harmony = new Harmony("blacks7ar.WearableWard");
			_configSync = new ConfigSync("blacks7ar.WearableWard")
			{
				DisplayName = "WearableWard",
				CurrentVersion = "1.0.9",
				MinimumRequiredVersion = "1.0.9",
				ModRequired = true
			};
		}
	}
}
namespace WearableWard.Utils
{
	public static class Helper
	{
		public static string GetLocalName(GameObject gameObject)
		{
			string name = gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
			return Localization.instance.Localize(name).Trim();
		}

		public static void AddClonedObject(this ZNetScene zNetScene, GameObject gameObject, bool overWrite = true)
		{
			GameObject prefab;
			if ((Object)(object)(prefab = zNetScene.GetPrefab(((Object)gameObject).name)) != (Object)null)
			{
				if (!overWrite)
				{
					return;
				}
				zNetScene.m_prefabs.Remove(prefab);
				zNetScene.m_namedPrefabs.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name));
			}
			zNetScene.m_prefabs.Add(gameObject);
			zNetScene.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject);
		}

		public static void AddClonedObject(this ObjectDB objectDB, GameObject gameObject, bool overWrite = true)
		{
			GameObject itemPrefab;
			if ((Object)(object)(itemPrefab = objectDB.GetItemPrefab(((Object)gameObject).name)) != (Object)null)
			{
				if (!overWrite)
				{
					return;
				}
				objectDB.m_items.Remove(itemPrefab);
				objectDB.m_itemByHash.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name));
			}
			objectDB.m_items.Add(gameObject);
			objectDB.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject);
		}

		public static void AddRecipe(this ObjectDB objectDB, Recipe recipe, bool overWrite = true)
		{
			Recipe recipe2;
			if ((Object)(object)(recipe2 = objectDB.GetRecipe(recipe.m_item.m_itemData)) != (Object)null)
			{
				if (!overWrite)
				{
					return;
				}
				objectDB.m_recipes.Remove(recipe2);
			}
			objectDB.m_recipes.Add(recipe);
		}

		public static bool ObjectDBAwake()
		{
			if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0)
			{
				return (Object)(object)ObjectDB.instance.GetItemPrefab("Wood") != (Object)null;
			}
			return false;
		}

		public static bool ZNetSceneAwake()
		{
			if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs.Count != 0)
			{
				return (Object)(object)ZNetScene.instance.GetPrefab("piece_workbench") != (Object)null;
			}
			return false;
		}
	}
	public static class Logging
	{
		public static void LogDebug(string debug)
		{
			Plugin.WWLogger.LogDebug((object)debug);
		}

		public static void LogInfo(string info)
		{
			Plugin.WWLogger.LogInfo((object)info);
		}

		public static void LogWarning(string warning)
		{
			Plugin.WWLogger.LogWarning((object)warning);
		}

		public static void LogError(string error)
		{
			Plugin.WWLogger.LogError((object)error);
		}
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
}
namespace WearableWard.Patches
{
	[HarmonyPatch(typeof(Humanoid), "UpdateEquipment")]
	public class HumanoidPatch
	{
		public static void Postfix(Humanoid __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && ((Character)__instance).IsPlayer() && __instance.m_utilityItem != null && ((Object)__instance.m_utilityItem.m_dropPrefab).name.Contains("BWW_Shield") && ((Character)__instance).GetSEMan().HaveStatusEffect("bww_shieldward"))
			{
				(((Character)__instance).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("bww_shieldward")) as SE_ShieldWard).SetDurability(__instance.m_utilityItem.GetDurabilityPercentage());
			}
		}
	}
	[HarmonyPatch(typeof(ItemDrop), "Awake")]
	public class ItemDropPatch
	{
		public static void Postfix(ItemDrop __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "main") && !((Object)(object)__instance == (Object)null))
			{
				switch (__instance.m_itemData.m_shared.m_name)
				{
				case "$bww_shieldward_lowtier":
					StatsSetup.LowTierShieldWard(__instance);
					break;
				case "$bww_shieldward_midtier":
					StatsSetup.MidTierShieldWard(__instance);
					break;
				case "$bww_shieldward_hightier":
					StatsSetup.HighTierShieldWard(__instance);
					break;
				case "$bww_shieldward_epictier":
					StatsSetup.EpicTierShieldWard(__instance);
					break;
				case "$bww_shieldward_legendarytier":
					StatsSetup.LegendaryTierShieldWard(__instance);
					break;
				case "$bww_shieldward_godtier":
					StatsSetup.GodTierShieldWard(__instance);
					break;
				}
			}
		}
	}
	[HarmonyPatch]
	public class ObjectDBPatch
	{
		[HarmonyPriority(700)]
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static void Awake_Postfix(ObjectDB __instance)
		{
			RegisterPrefabs.ToObjectDB();
			RegisterPrefabs.Recipes();
			__instance.UpdateItemHashes();
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		[HarmonyPostfix]
		[HarmonyPriority(700)]
		public static void CopyOtherDB_Postfix(ObjectDB __instance)
		{
			RegisterPrefabs.ToObjectDB();
			RegisterPrefabs.Recipes();
			__instance.UpdateItemHashes();
		}
	}
	[HarmonyPatch(typeof(Player), "DamageArmorDurability")]
	public class PlayerPatch
	{
		public static void Prefix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || ((Humanoid)__instance).m_utilityItem == null || !((Object)((Humanoid)__instance).m_utilityItem.m_dropPrefab).name.Contains("BWW_Shield") || !((Character)__instance).GetSEMan().HaveStatusEffect("bww_shieldward"))
			{
				return;
			}
			SE_ShieldWard sE_ShieldWard = ((Character)__instance).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("bww_shieldward")) as SE_ShieldWard;
			if (Plugin._enableDebug.Value == Toggle.On)
			{
				Debug.Log((object)$"Creature TotalDamage: {sE_ShieldWard.GetHitDamage()} / Shield AbsorbDamage: {sE_ShieldWard.GetTotalAbsorbDamage()}");
			}
			if (!(sE_ShieldWard.GetHitDamage() > sE_ShieldWard.GetTotalAbsorbDamage()))
			{
				return;
			}
			float num = Mathf.Max(0f, sE_ShieldWard.GetHitDamage() - sE_ShieldWard.GetTotalAbsorbDamage());
			if (!(num <= 0f))
			{
				Random random = new Random();
				float num2 = 0f;
				if (num > 0f)
				{
					num2 = random.Next(1, 5);
				}
				if (num > 10f)
				{
					num2 = random.Next(5, 10);
				}
				if (num > 25f)
				{
					num2 = random.Next(10, 20);
				}
				if (num > 50f)
				{
					num2 = random.Next(20, 40);
				}
				if (num > 100f)
				{
					num2 = random.Next(40, 60);
				}
				if (num > 250f)
				{
					num2 = random.Next(60, 100);
				}
				if (num > 500f)
				{
					num2 = random.Next(100, 150);
				}
				((Humanoid)__instance).m_utilityItem.m_durability = Mathf.Max(0f, ((Humanoid)__instance).m_utilityItem.m_durability - num2 / 10f);
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public class ZNetScenePatch
	{
		private static void Postfix()
		{
			RegisterPrefabs.ToZNetScene();
		}
	}
}
namespace WearableWard.Functions
{
	public static class ConfigSetup
	{
		public static ConfigEntry<float> _lowTierDurability;

		private static ConfigEntry<float> _lowTierAbsorbDamage;

		public static ConfigEntry<float> _midTierDurability;

		private static ConfigEntry<float> _midTierAbsorbDamage;

		public static ConfigEntry<float> _highTierDurability;

		private static ConfigEntry<float> _highTierAbsorbDamage;

		public static ConfigEntry<float> _epicTierDurability;

		private static ConfigEntry<float> _epicTierAbsorbDamage;

		public static ConfigEntry<float> _legendaryTierDurability;

		private static ConfigEntry<float> _legendaryTierAbsorbDamage;

		public static ConfigEntry<float> _godTierDurability;

		private static ConfigEntry<float> _godTierAbsorbDamage;

		private const string _durabilityDescription = "Shields durability before it breaks.";

		private const string _absorbDamageDescription = "How much damage can a shield take before it starts depleting durability.";

		public static void Init()
		{
			LowTier();
			MidTier();
			HighTier();
			LegendaryTier();
			EpicTier();
			GodTier();
		}

		private static void LowTier()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string localName = Helper.GetLocalName(Plugin._lowTier);
			_lowTierDurability = Plugin._Instance.config(localName, "Durability", 30f, new ConfigDescription("Shields durability before it breaks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 100f), Array.Empty<object>()));
			_lowTierAbsorbDamage = Plugin._Instance.config(localName, "Absorb Damage", 30f, new ConfigDescription("How much damage can a shield take before it starts depleting durability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 50f), Array.Empty<object>()));
			SE_ShieldWard statusEffect = ScriptableObject.CreateInstance<SE_ShieldWard>();
			ItemData itemData = Plugin._lowTier.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)statusEffect).m_icon = itemData.GetIcon();
			_lowTierDurability.SettingChanged += delegate
			{
				itemData.m_shared.m_maxDurability = _lowTierDurability.Value;
			};
			itemData.m_shared.m_maxDurability = _lowTierDurability.Value;
			_lowTierAbsorbDamage.SettingChanged += delegate
			{
				statusEffect.SetAbsorbDamage(_lowTierAbsorbDamage.Value);
			};
			statusEffect.SetAbsorbDamage(_lowTierAbsorbDamage.Value);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void MidTier()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string localName = Helper.GetLocalName(Plugin._midTier);
			_midTierDurability = Plugin._Instance.config(localName, "Durability", 60f, new ConfigDescription("Shields durability before it breaks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 100f), Array.Empty<object>()));
			_midTierAbsorbDamage = Plugin._Instance.config(localName, "Absorb Damage", 50f, new ConfigDescription("How much damage can a shield take before it starts depleting durability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 100f), Array.Empty<object>()));
			SE_ShieldWard statusEffect = ScriptableObject.CreateInstance<SE_ShieldWard>();
			ItemData itemData = Plugin._midTier.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)statusEffect).m_icon = itemData.GetIcon();
			_midTierDurability.SettingChanged += delegate
			{
				itemData.m_shared.m_maxDurability = _midTierDurability.Value;
			};
			itemData.m_shared.m_maxDurability = _midTierDurability.Value;
			_midTierAbsorbDamage.SettingChanged += delegate
			{
				statusEffect.SetAbsorbDamage(_midTierAbsorbDamage.Value);
			};
			statusEffect.SetAbsorbDamage(_midTierAbsorbDamage.Value);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void HighTier()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string localName = Helper.GetLocalName(Plugin._highTier);
			_highTierDurability = Plugin._Instance.config(localName, "Durability", 90f, new ConfigDescription("Shields durability before it breaks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(60f, 150f), Array.Empty<object>()));
			_highTierAbsorbDamage = Plugin._Instance.config(localName, "Absorb Damage", 100f, new ConfigDescription("How much damage can a shield take before it starts depleting durability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 200f), Array.Empty<object>()));
			SE_ShieldWard statusEffect = ScriptableObject.CreateInstance<SE_ShieldWard>();
			ItemData itemData = Plugin._highTier.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)statusEffect).m_icon = itemData.GetIcon();
			_highTierDurability.SettingChanged += delegate
			{
				itemData.m_shared.m_maxDurability = _highTierDurability.Value;
			};
			itemData.m_shared.m_maxDurability = _highTierDurability.Value;
			_highTierAbsorbDamage.SettingChanged += delegate
			{
				statusEffect.SetAbsorbDamage(_highTierAbsorbDamage.Value);
			};
			statusEffect.SetAbsorbDamage(_highTierAbsorbDamage.Value);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void EpicTier()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string localName = Helper.GetLocalName(Plugin._epicTier);
			_epicTierDurability = Plugin._Instance.config(localName, "Durability", 200f, new ConfigDescription("Shields durability before it breaks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(90f, 300f), Array.Empty<object>()));
			_epicTierAbsorbDamage = Plugin._Instance.config(localName, "Absorb Damage", 150f, new ConfigDescription("How much damage can a shield take before it starts depleting durability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 300f), Array.Empty<object>()));
			SE_ShieldWard statusEffect = ScriptableObject.CreateInstance<SE_ShieldWard>();
			ItemData itemData = Plugin._epicTier.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)statusEffect).m_icon = itemData.GetIcon();
			_epicTierDurability.SettingChanged += delegate
			{
				itemData.m_shared.m_maxDurability = _epicTierDurability.Value;
			};
			itemData.m_shared.m_maxDurability = _epicTierDurability.Value;
			_epicTierAbsorbDamage.SettingChanged += delegate
			{
				statusEffect.SetAbsorbDamage(_epicTierAbsorbDamage.Value);
			};
			statusEffect.SetAbsorbDamage(_epicTierAbsorbDamage.Value);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void LegendaryTier()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string localName = Helper.GetLocalName(Plugin._legendaryTier);
			_legendaryTierDurability = Plugin._Instance.config(localName, "Durability", 250f, new ConfigDescription("Shields durability before it breaks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(200f, 500f), Array.Empty<object>()));
			_legendaryTierAbsorbDamage = Plugin._Instance.config(localName, "Absorb Damage", 200f, new ConfigDescription("How much damage can a shield take before it starts depleting durability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(150f, 500f), Array.Empty<object>()));
			SE_ShieldWard statusEffect = ScriptableObject.CreateInstance<SE_ShieldWard>();
			ItemData itemData = Plugin._legendaryTier.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)statusEffect).m_icon = itemData.GetIcon();
			_legendaryTierDurability.SettingChanged += delegate
			{
				itemData.m_shared.m_maxDurability = _legendaryTierDurability.Value;
			};
			itemData.m_shared.m_maxDurability = _legendaryTierDurability.Value;
			_legendaryTierAbsorbDamage.SettingChanged += delegate
			{
				statusEffect.SetAbsorbDamage(_legendaryTierAbsorbDamage.Value);
			};
			statusEffect.SetAbsorbDamage(_legendaryTierAbsorbDamage.Value);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void GodTier()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string localName = Helper.GetLocalName(Plugin._godTier);
			_godTierDurability = Plugin._Instance.config(localName, "Durability", 500f, new ConfigDescription("Shields durability before it breaks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(250f, 1000f), Array.Empty<object>()));
			_godTierAbsorbDamage = Plugin._Instance.config(localName, "Absorb Damage", 250f, new ConfigDescription("How much damage can a shield take before it starts depleting durability.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(200f, 500f), Array.Empty<object>()));
			SE_ShieldWard statusEffect = ScriptableObject.CreateInstance<SE_ShieldWard>();
			ItemData itemData = Plugin._godTier.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)statusEffect).m_icon = itemData.GetIcon();
			_godTierDurability.SettingChanged += delegate
			{
				itemData.m_shared.m_maxDurability = _godTierDurability.Value;
			};
			itemData.m_shared.m_maxDurability = _godTierDurability.Value;
			_godTierAbsorbDamage.SettingChanged += delegate
			{
				statusEffect.SetAbsorbDamage(_godTierAbsorbDamage.Value);
			};
			statusEffect.SetAbsorbDamage(_godTierAbsorbDamage.Value);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}
	}
	public static class RegisterPrefabs
	{
		private static ObjectDB _objectDB => ObjectDB.instance;

		private static ZNetScene _zNetScene => ZNetScene.instance;

		public static void ToObjectDB()
		{
			if (Helper.ObjectDBAwake())
			{
				_objectDB.AddClonedObject(Plugin._lowTier);
				StatsSetup.LowTierShieldWard(Plugin._lowTier.GetComponent<ItemDrop>());
				_objectDB.AddClonedObject(Plugin._midTier);
				StatsSetup.MidTierShieldWard(Plugin._midTier.GetComponent<ItemDrop>());
				_objectDB.AddClonedObject(Plugin._highTier);
				StatsSetup.HighTierShieldWard(Plugin._highTier.GetComponent<ItemDrop>());
				_objectDB.AddClonedObject(Plugin._epicTier);
				StatsSetup.EpicTierShieldWard(Plugin._epicTier.GetComponent<ItemDrop>());
				_objectDB.AddClonedObject(Plugin._legendaryTier);
				StatsSetup.LegendaryTierShieldWard(Plugin._legendaryTier.GetComponent<ItemDrop>());
				_objectDB.AddClonedObject(Plugin._godTier);
				StatsSetup.GodTierShieldWard(Plugin._godTier.GetComponent<ItemDrop>());
			}
		}

		public static void ToZNetScene()
		{
			if (Helper.ZNetSceneAwake())
			{
				_zNetScene.AddClonedObject(Plugin._lowTier);
				_zNetScene.AddClonedObject(Plugin._midTier);
				_zNetScene.AddClonedObject(Plugin._highTier);
				_zNetScene.AddClonedObject(Plugin._epicTier);
				_zNetScene.AddClonedObject(Plugin._legendaryTier);
				_zNetScene.AddClonedObject(Plugin._godTier);
			}
		}

		public static void Recipes()
		{
			if (Helper.ObjectDBAwake() && Helper.ZNetSceneAwake())
			{
				LowTierShieldWard();
				MidTierShieldWard();
				HighTierShieldWard();
				EpicTierShieldWard();
				LegendaryTierShieldWard();
				GodTierShieldWard();
			}
		}

		private static void LowTierShieldWard()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_ShieldWard_LowTier";
			val.m_item = Plugin._lowTier.GetComponent<ItemDrop>();
			val.m_amount = 1;
			val.m_enabled = true;
			val.m_qualityResultAmountMultiplier = 1f;
			val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_minStationLevel = 1;
			val.m_requireOnlyOneIngredient = false;
			val.m_resources = (Requirement[])(object)new Requirement[4]
			{
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("HardAntler").GetComponent<ItemDrop>(),
					m_amount = 1,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("GreydwarfEye").GetComponent<ItemDrop>(),
					m_amount = 16,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Wood").GetComponent<ItemDrop>(),
					m_amount = 26,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Resin").GetComponent<ItemDrop>(),
					m_amount = 18,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				}
			};
			_objectDB.AddRecipe(val);
		}

		private static void MidTierShieldWard()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_ShieldWard_MidTier";
			val.m_item = Plugin._midTier.GetComponent<ItemDrop>();
			val.m_amount = 1;
			val.m_enabled = true;
			val.m_qualityResultAmountMultiplier = 1f;
			val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_minStationLevel = 1;
			val.m_requireOnlyOneIngredient = false;
			val.m_resources = (Requirement[])(object)new Requirement[4]
			{
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("SurtlingCore").GetComponent<ItemDrop>(),
					m_amount = 1,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("AncientSeed").GetComponent<ItemDrop>(),
					m_amount = 2,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("RoundLog").GetComponent<ItemDrop>(),
					m_amount = 26,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Copper").GetComponent<ItemDrop>(),
					m_amount = 12,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				}
			};
			_objectDB.AddRecipe(val);
		}

		private static void HighTierShieldWard()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_ShieldWard_HighTier";
			val.m_item = Plugin._highTier.GetComponent<ItemDrop>();
			val.m_amount = 1;
			val.m_enabled = true;
			val.m_qualityResultAmountMultiplier = 1f;
			val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_minStationLevel = 2;
			val.m_requireOnlyOneIngredient = false;
			val.m_resources = (Requirement[])(object)new Requirement[4]
			{
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("SurtlingCore").GetComponent<ItemDrop>(),
					m_amount = 1,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Guck").GetComponent<ItemDrop>(),
					m_amount = 18,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("ElderBark").GetComponent<ItemDrop>(),
					m_amount = 26,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Iron").GetComponent<ItemDrop>(),
					m_amount = 18,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				}
			};
			_objectDB.AddRecipe(val);
		}

		private static void EpicTierShieldWard()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_ShieldWard_EpicTier";
			val.m_item = Plugin._epicTier.GetComponent<ItemDrop>();
			val.m_amount = 1;
			val.m_enabled = true;
			val.m_qualityResultAmountMultiplier = 1f;
			val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_minStationLevel = 3;
			val.m_requireOnlyOneIngredient = false;
			val.m_resources = (Requirement[])(object)new Requirement[4]
			{
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("DragonTear").GetComponent<ItemDrop>(),
					m_amount = 1,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Crystal").GetComponent<ItemDrop>(),
					m_amount = 22,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("FreezeGland").GetComponent<ItemDrop>(),
					m_amount = 32,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Silver").GetComponent<ItemDrop>(),
					m_amount = 22,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				}
			};
			_objectDB.AddRecipe(val);
		}

		private static void LegendaryTierShieldWard()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_ShieldWard_LegendaryTier";
			val.m_item = Plugin._legendaryTier.GetComponent<ItemDrop>();
			val.m_amount = 1;
			val.m_enabled = true;
			val.m_qualityResultAmountMultiplier = 1f;
			val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_minStationLevel = 4;
			val.m_requireOnlyOneIngredient = false;
			val.m_resources = (Requirement[])(object)new Requirement[4]
			{
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("YagluthDrop").GetComponent<ItemDrop>(),
					m_amount = 1,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Wisp").GetComponent<ItemDrop>(),
					m_amount = 8,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("BlackMetal").GetComponent<ItemDrop>(),
					m_amount = 40,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Chitin").GetComponent<ItemDrop>(),
					m_amount = 24,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				}
			};
			_objectDB.AddRecipe(val);
		}

		private static void GodTierShieldWard()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_ShieldWard_GodTier";
			val.m_item = Plugin._godTier.GetComponent<ItemDrop>();
			val.m_amount = 1;
			val.m_enabled = true;
			val.m_qualityResultAmountMultiplier = 1f;
			val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_minStationLevel = 4;
			val.m_requireOnlyOneIngredient = false;
			val.m_resources = (Requirement[])(object)new Requirement[4]
			{
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("BlackCore").GetComponent<ItemDrop>(),
					m_amount = 1,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Eitr").GetComponent<ItemDrop>(),
					m_amount = 24,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("BlackMarble").GetComponent<ItemDrop>(),
					m_amount = 62,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				},
				new Requirement
				{
					m_resItem = _objectDB.GetItemPrefab("Wisp").GetComponent<ItemDrop>(),
					m_amount = 22,
					m_extraAmountOnlyOneIngredient = 0,
					m_amountPerLevel = 1,
					m_recover = true
				}
			};
			_objectDB.AddRecipe(val);
		}
	}
	public class SE_ShieldWard : StatusEffect
	{
		public float m_absorbDamage = 100f;

		public EffectList m_breakEffects;

		public EffectList m_hitEffects;

		public float m_damage;

		public float m_durability;

		public void Awake()
		{
			base.m_name = "Shield Ward";
			((Object)this).name = "bww_shieldward";
			base.m_tooltip = "Grants its wearer a protective shield.";
		}

		public override void Setup(Character character)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0047: Expected O, but got Unknown
			EffectList val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("vfx_StaffShield"),
					m_enabled = true,
					m_variant = -1,
					m_attach = true,
					m_scale = true
				}
			};
			base.m_startEffects = val;
			((StatusEffect)this).Setup(character);
		}

		public void SetAbsorbDamage(float damage)
		{
			m_absorbDamage = damage;
		}

		public void SetDurability(float durability)
		{
			m_durability = durability;
		}

		public override bool IsDone()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (!(m_durability <= 0.001f))
			{
				return ((StatusEffect)this).IsDone();
			}
			EffectList val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("fx_StaffShield_Break"),
					m_enabled = true,
					m_variant = -1,
					m_scale = true
				}
			};
			m_breakEffects = val;
			Transform transform;
			m_breakEffects.Create(base.m_character.GetCenterPoint(), (transform = ((Component)base.m_character).transform).rotation, transform, base.m_character.GetRadius() * 2f, -1);
			return true;
		}

		public override void OnDamaged(HitData hit, Character attacker)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			float totalDamage = hit.GetTotalDamage();
			m_damage += totalDamage;
			hit.ApplyModifier(0f);
			EffectList val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("fx_StaffShield_Hit"),
					m_enabled = true,
					m_variant = -1
				}
			};
			m_hitEffects = val;
			m_hitEffects.Create(hit.m_point, Quaternion.LookRotation(-hit.m_dir), ((Component)base.m_character).transform, 1f, -1);
		}

		public float GetHitDamage()
		{
			return m_damage;
		}

		public float GetTotalAbsorbDamage()
		{
			return m_absorbDamage;
		}

		public override string GetTooltipString()
		{
			return ((StatusEffect)this).GetTooltipString() + $"\nCan absorb a total damage of : <color=orange>{m_absorbDamage:0}</color>";
		}
	}
	public abstract class StatsSetup
	{
		public static void LowTierShieldWard(ItemDrop item)
		{
			ConfigSetup._lowTierDurability.SettingChanged += delegate
			{
				item.m_itemData.m_shared.m_maxDurability = ConfigSetup._lowTierDurability.Value;
				if (item.m_itemData.m_durability > ConfigSetup._lowTierDurability.Value)
				{
					item.m_itemData.m_durability = ConfigSetup._lowTierDurability.Value;
				}
			};
			item.m_itemData.m_shared.m_maxDurability = ConfigSetup._lowTierDurability.Value;
			if (item.m_itemData.m_durability > ConfigSetup._lowTierDurability.Value)
			{
				item.m_itemData.m_durability = ConfigSetup._lowTierDurability.Value;
			}
			Plugin._repairable.SettingChanged += delegate
			{
				if (Plugin._repairable.Value == Toggle.On)
				{
					item.m_itemData.m_shared.m_destroyBroken = false;
					item.m_itemData.m_shared.m_canBeReparied = true;
				}
				else
				{
					item.m_itemData.m_shared.m_destroyBroken = true;
					item.m_itemData.m_shared.m_canBeReparied = false;
				}
			};
			if (Plugin._repairable.Value == Toggle.On)
			{
				item.m_itemData.m_shared.m_destroyBroken = false;
				item.m_itemData.m_shared.m_canBeReparied = true;
			}
			else
			{
				item.m_itemData.m_shared.m_destroyBroken = true;
				item.m_itemData.m_shared.m_canBeReparied = false;
			}
		}

		public static void MidTierShieldWard(ItemDrop item)
		{
			ConfigSetup._midTierDurability.SettingChanged += delegate
			{
				item.m_itemData.m_shared.m_maxDurability = ConfigSetup._midTierDurability.Value;
				if (item.m_itemData.m_durability > ConfigSetup._midTierDurability.Value)
				{
					item.m_itemData.m_durability = ConfigSetup._midTierDurability.Value;
				}
			};
			item.m_itemData.m_shared.m_maxDurability = ConfigSetup._midTierDurability.Value;
			if (item.m_itemData.m_durability > ConfigSetup._midTierDurability.Value)
			{
				item.m_itemData.m_durability = ConfigSetup._midTierDurability.Value;
			}
			Plugin._repairable.SettingChanged += delegate
			{
				if (Plugin._repairable.Value == Toggle.On)
				{
					item.m_itemData.m_shared.m_destroyBroken = false;
					item.m_itemData.m_shared.m_canBeReparied = true;
				}
				else
				{
					item.m_itemData.m_shared.m_destroyBroken = true;
					item.m_itemData.m_shared.m_canBeReparied = false;
				}
			};
			if (Plugin._repairable.Value == Toggle.On)
			{
				item.m_itemData.m_shared.m_destroyBroken = false;
				item.m_itemData.m_shared.m_canBeReparied = true;
			}
			else
			{
				item.m_itemData.m_shared.m_destroyBroken = true;
				item.m_itemData.m_shared.m_canBeReparied = false;
			}
		}

		public static void HighTierShieldWard(ItemDrop item)
		{
			ConfigSetup._highTierDurability.SettingChanged += delegate
			{
				item.m_itemData.m_shared.m_maxDurability = ConfigSetup._highTierDurability.Value;
				if (item.m_itemData.m_durability > ConfigSetup._highTierDurability.Value)
				{
					item.m_itemData.m_durability = ConfigSetup._highTierDurability.Value;
				}
			};
			item.m_itemData.m_shared.m_maxDurability = ConfigSetup._highTierDurability.Value;
			if (item.m_itemData.m_durability > ConfigSetup._highTierDurability.Value)
			{
				item.m_itemData.m_durability = ConfigSetup._highTierDurability.Value;
			}
			Plugin._repairable.SettingChanged += delegate
			{
				if (Plugin._repairable.Value == Toggle.On)
				{
					item.m_itemData.m_shared.m_destroyBroken = false;
					item.m_itemData.m_shared.m_canBeReparied = true;
				}
				else
				{
					item.m_itemData.m_shared.m_destroyBroken = true;
					item.m_itemData.m_shared.m_canBeReparied = false;
				}
			};
			if (Plugin._repairable.Value == Toggle.On)
			{
				item.m_itemData.m_shared.m_destroyBroken = false;
				item.m_itemData.m_shared.m_canBeReparied = true;
			}
			else
			{
				item.m_itemData.m_shared.m_destroyBroken = true;
				item.m_itemData.m_shared.m_canBeReparied = false;
			}
		}

		public static void EpicTierShieldWard(ItemDrop item)
		{
			ConfigSetup._epicTierDurability.SettingChanged += delegate
			{
				item.m_itemData.m_shared.m_maxDurability = ConfigSetup._epicTierDurability.Value;
				if (item.m_itemData.m_durability > ConfigSetup._epicTierDurability.Value)
				{
					item.m_itemData.m_durability = ConfigSetup._epicTierDurability.Value;
				}
			};
			item.m_itemData.m_shared.m_maxDurability = ConfigSetup._epicTierDurability.Value;
			if (item.m_itemData.m_durability > ConfigSetup._epicTierDurability.Value)
			{
				item.m_itemData.m_durability = ConfigSetup._epicTierDurability.Value;
			}
			Plugin._repairable.SettingChanged += delegate
			{
				if (Plugin._repairable.Value == Toggle.On)
				{
					item.m_itemData.m_shared.m_destroyBroken = false;
					item.m_itemData.m_shared.m_canBeReparied = true;
				}
				else
				{
					item.m_itemData.m_shared.m_destroyBroken = true;
					item.m_itemData.m_shared.m_canBeReparied = false;
				}
			};
			if (Plugin._repairable.Value == Toggle.On)
			{
				item.m_itemData.m_shared.m_destroyBroken = false;
				item.m_itemData.m_shared.m_canBeReparied = true;
			}
			else
			{
				item.m_itemData.m_shared.m_destroyBroken = true;
				item.m_itemData.m_shared.m_canBeReparied = false;
			}
		}

		public static void LegendaryTierShieldWard(ItemDrop item)
		{
			ConfigSetup._legendaryTierDurability.SettingChanged += delegate
			{
				item.m_itemData.m_shared.m_maxDurability = ConfigSetup._legendaryTierDurability.Value;
				if (item.m_itemData.m_durability > ConfigSetup._legendaryTierDurability.Value)
				{
					item.m_itemData.m_durability = ConfigSetup._legendaryTierDurability.Value;
				}
			};
			item.m_itemData.m_shared.m_maxDurability = ConfigSetup._legendaryTierDurability.Value;
			if (item.m_itemData.m_durability > ConfigSetup._legendaryTierDurability.Value)
			{
				item.m_itemData.m_durability = ConfigSetup._legendaryTierDurability.Value;
			}
			Plugin._repairable.SettingChanged += delegate
			{
				if (Plugin._repairable.Value == Toggle.On)
				{
					item.m_itemData.m_shared.m_destroyBroken = false;
					item.m_itemData.m_shared.m_canBeReparied = true;
				}
				else
				{
					item.m_itemData.m_shared.m_destroyBroken = true;
					item.m_itemData.m_shared.m_canBeReparied = false;
				}
			};
			if (Plugin._repairable.Value == Toggle.On)
			{
				item.m_itemData.m_shared.m_destroyBroken = false;
				item.m_itemData.m_shared.m_canBeReparied = true;
			}
			else
			{
				item.m_itemData.m_shared.m_destroyBroken = true;
				item.m_itemData.m_shared.m_canBeReparied = false;
			}
		}

		public static void GodTierShieldWard(ItemDrop item)
		{
			ConfigSetup._godTierDurability.SettingChanged += delegate
			{
				item.m_itemData.m_shared.m_maxDurability = ConfigSetup._godTierDurability.Value;
				if (item.m_itemData.m_durability > ConfigSetup._godTierDurability.Value)
				{
					item.m_itemData.m_durability = ConfigSetup._godTierDurability.Value;
				}
			};
			item.m_itemData.m_shared.m_maxDurability = ConfigSetup._godTierDurability.Value;
			if (item.m_itemData.m_durability > ConfigSetup._godTierDurability.Value)
			{
				item.m_itemData.m_durability = ConfigSetup._godTierDurability.Value;
			}
			Plugin._repairable.SettingChanged += delegate
			{
				if (Plugin._repairable.Value == Toggle.On)
				{
					item.m_itemData.m_shared.m_destroyBroken = false;
					item.m_itemData.m_shared.m_canBeReparied = true;
				}
				else
				{
					item.m_itemData.m_shared.m_destroyBroken = true;
					item.m_itemData.m_shared.m_canBeReparied = false;
				}
			};
			if (Plugin._repairable.Value == Toggle.On)
			{
				item.m_itemData.m_shared.m_destroyBroken = false;
				item.m_itemData.m_shared.m_canBeReparied = true;
			}
			else
			{
				item.m_itemData.m_shared.m_destroyBroken = true;
				item.m_itemData.m_shared.m_canBeReparied = false;
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded]
	[CompilerGenerated]
	internal sealed class <b89b921d-8954-4084-bd4d-1feb826a594e>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LocalizationManager
{
	[<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(1)]
	[<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(0)]
	[PublicAPI]
	internal class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

		private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts;

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

		private static readonly List<WeakReference<Localization>> localizationObjects;

		[<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static readonly List<string> fileExtensions;

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		private static void UpdatePlaceholderText(Localization localization, string key)
		{
			localizationLanguage.TryGetValue(localization, out var value);
			string text = loadedTexts[value][key];
			if (PlaceholderProcessors.TryGetValue(key, out var value2))
			{
				text = value2.Aggregate(text, [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdatePlaceholder();
			};
			if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
			{
				UpdatePlaceholder();
			}
			void UpdatePlaceholder()
			{
				PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value);
				UpdatePlaceholderText(Localization.instance, key);
			}
		}

		public static void AddText(string key, string text)
		{
			List<WeakReference<Localization>> list = new List<WeakReference<Localization>>();
			foreach (WeakReference<Localization> localizationObject in localizationObjects)
			{
				if (localizationObject.TryGetTarget(out var target))
				{
					Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)];
					if (!target.m_translations.ContainsKey(key))
					{
						dictionary[key] = text;
						target.AddWord(key, text);
					}
				}
				else
				{
					list.Add(localizationObject);
				}
			}
			foreach (WeakReference<Localization> item in list)
			{
				localizationObjects.Remove(item);
			}
		}

		public static void Load()
		{
			LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage());
		}

		private static void LoadLocalization(Localization __instance, string language)
		{
			if (!localizationLanguage.Remove(__instance))
			{
				localizationObjects.Add(new WeakReference<Localization>(__instance));
			}
			localizationLanguage.Add(__instance, language);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories)
				where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0
				select f)
			{
				string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1];
				if (dictionary.ContainsKey(text))
				{
					Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped."));
				}
				else
				{
					dictionary[text] = item;
				}
			}
			byte[] array = LoadTranslationFromAssembly("English");
			if (array == null)
			{
				throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml.");
			}
			Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array));
			if (dictionary2 == null)
			{
				throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty.");
			}
			string text2 = null;
			if (language != "English")
			{
				if (dictionary.ContainsKey(language))
				{
					text2 = File.ReadAllText(dictionary[language]);
				}
				else
				{
					byte[] array2 = LoadTranslationFromAssembly(language);
					if (array2 != null)
					{
						text2 = Encoding.UTF8.GetString(array2);
					}
				}
			}
			if (text2 == null && dictionary.ContainsKey("English"))
			{
				text2 = File.ReadAllText(dictionary["English"]);
			}
			if (text2 != null)
			{
				foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>())
				{
					dictionary2[item2.Key] = item2.Value;
				}
			}
			loadedTexts[language] = dictionary2;
			foreach (KeyValuePair<string, string> item3 in dictionary2)
			{
				UpdatePlaceholderText(__instance, item3.Key);
			}
		}

		static Localizer()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>();
			loadedTexts = new Dictionary<string, Dictionary<string, string>>();
			localizationLanguage = new ConditionalWeakTable<Localization, string>();
			localizationObjects = new List<WeakReference<Localization>>();
			fileExtensions = new List<string> { ".json", ".yml" };
			new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		[return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(2)]
		private static byte[] LoadTranslationFromAssembly(string language)
		{
			foreach (string fileExtension in fileExtensions)
			{
				byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
				if (array != null)
				{
					return array;
				}
			}
			return null;
		}

		[<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<d15bd030-f887-4a0b-baae-32799bfe348b>Embedded]
	internal sealed class <d15bd030-f887-4a0b-baae-32799bfe348b>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<d15bd030-f887-4a0b-baae-32799bfe348b>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <6efc7da9-c261-4ce6-bb1a-7887e175101a>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <6efc7da9-c261-4ce6-bb1a-7887e175101a>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <6efc7da9-c261-4ce6-bb1a-7887e175101a>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<d15bd030-f887-4a0b-baae-32799bfe348b>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <2dea8664-adde-4311-94d3-2715e3215af9>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <2dea8664-adde-4311-94d3-2715e3215af9>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)]
	[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace System.Collections.Generic
{
	internal static class DeconstructionExtensions
	{
		[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
		public static void Deconstruct<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TKey, [<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TValue>([<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(new byte[] { 0, 1, 1 })] this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value)
		{
			key = pair.Key;
			value = pair.Value;
		}
	}
}
namespace YamlDotNet
{
	[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
	[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)]
	internal sealed class CultureInfoAdapter : CultureInfo
	{
		private readonly IFormatProvider provider;

		public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider)
			: base(baseCulture.LCID)
		{
			this.provider = provider;
		}

		[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(2)]
		public override object GetFormat(Type formatType)
		{
			return provider.GetFormat(formatType);
		}
	}
	[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)]
	[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
	internal static class ReflectionExtensions
	{
		[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		private static readonly FieldInfo RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public static Type BaseType(this Type type)
		{
			return type.BaseType;
		}

		public static bool IsValueType(this Type type)
		{
			return type.IsValueType;
		}

		public static bool IsGenericType(this Type type)
		{
			return type.IsGenericType;
		}

		public static bool IsGenericTypeDefinition(this Type type)
		{
			return type.IsGenericTypeDefinition;
		}

		public static bool IsInterface(this Type type)
		{
			return type.IsInterface;
		}

		public static bool IsEnum(this Type type)
		{
			return type.IsEnum;
		}

		public static bool IsDbNull(this object value)
		{
			return value is DBNull;
		}

		public static bool HasDefaultConstructor(this Type type)
		{
			if (!type.IsValueType)
			{
				return type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null) != null;
			}
			return true;
		}

		public static TypeCode GetTypeCode(this Type type)
		{
			return Type.GetTypeCode(type);
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public static PropertyInfo GetPublicProperty(this Type type, string name)
		{
			return type.GetProperty(name);
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public static FieldInfo GetPublicStaticField(this Type type, string name)
		{
			return type.GetField(name, BindingFlags.Static | BindingFlags.Public);
		}

		public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic)
		{
			BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
			if (includeNonPublic)
			{
				bindingFlags |= BindingFlags.NonPublic;
			}
			if (!type.IsInterface)
			{
				return type.GetProperties(bindingFlags);
			}
			return new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany([<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(0)] (Type i) => i.GetProperties(bindingFlags));
		}

		public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type)
		{
			return type.GetProperties(includeNonPublic: false);
		}

		public static IEnumerable<FieldInfo> GetPublicFields(this Type type)
		{
			return type.GetFields(BindingFlags.Instance | BindingFlags.Public);
		}

		public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type)
		{
			return type.GetMethods(BindingFlags.Static | BindingFlags.Public);
		}

		public static MethodInfo GetPrivateStaticMethod(this Type type, string name)
		{
			return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'.");
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public static MethodInfo GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes)
		{
			return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null);
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public static MethodInfo GetPublicInstanceMethod(this Type type, string name)
		{
			return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public);
		}

		public static Exception Unwrap(this TargetInvocationException ex)
		{
			Exception innerException = ex.InnerException;
			if (innerException == null)
			{
				return ex;
			}
			if (RemoteStackTraceField != null)
			{
				RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n");
			}
			return innerException;
		}

		public static bool IsInstanceOf(this Type type, object o)
		{
			return type.IsInstanceOfType(o);
		}

		public static Attribute[] GetAllCustomAttributes<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TAttribute>(this PropertyInfo property)
		{
			return Attribute.GetCustomAttributes(property, typeof(TAttribute));
		}
	}
	internal static class PropertyInfoExtensions
	{
		[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public static object ReadValue(this PropertyInfo property, object target)
		{
			return property.GetValue(target, null);
		}
	}
	internal static class StandardRegexOptions
	{
		public const RegexOptions Compiled = RegexOptions.Compiled;
	}
}
namespace YamlDotNet.Serialization
{
	[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
	[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)]
	internal abstract class BuilderSkeleton<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TBuilder> where TBuilder : BuilderSkeleton<TBuilder>
	{
		internal INamingConvention namingConvention = NullNamingConvention.Instance;

		internal ITypeResolver typeResolver;

		internal readonly YamlAttributeOverrides overrides;

		internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories;

		internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories;

		private bool ignoreFields;

		private bool includeNonPublicProperties;

		protected abstract TBuilder Self { get; }

		internal BuilderSkeleton(ITypeResolver typeResolver)
		{
			overrides = new YamlAttributeOverrides();
			typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter>
			{
				{
					typeof(YamlDotNet.Serialization.Converters.GuidConverter),
					(Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false)
				},
				{
					typeof(SystemTypeConverter),
					(Nothing _) => new SystemTypeConverter()
				}
			};
			typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>();
			this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver");
		}

		internal ITypeInspector BuildTypeInspector()
		{
			ITypeInspector typeInspector = new ReadablePropertiesTypeInspector(typeResolver, includeNonPublicProperties);
			if (!ignoreFields)
			{
				typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector);
			}
			return typeInspectorFactories.BuildComponentChain(typeInspector);
		}

		public TBuilder IgnoreFields()
		{
			ignoreFields = true;
			return Self;
		}

		public TBuilder IncludeNonPublicProperties()
		{
			includeNonPublicProperties = true;
			return Self;
		}

		public TBuilder WithNamingConvention(INamingConvention namingConvention)
		{
			this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention");
			return Self;
		}

		public TBuilder WithTypeResolver(ITypeResolver typeResolver)
		{
			this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver");
			return Self;
		}

		public abstract TBuilder WithTagMapping(TagName tag, Type type);

		public TBuilder WithAttributeOverride<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute)
		{
			overrides.Add(propertyAccessor, attribute);
			return Self;
		}

		public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute)
		{
			overrides.Add(type, member, attribute);
			return Self;
		}

		public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter)
		{
			return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w)
			{
				w.OnTop();
			});
		}

		public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where)
		{
			if (typeConverter == null)
			{
				throw new ArgumentNullException("typeConverter");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter.GetType(), (Nothing _) => typeConverter));
			return Self;
		}

		public TBuilder WithTypeConverter<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter
		{
			if (typeConverterFactory == null)
			{
				throw new ArgumentNullException("typeConverterFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory(wrapped)));
			return Self;
		}

		public TBuilder WithoutTypeConverter<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter
		{
			return WithoutTypeConverter(typeof(TYamlTypeConverter));
		}

		public TBuilder WithoutTypeConverter(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			typeConverterFactories.Remove(converterType);
			return Self;
		}

		public TBuilder WithTypeInspector<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector
		{
			return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w)
			{
				w.OnTop();
			});
		}

		public TBuilder WithTypeInspector<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector
		{
			if (typeInspectorFactory == null)
			{
				throw new ArgumentNullException("typeInspectorFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory(inner)));
			return Self;
		}

		public TBuilder WithTypeInspector<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector
		{
			if (typeInspectorFactory == null)
			{
				throw new ArgumentNullException("typeInspectorFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory(wrapped, inner)));
			return Self;
		}

		public TBuilder WithoutTypeInspector<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TTypeInspector>() where TTypeInspector : ITypeInspector
		{
			return WithoutTypeInspector(typeof(TTypeInspector));
		}

		public TBuilder WithoutTypeInspector(Type inspectorType)
		{
			if (inspectorType == null)
			{
				throw new ArgumentNullException("inspectorType");
			}
			typeInspectorFactories.Remove(inspectorType);
			return Self;
		}

		protected IEnumerable<IYamlTypeConverter> BuildTypeConverters()
		{
			return typeConverterFactories.BuildComponentList();
		}
	}
	internal delegate TComponent WrapperFactory<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase;
	internal delegate TComponent WrapperFactory<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TArgument, [<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase;
	[Flags]
	internal enum DefaultValuesHandling
	{
		Preserve = 0,
		OmitNull = 1,
		OmitDefaults = 2,
		OmitEmptyCollections = 4
	}
	[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
	[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)]
	internal sealed class Deserializer : IDeserializer
	{
		private readonly IValueDeserializer valueDeserializer;

		public Deserializer()
			: this(new DeserializerBuilder().BuildValueDeserializer())
		{
		}

		private Deserializer(IValueDeserializer valueDeserializer)
		{
			this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer");
		}

		public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer)
		{
			return new Deserializer(valueDeserializer);
		}

		public T Deserialize<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] T>(string input)
		{
			using StringReader input2 = new StringReader(input);
			return Deserialize<T>(input2);
		}

		public T Deserialize<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] T>(TextReader input)
		{
			return Deserialize<T>(new Parser(input));
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public object Deserialize(TextReader input)
		{
			return Deserialize(input, typeof(object));
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public object Deserialize(string input, Type type)
		{
			using StringReader input2 = new StringReader(input);
			return Deserialize(input2, type);
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public object Deserialize(TextReader input, Type type)
		{
			return Deserialize(new Parser(input), type);
		}

		public T Deserialize<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] T>(IParser parser)
		{
			return (T)Deserialize(parser, typeof(T));
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public object Deserialize(IParser parser)
		{
			return Deserialize(parser, typeof(object));
		}

		[return: <6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)]
		public object Deserialize(IParser parser, Type type)
		{
			if (parser == null)
			{
				throw new ArgumentNullException("parser");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			YamlDotNet.Core.Events.StreamStart @event;
			bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event);
			YamlDotNet.Core.Events.DocumentStart event2;
			bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2);
			object result = null;
			if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _))
			{
				using SerializerState serializerState = new SerializerState();
				result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer);
				serializerState.OnDeserialization();
			}
			if (flag2)
			{
				parser.Consume<YamlDotNet.Core.Events.DocumentEnd>();
			}
			if (flag)
			{
				parser.Consume<YamlDotNet.Core.Events.StreamEnd>();
			}
			return result;
		}
	}
	[<2dea8664-adde-4311-94d3-2715e3215af9>NullableContext(1)]
	[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(new byte[] { 0, 1 })]
	internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder>
	{
		private Lazy<IObjectFactory> objectFactory;

		private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories;

		private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories;

		private readonly Dictionary<TagName, Type> tagMappings;

		private readonly Dictionary<Type, Type> typeMappings;

		private bool ignoreUnmatched;

		protected override DeserializerBuilder Self => this;

		public DeserializerBuilder()
			: base((ITypeResolver)new StaticTypeResolver())
		{
			typeMappings = new Dictionary<Type, Type>();
			objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings), isThreadSafe: true);
			tagMappings = new Dictionary<TagName, Type>
			{
				{
					FailsafeSchema.Tags.Map,
					typeof(Dictionary<object, object>)
				},
				{
					FailsafeSchema.Tags.Str,
					typeof(string)
				},
				{
					JsonSchema.Tags.Bool,
					typeof(bool)
				},
				{
					JsonSchema.Tags.Float,
					typeof(double)
				},
				{
					JsonSchema.Tags.Int,
					typeof(int)
				},
				{
					DefaultSchema.Tags.Timestamp,
					typeof(DateTime)
				}
			};
			typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner));
			typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner);
			typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner));
			typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone()));
			typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner));
			nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer>
			{
				{
					typeof(YamlConvertibleNodeDeserializer),
					(Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(YamlSerializableNodeDeserializer),
					(Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(TypeConverterNodeDeserializer),
					(Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters())
				},
				{
					typeof(NullNodeDeserializer),
					(Nothing _) => new NullNodeDeserializer()
				},
				{
					typeof(ScalarNodeDeserializer),
					(Nothing _) => new ScalarNodeDeserializer()
				},
				{
					typeof(ArrayNodeDeserializer),
					(Nothing _) => new ArrayNodeDeserializer()
				},
				{
					typeof(DictionaryNodeDeserializer),
					(Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(CollectionNodeDeserializer),
					(Nothing _) => new CollectionNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(EnumerableNodeDeserializer),
					(Nothing _) => new EnumerableNodeDeserializer()
				},
				{
					typeof(ObjectNodeDeserializer),
					(Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched)
				}
			};
			nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver>
			{
				{
					typeof(MappingNodeTypeResolver),
					(Nothing _) => new MappingNodeTypeResolver(typeMappings)
				},
				{
					typeof(YamlConvertibleTypeResolver),
					(Nothing _) => new YamlConvertibleTypeResolver()
				},
				{
					typeof(YamlSerializableTypeResolver),
					(Nothing _) => new YamlSerializableTypeResolver()
				},
				{
					typeof(TagNodeTypeResolver),
					(Nothing _) => new TagNodeTypeResolver(tagMappings)
				},
				{
					typeof(PreventUnknownTagsNodeTypeResolver),
					(Nothing _) => new PreventUnknownTagsNodeTypeResolver()
				},
				{
					typeof(DefaultContainersNodeTypeResolver),
					(Nothing _) => new DefaultContainersNodeTypeResolver()
				}
			};
		}

		public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory)
		{
			if (objectFactory == null)
			{
				throw new ArgumentNullException("objectFactory");
			}
			this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory, isThreadSafe: true);
			return this;
		}

		public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory)
		{
			if (objectFactory == null)
			{
				throw new ArgumentNullException("objectFactory");
			}
			return WithObjectFactory(new LambdaObjectFactory(objectFactory));
		}

		public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer)
		{
			return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w)
			{
				w.OnTop();
			});
		}

		public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where)
		{
			if (nodeDeserializer == null)
			{
				throw new ArgumentNullException("nodeDeserializer");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer.GetType(), (Nothing _) => nodeDeserializer));
			return this;
		}

		public DeserializerBuilder WithNodeDeserializer<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer
		{
			if (nodeDeserializerFactory == null)
			{
				throw new ArgumentNullException("nodeDeserializerFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory(wrapped)));
			return this;
		}

		public DeserializerBuilder WithoutNodeDeserializer<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer
		{
			return WithoutNodeDeserializer(typeof(TNodeDeserializer));
		}

		public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType)
		{
			if (nodeDeserializerType == null)
			{
				throw new ArgumentNullException("nodeDeserializerType");
			}
			nodeDeserializerFactories.Remove(nodeDeserializerType);
			return this;
		}

		public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver)
		{
			return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w)
			{
				w.OnTop();
			});
		}

		public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where)
		{
			if (nodeTypeResolver == null)
			{
				throw new ArgumentNullException("nodeTypeResolver");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver.GetType(), (Nothing _) => nodeTypeResolver));
			return this;
		}

		public DeserializerBuilder WithNodeTypeResolver<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver
		{
			if (nodeTypeResolverFactory == null)
			{
				throw new ArgumentNullException("nodeTypeResolverFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory(wrapped)));
			return this;
		}

		public DeserializerBuilder WithoutNodeTypeResolver<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver
		{
			return WithoutNodeTypeResolver(typeof(TNodeTypeResolver));
		}

		public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType)
		{
			if (nodeTypeResolverType == null)
			{
				throw new ArgumentNullException("nodeTypeResolverType");
			}
			nodeTypeResolverFactories.Remove(nodeTypeResolverType);
			return this;
		}

		public override DeserializerBuilder WithTagMapping(TagName tag, Type type)
		{
			if (tag.IsEmpty)
			{
				throw new ArgumentException("Non-specific tags cannot be maped");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (tagMappings.TryGetValue(tag, out var value))
			{
				throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag");
			}
			tagMappings.Add(tag, type);
			return this;
		}

		public DeserializerBuilder WithTypeMapping<[<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(2)] TInterface, [<6efc7da9-c261-4ce6-bb1a-7887e175101a>Nullable(0)] TConcrete>() where TConcrete : TInterface
		{
			Type typeFromHandle = typeof(TInterface);
			Type typeFromHandle2 = typeof(TConcrete);
			if (!t