Decompiled source of WarheimStuff v1.2.4

WarheimStuff.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jewelcrafting;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using PvpOverhaul.API;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;
using WarheimStuff.RaidSystem;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WarheimStuff")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WarheimStuff")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace WarheimStuff
{
	[HarmonyPatch(typeof(Skills), "Awake")]
	[HarmonyAfter(new string[] { "org.bepinex.plugins.professions" })]
	public static class ProfessionsKeepLevelsPatch
	{
		private static readonly HashSet<int> PatchedButtons = new HashSet<int>();

		private static Type _professionsType;

		private static Type _helperType;

		private static Type _skillElementType;

		private static FieldInfo _professionPanelElementsField;

		private static FieldInfo _allowUnselectField;

		private static FieldInfo _professionChangeCooldownField;

		private static FieldInfo _serverTimeField;

		private static MethodInfo _updateSelectPanelSelectionsMethod;

		private static MethodInfo _fromProfessionMethod;

		private static MethodInfo _getActiveProfessionsMethod;

		private static MethodInfo _storeActiveProfessionsMethod;

		private static MethodInfo _getInactiveProfessionsMethod;

		private static MethodInfo _storeInactiveProfessionsMethod;

		private static MethodInfo _getHumanFriendlyTimeMethod;

		private static bool _reflectionReady;

		private static void Postfix()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			try
			{
				if (!PrepareReflection() || !(_professionPanelElementsField?.GetValue(null) is IDictionary { Count: not 0 } dictionary))
				{
					return;
				}
				foreach (DictionaryEntry item in dictionary)
				{
					object professionObj = item.Key;
					object? value = item.Value;
					GameObject val = (GameObject)((value is GameObject) ? value : null);
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					Component component = val.GetComponent(_skillElementType);
					if ((Object)(object)component == (Object)null)
					{
						continue;
					}
					object? obj = AccessTools.Field(_skillElementType, "Select")?.GetValue(component);
					Button val2 = (Button)((obj is Button) ? obj : null);
					if (!((Object)(object)val2 == (Object)null) && PatchedButtons.Add(((Object)val2).GetInstanceID()))
					{
						((UnityEventBase)val2.onClick).RemoveAllListeners();
						((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
						{
							OnProfessionButtonClicked(professionObj);
						});
					}
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[WarheimStuff] Failed to rewire Professions buttons: {arg}");
			}
		}

		private static bool PrepareReflection()
		{
			if (_reflectionReady)
			{
				return true;
			}
			_professionsType = AccessTools.TypeByName("Professions.Professions");
			_helperType = AccessTools.TypeByName("Professions.Helper");
			_skillElementType = AccessTools.TypeByName("Skill_Element");
			if (_professionsType == null || _helperType == null || _skillElementType == null)
			{
				return false;
			}
			_professionPanelElementsField = AccessTools.Field(_professionsType, "professionPanelElements");
			_allowUnselectField = AccessTools.Field(_professionsType, "allowUnselect");
			_professionChangeCooldownField = AccessTools.Field(_professionsType, "professionChangeCooldown");
			_serverTimeField = AccessTools.Field(_professionsType, "serverTime");
			_updateSelectPanelSelectionsMethod = AccessTools.Method(_professionsType, "UpdateSelectPanelSelections", (Type[])null, (Type[])null);
			_fromProfessionMethod = AccessTools.Method(_professionsType, "fromProfession", (Type[])null, (Type[])null);
			_getActiveProfessionsMethod = AccessTools.Method(_helperType, "getActiveProfessions", (Type[])null, (Type[])null);
			_storeActiveProfessionsMethod = AccessTools.Method(_helperType, "storeActiveProfessions", (Type[])null, (Type[])null);
			_getInactiveProfessionsMethod = AccessTools.Method(_helperType, "getInactiveProfessions", (Type[])null, (Type[])null);
			_storeInactiveProfessionsMethod = AccessTools.Method(_helperType, "storeInactiveProfessions", (Type[])null, (Type[])null);
			_getHumanFriendlyTimeMethod = AccessTools.Method(_helperType, "getHumanFriendlyTime", (Type[])null, (Type[])null);
			_reflectionReady = _professionPanelElementsField != null && _allowUnselectField != null && _professionChangeCooldownField != null && _serverTimeField != null && _updateSelectPanelSelectionsMethod != null && _fromProfessionMethod != null && _getActiveProfessionsMethod != null && _storeActiveProfessionsMethod != null && _getInactiveProfessionsMethod != null && _storeInactiveProfessionsMethod != null && _getHumanFriendlyTimeMethod != null;
			return _reflectionReady;
		}

		private static void OnProfessionButtonClicked(object professionObj)
		{
			try
			{
				if (!PrepareReflection() || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				object obj = _getActiveProfessionsMethod.Invoke(null, null);
				if (obj == null)
				{
					return;
				}
				Type type = obj.GetType();
				MethodInfo method = type.GetMethod("Contains");
				MethodInfo method2 = type.GetMethod("Add");
				MethodInfo method3 = type.GetMethod("Remove");
				if (method != null && (bool)method.Invoke(obj, new object[1] { professionObj }))
				{
					if (!CanUnselectNow())
					{
						return;
					}
					method3?.Invoke(obj, new object[1] { professionObj });
					_storeActiveProfessionsMethod.Invoke(null, new object[1] { obj });
					Player.m_localPlayer.m_customData["Professions LastProfessionChange"] = GetServerUnixTime().ToString();
				}
				else
				{
					RestoreOldInactiveLevelIfNeeded(professionObj);
					method2?.Invoke(obj, new object[1] { professionObj });
					_storeActiveProfessionsMethod.Invoke(null, new object[1] { obj });
				}
				_updateSelectPanelSelectionsMethod.Invoke(null, null);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[WarheimStuff] Error in profession click override: {arg}");
			}
		}

		private static bool CanUnselectNow()
		{
			object value = _allowUnselectField.GetValue(null);
			object value2 = _professionChangeCooldownField.GetValue(null);
			object obj = value?.GetType().GetProperty("Value")?.GetValue(value);
			object obj2 = value2?.GetType().GetProperty("Value")?.GetValue(value2);
			bool flag = string.Equals(obj?.ToString(), "On", StringComparison.OrdinalIgnoreCase);
			float num = ((obj2 != null) ? Convert.ToSingle(obj2) : 0f);
			if (!flag)
			{
				return false;
			}
			if (num <= 0f)
			{
				return true;
			}
			if (!Player.m_localPlayer.m_customData.TryGetValue("Professions LastProfessionChange", out var value3))
			{
				return true;
			}
			if (!int.TryParse(value3, out var result))
			{
				return true;
			}
			int serverUnixTime = GetServerUnixTime();
			int num2 = result + (int)(num * 3600f) - serverUnixTime;
			if (num2 > 0)
			{
				string text = (string)_getHumanFriendlyTimeMethod.Invoke(null, new object[1] { num2 });
				((Character)Player.m_localPlayer).Message((MessageType)2, "You can change your profession in " + text + ".", 0, (Sprite)null);
				return false;
			}
			return true;
		}

		private static int GetServerUnixTime()
		{
			DateTime dateTime = (DateTime)_serverTimeField.GetValue(null);
			return (int)((DateTimeOffset)dateTime).ToUnixTimeSeconds();
		}

		private static Skill GetOrCreateSkill(Player player, SkillType skillType)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			object value = Traverse.Create((object)player).Field("m_skills").GetValue();
			if (value == null)
			{
				return null;
			}
			object value2 = Traverse.Create(value).Method("GetSkill", new object[1] { skillType }).GetValue();
			return (Skill)((value2 is Skill) ? value2 : null);
		}

		private static void RestoreOldInactiveLevelIfNeeded(object professionObj)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				object obj = _getInactiveProfessionsMethod.Invoke(null, null);
				if (!(obj is IDictionary dictionary) || !dictionary.Contains(professionObj))
				{
					return;
				}
				float num = 0f;
				object obj2 = dictionary[professionObj];
				if (obj2 != null)
				{
					num = Convert.ToSingle(obj2);
				}
				if (num <= 0f)
				{
					return;
				}
				object obj3 = _fromProfessionMethod.Invoke(null, new object[1] { professionObj });
				if (obj3 != null)
				{
					SkillType skillType = (SkillType)obj3;
					Skill orCreateSkill = GetOrCreateSkill(Player.m_localPlayer, skillType);
					if (orCreateSkill != null)
					{
						orCreateSkill.m_level = Mathf.Max(orCreateSkill.m_level, num);
					}
					dictionary.Remove(professionObj);
					_storeInactiveProfessionsMethod.Invoke(null, new object[1] { obj });
				}
			}
			catch (Exception arg)
			{
				Debug.LogWarning((object)$"[WarheimStuff] Failed to restore old inactive profession level: {arg}");
			}
		}
	}
	internal static class WarheimGems
	{
		public struct IncreasePercentPower
		{
			[MultiplicativePercentagePower]
			public float Power;
		}

		public struct ReductionPercentPower
		{
			[InverseMultiplicativePercentagePower]
			public float Power;
		}

		public struct ResiliencePower
		{
			[AdditivePower]
			public float Power;
		}

		[HarmonyPatch(typeof(Character), "GetMaxHealth")]
		private static class MalachiteHealthPatch
		{
			private static void Postfix(Character __instance, ref float __result)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					__result *= 1f + GetIncrease(val, "Vitalité de la malachite") / 100f;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetMaxStamina")]
		private static class MalachiteStaminaPatch
		{
			private static void Postfix(Player __instance, ref float __result)
			{
				__result *= 1f + GetIncrease(__instance, "Endurance de la malachite") / 100f;
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class MalachiteDamagePatch
		{
			private static void Prefix(Character __instance, HitData hit)
			{
				if (hit != null)
				{
					Character attacker = hit.GetAttacker();
					Player val = (Player)(object)((attacker is Player) ? attacker : null);
					if (val != null && (Object)(object)val != (Object)(object)__instance)
					{
						hit.ApplyModifier(1f + GetIncrease(val, "Puissance de la malachite") / 100f);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class GemDamageReductionPatch
		{
			private static void Prefix(Character __instance, HitData hit)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && hit != null)
				{
					Character attacker = hit.GetAttacker();
					if (!((Object)(object)attacker == (Object)(object)__instance))
					{
						hit.m_damage.m_pierce *= RemainingDamage(GetReduction(val, "Égide perforante de l'ambre"));
						hit.m_damage.m_blunt *= RemainingDamage(GetReduction(val, "Égide contondante de l'ambre"));
						hit.m_damage.m_slash *= RemainingDamage(GetReduction(val, "Égide tranchante de l'ambre"));
						hit.m_damage.m_lightning *= RemainingDamage(GetReduction(val, "Protection foudroyante de l'alexandrite"));
						hit.m_damage.m_poison *= RemainingDamage(GetReduction(val, "Protection toxique de l'alexandrite"));
						hit.m_damage.m_fire *= RemainingDamage(GetReduction(val, "Protection ardente de l'alexandrite"));
						hit.m_damage.m_spirit *= RemainingDamage(GetReduction(val, "Protection spirituelle de l'alexandrite"));
						hit.m_damage.m_frost *= RemainingDamage(GetReduction(val, "Protection glaciale de l'alexandrite"));
						hit.ApplyModifier(RemainingDamage(GetReduction(val, "Rempart d'ambre")));
					}
				}
			}
		}

		[HarmonyPatch(typeof(SEMan), "ModifyAttackStaminaUsage")]
		private static class AmberAttackStaminaPatch
		{
			private static void Postfix(Character ___m_character, ref float staminaUse)
			{
				Player val = (Player)(object)((___m_character is Player) ? ___m_character : null);
				if (val != null)
				{
					staminaUse *= RemainingDamage(GetReduction(val, "Assaut d'ambre"));
				}
			}
		}

		[HarmonyPatch(typeof(SEMan), "ModifyJumpStaminaUsage")]
		private static class AmberJumpStaminaPatch
		{
			private static void Postfix(Character ___m_character, ref float staminaUse)
			{
				Player val = (Player)(object)((___m_character is Player) ? ___m_character : null);
				if (val != null)
				{
					staminaUse *= RemainingDamage(GetReduction(val, "Bond d'ambre"));
				}
			}
		}

		[HarmonyPatch(typeof(PvpResilienceAPI), "GetLocalEquippedResilience")]
		private static class AzuriteResiliencePatch
		{
			private static void Postfix(Player player, ref float __result)
			{
				__result += GetResilience(player);
			}
		}

		private const string ComfortTweaksGuid = "xyz.alcan.comfortcalc";

		private const string MalachiteAttackSpeed = "Vivacité de la malachite";

		private const string MalachiteHealth = "Vitalité de la malachite";

		private const string MalachiteStamina = "Endurance de la malachite";

		private const string MalachiteDamage = "Puissance de la malachite";

		private const string AmberPierceResistance = "Égide perforante de l'ambre";

		private const string AmberBluntResistance = "Égide contondante de l'ambre";

		private const string AmberSlashResistance = "Égide tranchante de l'ambre";

		private const string AmberShieldReduction = "Rempart d'ambre";

		private const string AmberAttackStamina = "Assaut d'ambre";

		private const string AmberJumpStamina = "Bond d'ambre";

		private const string AlexandriteLightningResistance = "Protection foudroyante de l'alexandrite";

		private const string AlexandritePoisonResistance = "Protection toxique de l'alexandrite";

		private const string AlexandriteFireResistance = "Protection ardente de l'alexandrite";

		private const string AlexandriteSpiritResistance = "Protection spirituelle de l'alexandrite";

		private const string AlexandriteFrostResistance = "Protection glaciale de l'alexandrite";

		private const string AzuriteResilience = "Warheim Azurite Resilience";

		private static readonly int ColorProperty = Shader.PropertyToID("_Color");

		private static readonly int BaseColorProperty = Shader.PropertyToID("_BaseColor");

		private static readonly int EmissionColorProperty = Shader.PropertyToID("_EmissionColor");

		private static bool initialized;

		private const string GemConfiguration = "Vivacité de la malachite:\r\n  slot: legs\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nVitalité de la malachite:\r\n  slot: chest\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nEndurance de la malachite:\r\n  slot: head\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nPuissance de la malachite:\r\n  slot: [weapon, bow, crossbow, magic]\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nÉgide perforante de l'ambre:\r\n  slot: chest\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nÉgide contondante de l'ambre:\r\n  slot: legs\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nÉgide tranchante de l'ambre:\r\n  slot: head\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nRempart d'ambre:\r\n  slot: shield\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nAssaut d'ambre:\r\n  slot: weapon\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nBond d'ambre:\r\n  slot: cloak\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nProtection foudroyante de l'alexandrite:\r\n  slot: chest\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection toxique de l'alexandrite:\r\n  slot: head\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection ardente de l'alexandrite:\r\n  slot: legs\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection spirituelle de l'alexandrite:\r\n  slot: utility\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection glaciale de l'alexandrite:\r\n  slot: cloak\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nWarheim Azurite Resilience:\r\n  slot: [head, legs, chest, cloak, utility]\r\n  gem: Azurite\r\n  power: [1, 2, 3]\r\ngems:\r\n  Meadows:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Black Forest:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Swamp:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Mountain:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Plains:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Mistlands:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Ash Lands:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Deep North:\r\n    Malachite: 0.0125\r\n    Amber: 0.0125\r\n    Alexandrite: 0.0125\r\n    Azurite: 0.0125\r\n";

		public static void Initialize()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized && API.IsLoaded())
			{
				initialized = true;
				RegisterEffects();
				RegisterGemFamily("Malachite", new Color(0.05f, 0.55f, 0.18f, 1f), new Color(1.35f, 0.03f, 0.02f, 1f));
				RegisterGemFamily("Amber", new Color(0.015f, 0.012f, 0.008f, 1f), new Color(1.5f, 0.8f, 0.02f, 1f));
				RegisterGemFamily("Alexandrite", new Color(0.92f, 0.96f, 1f, 1f), new Color(0.05f, 0.4f, 1.4f, 1f));
				RegisterGemFamily("Azurite", new Color(0.38f, 0.05f, 0.58f, 1f), new Color(1.5f, 0.32f, 0.01f, 1f));
				API.AddGemConfig("Vivacité de la malachite:\r\n  slot: legs\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nVitalité de la malachite:\r\n  slot: chest\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nEndurance de la malachite:\r\n  slot: head\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nPuissance de la malachite:\r\n  slot: [weapon, bow, crossbow, magic]\r\n  gem: Malachite\r\n  power: [1, 1.5, 2]\r\nÉgide perforante de l'ambre:\r\n  slot: chest\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nÉgide contondante de l'ambre:\r\n  slot: legs\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nÉgide tranchante de l'ambre:\r\n  slot: head\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nRempart d'ambre:\r\n  slot: shield\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nAssaut d'ambre:\r\n  slot: weapon\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nBond d'ambre:\r\n  slot: cloak\r\n  gem: Amber\r\n  power: [1, 1.5, 2]\r\nProtection foudroyante de l'alexandrite:\r\n  slot: chest\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection toxique de l'alexandrite:\r\n  slot: head\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection ardente de l'alexandrite:\r\n  slot: legs\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection spirituelle de l'alexandrite:\r\n  slot: utility\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nProtection glaciale de l'alexandrite:\r\n  slot: cloak\r\n  gem: Alexandrite\r\n  power: [1, 1.5, 2]\r\nWarheim Azurite Resilience:\r\n  slot: [head, legs, chest, cloak, utility]\r\n  gem: Azurite\r\n  power: [1, 2, 3]\r\ngems:\r\n  Meadows:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Black Forest:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Swamp:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Mountain:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Plains:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Mistlands:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Ash Lands:\r\n    Malachite: 0\r\n    Amber: 0\r\n    Alexandrite: 0\r\n    Azurite: 0\r\n  Deep North:\r\n    Malachite: 0.0125\r\n    Amber: 0.0125\r\n    Alexandrite: 0.0125\r\n    Azurite: 0.0125\r\n");
				RegisterAttackSpeedModifier();
				API.OnEffectRecalc += SyncLocalResilience;
				AddFrenchTranslations();
			}
		}

		private static void RegisterAttackSpeedModifier()
		{
			if (!Chainloader.PluginInfos.TryGetValue("xyz.alcan.comfortcalc", out var value) || (Object)(object)value.Instance == (Object)null)
			{
				Debug.LogWarning((object)"[WarheimGems] ComfortTweaks n'est pas chargé, le bonus de vitesse d'attaque de la malachite est désactivé.");
				return;
			}
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			Type type = assembly.GetType("AnimationSpeedManager");
			Type type2 = type?.GetNestedType("Handler", BindingFlags.Public);
			MethodInfo methodInfo = type?.GetMethod("Add", BindingFlags.Static | BindingFlags.Public);
			MethodInfo method = typeof(WarheimGems).GetMethod("ApplyMalachiteAttackSpeed", BindingFlags.Static | BindingFlags.NonPublic);
			if (type2 == null || methodInfo == null || method == null)
			{
				Debug.LogWarning((object)"[WarheimGems] AnimationSpeedManager est introuvable dans ComfortTweaks.");
				return;
			}
			Delegate obj = Delegate.CreateDelegate(type2, method);
			methodInfo.Invoke(null, new object[2] { obj, 400 });
		}

		private static double ApplyMalachiteAttackSpeed(Character character, double speed)
		{
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val == null || !((Character)val).InAttack())
			{
				return speed;
			}
			return speed * (1.0 + (double)GetMalachiteAttackSpeed(val));
		}

		private static void RegisterGemFamily(string gemName, Color baseColor, Color emissionColor)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			GameObject shard = API.AddShardFromTemplate(gemName, gemName, baseColor);
			Material val = CreateGemMaterial(gemName, shard, baseColor, emissionColor);
			if ((Object)(object)val != (Object)null)
			{
				GameObject val2 = API.AddUncutFromTemplate(gemName, gemName, val);
				API.AddUncutGem(val2, gemName, (ConfigEntry<float>)null);
				API.AddDestructibleFromTemplate(gemName, gemName, val);
				API.AddTieredGemFromTemplate(gemName, gemName, val, baseColor);
			}
			else
			{
				GameObject val3 = API.AddUncutFromTemplate(gemName, gemName, baseColor);
				API.AddUncutGem(val3, gemName, (ConfigEntry<float>)null);
				API.AddDestructibleFromTemplate(gemName, gemName, baseColor);
				API.AddTieredGemFromTemplate(gemName, gemName, baseColor);
			}
		}

		private static Material CreateGemMaterial(string gemName, GameObject shard, Color baseColor, Color emissionColor)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)shard == (Object)null)
			{
				return null;
			}
			Transform val = shard.transform.Find("attach/Custom_Color_Mesh");
			MeshRenderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshRenderer>() : null);
			Material val3 = (((Object)(object)val2 != (Object)null) ? ((Renderer)val2).sharedMaterial : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return null;
			}
			Material val4 = new Material(val3)
			{
				name = "Warheim_" + gemName + "_Gem_Material"
			};
			if (val4.HasProperty(ColorProperty))
			{
				val4.SetColor(ColorProperty, baseColor);
			}
			if (val4.HasProperty(BaseColorProperty))
			{
				val4.SetColor(BaseColorProperty, baseColor);
			}
			if (val4.HasProperty(EmissionColorProperty))
			{
				val4.EnableKeyword("_EMISSION");
				val4.SetColor(EmissionColorProperty, emissionColor);
			}
			((Renderer)val2).sharedMaterial = val4;
			return val4;
		}

		private static void RegisterEffects()
		{
			API.AddGemEffect<IncreasePercentPower>("Vivacité de la malachite", "Increases attack speed.", "Attack speed is increased by $1%.");
			API.AddGemEffect<IncreasePercentPower>("Vitalité de la malachite", "Increases maximum health.", "Maximum health is increased by $1%.");
			API.AddGemEffect<IncreasePercentPower>("Endurance de la malachite", "Increases maximum stamina.", "Maximum stamina is increased by $1%.");
			API.AddGemEffect<IncreasePercentPower>("Puissance de la malachite", "Increases weapon damage.", "All damage dealt by the socketed weapon is increased by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Égide perforante de l'ambre", "Reduces piercing damage taken.", "Piercing damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Égide contondante de l'ambre", "Reduces blunt damage taken.", "Blunt damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Égide tranchante de l'ambre", "Reduces slashing damage taken.", "Slashing damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Rempart d'ambre", "Reduces all damage taken while using a shield.", "All damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Assaut d'ambre", "Reduces melee attack stamina usage.", "Melee attack stamina usage is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Bond d'ambre", "Reduces jump stamina usage.", "Jump stamina usage is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Protection foudroyante de l'alexandrite", "Reduces lightning damage taken.", "Lightning damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Protection toxique de l'alexandrite", "Reduces poison damage taken.", "Poison damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Protection ardente de l'alexandrite", "Reduces fire damage taken.", "Fire damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Protection spirituelle de l'alexandrite", "Reduces spirit damage taken.", "Spirit damage taken is reduced by $1%.");
			API.AddGemEffect<ReductionPercentPower>("Protection glaciale de l'alexandrite", "Reduces frost damage taken.", "Frost damage taken is reduced by $1%.");
			API.AddGemEffect<ResiliencePower>("Warheim Azurite Resilience", "Increases PvP resilience.", "PvP resilience is increased by $1.");
		}

		private static float GetMalachiteAttackSpeed(Player player)
		{
			return GetIncrease(player, "Vivacité de la malachite") / 100f;
		}

		private static void SyncLocalResilience()
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				PvpResilienceAPI.SyncLocalPlayerResilienceDelayed(Player.m_localPlayer);
			}
		}

		private static float GetIncrease(Player player, string effect)
		{
			return ((Object)(object)player != (Object)null) ? API.GetEffectPower<IncreasePercentPower>(player, effect).Power : 0f;
		}

		private static float GetReduction(Player player, string effect)
		{
			return ((Object)(object)player != (Object)null) ? API.GetEffectPower<ReductionPercentPower>(player, effect).Power : 0f;
		}

		private static float GetResilience(Player player)
		{
			return ((Object)(object)player != (Object)null) ? API.GetEffectPower<ResiliencePower>(player, "Warheim Azurite Resilience").Power : 0f;
		}

		private static float RemainingDamage(float reduction)
		{
			return 1f - Mathf.Clamp(reduction, 0f, 100f) / 100f;
		}

		private static void AddFrenchTranslations()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			AddGemTranslations(dictionary, "malachite", "Malachite", "Malachite simple", "Malachite avancée", "Malachite parfaite");
			AddGemTranslations(dictionary, "amber", "Ambre", "Ambre simple", "Ambre avancé", "Ambre parfait");
			AddGemTranslations(dictionary, "alexandrite", "Alexandrite", "Alexandrite simple", "Alexandrite avancée", "Alexandrite parfaite");
			AddGemTranslations(dictionary, "azurite", "Azurite", "Azurite simple", "Azurite avancée", "Azurite parfaite");
			AddEffectTranslation(dictionary, "Vivacité de la malachite", "Vivacité de la malachite", "Augmente la vitesse d'attaque.", "La vitesse d'attaque est augmentée de $1%.");
			AddEffectTranslation(dictionary, "Vitalité de la malachite", "Vitalité de la malachite", "Augmente la vie maximale.", "La vie maximale est augmentée de $1%.");
			AddEffectTranslation(dictionary, "Endurance de la malachite", "Endurance de la malachite", "Augmente l'endurance maximale.", "L'endurance maximale est augmentée de $1%.");
			AddEffectTranslation(dictionary, "Puissance de la malachite", "Puissance de la malachite", "Augmente les dégâts de l'arme.", "Tous les dégâts de l'arme sertie sont augmentés de $1%.");
			AddEffectTranslation(dictionary, "Égide perforante de l'ambre", "Égide perforante de l'ambre", "Réduit les dégâts perforants subis.", "Les dégâts perforants subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Égide contondante de l'ambre", "Égide contondante de l'ambre", "Réduit les dégâts contondants subis.", "Les dégâts contondants subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Égide tranchante de l'ambre", "Égide tranchante de l'ambre", "Réduit les dégâts tranchants subis.", "Les dégâts tranchants subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Rempart d'ambre", "Rempart d'ambre", "Réduit tous les dégâts subis avec un bouclier serti.", "Tous les dégâts subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Assaut d'ambre", "Assaut d'ambre", "Réduit le coût d'endurance des attaques de mêlée.", "Le coût d'endurance des attaques de mêlée est réduit de $1%.");
			AddEffectTranslation(dictionary, "Bond d'ambre", "Bond d'ambre", "Réduit le coût d'endurance des sauts.", "Le coût d'endurance des sauts est réduit de $1%.");
			AddEffectTranslation(dictionary, "Protection foudroyante de l'alexandrite", "Protection foudroyante de l'alexandrite", "Réduit les dégâts de foudre subis.", "Les dégâts de foudre subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Protection toxique de l'alexandrite", "Protection toxique de l'alexandrite", "Réduit les dégâts de poison subis.", "Les dégâts de poison subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Protection ardente de l'alexandrite", "Protection ardente de l'alexandrite", "Réduit les dégâts de feu subis.", "Les dégâts de feu subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Protection spirituelle de l'alexandrite", "Protection spirituelle de l'alexandrite", "Réduit les dégâts d'esprit subis.", "Les dégâts d'esprit subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Protection glaciale de l'alexandrite", "Protection glaciale de l'alexandrite", "Réduit les dégâts de givre subis.", "Les dégâts de givre subis sont réduits de $1%.");
			AddEffectTranslation(dictionary, "Warheim Azurite Resilience", "Résilience de l'azurite", "Augmente la résilience en combat JcJ.", "La résilience JcJ est augmentée de $1.");
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "French";
			localization.AddTranslation(ref text, dictionary);
		}

		private static void AddGemTranslations(Dictionary<string, string> translations, string key, string displayName, string simpleName, string advancedName, string perfectName)
		{
			string value = "Une gemme pouvant être sertie dans une pièce d'équipement.";
			string text = displayName.ToLowerInvariant();
			string text2 = (("aeiouyh".IndexOf(text[0]) >= 0) ? ("d'" + text) : ("de " + text));
			translations["jc_merged_gemstone_" + key] = displayName;
			translations["jc_shattered_" + key + "_crystal"] = "Éclat " + text2;
			translations["jc_shattered_" + key + "_crystal_description"] = value;
			translations["jc_uncut_" + key + "_stone"] = displayName + " brute";
			translations["jc_uncut_" + key + "_stone_description"] = "Une gemme brute pouvant être taillée à la table du lapidaire.";
			translations["jc_" + key + "_socket"] = simpleName;
			translations["jc_" + key + "_socket_description"] = value;
			translations["jc_adv_" + key + "_socket"] = advancedName;
			translations["jc_adv_" + key + "_socket_description"] = value;
			translations["jc_perfect_" + key + "_socket"] = perfectName;
			translations["jc_perfect_" + key + "_socket_description"] = value;
			translations["jc_raw_" + key + "_gemstone"] = "Formation " + text2;
		}

		private static void AddEffectTranslation(Dictionary<string, string> translations, string effect, string name, string description, string detailedDescription)
		{
			string text = "jc_effect_" + effect.Replace(" ", "_").ToLowerInvariant();
			translations[text] = name;
			translations[text + "_desc"] = description;
			translations[text + "_desc_detail"] = detailedDescription;
		}
	}
	internal static class WarheimGemTweaks
	{
		private struct RestedCostState
		{
			public StatusEffect Rested;

			public float OriginalTtl;

			public float FixedCost;
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		private static class OverexertionFixedRestedCostPatch
		{
			[HarmonyPrepare]
			private static bool Prepare()
			{
				return ResolveMembers();
			}

			[HarmonyPrefix]
			[HarmonyPriority(800)]
			private static void Prefix(HitData hit, ref RestedCostState __state)
			{
				if (!API.IsLoaded() || !IsComfortTweaksEnabled() || hit == null)
				{
					return;
				}
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val != null)
				{
					object obj = getEffectPowerMethod.Invoke(null, new object[2] { val, "Overexertion" });
					float num = Convert.ToSingle(penaltyField.GetValue(obj));
					StatusEffect statusEffect = ((Character)val).GetSEMan().GetStatusEffect(RestedHash);
					if (!((Object)(object)statusEffect == (Object)null) && !(num <= 0f))
					{
						__state.Rested = statusEffect;
						__state.OriginalTtl = statusEffect.m_ttl;
						__state.FixedCost = GetFixedRestedCost(num);
					}
				}
			}

			[HarmonyPostfix]
			[HarmonyPriority(0)]
			private static void Postfix(RestedCostState __state)
			{
				if ((Object)(object)__state.Rested != (Object)null)
				{
					__state.Rested.m_ttl = __state.OriginalTtl - __state.FixedCost;
				}
			}
		}

		private const string OverexertionEffect = "Overexertion";

		private const float SimpleRestedCost = 15f;

		private const float AdvancedRestedCost = 25f;

		private const float PerfectRestedCost = 45f;

		private static readonly int RestedHash = StringExtensionMethods.GetStableHashCode("Rested");

		private static MethodInfo getEffectPowerMethod;

		private static FieldInfo penaltyField;

		private static FieldInfo comfortEnabledField;

		private static PropertyInfo comfortEnabledValueProperty;

		private static bool ResolveMembers()
		{
			Type type = AccessTools.TypeByName("ComfortTweaks.gems.Overexertion+Config");
			Type type2 = AccessTools.TypeByName("ComfortTweaks.ComfortTweaks");
			if (type == null || type2 == null)
			{
				return false;
			}
			penaltyField = AccessTools.Field(type, "Penalty");
			comfortEnabledField = AccessTools.Field(type2, "isEnabled");
			comfortEnabledValueProperty = comfortEnabledField?.FieldType.GetProperty("Value");
			MethodInfo[] methods = typeof(API).GetMethods(BindingFlags.Static | BindingFlags.Public);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name == "GetEffectPower" && methodInfo.IsGenericMethodDefinition && methodInfo.GetParameters().Length == 2)
				{
					getEffectPowerMethod = methodInfo.MakeGenericMethod(type);
					break;
				}
			}
			return getEffectPowerMethod != null && penaltyField != null && comfortEnabledField != null && comfortEnabledValueProperty != null;
		}

		private static bool IsComfortTweaksEnabled()
		{
			object value = comfortEnabledField.GetValue(null);
			return value != null && (bool)comfortEnabledValueProperty.GetValue(value, null);
		}

		private static float GetFixedRestedCost(float penalty)
		{
			if (penalty <= 0f)
			{
				return 0f;
			}
			if (penalty < 1.5f)
			{
				return 15f;
			}
			if (penalty < 3f)
			{
				return 25f;
			}
			return 45f;
		}
	}
	public static class WarheimPdf
	{
		public class SE_WarheimPdfCooldown : StatusEffect
		{
		}

		private static class PdfCastBar
		{
			private static GameObject _root;

			private static Text _text;

			private static readonly Color Gold = new Color(1f, 0.78f, 0.35f, 1f);

			public static void Show()
			{
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_root != (Object)null)
				{
					_root.SetActive(true);
					SetProgress(0f, 10f);
					return;
				}
				Hud instance = Hud.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject rootObject = instance.m_rootObject;
					obj = ((rootObject != null) ? rootObject.GetComponentInParent<Canvas>() : null);
				}
				Canvas val = (Canvas)obj;
				if (!((Object)(object)val == (Object)null))
				{
					_root = new GameObject("WarheimPdfCastText");
					_root.transform.SetParent(((Component)val).transform, false);
					RectTransform val2 = _root.AddComponent<RectTransform>();
					val2.anchorMin = new Vector2(0.5f, 0f);
					val2.anchorMax = new Vector2(0.5f, 0f);
					val2.pivot = new Vector2(0.5f, 0.5f);
					val2.anchoredPosition = new Vector2(0f, 145f);
					val2.sizeDelta = new Vector2(520f, 40f);
					_text = _root.AddComponent<Text>();
					_text.alignment = (TextAnchor)4;
					_text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
					_text.fontSize = 22;
					_text.fontStyle = (FontStyle)1;
					((Graphic)_text).color = Gold;
					Outline val3 = _root.AddComponent<Outline>();
					((Shadow)val3).effectColor = Color.black;
					((Shadow)val3).effectDistance = new Vector2(1.8f, -1.8f);
					SetProgress(0f, 10f);
				}
			}

			public static void SetProgress(float progress, float remaining)
			{
				if (!((Object)(object)_root == (Object)null) && !((Object)(object)_text == (Object)null))
				{
					_text.text = $"Canalisation de la Pierre de Foyer... {remaining:0.0}s";
				}
			}

			public static void Hide()
			{
				if ((Object)(object)_root != (Object)null)
				{
					_root.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UseItem")]
		private static class Humanoid_UseItem_PdfPatch
		{
			private static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui)
			{
				if ((Object)(object)__instance == (Object)null || item == null || !IsPdf(item))
				{
					return true;
				}
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val == null)
				{
					return true;
				}
				TryUse(val, inventory, item);
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "OnSpawned")]
		private static class Player_OnSpawned_PdfCooldownPatch
		{
			private static void Postfix(Player __instance)
			{
				if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
				{
					((MonoBehaviour)__instance).StartCoroutine(ReapplyCooldownAfterSpawn(__instance));
				}
			}
		}

		private const string PdfSimplePrefab = "PdfSimple";

		private const string PdfWarheimPrefab = "PdfWarheim";

		private const string CooldownKey = "Warheim.Pdf.CooldownUntilUtc";

		private const float PdfSimpleCooldownSeconds = 3600f;

		private const float PdfWarheimCooldownSeconds = 1800f;

		private const float CastDuration = 10f;

		private static bool _isCasting;

		private const string PdfSimpleCooldownSeName = "SE_WarheimPdfSimpleCooldown";

		private const string PdfWarheimCooldownSeName = "SE_WarheimPdfWarheimCooldown";

		private static Sprite _pdfSimpleIcon;

		private static Sprite _pdfWarheimIcon;

		private static StatusEffect _pdfSimpleCooldownSe;

		private static StatusEffect _pdfWarheimCooldownSe;

		private static AudioClip _castAudioClip;

		private static GameObject _castVfxPrefab;

		public static bool IsPdf(ItemData item)
		{
			string prefabName = GetPrefabName(item);
			return prefabName == "PdfSimple" || prefabName == "PdfWarheim";
		}

		private static bool IsSimple(ItemData item)
		{
			return GetPrefabName(item) == "PdfSimple";
		}

		private static bool IsWarheim(ItemData item)
		{
			return GetPrefabName(item) == "PdfWarheim";
		}

		private static string GetPrefabName(ItemData item)
		{
			return ((Object)(object)item?.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : "";
		}

		private static float GetCooldownSeconds(ItemData item)
		{
			return IsWarheim(item) ? 1800f : 3600f;
		}

		private static bool ShouldConsume(ItemData item)
		{
			return IsSimple(item);
		}

		public static bool TryUse(Player player, Inventory sourceInventory, ItemData item)
		{
			if ((Object)(object)player == (Object)null || item == null || !IsPdf(item))
			{
				return false;
			}
			if (sourceInventory == null)
			{
				sourceInventory = ((Humanoid)player).GetInventory();
			}
			if (_isCasting)
			{
				((Character)player).Message((MessageType)2, "La Pierre de Foyer est déjà en cours d'utilisation.", 0, (Sprite)null);
				return true;
			}
			double cooldownRemainingSeconds = GetCooldownRemainingSeconds(player);
			if (cooldownRemainingSeconds > 0.0)
			{
				((Character)player).Message((MessageType)2, "Pierre de Foyer en rechargement : " + FormatTime(cooldownRemainingSeconds), 0, (Sprite)null);
				return true;
			}
			if (!CanTeleport(player, showMessage: true))
			{
				return true;
			}
			((MonoBehaviour)player).StartCoroutine(CastAndTeleport(player, sourceInventory, item));
			return true;
		}

		private static IEnumerator CastAndTeleport(Player player, Inventory sourceInventory, ItemData item)
		{
			_isCasting = true;
			AudioSource castAudio = StartCastSound(player);
			GameObject castVfx = StartCastVfx(player);
			player.StartEmote("sit", false);
			Vector3 startPosition = ((Component)player).transform.position;
			((Character)player).Message((MessageType)2, "Canalisation de la Pierre de Foyer...", 0, (Sprite)null);
			float timer = 0f;
			PdfCastBar.Show();
			while (timer < 10f)
			{
				if ((Object)(object)player == (Object)null || ((Character)player).IsDead())
				{
					_isCasting = false;
					PdfCastBar.Hide();
					StopCastSound(castAudio);
					StopCastVfx(castVfx);
					yield break;
				}
				if (IsTryingToMove() || Vector3.Distance(startPosition, ((Component)player).transform.position) > 0.75f)
				{
					((Character)player).Message((MessageType)2, "Canalisation interrompue.", 0, (Sprite)null);
					_isCasting = false;
					PdfCastBar.Hide();
					StopCastSound(castAudio);
					StopCastVfx(castVfx);
					yield break;
				}
				float progress = timer / 10f;
				PdfCastBar.SetProgress(progress, 10f - timer);
				timer += Time.deltaTime;
				yield return null;
			}
			PdfCastBar.Hide();
			if (!CanTeleport(player, showMessage: true))
			{
				_isCasting = false;
				PdfCastBar.Hide();
				StopCastSound(castAudio);
				StopCastVfx(castVfx);
				yield break;
			}
			if (!TryGetBedSpawnPoint(player, out var spawnPoint))
			{
				((Character)player).Message((MessageType)2, "Aucun point de retour trouvé.", 0, (Sprite)null);
				_isCasting = false;
				PdfCastBar.Hide();
				StopCastSound(castAudio);
				StopCastVfx(castVfx);
				yield break;
			}
			((Character)player).TeleportTo(spawnPoint, ((Component)player).transform.rotation, true);
			float cooldown = GetCooldownSeconds(item);
			SetCooldown(player, cooldown, item);
			ApplyCooldownStatusEffect(player, cooldown);
			if (ShouldConsume(item))
			{
				bool removed = sourceInventory != null && sourceInventory.RemoveItem(item, 1);
				if (!removed)
				{
					removed = ((Humanoid)player).GetInventory().RemoveItem(item, 1);
				}
				if (!removed)
				{
					Logger.LogWarning((object)("[WarheimPdf] Impossible de consommer " + GetPrefabName(item) + ". Inventaire source invalide ou item introuvable."));
				}
			}
			((Character)player).Message((MessageType)2, "La Pierre de Foyer vous ramène chez vous.", 0, (Sprite)null);
			StopCastSound(castAudio);
			StopCastVfx(castVfx);
			_isCasting = false;
		}

		private static bool IsTryingToMove()
		{
			return Input.GetKey((KeyCode)119) || Input.GetKey((KeyCode)97) || Input.GetKey((KeyCode)115) || Input.GetKey((KeyCode)100) || Input.GetKey((KeyCode)32) || Input.GetKey((KeyCode)306);
		}

		private static void ApplyCooldownStatusEffect(Player player, double durationSeconds)
		{
			if (!((Object)(object)player == (Object)null))
			{
				SEMan sEMan = ((Character)player).GetSEMan();
				if (sEMan != null)
				{
					sEMan.RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WarheimPdfSimpleCooldown"), false);
					sEMan.RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WarheimPdfWarheimCooldown"), false);
					string value;
					bool flag = player.m_customData.TryGetValue("Warheim.Pdf.Type", out value) && value == "Warheim";
					SE_WarheimPdfCooldown sE_WarheimPdfCooldown = ScriptableObject.CreateInstance<SE_WarheimPdfCooldown>();
					((Object)sE_WarheimPdfCooldown).name = (flag ? "SE_WarheimPdfWarheimCooldown" : "SE_WarheimPdfSimpleCooldown");
					((StatusEffect)sE_WarheimPdfCooldown).m_name = (flag ? "Pierre de Foyer Warheim" : "Pierre de Foyer");
					((StatusEffect)sE_WarheimPdfCooldown).m_tooltip = "Recharge restante : " + FormatTime(durationSeconds);
					((StatusEffect)sE_WarheimPdfCooldown).m_icon = (flag ? _pdfWarheimIcon : _pdfSimpleIcon);
					((StatusEffect)sE_WarheimPdfCooldown).m_ttl = (float)durationSeconds;
					Logger.LogInfo((object)$"[WarheimPdf] Adding SE {((Object)sE_WarheimPdfCooldown).name}, icon={(Object)(object)((StatusEffect)sE_WarheimPdfCooldown).m_icon != (Object)null}, ttl={((StatusEffect)sE_WarheimPdfCooldown).m_ttl}");
					sEMan.AddStatusEffect((StatusEffect)(object)sE_WarheimPdfCooldown, true, 0, 0f);
				}
			}
		}

		private static bool CanTeleport(Player player, bool showMessage)
		{
			if (!((Humanoid)player).IsTeleportable())
			{
				if (showMessage)
				{
					((Character)player).Message((MessageType)2, "Une force empêche la Pierre de Foyer de fonctionner.", 0, (Sprite)null);
				}
				return false;
			}
			if (HasBlockedStatusEffect(player))
			{
				if (showMessage)
				{
					((Character)player).Message((MessageType)2, "Impossible d'utiliser la Pierre de Foyer en combat.", 0, (Sprite)null);
				}
				return false;
			}
			return true;
		}

		private static bool HasBlockedStatusEffect(Player player)
		{
			SEMan sEMan = ((Character)player).GetSEMan();
			if (sEMan == null)
			{
				return false;
			}
			return sEMan.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_PvpModes_Bounty")) || sEMan.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Combat")) || sEMan.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_PvP")) || sEMan.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PvpTweaks_SE_Combat")) || sEMan.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PvpTweaks_SE_NoTeleport"));
		}

		private static bool TryGetBedSpawnPoint(Player player, out Vector3 point)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			point = Vector3.zero;
			Game instance = Game.instance;
			PlayerProfile val = ((instance != null) ? instance.GetPlayerProfile() : null);
			if (val == null)
			{
				return false;
			}
			if (val.HaveCustomSpawnPoint())
			{
				point = val.GetCustomSpawnPoint();
				return true;
			}
			point = val.GetHomePoint();
			return point != Vector3.zero;
		}

		private static void SetCooldown(Player player, float seconds, ItemData item)
		{
			long num = DateTimeOffset.UtcNow.AddSeconds(seconds).ToUnixTimeSeconds();
			player.m_customData["Warheim.Pdf.CooldownUntilUtc"] = num.ToString();
			player.m_customData["Warheim.Pdf.Type"] = (IsWarheim(item) ? "Warheim" : "Simple");
		}

		private static double GetCooldownRemainingSeconds(Player player)
		{
			if (!player.m_customData.TryGetValue("Warheim.Pdf.CooldownUntilUtc", out var value))
			{
				return 0.0;
			}
			if (!long.TryParse(value, out var result))
			{
				return 0.0;
			}
			long num = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
			double num2 = result - num;
			if (num2 <= 0.0)
			{
				player.m_customData.Remove("Warheim.Pdf.CooldownUntilUtc");
				return 0.0;
			}
			return num2;
		}

		private static string FormatTime(double seconds)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			if (timeSpan.TotalMinutes >= 1.0)
			{
				return $"{(int)timeSpan.TotalMinutes}m {timeSpan.Seconds}s";
			}
			return $"{timeSpan.Seconds}s";
		}

		public static void InitStatusEffects(AssetBundle bundle)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			_pdfSimpleIcon = bundle.LoadAsset<Sprite>("assets/pdf/pdfsimpleicon.png");
			_pdfWarheimIcon = bundle.LoadAsset<Sprite>("assets/pdf/pdfwarheimicon.png");
			_castVfxPrefab = bundle.LoadAsset<GameObject>("assets/pdf/vfx_pdf_cast.prefab");
			Logger.LogInfo((object)$"PDF VFX loaded = {(Object)(object)_castVfxPrefab != (Object)null}");
			_pdfSimpleCooldownSe = CreateCooldownSe("SE_WarheimPdfSimpleCooldown", "Pierre de Foyer en recharge", "Votre Pierre de Foyer simple se recharge.", _pdfSimpleIcon, 3600f);
			_pdfWarheimCooldownSe = CreateCooldownSe("SE_WarheimPdfWarheimCooldown", "Pierre de Foyer Warheim en recharge", "Votre Pierre de Foyer Warheim se recharge.", _pdfWarheimIcon, 1800f);
			_castAudioClip = bundle.LoadAsset<AudioClip>("assets/pdf/pdf_cast_loop.mp3");
			Logger.LogInfo((object)$"PDF SFX loaded = {(Object)(object)_castAudioClip != (Object)null}");
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(_pdfSimpleCooldownSe, false));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(_pdfWarheimCooldownSe, false));
		}

		private static GameObject StartCastVfx(Player player)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_castVfxPrefab == (Object)null)
			{
				Logger.LogWarning((object)"[WarheimPdf] Cast VFX prefab is null");
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(_castVfxPrefab);
			val.transform.position = ((Component)player).transform.position + new Vector3(0f, 0.05f, 0f);
			val.transform.rotation = Quaternion.identity;
			val.transform.SetParent(((Component)player).transform, true);
			Logger.LogInfo((object)$"[WarheimPdf] Cast VFX spawned at {val.transform.position}");
			return val;
		}

		private static void StopCastVfx(GameObject vfx)
		{
			if ((Object)(object)vfx != (Object)null)
			{
				Object.Destroy((Object)(object)vfx);
			}
		}

		private static AudioSource StartCastSound(Player player)
		{
			if ((Object)(object)_castAudioClip == (Object)null)
			{
				Logger.LogWarning((object)"[WarheimPdf] Cast SFX clip is null");
				return null;
			}
			AudioSource val = ((Component)player).gameObject.AddComponent<AudioSource>();
			val.clip = _castAudioClip;
			val.loop = true;
			val.playOnAwake = false;
			val.spatialBlend = 0f;
			val.volume = 1f;
			val.Play();
			Logger.LogInfo((object)"[WarheimPdf] Cast SFX started");
			return val;
		}

		private static void StopCastSound(AudioSource source)
		{
			if (!((Object)(object)source == (Object)null))
			{
				source.Stop();
				Object.Destroy((Object)(object)source);
			}
		}

		private static StatusEffect CreateCooldownSe(string name, string displayName, string tooltip, Sprite icon, float duration)
		{
			SE_WarheimPdfCooldown sE_WarheimPdfCooldown = ScriptableObject.CreateInstance<SE_WarheimPdfCooldown>();
			((Object)sE_WarheimPdfCooldown).name = name;
			((StatusEffect)sE_WarheimPdfCooldown).m_name = displayName;
			((StatusEffect)sE_WarheimPdfCooldown).m_tooltip = tooltip;
			((StatusEffect)sE_WarheimPdfCooldown).m_icon = icon;
			((StatusEffect)sE_WarheimPdfCooldown).m_ttl = duration;
			return (StatusEffect)(object)sE_WarheimPdfCooldown;
		}

		private static IEnumerator ReapplyCooldownAfterSpawn(Player player)
		{
			yield return null;
			yield return (object)new WaitForSeconds(1f);
			double remaining = GetCooldownRemainingSeconds(player);
			if (!(remaining <= 0.0))
			{
				ApplyCooldownStatusEffect(player, remaining);
			}
		}
	}
	[BepInPlugin("dzk.warheimstuff", "WarheimStuff", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class WarheimStuff : BaseUnityPlugin
	{
		private static class ReaperSpearRotationPatch
		{
			public static void Postfix(VisEquipment __instance, object[] __args, GameObject __result)
			{
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: 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)
				if (!((Object)(object)__result == (Object)null) && __args != null && __args.Length >= 3 && __args[0] is int num && num == StringExtensionMethods.GetStableHashCode("JC_Reaper_Spear"))
				{
					object obj = __args[2];
					Transform val = (Transform)((obj is Transform) ? obj : null);
					if (val != null && !((Object)(object)val != (Object)(object)__instance.m_rightHand))
					{
						__result.transform.localRotation = Quaternion.Euler(0f, 180f, 0f) * __result.transform.localRotation;
					}
				}
			}
		}

		private readonly struct PvpItemDef
		{
			public readonly string Path;

			public readonly float Resilience;

			public PvpItemDef(string path, float resilience)
			{
				Path = path;
				Resilience = resilience;
			}
		}

		private enum WarheimRingType
		{
			DPS,
			Tank,
			Archer,
			Mage,
			Miner,
			Lumberjack,
			Leviathan
		}

		public class SE_WarheimRingDPS : StatusEffect
		{
			public float m_staminaRegenMultiplier = 1f;

			public float m_damageMultiplier = 1f;

			public void SetStaminaRegenMultiplier(float value)
			{
				m_staminaRegenMultiplier = value;
			}

			public void SetDamageMultiplier(float value)
			{
				m_damageMultiplier = value;
			}

			public override void ModifyStaminaRegen(ref float staminaRegen)
			{
				staminaRegen *= m_staminaRegenMultiplier;
			}

			public override void ModifyAttack(SkillType skill, ref HitData hitData)
			{
				((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMultiplier);
			}
		}

		public class SE_WarheimRingTank : StatusEffect
		{
			public float m_healthPercentBonus;

			public float m_healthRegenMultiplier = 1f;

			public void SetHealthPercentBonus(float value)
			{
				m_healthPercentBonus = value;
			}

			public void SetHealthRegenMultiplier(float value)
			{
				m_healthRegenMultiplier = value;
			}

			public override void ModifyHealthRegen(ref float regenMultiplier)
			{
				regenMultiplier *= m_healthRegenMultiplier;
			}
		}

		public class SE_WarheimRingArcher : StatusEffect
		{
			public float m_staminaPercentBonus;

			public float m_moveSpeedMultiplier = 1f;

			public void SetStaminaPercentBonus(float value)
			{
				m_staminaPercentBonus = value;
			}

			public void SetMoveSpeedMultiplier(float value)
			{
				m_moveSpeedMultiplier = value;
			}

			public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir)
			{
				speed *= m_moveSpeedMultiplier;
			}
		}

		public class SE_WarheimRingMage : StatusEffect
		{
			public float m_eitrPercentBonus;

			public float m_eitrRegenMultiplier = 1f;

			public void SetEitrPercentBonus(float value)
			{
				m_eitrPercentBonus = value;
			}

			public void SetEitrRegenMultiplier(float value)
			{
				m_eitrRegenMultiplier = value;
			}

			public override void ModifyEitrRegen(ref float regen)
			{
				regen *= m_eitrRegenMultiplier;
			}
		}

		public class SE_WarheimRingMiner : StatusEffect
		{
			public float m_carryWeightBonus;

			public float m_pickaxeDamageMultiplier = 1f;

			public float m_healthPercentBonus;

			public void SetCarryWeightBonus(float value)
			{
				m_carryWeightBonus = value;
			}

			public void SetPickaxeDamageMultiplier(float value)
			{
				m_pickaxeDamageMultiplier = value;
			}

			public void SetHealthPercentBonus(float value)
			{
				m_healthPercentBonus = value;
			}

			public override void ModifyAttack(SkillType skill, ref HitData hitData)
			{
				hitData.m_damage.m_pickaxe *= m_pickaxeDamageMultiplier;
			}

			public override void ModifyMaxCarryWeight(float baseLimit, ref float limit)
			{
				limit += m_carryWeightBonus;
			}
		}

		public class SE_WarheimRingLumberjack : StatusEffect
		{
			public float m_carryWeightBonus;

			public float m_chopDamageMultiplier = 1f;

			public float m_staminaPercentBonus;

			public void SetCarryWeightBonus(float value)
			{
				m_carryWeightBonus = value;
			}

			public void SetChopDamageMultiplier(float value)
			{
				m_chopDamageMultiplier = value;
			}

			public void SetStaminaPercentBonus(float value)
			{
				m_staminaPercentBonus = value;
			}

			public override void ModifyAttack(SkillType skill, ref HitData hitData)
			{
				hitData.m_damage.m_chop *= m_chopDamageMultiplier;
			}

			public override void ModifyMaxCarryWeight(float baseLimit, ref float limit)
			{
				limit += m_carryWeightBonus;
			}
		}

		public class SE_WarheimRingLeviathan : StatusEffect
		{
			public float m_swimSkillBonus;

			public float m_swimSpeedMultiplier = 1f;

			public void SetSwimSkillBonus(float value)
			{
				m_swimSkillBonus = value;
			}

			public void SetSwimSpeedMultiplier(float value)
			{
				m_swimSpeedMultiplier = value;
			}

			public override void ModifySkillLevel(SkillType skill, ref float level)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: Invalid comparison between Unknown and I4
				if ((int)skill == 103)
				{
					level += m_swimSkillBonus;
				}
			}
		}

		public class SE_WarheimRingElementalist : StatusEffect
		{
			public override void ModifyDamageMods(ref DamageModifiers modifiers)
			{
				((DamageModifiers)(ref modifiers)).Apply(CreateElementalistDamageModifiers());
			}
		}

		public class SE_CollierWarheimDPS : StatusEffect
		{
			public float m_damageMultiplier = 1f;

			public float m_staminaRegenMultiplier = 1f;

			public void SetDamageMultiplier(float value)
			{
				m_damageMultiplier = value;
			}

			public void SetStaminaRegenMultiplier(float value)
			{
				m_staminaRegenMultiplier = value;
			}

			public override void ModifyAttack(SkillType skill, ref HitData hitData)
			{
				((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMultiplier);
			}

			public override void ModifyStaminaRegen(ref float staminaRegen)
			{
				staminaRegen *= m_staminaRegenMultiplier;
			}
		}

		public class SE_CollierWarheimBerserker : StatusEffect
		{
			public float m_damageDoneMultiplier = 1f;

			public float m_attackStaminaMultiplier = 1f;

			public float m_damageTakenMultiplier = 1f;

			public float m_moveSpeedMultiplier = 1f;

			public void SetBonuses(float damageDone, float attackStamina, float damageTaken, float moveSpeed)
			{
				m_damageDoneMultiplier = damageDone;
				m_attackStaminaMultiplier = attackStamina;
				m_damageTakenMultiplier = damageTaken;
				m_moveSpeedMultiplier = moveSpeed;
			}

			public override void ModifyAttack(SkillType skill, ref HitData hitData)
			{
				hitData.ApplyModifier(m_damageDoneMultiplier);
			}

			public override void OnDamaged(HitData hit, Character attacker)
			{
				hit.ApplyModifier(m_damageTakenMultiplier);
			}

			public override void ModifyAttackStaminaUsage(float baseStaminaUse, ref float staminaUse)
			{
				staminaUse *= m_attackStaminaMultiplier;
			}

			public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir)
			{
				speed *= m_moveSpeedMultiplier;
			}
		}

		public class SE_CollierWarheimMage : StatusEffect
		{
			public float m_eitr;

			public float m_skillup;

			public float m_regenModifier;

			public void SetEitr(float eitr)
			{
				m_eitr = eitr;
			}

			public void SetSkill(float skill)
			{
				m_skillup = skill;
			}

			public void SetRegenModifier(float regenModifier)
			{
				m_regenModifier = regenModifier;
			}

			public override void ModifyEitrRegen(ref float regen)
			{
				regen *= m_regenModifier;
			}

			public override void ModifySkillLevel(SkillType skill, ref float value)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: Invalid comparison between Unknown and I4
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				if ((int)skill == 10 || (int)skill == 9)
				{
					value += m_skillup;
				}
			}
		}

		public class SE_CollierWarheimTank : StatusEffect
		{
			public float m_healthPercentBonus;

			public float m_healthRegenMultiplier = 1f;

			public void SetHealthPercentBonus(float value)
			{
				m_healthPercentBonus = value;
			}

			public void SetHealthRegenMultiplier(float value)
			{
				m_healthRegenMultiplier = value;
			}

			public override void ModifyHealthRegen(ref float regenMultiplier)
			{
				regenMultiplier *= m_healthRegenMultiplier;
			}
		}

		public class SE_WarheimRingGladiator : StatusEffect
		{
			public float m_regenMultiplier = 1f;

			public void SetRegenMultiplier(float value)
			{
				m_regenMultiplier = value;
			}

			public override void ModifyHealthRegen(ref float regenMultiplier)
			{
				regenMultiplier *= m_regenMultiplier;
			}

			public override void ModifyStaminaRegen(ref float staminaRegen)
			{
				staminaRegen *= m_regenMultiplier;
			}

			public override void ModifyEitrRegen(ref float regen)
			{
				regen *= m_regenMultiplier;
			}
		}

		public class SE_CollierWarheimGladiator : StatusEffect
		{
			public float m_health;

			public float m_stamina;

			public float m_eitr;

			public void SetBonuses(float health, float stamina, float eitr)
			{
				m_health = health;
				m_stamina = stamina;
				m_eitr = eitr;
			}
		}

		[HarmonyPatch]
		public static class SwimmingReworkedLeviathanSpeedPatch
		{
			private static bool Prepare()
			{
				return Chainloader.PluginInfos.ContainsKey("dzk.SwimmingReworked");
			}

			private static MethodBase TargetMethod()
			{
				if (!Chainloader.PluginInfos.TryGetValue("dzk.SwimmingReworked", out var value))
				{
					return null;
				}
				Type type = ((object)value.Instance).GetType().Assembly.GetType("SwimmingReworked.SwimAPI");
				return AccessTools.Method(type, "GetExternalSwimSpeedMultiplier", new Type[1] { typeof(Player) }, (Type[])null);
			}

			[HarmonyPostfix]
			private static void Postfix(Player __0, ref float __result)
			{
				if ((Object)(object)__0 == (Object)null)
				{
					return;
				}
				SEMan sEMan = ((Character)__0).GetSEMan();
				if (sEMan == null)
				{
					return;
				}
				foreach (StatusEffect statusEffect in sEMan.GetStatusEffects())
				{
					if (statusEffect is SE_WarheimRingLeviathan sE_WarheimRingLeviathan)
					{
						__result *= sE_WarheimRingLeviathan.m_swimSpeedMultiplier;
						break;
					}
				}
			}
		}

		[HarmonyPatch]
		public static class Patch_IsNeckItem
		{
			private static MethodBase TargetMethod()
			{
				if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value))
				{
					return null;
				}
				Assembly assembly = ((object)value.Instance).GetType().Assembly;
				Type type = assembly.GetType("Jewelcrafting.Visual");
				if (type == null)
				{
					return null;
				}
				return AccessTools.Method(type, "IsNeckItem", (Type[])null, (Type[])null);
			}

			private static void Postfix(ItemData item, ref bool __result)
			{
				if ((Object)(object)item?.m_dropPrefab != (Object)null && ((Object)item.m_dropPrefab).name.StartsWith("JC_Necklace_Warheim"))
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch]
		public static class Patch_IsFingerItem
		{
			private static MethodBase TargetMethod()
			{
				if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value))
				{
					return null;
				}
				Assembly assembly = ((object)value.Instance).GetType().Assembly;
				Type type = assembly.GetType("Jewelcrafting.Visual");
				if (type == null)
				{
					return null;
				}
				return AccessTools.Method(type, "IsFingerItem", (Type[])null, (Type[])null);
			}

			private static void Postfix(ItemData item, ref bool __result)
			{
				object obj;
				if (item == null)
				{
					obj = null;
				}
				else
				{
					GameObject dropPrefab = item.m_dropPrefab;
					obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
				}
				string text = (string)obj;
				if (!string.IsNullOrEmpty(text) && text.StartsWith("JC_Ring_Warheim", StringComparison.Ordinal))
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
		public static class FoodTotalsFromWarheimNecklacesPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				SEMan value = Traverse.Create((object)__instance).Field("m_seman").GetValue<SEMan>();
				if (value == null)
				{
					return;
				}
				List<StatusEffect> value2 = Traverse.Create((object)value).Field("m_statusEffects").GetValue<List<StatusEffect>>();
				if (value2 == null)
				{
					return;
				}
				float num = 0f;
				float num2 = 0f;
				float num3 = 0f;
				float num4 = 0f;
				foreach (StatusEffect item in value2)
				{
					if (item is SE_CollierWarheimMage { m_eitr: not 0f } sE_CollierWarheimMage)
					{
						num += sE_CollierWarheimMage.m_eitr;
					}
					if (item is SE_CollierWarheimTank { m_healthPercentBonus: not 0f } sE_CollierWarheimTank)
					{
						num2 += sE_CollierWarheimTank.m_healthPercentBonus;
					}
					if (item is SE_CollierWarheimGladiator sE_CollierWarheimGladiator)
					{
						num3 += sE_CollierWarheimGladiator.m_health;
						num4 += sE_CollierWarheimGladiator.m_stamina;
						num += sE_CollierWarheimGladiator.m_eitr;
					}
				}
				if (num != 0f)
				{
					eitr += num;
				}
				if (num2 != 0f)
				{
					hp *= 1f + num2;
				}
				if (num3 != 0f)
				{
					hp += num3;
				}
				if (num4 != 0f)
				{
					stamina += num4;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
		public static class FoodTotalsFromWarheimRingsPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				SEMan sEMan = ((Character)__instance).GetSEMan();
				if (sEMan == null)
				{
					return;
				}
				float num = 0f;
				float num2 = 0f;
				float num3 = 0f;
				foreach (StatusEffect statusEffect in sEMan.GetStatusEffects())
				{
					if (statusEffect is SE_WarheimRingTank { m_healthPercentBonus: not 0f } sE_WarheimRingTank)
					{
						num += sE_WarheimRingTank.m_healthPercentBonus;
					}
					if (statusEffect is SE_WarheimRingArcher { m_staminaPercentBonus: not 0f } sE_WarheimRingArcher)
					{
						num2 += sE_WarheimRingArcher.m_staminaPercentBonus;
					}
					if (statusEffect is SE_WarheimRingMage { m_eitrPercentBonus: not 0f } sE_WarheimRingMage)
					{
						num3 += sE_WarheimRingMage.m_eitrPercentBonus;
					}
					if (statusEffect is SE_WarheimRingMiner { m_healthPercentBonus: not 0f } sE_WarheimRingMiner)
					{
						num += sE_WarheimRingMiner.m_healthPercentBonus;
					}
					if (statusEffect is SE_WarheimRingLumberjack { m_staminaPercentBonus: not 0f } sE_WarheimRingLumberjack)
					{
						num2 += sE_WarheimRingLumberjack.m_staminaPercentBonus;
					}
				}
				if (num != 0f)
				{
					hp += hp * num;
				}
				if (num2 != 0f)
				{
					stamina += stamina * num2;
				}
				if (num3 != 0f)
				{
					eitr += eitr * num3;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetBodyArmor")]
		public static class WarheimJewelryArmorPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Player __instance, ref float __result)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				Inventory inventory = ((Humanoid)__instance).GetInventory();
				if (inventory == null)
				{
					return;
				}
				foreach (ItemData equippedItem in inventory.GetEquippedItems())
				{
					if (!((Object)(object)equippedItem?.m_dropPrefab == (Object)null))
					{
						string name = ((Object)equippedItem.m_dropPrefab).name;
						if (name.StartsWith("JC_Ring_Warheim", StringComparison.Ordinal) || name.StartsWith("JC_Necklace_Warheim", StringComparison.Ordinal))
						{
							__result += Mathf.Max(1f, (float)equippedItem.m_quality);
						}
					}
				}
			}
		}

		[HarmonyPatch]
		public static class WarheimJewelryArmorTooltipPatch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				return AccessTools.GetDeclaredMethods(typeof(ItemData)).FindAll((MethodInfo m) => m.Name == "GetTooltip");
			}

			[HarmonyPostfix]
			private static void Postfix(ItemData __instance, ref string __result)
			{
				if (!((Object)(object)__instance?.m_dropPrefab == (Object)null) && !string.IsNullOrEmpty(__result))
				{
					string name = ((Object)__instance.m_dropPrefab).name;
					if ((name.StartsWith("JC_Ring_Warheim", StringComparison.Ordinal) || name.StartsWith("JC_Necklace_Warheim", StringComparison.Ordinal)) && !__result.Contains("Armure :"))
					{
						int num = Mathf.Max(1, __instance.m_quality);
						__result += $"\n<color=orange>Armure : {num}</color>";
					}
				}
			}
		}

		public const string PluginGUID = "dzk.warheimstuff";

		public const string PluginName = "WarheimStuff";

		public const string PluginVersion = "1.2.2";

		public static AssetBundle WarheimBundle;

		private static readonly PvpItemDef[] PvpItems = new PvpItemDef[14]
		{
			new PvpItemDef("assets/pvpitems/pvpswordohs1.prefab", 25f),
			new PvpItemDef("assets/pvpitems/pvpaxeohs1.prefab", 25f),
			new PvpItemDef("assets/pvpitems/pvpaxeths1.prefab", 35f),
			new PvpItemDef("assets/pvpitems/pvpswordths1.prefab", 35f),
			new PvpItemDef("assets/pvpitems/pvpatgeirs1.prefab", 35f),
			new PvpItemDef("assets/pvpitems/pvpbucklers1.prefab", 25f),
			new PvpItemDef("assets/pvpitems/pvptowers1.prefab", 35f),
			new PvpItemDef("assets/pvpitems/pvpspears1.prefab", 25f),
			new PvpItemDef("assets/pvpitems/pvpbows1.prefab", 20f),
			new PvpItemDef("assets/pvpitems/pvpdaggerss1.prefab", 15f),
			new PvpItemDef("assets/pvpitems/pvpmaceohs1.prefab", 25f),
			new PvpItemDef("assets/pvpitems/pvpsledgeths1.prefab", 40f),
			new PvpItemDef("assets/pvpitems/pvpcrossbows1.prefab", 20f),
			new PvpItemDef("assets/pvpitems/pvpstaffs1.prefab", 30f)
		};

		private readonly float[] _tierSmall = new float[5] { 2f, 4f, 6f, 8f, 10f };

		private readonly float[] _tierMedium = new float[5] { 1f, 2f, 3f, 4f, 5f };

		private readonly float[] _tierLarge = new float[5] { 5f, 10f, 15f, 20f, 25f };

		private void Awake()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			LoadAssets();
			InitializeWarheimGems();
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsReady;
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaItemsReady;
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailableForColliers;
			new Harmony("dzk.warheimstuff").PatchAll();
			WarheimRaids.Init(WarheimBundle, (MonoBehaviour)(object)this);
			((MonoBehaviour)this).StartCoroutine(RaidManager.WaitAndRegisterRoutedRpc());
			((MonoBehaviour)this).StartCoroutine(RaidConfigHotReloadLoop());
			InstallReaperSpearRotationPatch();
		}

		private static void InstallReaperSpearRotationPatch()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(VisEquipment), "AttachItem", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(ReaperSpearRotationPatch), "Postfix", (Type[])null, (Type[])null);
			new Harmony("warheimstuff.reaperspear.rotation").Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private void InitializeWarheimGems()
		{
			if (!API.IsLoaded())
			{
				return;
			}
			try
			{
				WarheimGems.Initialize();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[WarheimGems] Échec de l'initialisation : " + ex));
			}
		}

		private IEnumerator RaidConfigHotReloadLoop()
		{
			string path = RaidConfigLoader.ConfigPath;
			DateTime lastWrite = (File.Exists(path) ? File.GetLastWriteTimeUtc(path) : DateTime.MinValue);
			while (true)
			{
				yield return (object)new WaitForSeconds(2f);
				if (File.Exists(path))
				{
					DateTime currentWrite = File.GetLastWriteTimeUtc(path);
					if (!(currentWrite <= lastWrite))
					{
						lastWrite = currentWrite;
						yield return (object)new WaitForSeconds(0.25f);
						WarheimRaids.Config = RaidConfigLoader.LoadOrCreateDefault();
						Debug.Log((object)"[WarheimRaids] YAML rechargé à chaud.");
					}
				}
			}
		}

		private void OnVanillaPrefabsAvailableForColliers()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailableForColliers;
			((MonoBehaviour)this).StartCoroutine(AddColliersWhenReady());
		}

		private IEnumerator AddColliersWhenReady()
		{
			while ((Object)(object)ObjectDB.instance == (Object)null || (Object)(object)ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("GP_Moder")) == (Object)null)
			{
				yield return null;
			}
			AddColliers();
		}

		private void LoadAssets()
		{
			WarheimBundle = AssetUtils.LoadAssetBundleFromResources("customcoins");
		}

		private void OnVanillaPrefabsReady()
		{
			AddWarheimCoin();
			AddPvpItems();
			AddPdfItems();
			AddHelQuestItems();
		}

		private void OnVanillaItemsReady()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsReady;
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaItemsReady;
		}

		private static ZNetView GetNView(Component component)
		{
			return ((Object)(object)component != (Object)null) ? component.GetComponent<ZNetView>() : null;
		}

		private void AddHelQuestItems()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Expected O, but got Unknown
			GameObject val = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helskewer.prefab");
			ItemConfig val2 = new ItemConfig
			{
				CraftingStation = CraftingStations.Cauldron,
				MinStationLevel = 1,
				Amount = 1
			};
			val2.AddRequirement("HelMeat", 3, 0);
			val2.AddRequirement("HelBones", 1, 0);
			val2.AddRequirement("HelEye", 2, 0);
			CustomItem val3 = new CustomItem(val, true, val2);
			ItemManager.Instance.AddItem(val3);
			GameObject val4 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helsoup.prefab");
			ItemConfig val5 = new ItemConfig
			{
				CraftingStation = CraftingStations.Cauldron,
				MinStationLevel = 1,
				Amount = 1
			};
			val5.AddRequirement("HelBlood", 3, 0);
			val5.AddRequirement("HelMeat", 2, 0);
			val5.AddRequirement("HelHeart", 1, 0);
			CustomItem val6 = new CustomItem(val4, true, val5);
			ItemManager.Instance.AddItem(val6);
			GameObject val7 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helsausage.prefab");
			ItemConfig val8 = new ItemConfig
			{
				CraftingStation = CraftingStations.Cauldron,
				MinStationLevel = 1,
				Amount = 1
			};
			val8.AddRequirement("HelEntrails", 4, 0);
			val8.AddRequirement("HelMeat", 1, 0);
			val8.AddRequirement("HelHeart", 2, 0);
			CustomItem val9 = new CustomItem(val7, true, val8);
			ItemManager.Instance.AddItem(val9);
			GameObject val10 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helblood.prefab");
			CustomItem val11 = new CustomItem(val10, true);
			ItemManager.Instance.AddItem(val11);
			GameObject val12 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helbones.prefab");
			CustomItem val13 = new CustomItem(val12, true);
			ItemManager.Instance.AddItem(val13);
			GameObject val14 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helcrystal.prefab");
			CustomItem val15 = new CustomItem(val14, true);
			ItemManager.Instance.AddItem(val15);
			GameObject val16 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helcuir.prefab");
			CustomItem val17 = new CustomItem(val16, true);
			ItemManager.Instance.AddItem(val17);
			GameObject val18 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helentrails.prefab");
			CustomItem val19 = new CustomItem(val18, true);
			ItemManager.Instance.AddItem(val19);
			GameObject val20 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/heleye.prefab");
			CustomItem val21 = new CustomItem(val20, true);
			ItemManager.Instance.AddItem(val21);
			GameObject val22 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helfang.prefab");
			CustomItem val23 = new CustomItem(val22, true);
			ItemManager.Instance.AddItem(val23);
			GameObject val24 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helfil.prefab");
			CustomItem val25 = new CustomItem(val24, true);
			ItemManager.Instance.AddItem(val25);
			GameObject val26 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helheart.prefab");
			CustomItem val27 = new CustomItem(val26, true);
			ItemManager.Instance.AddItem(val27);
			GameObject val28 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helmeat.prefab");
			CustomItem val29 = new CustomItem(val28, true);
			ItemManager.Instance.AddItem(val29);
			GameObject val30 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helscale.prefab");
			CustomItem val31 = new CustomItem(val30, true);
			ItemManager.Instance.AddItem(val31);
			GameObject val32 = WarheimBundle.LoadAsset<GameObject>("assets/helquest/helskull.prefab");
			CustomItem val33 = new CustomItem(val32, true);
			ItemManager.Instance.AddItem(val33);
		}

		private void AddWarheimCoin()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			GameObject val = WarheimBundle.LoadAsset<GameObject>("assets/custombb/warheimcoin.prefab");
			CustomItem val2 = new CustomItem(val, true);
			ItemManager.Instance.AddItem(val2);
			GameObject val3 = WarheimBundle.LoadAsset<GameObject>("assets/custombb/goldbar.prefab");
			CustomItem val4 = new CustomItem(val3, true);
			ItemManager.Instance.AddItem(val4);
			GameObject val5 = WarheimBundle.LoadAsset<GameObject>("assets/custombb/emeraldbar.prefab");
			CustomItem val6 = new CustomItem(val5, true);
			ItemManager.Instance.AddItem(val6);
		}

		private void AddPdfItems()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			WarheimPdf.InitStatusEffects(WarheimBundle);
			GameObject val = WarheimBundle.LoadAsset<GameObject>("assets/pdf/pdfsimple.prefab");
			ItemConfig val2 = new ItemConfig();
			val2.AddRequirement("Stone", 10, 0);
			val2.AddRequirement("SurtlingCore", 1, 0);
			val2.CraftingStation = "piece_workbench";
			val2.RepairStation = "piece_workbench";
			CustomItem val3 = new CustomItem(val, false, val2);
			ItemManager.Instance.AddItem(val3);
			GameObject val4 = WarheimBundle.LoadAsset<GameObject>("assets/pdf/pdfwarheim.prefab");
			CustomItem val5 = new CustomItem(val4, true);
			ItemManager.Instance.AddItem(val5);
		}

		private void AddPvpItems()
		{
			PvpItemDef[] pvpItems = PvpItems;
			for (int i = 0; i < pvpItems.Length; i++)
			{
				PvpItemDef pvpItemDef = pvpItems[i];
				AddPvpItem(pvpItemDef.Path, pvpItemDef.Resilience);
			}
		}

		private void AddPvpItem(string path, float resilience)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			GameObject val = WarheimBundle.LoadAsset<GameObject>(path);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogWarning((object)("Missing prefab: " + path));
				return;
			}
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.LogWarning((object)("Prefab has no ItemDrop: " + path));
				return;
			}
			PvpResilienceAPI.SetResilience(component.m_itemData, resilience);
			CustomItem val2 = new CustomItem(val, false);
			ItemManager.Instance.AddItem(val2);
		}

		private void AddColliers()
		{
			//IL_000c: 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_0030: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Expected O, but got Unknown
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Expected O, but got Unknown
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Expected O, but got Unknown
			GameObject val = API.CreateNecklaceFromTemplate("Red", Color.red);
			API.MarkJewelry(val);
			((Object)val).name = "JC_Necklace_Warheim_Sailing";
			ItemConfig val2 = new ItemConfig();
			val2.Name = "Collier du Capitaine";
			val2.Description = "Ce collier vous permettra de toujours avoir le vent dans le dos.";
			Sprite icon1 = WarheimBundle.LoadAsset<Sprite>("colliersailing_icon.png");
			val2.Icon = icon1;
			val2.AddRequirement("WarheimCoin", 40, 20);
			val2.CraftingStation = "piece_workbench";
			val2.RepairStation = "piece_workbench";
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_armor = 1f;
			shared.m_armorPerLevel = 1f;
			StatusEffect val3 = WarheimBundle.LoadAsset<StatusEffect>("SE_SailingWarheim");
			CustomStatusEffect val4 = new CustomStatusEffect(val3, false);
			ItemManager.Instance.AddStatusEffect(val4);
			shared.m_equipStatusEffect = val4.StatusEffect;
			CustomItem val5 = new CustomItem(val, false, val2);
			ItemManager.Instance.AddItem(val5);
			ItemManager.OnItemsRegistered += delegate
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Sailing");
				ItemDrop val15 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val15 != (Object)null)
				{
					val15.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon1 };
				}
			};
			GameObject val6 = API.CreateNecklaceFromTemplate("Red", Color.red);
			API.MarkJewelry(val6);
			((Object)val6).name = "JC_Necklace_Warheim_DPS";
			ItemConfig val7 = new ItemConfig();
			val7.Name = "Collier du Carnage";
			val7.Description = "Ce collier augmente considérablement vos dégâts et votre régénération d'endurance.";
			Sprite icon2 = WarheimBundle.LoadAsset<Sprite>("collierdps_icon.png");
			val7.Icon = icon2;
			val7.AddRequirement("WarheimCoin", 40, 20);
			val7.CraftingStation = "piece_workbench";
			val7.RepairStation = "piece_workbench";
			SharedData shared2 = val6.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared2.m_icons = (Sprite[])(object)new Sprite[1] { icon2 };
			shared2.m_armor = 1f;
			shared2.m_armorPerLevel = 1f;
			SE_CollierWarheimDPS sE_CollierWarheimDPS = ScriptableObject.CreateInstance<SE_CollierWarheimDPS>();
			((Object)sE_CollierWarheimDPS).name = "SE_CollierWarheim_DPS";
			((StatusEffect)sE_CollierWarheimDPS).m_name = "Collier du Carnage";
			((StatusEffect)sE_CollierWarheimDPS).m_icon = icon2;
			((StatusEffect)sE_CollierWarheimDPS).m_tooltip = "+15% de dégâts totaux et +10% de régénération d'endurance.";
			sE_CollierWarheimDPS.SetDamageMultiplier(1.15f);
			sE_CollierWarheimDPS.SetStaminaRegenMultiplier(1.1f);
			shared2.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimDPS;
			CustomItem val8 = new CustomItem(val6, false, val7);
			ItemManager.Instance.AddItem(val8);
			ItemManager.OnItemsRegistered += delegate
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_DPS");
				ItemDrop val15 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val15 != (Object)null)
				{
					val15.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon2 };
				}
			};
			GameObject val9 = API.CreateNecklaceFromTemplate("Red", Color.red);
			API.MarkJewelry(val9);
			((Object)val9).name = "JC_Necklace_Warheim_Mage";
			ItemConfig val10 = new ItemConfig();
			val10.Name = "Collier du Mage";
			val10.Description = "Ce collier augmente vos capacités magiques.";
			Sprite icon3 = WarheimBundle.LoadAsset<Sprite>("colliermage_icon.png");
			val10.Icon = icon3;
			val10.AddRequirement("WarheimCoin", 40, 20);
			val10.CraftingStation = "piece_workbench";
			val10.RepairStation = "piece_workbench";
			SharedData shared3 = val9.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared3.m_icons = (Sprite[])(object)new Sprite[1] { icon3 };
			shared3.m_armor = 1f;
			shared3.m_armorPerLevel = 1f;
			SE_CollierWarheimMage sE_CollierWarheimMage = ScriptableObject.CreateInstance<SE_CollierWarheimMage>();
			((Object)sE_CollierWarheimMage).name = "SE_CollierWarheim_Mage";
			((StatusEffect)sE_CollierWarheimMage).m_name = "Collier du Mage";
			((StatusEffect)sE_CollierWarheimMage).m_icon = icon3;
			((StatusEffect)sE_CollierWarheimMage).m_tooltip = "+10% aux skills de magie, +30% de regen d'eitr, +50 d'eitr max.";
			sE_CollierWarheimMage.SetEitr(50f);
			sE_CollierWarheimMage.SetSkill(11f);
			sE_CollierWarheimMage.SetRegenModifier(1.3f);
			shared3.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimMage;
			CustomItem val11 = new CustomItem(val9, false, val10);
			ItemManager.Instance.AddItem(val11);
			ItemManager.OnItemsRegistered += delegate
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Mage");
				ItemDrop val15 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val15 != (Object)null)
				{
					val15.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon3 };
				}
			};
			GameObject val12 = API.CreateNecklaceFromTemplate("Red", Color.red);
			API.MarkJewelry(val12);
			((Object)val12).name = "JC_Necklace_Warheim_Tank";
			ItemConfig val13 = new ItemConfig();
			val13.Name = "Collier du Gardien";
			val13.Description = "Ce collier augmente vos capacités défensives.";
			Sprite icon4 = WarheimBundle.LoadAsset<Sprite>("colliertank_icon.png");
			val13.Icon = icon4;
			val13.AddRequirement("WarheimCoin", 40, 20);
			val13.CraftingStation = "piece_workbench";
			val13.RepairStation = "piece_workbench";
			SharedData shared4 = val12.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared4.m_icons = (Sprite[])(object)new Sprite[1] { icon4 };
			shared4.m_armor = 1f;
			shared4.m_armorPerLevel = 1f;
			SE_CollierWarheimTank sE_CollierWarheimTank = ScriptableObject.CreateInstance<SE_CollierWarheimTank>();
			((Object)sE_CollierWarheimTank).name = "SE_CollierWarheim_Tank";
			((StatusEffect)sE_CollierWarheimTank).m_name = "Collier du Gardien";
			((StatusEffect)sE_CollierWarheimTank).m_icon = icon4;
			((StatusEffect)sE_CollierWarheimTank).m_tooltip = "+10% de vie totale finale et +15% de régénération de vie.";
			sE_CollierWarheimTank.SetHealthPercentBonus(0.1f);
			sE_CollierWarheimTank.SetHealthRegenMultiplier(1.15f);
			shared4.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimTank;
			CustomItem val14 = new CustomItem(val12, false, val13);
			ItemManager.Instance.AddItem(val14);
			ItemManager.OnItemsRegistered += delegate
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Tank");
				ItemDrop val15 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val15 != (Object)null)
				{
					val15.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon4 };
				}
			};
			AddGladiatorJewelry();
			AddBerserkerNecklace();
			AddElementalistRing();
			AddRings();
			AddMinerRings();
			AddLumberjackRings();
			AddLeviathanRings();
			ItemManager.OnItemsRegistered += ApplyAllWarheimJewelryArmor;
		}

		private void AddBerserkerNecklace()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			GameObject val = API.CreateNecklaceFromTemplate("Red", Color.red);
			API.MarkJewelry(val);
			((Object)val).name = "JC_Necklace_Warheim_Berserker";
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			Sprite icon = WarheimBundle.LoadAsset<Sprite>("collierberserker_icon.png");
			if ((Object)(object)icon == (Object)null && shared.m_icons != null && shared.m_icons.Length != 0)
			{
				icon = shared.m_icons[0];
			}
			ItemConfig val2 = new ItemConfig
			{
				Name = "Collier du Forcené",
				Description = "Co collier est fait pour les vikings un peu barjos...",
				Icon = icon,
				CraftingStation = "piece_workbench",
				RepairStation = "piece_workbench"
			};
			val2.AddRequirement("WarheimCoin", 40, 20);
			shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
			shared.m_armor = 1f;
			shared.m_armorPerLevel = 1f;
			SE_CollierWarheimBerserker sE_CollierWarheimBerserker = ScriptableObject.CreateInstance<SE_CollierWarheimBerserker>();
			((Object)sE_CollierWarheimBerserker).name = "SE_CollierWarheim_Berserker";
			((StatusEffect)sE_CollierWarheimBerserker).m_name = "Collier du Forcené";
			((StatusEffect)sE_CollierWarheimBerserker).m_icon = icon;
			((StatusEffect)sE_CollierWarheimBerserker).m_tooltip = "+50% de dégâts infligés, -50% de coût d'endurance des attaques, +25% de dégâts subis et -10% de vitesse de déplacement.";
			sE_CollierWarheimBerserker.SetBonuses(1.5f, 0.5f, 1.25f, 0.9f);
			shared.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimBerserker;
			CustomItem val3 = new CustomItem(val, false, val2);
			ItemManager.Instance.AddItem(val3);
			ItemManager.OnItemsRegistered += delegate
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Berserker");
				ItemDrop val4 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val4 != (Object)null)
				{
					val4.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
				}
			};
		}

		private void AddElementalistRing()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			GameObject val = API.CreateRingFromTemplate("Red", Color.red);
			API.MarkJewelry(val);
			((Object)val).name = "JC_Ring_Warheim_ELEMENTALIST";
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			Sprite icon = WarheimBundle.LoadAsset<Sprite>("ring_elementalist.png");
			if ((Object)(object)icon == (Object)null && shared.m_icons != null && shared.m_icons.Length != 0)
			{
				icon = shared.m_icons[0];
			}
			ItemConfig val2 = new ItemConfig
			{
				Name = "Anneau de l'Élémentaliste",
				Description = "Votre maitrise des élèments est telle que maintenant, vous subirez moins les assauts des monstres costauds en magie.",
				Icon = icon,
				CraftingStation = "piece_workbench",
				RepairStation = "piece_workbench"
			};
			val2.AddRequirement("WarheimCoin", 40, 20);
			shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
			shared.m_armor = 1f;
			shared.m_armorPerLevel = 1f;
			shared.m_damageModifiers = CreateElementalistDamageModifiers();
			SE_WarheimRingElementalist sE_WarheimRingElementalist = Scripta