Decompiled source of WarheimStuff v1.0.6

WarheimStuff.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 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.UI;

[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}");
		}
	}
}
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, 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)
	{
		string text = (((Object)(object)item?.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : "");
		Logger.LogInfo((object)("PDF DEBUG PREFAB = " + text));
		return text;
	}

	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, ItemData item)
	{
		if ((Object)(object)player == (Object)null || item == null || !IsPdf(item))
		{
			return false;
		}
		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, item));
		return true;
	}

	private static IEnumerator CastAndTeleport(Player player, 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))
		{
			((Humanoid)player).GetInventory().RemoveItem(item, 1);
		}
		((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_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Expected O, but got Unknown
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Expected O, but got Unknown
		string[] allAssetNames = bundle.GetAllAssetNames();
		foreach (string text in allAssetNames)
		{
			if (text.Contains("pdf"))
			{
				Logger.LogInfo((object)("PDF ASSET = " + text));
			}
		}
		_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.0.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class WarheimStuff : BaseUnityPlugin
{
	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
	}

	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_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_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 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 (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.0.6";

	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_0043: Unknown result type (might be due to invalid IL or missing references)
		LoadAssets();
		PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsReady;
		PrefabManager.OnVanillaPrefabsAvailable += OnVanillaItemsReady;
		PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailableForColliers;
		new Harmony("dzk.warheimstuff").PatchAll();
	}

	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();
	}

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

	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
		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);
	}

	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();
		AddRings();
		ItemManager.OnItemsRegistered += ApplyAllWarheimJewelryArmor;
	}

	private static void ApplyAllWarheimJewelryArmor()
	{
		if ((Object)(object)ObjectDB.instance == (Object)null)
		{
			return;
		}
		foreach (GameObject item in ObjectDB.instance.m_items)
		{
			if (!((Object)(object)item == (Object)null))
			{
				string name = ((Object)item).name;
				if (name.StartsWith("JC_Ring_Warheim") || name.StartsWith("JC_Necklace_Warheim"))
				{
					ItemDrop component = item.GetComponent<ItemDrop>();
					ApplyJewelryArmor(component);
				}
			}
		}
	}

	private static void ApplyJewelryArmor(ItemDrop item)
	{
		if (item?.m_itemData?.m_shared != null)
		{
			item.m_itemData.m_shared.m_armor = 1f;
			item.m_itemData.m_shared.m_armorPerLevel = 1f;
		}
	}

	private void AddGladiatorJewelry()
	{
		//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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Expected O, but got Unknown
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Expected O, but got Unknown
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Expected O, but got Unknown
		GameObject val = API.CreateRingFromTemplate("Red", Color.red);
		API.MarkJewelry(val);
		((Object)val).name = "JC_Ring_Warheim_Pvp_S1";
		ItemConfig val2 = new ItemConfig();
		val2.Name = "Anneau du Gladiateur Saison 1";
		val2.Description = "Cet anneau fut porté par les Vikings les plus brutaux de Warheim.";
		Sprite ringIcon = WarheimBundle.LoadAsset<Sprite>("assets/pvpitems/icons/rings1icon.png");
		val2.Icon = ringIcon;
		SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
		shared.m_icons = (Sprite[])(object)new Sprite[1] { ringIcon };
		shared.m_armor = 1f;
		shared.m_armorPerLevel = 1f;
		PvpResilienceAPI.SetResilience(val.GetComponent<ItemDrop>().m_itemData, 25f);
		SE_WarheimRingGladiator sE_WarheimRingGladiator = ScriptableObject.CreateInstance<SE_WarheimRingGladiator>();
		((Object)sE_WarheimRingGladiator).name = "SE_WarheimRing_Gladiator_S1";
		((StatusEffect)sE_WarheimRingGladiator).m_name = "Anneau du Gladiateur Saison 1";
		((StatusEffect)sE_WarheimRingGladiator).m_icon = ringIcon;
		((StatusEffect)sE_WarheimRingGladiator).m_tooltip = "Cet anneau vous octroye 25 de résilience ainsi que 15% de régénération de vie, endurance & eitr.";
		sE_WarheimRingGladiator.SetRegenMultiplier(1.15f);
		shared.m_equipStatusEffect = (StatusEffect)(object)sE_WarheimRingGladiator;
		CustomItem val3 = new CustomItem(val, false, val2);
		ItemManager.Instance.AddItem(val3);
		ItemManager.OnItemsRegistered += delegate
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Ring_Warheim_Pvp_S1");
			ItemDrop val7 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val7 != (Object)null)
			{
				val7.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { ringIcon };
				val7.m_itemData.m_shared.m_armor = 1f;
				val7.m_itemData.m_shared.m_armorPerLevel = 1f;
			}
		};
		GameObject val4 = API.CreateNecklaceFromTemplate("Red", Color.red);
		API.MarkJewelry(val4);
		((Object)val4).name = "JC_Necklace_Warheim_Pvp_S1";
		ItemConfig val5 = new ItemConfig();
		val5.Name = "Collier du Gladiateur Saison 1";
		val5.Description = "Ce collier, si vous le voulez autour du cou d'un Viking, ne signifie qu'une chose : Courez. Vite, et loin.";
		Sprite neckIcon = WarheimBundle.LoadAsset<Sprite>("assets/pvpitems/icons/necks1icon.png");
		val5.Icon = neckIcon;
		SharedData shared2 = val4.GetComponent<ItemDrop>().m_itemData.m_shared;
		shared2.m_icons = (Sprite[])(object)new Sprite[1] { neckIcon };
		shared2.m_armor = 1f;
		shared2.m_armorPerLevel = 1f;
		PvpResilienceAPI.SetResilience(val4.GetComponent<ItemDrop>().m_itemData, 35f);
		SE_CollierWarheimGladiator sE_CollierWarheimGladiator = ScriptableObject.CreateInstance<SE_CollierWarheimGladiator>();
		((Object)sE_CollierWarheimGladiator).name = "SE_CollierWarheim_Gladiator_S1";
		((StatusEffect)sE_CollierWarheimGladiator).m_name = "Collier du Gladiateur Saison 1";
		((StatusEffect)sE_CollierWarheimGladiator).m_icon = neckIcon;
		((StatusEffect)sE_CollierWarheimGladiator).m_tooltip = "Ce collier augmente votre résilience de 35 ainsi que vos attributs de vie, endurance & eitr de 50.";
		sE_CollierWarheimGladiator.SetBonuses(50f, 50f, 50f);
		shared2.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimGladiator;
		CustomItem val6 = new CustomItem(val4, false, val5);
		ItemManager.Instance.AddItem(val6);
		ItemManager.OnItemsRegistered += delegate
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Pvp_S1");
			ItemDrop val7 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val7 != (Object)null)
			{
				val7.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { neckIcon };
				val7.m_itemData.m_shared.m_armor = 1f;
				val7.m_itemData.m_shared.m_armorPerLevel = 1f;
			}
		};
	}

	private void AddRings()
	{
		AddRingSeries(WarheimRingType.DPS);
		AddRingSeries(WarheimRingType.Tank);
		AddRingSeries(WarheimRingType.Archer);
		AddRingSeries(WarheimRingType.Mage);
	}

	private void AddRingSeries(WarheimRingType type)
	{
		for (int i = 1; i <= 5; i++)
		{
			AddSingleRing(type, i);
		}
	}

	private void AddSingleRing(WarheimRingType type, int tier)
	{
		//IL_0013: 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)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Expected O, but got Unknown
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		GameObject val = API.CreateRingFromTemplate("Red", Color.red);
		API.MarkJewelry(val);
		string typeName = type.ToString().ToUpperInvariant();
		string name = $"JC_Ring_Warheim_{typeName}_T{tier}";
		((Object)val).name = name;
		string ringDisplayName = GetRingDisplayName(type, tier);
		string ringDescription = GetRingDescription(type, tier);
		Sprite icon = GetRingIcon(type, tier);
		ItemConfig val2 = new ItemConfig
		{
			Name = ringDisplayName,
			Description = ringDescription,
			Icon = icon,
			CraftingStation = "piece_workbench",
			RepairStation = "piece_workbench"
		};
		int ringCost = GetRingCost(tier);
		val2.AddRequirement("WarheimCoin", ringCost, ringCost + 5);
		if (tier > 1)
		{
			string text = $"JC_Ring_Warheim_{typeName}_T{tier - 1}";
			val2.AddRequirement(text, 1, 0);
		}
		SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
		shared.m_armor = 1f;
		shared.m_armorPerLevel = 1f;
		shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
		StatusEffect equipStatusEffect = CreateRingStatusEffect(type, tier, icon);
		shared.m_equipStatusEffect = equipStatusEffect;
		CustomItem val3 = new CustomItem(val, false, val2);
		ItemManager.Instance.AddItem(val3);
		ItemManager.OnItemsRegistered += delegate
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab($"JC_Ring_Warheim_{typeName}_T{tier}");
			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 string GetRingDisplayName(WarheimRingType type, int tier)
	{
		if (1 == 0)
		{
		}
		string result = type switch
		{
			WarheimRingType.DPS => $"Anneau du Carnage T{tier}", 
			WarheimRingType.Tank => $"Anneau du Gardien T{tier}", 
			WarheimRingType.Archer => $"Anneau du Traqueur T{tier}", 
			WarheimRingType.Mage => $"Anneau de l'Arcaniste T{tier}", 
			_ => $"Anneau Warheim T{tier}", 
		};
		if (1 == 0)
		{
		}
		return result;
	}

	private string GetRingDescription(WarheimRingType type, int tier)
	{
		int num = tier - 1;
		if (1 == 0)
		{
		}
		string result = type switch
		{
			WarheimRingType.DPS => "Cet anneau augmente vos capacités offensives en général.", 
			WarheimRingType.Tank => "Cet anneau augmente vos capacités défensives.", 
			WarheimRingType.Archer => "Cet anneau augmente vos capacités d'archer.", 
			WarheimRingType.Mage => "Cet anneau augmente vos capacités de mage.", 
			_ => "Anneau Warheim.", 
		};
		if (1 == 0)
		{
		}
		return result;
	}

	private int GetRingCost(int tier)
	{
		if (1 == 0)
		{
		}
		int result = tier switch
		{
			1 => 5, 
			2 => 10, 
			3 => 15, 
			4 => 20, 
			5 => 25, 
			_ => 10, 
		};
		if (1 == 0)
		{
		}
		return result;
	}

	private Sprite GetRingIcon(WarheimRingType type, int tier)
	{
		string arg = type.ToString().ToLowerInvariant();
		return WarheimBundle.LoadAsset<Sprite>($"ring_{arg}_t{tier}.png");
	}

	private StatusEffect CreateRingStatusEffect(WarheimRingType type, int tier, Sprite icon)
	{
		int num = tier - 1;
		switch (type)
		{
		case WarheimRingType.DPS:
		{
			SE_WarheimRingDPS sE_WarheimRingDPS = ScriptableObject.CreateInstance<SE_WarheimRingDPS>();
			((Object)sE_WarheimRingDPS).name = $"SE_WarheimRing_DPS_T{tier}";
			((StatusEffect)sE_WarheimRingDPS).m_name = $"Anneau du Carnage T{tier}";
			((StatusEffect)sE_WarheimRingDPS).m_icon = icon;
			((StatusEffect)sE_WarheimRingDPS).m_tooltip = $"+{_tierSmall[num]}% regen stamina, +{_tierMedium[num]}% dégâts totaux.";
			sE_WarheimRingDPS.SetStaminaRegenMultiplier(1f + _tierSmall[num] / 100f);
			sE_WarheimRingDPS.SetDamageMultiplier(1f + _tierMedium[num] / 100f);
			return (StatusEffect)(object)sE_WarheimRingDPS;
		}
		case WarheimRingType.Tank:
		{
			SE_WarheimRingTank sE_WarheimRingTank = ScriptableObject.CreateInstance<SE_WarheimRingTank>();
			((Object)sE_WarheimRingTank).name = $"SE_WarheimRing_Tank_T{tier}";
			((StatusEffect)sE_WarheimRingTank).m_name = $"Anneau du Gardien T{tier}";
			((StatusEffect)sE_WarheimRingTank).m_icon = icon;
			((StatusEffect)sE_WarheimRingTank).m_tooltip = $"+{_tierSmall[num]}% vie totale, +{_tierLarge[num]}% regen vie.";
			sE_WarheimRingTank.SetHealthPercentBonus(_tierSmall[num] / 100f);
			sE_WarheimRingTank.SetHealthRegenMultiplier(1f + _tierLarge[num] / 100f);
			return (StatusEffect)(object)sE_WarheimRingTank;
		}
		case WarheimRingType.Archer:
		{
			SE_WarheimRingArcher sE_WarheimRingArcher = ScriptableObject.CreateInstance<SE_WarheimRingArcher>();
			((Object)sE_WarheimRingArcher).name = $"SE_WarheimRing_Archer_T{tier}";
			((StatusEffect)sE_WarheimRingArcher).m_name = $"Anneau du Traqueur T{tier}";
			((StatusEffect)sE_WarheimRingArcher).m_icon = icon;
			((StatusEffect)sE_WarheimRingArcher).m_tooltip = $"+{_tierSmall[num]}% stamina totale, +{_tierMedium[num]}% vitesse de déplacement.";
			sE_WarheimRingArcher.SetStaminaPercentBonus(_tierSmall[num] / 100f);
			sE_WarheimRingArcher.SetMoveSpeedMultiplier(1f + _tierMedium[num] / 100f);
			return (StatusEffect)(object)sE_WarheimRingArcher;
		}
		case WarheimRingType.Mage:
		{
			SE_WarheimRingMage sE_WarheimRingMage = ScriptableObject.CreateInstance<SE_WarheimRingMage>();
			((Object)sE_WarheimRingMage).name = $"SE_WarheimRing_Mage_T{tier}";
			((StatusEffect)sE_WarheimRingMage).m_name = $"Anneau de l'Arcaniste T{tier}";
			((StatusEffect)sE_WarheimRingMage).m_icon = icon;
			((StatusEffect)sE_WarheimRingMage).m_tooltip = $"+{_tierSmall[num]}% eitr total, +{_tierLarge[num]}% regen d'eitr.";
			sE_WarheimRingMage.SetEitrPercentBonus(_tierSmall[num] / 100f);
			sE_WarheimRingMage.SetEitrRegenMultiplier(1f + _tierLarge[num] / 100f);
			return (StatusEffect)(object)sE_WarheimRingMage;
		}
		default:
			return null;
		}
	}
}
internal static class WeightPanelFix
{
	[HarmonyPatch]
	private static class InventoryGui_Awake_Patch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(InventoryGui), "Awake", (Type[])null, (Type[])null);
		}

		private static void Postfix(InventoryGui __instance)
		{
			if (!((Object)(object)__instance?.m_weight == (Object)null) && (Object)(object)((Component)__instance.m_weight).GetComponent<WarheimWeightPanelOffset>() == (Object)null)
			{
				((Component)__instance.m_weight).gameObject.AddComponent<WarheimWeightPanelOffset>();
			}
		}
	}

	private sealed class WarheimWeightPanelOffset : MonoBehaviour
	{
		private TMP_Text _text;

		private void Awake()
		{
			_text = ((Component)this).GetComponent<TMP_Text>();
		}

		private void OnEnable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Canvas.willRenderCanvases += new WillRenderCanvases(Apply);
		}

		private void OnDisable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Canvas.willRenderCanvases -= new WillRenderCanvases(Apply);
		}

		private void OnDestroy()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Canvas.willRenderCanvases -= new WillRenderCanvases(Apply);
		}

		private void Apply()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_text == (Object)null)
			{
				return;
			}
			Transform parent = _text.transform.parent;
			if (!((Object)(object)parent == (Object)null))
			{
				RectTransform component = ((Component)parent).GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null))
				{
					component.anchoredPosition = new Vector2(40f, component.anchoredPosition.y);
				}
			}
		}
	}

	private const float WeightPanelX = 40f;
}