Decompiled source of MagicPlugin v2.1.8

MagicPlugin.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.8")]
[assembly: AssemblyInformationalVersion("2.1.8")]
[assembly: AssemblyProduct("MagicPlugin")]
[assembly: AssemblyTitle("MagicPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MagicPlugin
{
	[BepInPlugin("blacks7ar.MagicPlugin", "MagicPlugin", "2.1.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "blacks7ar.MagicPlugin";

		public const string modName = "MagicPlugin";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "2.1.8";

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

		private static readonly Harmony _harmony = new Harmony("blacks7ar.MagicPlugin");

		private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.MagicPlugin")
		{
			DisplayName = "MagicPlugin",
			CurrentVersion = "2.1.8",
			MinimumRequiredVersion = "2.1.8",
			ModRequired = true
		};

		private static ConfigEntry<MagicPlugin.Functions.Toggle> _serverConfigLocked;

		public static ConfigEntry<float> _magicVelocity;

		public static ConfigEntry<float> _magciAccuracy;

		public static ConfigEntry<MagicPlugin.Functions.Toggle> _enableExpMultiplier;

		public static ConfigEntry<MagicPlugin.Functions.Toggle> _displayExpGained;

		public static ConfigEntry<float> _bmExpMultiplier;

		public static ConfigEntry<float> _emExpMultiplier;

		public static ConfigEntry<MagicPlugin.Functions.Toggle> _enableTomeSlot;

		public static ConfigEntry<MagicPlugin.Functions.Toggle> _enableEarringSlot;

		public static ConfigEntry<MagicPlugin.Functions.Toggle> _enableSlowFall;

		public static ConfigEntry<KeyboardShortcut> _unSummonKey;

		public static Plugin _Instance;

		public static bool _autoRun;

		public static Localization english;

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

		public void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Expected O, but got Unknown
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			_Instance = this;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			Localizer.Load();
			english = new Localization();
			english.SetupLanguage("English");
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", MagicPlugin.Functions.Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<MagicPlugin.Functions.Toggle>(_serverConfigLocked);
			_magicVelocity = config("2- General", "Velocity Multiplier", 2f, new ConfigDescription("Magic projectiles velocity multiplier.\nRecommended: 2", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			_magciAccuracy = config("2- General", "Accuracy Multiplier", 0f, new ConfigDescription("Magic projectiles accuracy multiplier.\nRecommended: 0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1]
			{
				new MagicPlugin.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_enableTomeSlot = config("2- General", "Enable Tome Slot", MagicPlugin.Functions.Toggle.On, new ConfigDescription("If On, tomes or books has a dedicated slot when using Azu ExtendPlayerInventory mod.", (AcceptableValueBase)null, Array.Empty<object>()));
			_enableTomeSlot.SettingChanged += delegate
			{
				MagicSlot.AddCustomSlot(_enableTomeSlot);
			};
			MagicSlot.AddCustomSlot(_enableTomeSlot);
			_enableEarringSlot = config("2- General", "Enable Earring Slot", MagicPlugin.Functions.Toggle.On, new ConfigDescription("If On, earrings has a dedicated slot when using Azu ExtendedPlayerInventory mod.", (AcceptableValueBase)null, Array.Empty<object>()));
			_enableEarringSlot.SettingChanged += delegate
			{
				MagicSlot.AddCustomSlot(_enableEarringSlot);
			};
			MagicSlot.AddCustomSlot(_enableEarringSlot);
			_enableSlowFall = config("2- General", "Enable Slow Fall", MagicPlugin.Functions.Toggle.On, new ConfigDescription("If Off, disables slow fall effect on capes.", (AcceptableValueBase)null, Array.Empty<object>()));
			_unSummonKey = config<KeyboardShortcut>("2- General", "Unsummon Key", new KeyboardShortcut((KeyCode)102, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), new ConfigDescription("Hotkey combination to unsummon summons.", (AcceptableValueBase)null, Array.Empty<object>()), _synchronizedConfig: false);
			_enableExpMultiplier = config("4- Skill Exp", "Enable Exp Multiplier", MagicPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables exp multiplier.", (AcceptableValueBase)null, Array.Empty<object>()));
			_displayExpGained = config("4- Skill Exp", "Display Exp Gained", MagicPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables exp gain notifications", (AcceptableValueBase)null, Array.Empty<object>()));
			_bmExpMultiplier = config("4- Skill Exp", "BloodMagic Exp Multiplier", 1f, new ConfigDescription("Exp multiplier for BloodMagic skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			_emExpMultiplier = config("4- Skill Exp", "ElementalMagic Exp Multiplier", 1f, new ConfigDescription("Exp multiplier for ElementalMagic skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			SummonHelper.CloneContainerInit();
			ConfigSetup.Init();
			PrefabsSetup.Init();
			RingsAndNecklaces.Init();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
		}

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

		private void Update()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			Player player = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)player))
			{
				return;
			}
			foreach (Tameable item in Enumerable.Select(Enumerable.Where(Enumerable.Where(Character.GetAllCharacters(), (Character summon) => ((Object)((Component)summon).gameObject).name.StartsWith("BMP_") && summon.m_nview.IsValid() && summon.m_nview.IsOwner()), (Func<Character, bool>)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				KeyboardShortcut value = _unSummonKey.Value;
				return ((KeyboardShortcut)(ref value)).IsDown() && ((Character)player).TakeInput();
			}), (Character summon) => ((Component)summon).GetComponent<Tameable>()))
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					item.UnSummon();
				}
			}
			IDoodadController doodadController = player.GetDoodadController();
			Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
			if (val == null || !Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Humanoid val2 = (Humanoid)val.GetCharacter();
			if (((Character)val2).m_name.Contains("asksvin_summon"))
			{
				((MonoBehaviour)((Character)val2).m_baseAI).StopAllCoroutines();
				float num = Mathf.Lerp(1f, 0.5f, val.GetRiderSkill());
				if ((ZInput.GetButton("Attack") || ZInput.GetButton("JoyAttack")) && !((Character)val2).InAttack() && ((Character)player).TakeInput() && val.GetStamina() > 8f)
				{
					val2.m_rightItem = val2.m_defaultItems[0].GetComponent<ItemDrop>().m_itemData;
					((Character)val2).StartAttack((Character)null, false);
					val.UseStamina(8f * num);
					_autoRun = false;
				}
				if ((ZInput.GetButton("SecondaryAttack") || ZInput.GetButton("JoySecondaryAttack")) && !((Character)val2).InAttack() && ((Character)player).TakeInput() && val.GetStamina() > 16f)
				{
					val2.m_rightItem = val2.m_defaultItems[1].GetComponent<ItemDrop>().m_itemData;
					((Character)val2).StartAttack((Character)null, false);
					val.UseStamina(16f * num);
					_autoRun = false;
				}
				if ((ZInput.GetButton("Block") || ZInput.GetButton("JoyBlock")) && !((Character)val2).InAttack() && ((Character)player).TakeInput() && val.GetStamina() > 20f)
				{
					val2.m_rightItem = val2.m_defaultItems[2].GetComponent<ItemDrop>().m_itemData;
					((Character)val2).StartAttack((Character)null, false);
					val.UseStamina(20f * num);
					_autoRun = false;
				}
				if (ZInput.GetButton("Forward") || ZInput.GetButton("Backward"))
				{
					_autoRun = false;
				}
			}
		}
	}
}
namespace MagicPlugin.SE
{
	public class AddEitr : StatusEffect
	{
		public float m_eitr;

		public void Awake()
		{
			base.m_tooltip = $"Boost wearer's <color=orange>Eitr</color> by <color=orange>+{m_eitr}</color>.";
		}

		public void SetEitr(float eitr)
		{
			m_eitr = eitr;
			base.m_tooltip = $"Boost wearer's <color=orange>Eitr</color> by <color=orange>+{m_eitr}</color>.";
		}
	}
	public class ArcticBuff : StatusEffect
	{
		private float m_eitrRegen;

		public void Awake()
		{
			base.m_name = "Arctic Buff";
			((Object)this).name = base.m_name;
			base.m_tooltip = $"The Polarwolf armor set gives enough protection against cold and freezing. It is imbued with magic so its wearer will replenish eitr faster.\n\nEitr regen increased by <color=orange>+{Mathf.FloorToInt(m_eitrRegen)}%\nResistant</color> VS <color=orange>Cold</color> and <color=orange>Freezing</color>";
		}

		public void SetEitrRegen(float bonus)
		{
			m_eitrRegen = bonus;
			base.m_tooltip = $"The Polarwolf armor set gives enough protection against cold and freezing. It is imbued with magic so its wearer will replenish eitr faster.\n\nEitr regen increased by <color=orange>+{Mathf.FloorToInt(m_eitrRegen)}%\nResistant</color> VS <color=orange>Cold</color> and <color=orange>Freezing</color>";
		}

		public override void ModifyEitrRegen(ref float eitrRegen)
		{
			eitrRegen += m_eitrRegen / 100f;
		}
	}
	public class Elementalist : StatusEffect
	{
		public float m_elementalMagic;

		public void Awake()
		{
			((Object)this).name = "bmp_elementalist";
			base.m_name = "Elementalist Belt";
			base.m_tooltip = "Boost Elemental Magics skill level." + $"\n<color=orange>ElementalMagic: +{m_elementalMagic}</color>";
		}

		public void SetElementalMagic(float value)
		{
			m_elementalMagic = value;
			base.m_tooltip = "Boost Elemental Magics skill level." + $"\n<color=orange>ElementalMagic: +{m_elementalMagic}</color>";
		}
	}
	public class ForestMagic : StatusEffect
	{
		private float m_eitrRegen;

		public void Awake()
		{
			base.m_name = "Forest Magic";
			((Object)this).name = base.m_name;
			base.m_tooltip = $"This pair of armor doesn't give enough armor defense to its wearer but will be beneficial to a newborn Mage.\n\nEitr regen increased by <color=orange>+{Mathf.FloorToInt(m_eitrRegen)}%</color>";
		}

		public void SetEitrRegen(float bonus)
		{
			m_eitrRegen = bonus;
			base.m_tooltip = $"This pair of armor doesn't give enough armor defense to its wearer but will be beneficial to a newborn Mage.\n\nEitr regen increased by <color=orange>+{Mathf.FloorToInt(m_eitrRegen)}%</color>";
		}

		public override void ModifyEitrRegen(ref float eitrRegen)
		{
			eitrRegen += m_eitrRegen / 100f;
		}
	}
	public class HealGroup : StatusEffect
	{
		public float m_healthOverTime;

		public float m_healthOverTimeInterval;

		public float m_healthOverTimeDuration;

		public float m_healthOverTimeTimer;

		public float m_healthOverTimeTicks;

		public float m_healthOverTimeTickHP;

		public SkillType m_levelUpSkill;

		public float m_levelUpSkillFactor = 0.2f;

		public void Awake()
		{
			base.m_name = "Staff Of Healing";
			((Object)this).name = "healstaff_cooldown";
			base.m_tooltip = "Heals everyone over time." + $"\n<color=orange>HealOverTime: {Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\n<color=orange>Duration: {m_healthOverTimeDuration}secs</color>";
			base.m_icon = PrefabsSetup._magicBundle.LoadAsset<Sprite>("bmr_heart_icon");
		}

		public void SetHealthOverTimeInterval(float value)
		{
			m_healthOverTimeInterval = value;
			base.m_tooltip = "Heals everyone over time." + $"\n<color=orange>HealOverTime: {Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\n<color=orange>Duration: {m_healthOverTimeDuration}secs</color>";
		}

		public void SetHealthOverTime(float value)
		{
			m_healthOverTime = value;
			base.m_tooltip = "Heals everyone over time." + $"\n<color=orange>HealOverTime: {Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\n<color=orange>Duration: {m_healthOverTimeDuration}secs</color>";
		}

		public void SetHealthOverTimeDuration(float value)
		{
			m_healthOverTimeDuration = value;
			base.m_tooltip = "Heals everyone over time." + $"\n<color=orange>HealOverTime: {Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\n<color=orange>Duration: {m_healthOverTimeDuration}secs</color>";
		}

		public override void Setup(Character character)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).Setup(character);
			if (m_healthOverTime > 0f && m_healthOverTimeInterval > 0f)
			{
				if (m_healthOverTimeDuration <= 0f)
				{
					m_healthOverTimeDuration = base.m_ttl;
				}
				m_healthOverTimeTicks = m_healthOverTimeDuration / m_healthOverTimeInterval;
				m_healthOverTimeTickHP = m_healthOverTime / m_healthOverTimeTicks;
				m_levelUpSkill = (SkillType)10;
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (m_healthOverTimeTicks > 0f)
			{
				m_healthOverTimeTimer += dt;
				if (m_healthOverTimeTimer > m_healthOverTimeInterval)
				{
					m_healthOverTimeTimer = 0f;
					m_healthOverTimeTicks -= 1f;
					base.m_character.Heal(m_healthOverTimeTickHP, true);
				}
			}
		}
	}
	public class Hogwarts : StatusEffect
	{
		public float m_damageMultiplier;

		public void Awake()
		{
			((Object)this).name = "bmp_hogwarts";
			base.m_name = "Hogwarts Belt";
			base.m_tooltip = "Boost wearer's elemental damages." + $"\n<color=orange>Damage Multiplier: {m_damageMultiplier}x</color>";
		}

		public void SetDamageMultiplier(float value)
		{
			m_damageMultiplier = value;
			base.m_tooltip = "Boost wearer's elemental damages." + $"\n<color=orange>Damage Multiplier: {m_damageMultiplier}x</color>";
		}
	}
	public class Necromancer : StatusEffect
	{
		public float m_bloodMagic;

		public void Awake()
		{
			((Object)this).name = "bmp_necromancer";
			base.m_name = "Necromancers Belt";
			base.m_tooltip = "Boost Blood Magics skill level." + $"\n<color=orange>BloodMagic: +{m_bloodMagic}</color>";
		}

		public void SetBloodMagic(float value)
		{
			m_bloodMagic = value;
			base.m_tooltip = "Boost Blood Magics skill level." + $"\n<color=orange>BloodMagic: +{m_bloodMagic}</color>";
		}
	}
	public class SlowFallAndEitr : StatusEffect
	{
		public float m_eitr;

		public float m_maxFallSpeed = 5f;

		public float m_fallDamageModifier = -1f;

		public void Awake()
		{
			base.m_name = "Slow Fall";
			if (Plugin._enableSlowFall.Value == MagicPlugin.Functions.Toggle.On)
			{
				base.m_tooltip = "$bmr_featherfall_tooltip" + $"\nLimit fall speed: <color=orange>{m_maxFallSpeed}m/s</color>" + $"\nFall damage: <color=orange>{m_fallDamageModifier}%</color>" + $"\nEitr: <color=orange>+{m_eitr}</color>";
			}
			else
			{
				base.m_tooltip = "$bmr_featherfall_tooltip" + $"\nEitr: <color=orange>+{m_eitr}</color>";
			}
			base.m_icon = Enumerable.FirstOrDefault((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>(), (Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "SlowFall"));
		}

		public void SetEitr(float eitr)
		{
			m_eitr = eitr;
			if (Plugin._enableSlowFall.Value == MagicPlugin.Functions.Toggle.On)
			{
				base.m_tooltip = "$bmr_featherfall_tooltip" + $"\nLimit fall speed: <color=orange>{m_maxFallSpeed}m/s</color>" + $"\nFall damage: <color=orange>{m_fallDamageModifier}%</color>" + $"\nEitr: <color=orange>+{m_eitr}</color>";
			}
			else
			{
				base.m_tooltip = "$bmr_featherfall_tooltip" + $"\nEitr: <color=orange>+{m_eitr}</color>";
			}
		}

		public override void ModifyWalkVelocity(ref Vector3 vel)
		{
			if (Plugin._enableSlowFall.Value != 0 && m_maxFallSpeed > 0f && vel.y < 0f - m_maxFallSpeed)
			{
				vel.y = 0f - m_maxFallSpeed;
			}
		}

		public override void ModifyFallDamage(float baseDamage, ref float damage)
		{
			if (Plugin._enableSlowFall.Value != 0)
			{
				damage += baseDamage * m_fallDamageModifier;
				if (damage < 0f)
				{
					damage = 0f;
				}
			}
		}
	}
}
namespace MagicPlugin.Patches
{
	[HarmonyPatch]
	public class AttackPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Attack), "Start")]
		public static void AttackStart_Postfix(Attack __instance)
		{
			if (__instance == null)
			{
				return;
			}
			Humanoid character = __instance.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val == null)
			{
				return;
			}
			string name = __instance.m_weapon.m_shared.m_name;
			if (name == null)
			{
				return;
			}
			switch (name.Length)
			{
			case 18:
				switch (name[5])
				{
				case 's':
					if (name == "$bmp_surtlingstaff")
					{
						float damageMultiplier11 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier11;
					}
					break;
				case 'e':
					if (name == "$bmp_eikthyrsstaff")
					{
						float damageMultiplier9 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier9;
					}
					break;
				case 'l':
					if (name == "$bmp_lightningwand")
					{
						float damageMultiplier10 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier10;
					}
					break;
				case 'b':
					if (name == "$bmp_beginnerstaff")
					{
						float damageMultiplier8 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier8;
					}
					break;
				}
				break;
			case 16:
				switch (name[5])
				{
				case 'a':
					if (name == "$bmp_arcticstaff")
					{
						float damageMultiplier6 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier6;
					}
					break;
				case 'p':
					if (name == "$bmp_poisonstaff")
					{
						float damageMultiplier5 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier5;
					}
					break;
				}
				break;
			case 15:
				switch (name[5])
				{
				case 'f':
					if (name == "$bmp_flamestaff")
					{
						float damageMultiplier3 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier3;
					}
					break;
				case 'p':
					if (name == "$bmp_poisonwand")
					{
						float damageMultiplier2 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier2;
					}
					break;
				}
				break;
			case 14:
				switch (name[5])
				{
				case 's':
					if (name == "$bmp_staffheal" && ((Character)val).GetHealth() < ((Character)val).GetMaxHealth() && val.GetEitr() > __instance.m_weapon.m_shared.m_attack.m_attackEitr && !((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("healstaff_cooldown")))
					{
						((Character)val).RaiseSkill((SkillType)10, 1f);
					}
					break;
				case 'f':
					if (name == "$bmp_flamewand")
					{
						float damageMultiplier12 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
						__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier12;
					}
					break;
				}
				break;
			case 19:
				if (name == "$bmp_lightningstaff")
				{
					float damageMultiplier7 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
					__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier7;
				}
				break;
			case 17:
				if (name == "$bmp_thunderstaff")
				{
					float damageMultiplier4 = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
					__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier4;
				}
				break;
			case 12:
				if (name == "$bmp_icewand")
				{
					float damageMultiplier = 1f + 1f * ((Character)val).GetSkillFactor((SkillType)9);
					__instance.m_weapon.m_shared.m_attack.m_damageMultiplier = damageMultiplier;
				}
				break;
			case 13:
				break;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Attack), "FireProjectileBurst")]
		public static bool FireProjectileBurst_Prefix(Attack __instance)
		{
			//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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			if (__instance != null)
			{
				Humanoid character = __instance.m_character;
				Player player = (Player)(object)((character is Player) ? character : null);
				if (player != null)
				{
					SkillType skillType = __instance.m_weapon.m_shared.m_skillType;
					if (__instance.m_weapon == null || (int)skillType != 9)
					{
						return true;
					}
					string name = __instance.m_weapon.m_shared.m_name;
					if (__instance.m_weapon.m_shared.m_name.EndsWith("scepter") || __instance.m_weapon.m_shared.m_name.Contains("flamestaff") || __instance.m_weapon.m_shared.m_name.Contains("thunderstaff") || __instance.m_weapon.m_shared.m_ammoType.Contains("ammo_spells"))
					{
						return true;
					}
					if ((Object)(object)__instance.m_weapon.m_shared.m_secondaryAttack.m_attackProjectile != (Object)null && ((Object)__instance.m_weapon.m_shared.m_secondaryAttack.m_attackProjectile).name == "BDS_DvergerStaffFire_clusterbomb_projectile")
					{
						return true;
					}
					if ((name == "$bmp_arcticstaff" || name == "$item_stafficeshards") ? true : false)
					{
						Attack obj = __instance;
						obj.m_projectileVel *= 1.2f;
						Attack obj2 = __instance;
						obj2.m_projectileVelMin *= 1.2f;
						Attack obj3 = __instance;
						obj3.m_projectileAccuracy *= 0f;
						Attack obj4 = __instance;
						obj4.m_projectileAccuracyMin *= 0f;
					}
					else
					{
						Plugin._magicVelocity.SettingChanged += delegate
						{
							Attack obj11 = __instance;
							obj11.m_projectileVel *= Plugin._magicVelocity.Value;
							Attack obj12 = __instance;
							obj12.m_projectileVelMin *= Plugin._magicVelocity.Value;
						};
						Attack obj5 = __instance;
						obj5.m_projectileVel *= Plugin._magicVelocity.Value;
						Attack obj6 = __instance;
						obj6.m_projectileVelMin *= Plugin._magicVelocity.Value;
						Plugin._magciAccuracy.SettingChanged += delegate
						{
							Attack obj9 = __instance;
							obj9.m_projectileAccuracy *= Plugin._magciAccuracy.Value;
							Attack obj10 = __instance;
							obj10.m_projectileAccuracyMin *= Plugin._magciAccuracy.Value;
						};
						Attack obj7 = __instance;
						obj7.m_projectileAccuracy *= Plugin._magciAccuracy.Value;
						Attack obj8 = __instance;
						obj8.m_projectileAccuracyMin *= Plugin._magciAccuracy.Value;
					}
					if (((Object)__instance.m_attackProjectile).name.ToLower().Contains("surtlingstaff"))
					{
						ConfigSetup._surtlingStaffAOE.SettingChanged += delegate
						{
							__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._surtlingStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._surtlingStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
					}
					if (((Object)__instance.m_attackProjectile).name.ToLower().Contains("eikthyrsstaff"))
					{
						ConfigSetup._eikthyrStaffAOE.SettingChanged += delegate
						{
							__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._eikthyrStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._eikthyrStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
					}
					if (((Object)__instance.m_attackProjectile).name.ToLower().Contains("lightningstaff"))
					{
						ConfigSetup._lightningStaffAOE.SettingChanged += delegate
						{
							__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._lightningStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._lightningStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
					}
					if (((Object)__instance.m_attackProjectile).name.ToLower().Contains("poisonstaff"))
					{
						ConfigSetup._poisonStaffAOE.SettingChanged += delegate
						{
							__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._poisonStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._poisonStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
					}
					if (((Object)__instance.m_attackProjectile).name.ToLower().Contains("arcticstaff"))
					{
						ConfigSetup._arcticStaffAOE.SettingChanged += delegate
						{
							__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._arcticStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						__instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_aoe = ConfigSetup._arcticStaffAOE.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
					}
					if (((Object)__instance.m_attackProjectile).name == "bmp_modersheritage_projectile")
					{
						SpawnAbility component = __instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_spawnOnHit.gameObject.GetComponent<SpawnAbility>();
						Projectile iceblast = component.m_spawnPrefab[0].gameObject.GetComponent<Projectile>();
						ConfigSetup._modersAoeRange.SettingChanged += delegate
						{
							iceblast.m_aoe = ConfigSetup._modersAoeRange.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						iceblast.m_aoe = ConfigSetup._modersAoeRange.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						ConfigSetup._modersChopDamage.SettingChanged += delegate
						{
							iceblast.m_damage.m_chop = ConfigSetup._modersChopDamage.Value;
						};
						iceblast.m_damage.m_chop = ConfigSetup._modersChopDamage.Value;
						ConfigSetup._modersFrostDamage.SettingChanged += delegate
						{
							iceblast.m_damage.m_frost = ConfigSetup._modersFrostDamage.Value + ConfigSetup._modersFrostDamage.Value * ((Character)player).GetSkillFactor((SkillType)9);
						};
						iceblast.m_damage.m_frost = ConfigSetup._modersFrostDamage.Value + ConfigSetup._modersFrostDamage.Value * ((Character)player).GetSkillFactor((SkillType)9);
						ConfigSetup._modersPickaxeDamage.SettingChanged += delegate
						{
							iceblast.m_damage.m_pickaxe = ConfigSetup._modersPickaxeDamage.Value;
						};
						iceblast.m_damage.m_pickaxe = ConfigSetup._modersPickaxeDamage.Value;
						ConfigSetup._modersPierceDamage.SettingChanged += delegate
						{
							iceblast.m_damage.m_pierce = ConfigSetup._modersPierceDamage.Value;
						};
						iceblast.m_damage.m_pierce = ConfigSetup._modersPierceDamage.Value;
					}
					if (((Object)__instance.m_attackProjectile).name == "bmp_yagluthsheritage_projectile")
					{
						SpawnAbility component2 = __instance.m_attackProjectile.gameObject.GetComponent<Projectile>().m_spawnOnHit.gameObject.GetComponent<SpawnAbility>();
						Projectile meteors = component2.m_spawnPrefab[0].gameObject.GetComponent<Projectile>();
						ConfigSetup._yagluthAoeRange.SettingChanged += delegate
						{
							meteors.m_aoe = ConfigSetup._yagluthAoeRange.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						};
						meteors.m_aoe = ConfigSetup._yagluthAoeRange.Value + 2f * ((Character)player).GetSkillFactor((SkillType)9);
						ConfigSetup._yagluthBluntDamage.SettingChanged += delegate
						{
							meteors.m_damage.m_blunt = ConfigSetup._yagluthBluntDamage.Value;
						};
						meteors.m_damage.m_blunt = ConfigSetup._yagluthBluntDamage.Value;
						ConfigSetup._yagluthChopDamage.SettingChanged += delegate
						{
							meteors.m_damage.m_chop = ConfigSetup._yagluthChopDamage.Value;
						};
						meteors.m_damage.m_chop = ConfigSetup._yagluthChopDamage.Value;
						ConfigSetup._yagluthFireDamage.SettingChanged += delegate
						{
							meteors.m_damage.m_fire = ConfigSetup._yagluthFireDamage.Value + ConfigSetup._yagluthFireDamage.Value * ((Character)player).GetSkillFactor((SkillType)9);
						};
						meteors.m_damage.m_fire = ConfigSetup._yagluthFireDamage.Value + ConfigSetup._yagluthFireDamage.Value * ((Character)player).GetSkillFactor((SkillType)9);
						ConfigSetup._yagluthPickaxeDamage.SettingChanged += delegate
						{
							meteors.m_damage.m_pickaxe = ConfigSetup._yagluthPickaxeDamage.Value;
						};
						meteors.m_damage.m_pickaxe = ConfigSetup._yagluthPickaxeDamage.Value;
					}
					return true;
				}
			}
			return true;
		}
	}
	[HarmonyPatch]
	public class DestructiblePatch
	{
		[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
		public static class RpcDamagePatch
		{
			private static bool Prefix(Destructible __instance, HitData hit)
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Invalid comparison between Unknown and I4
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Invalid comparison between Unknown and I4
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Invalid comparison between Unknown and I4
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val == null || ((Humanoid)val).GetCurrentWeapon() == null || ((Humanoid)val).GetCurrentWeapon() == ((Humanoid)val).m_unarmedWeapon.m_itemData)
				{
					return true;
				}
				if (((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name == "BMP_SurtlingStaff" && (int)__instance.m_destructibleType == 2 && hit.m_damage.m_chop > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
				{
					hit.m_toolTier = (short)((Humanoid)val).GetCurrentWeapon().m_quality;
					((Character)val).RaiseSkill((SkillType)13, 0.2f);
				}
				if ((((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name == "BMP_EikthyrsStaff" || ((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name == "BMP_LightningStaff") && (int)__instance.m_damages.m_pickaxe != 3 && (int)__instance.m_destructibleType != 2 && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
				{
					hit.m_toolTier = (short)((Humanoid)val).GetCurrentWeapon().m_quality;
					((Character)val).RaiseSkill((SkillType)12, 0.2f);
				}
				return true;
			}
		}
	}
	[HarmonyPatch]
	public class HumanoidPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Humanoid), "IsItemEquiped")]
		private static void IsItemEquipped_Postfix(Humanoid __instance, ItemData item, ref bool __result)
		{
			if (AzuExtendedPlayerInventory.API.IsLoaded())
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && MagicSlot._magicSlots.TryGetValue(((Humanoid)val).m_visEquipment, out var value) && (value._equippedTomeItem == item || value._equippedEarringItem == item))
				{
					__result = true;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Humanoid), "SetupVisEquipment")]
		private static void SetupVisEquipment_Prefix(Humanoid __instance)
		{
			if (AzuExtendedPlayerInventory.API.IsLoaded())
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && MagicSlot._magicSlots.TryGetValue(((Humanoid)val).m_visEquipment, out var value))
				{
					value.SetTomeItem((value._equippedTomeItem == null) ? "" : ((Object)value._equippedTomeItem.m_dropPrefab).name);
					value.SetEarringItem((value._equippedEarringItem == null) ? "" : ((Object)value._equippedEarringItem.m_dropPrefab).name);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Humanoid), "UnequipAllItems")]
		private static void UnEquipAllItems_Prefix(Humanoid __instance)
		{
			if (AzuExtendedPlayerInventory.API.IsLoaded())
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					((Humanoid)val).UnequipItem(MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedTomeItem, false);
					((Humanoid)val).UnequipItem(MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedEarringItem, false);
				}
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(Humanoid), "EquipItem")]
		private static IEnumerable<CodeInstruction> EquipItemTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.LoadsConstant(list[i], (Enum)(object)(ItemType)18))
				{
					num = i;
				}
			}
			if (num == -1)
			{
				return list;
			}
			Label label = il.DefineLabel();
			int j;
			for (j = num; j < list.Count; j++)
			{
				if (list[j].operand is Label label2)
				{
					label = label2;
					break;
				}
			}
			List<CodeInstruction> collection = new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_1, (object)null),
				new CodeInstruction(OpCodes.Ldarg_2, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(HumanoidPatch), "EquipItem", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Brtrue, (object)label)
			};
			list.InsertRange(j + 1, collection);
			return list;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
		private static IEnumerable<CodeInstruction> UnEquipItemTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Humanoid), "SetupEquipment", (Type[])null, (Type[])null);
			List<CodeInstruction> list = Enumerable.ToList(instructions);
			int num = list.FindIndex((CodeInstruction i) => CodeInstructionExtensions.Calls(i, methodInfo));
			list.InsertRange(num - 1, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(HumanoidPatch), "UnEquipItem", (Type[])null, (Type[])null))
			}));
			return list;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(Humanoid), "UpdateEquipmentStatusEffects")]
		private static IEnumerable<CodeInstruction> StatusEffectsTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			List<CodeInstruction> list = Enumerable.ToList(instructions);
			list.InsertRange(2, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldloc_0, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(HumanoidPatch), "AddStatusEffects", (Type[])null, (Type[])null))
			}));
			return list;
		}

		private static bool EquipItem(Humanoid humanoid, ItemData item, bool triggerEquipmentEffects)
		{
			if (!AzuExtendedPlayerInventory.API.IsLoaded())
			{
				return false;
			}
			Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
			if (val == null)
			{
				return false;
			}
			if (MagicSlot.IsTomeItem(item))
			{
				((Humanoid)val).UnequipItem(MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedTomeItem, triggerEquipmentEffects);
				MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedTomeItem = item;
				return true;
			}
			if (MagicSlot.IsEarringItem(item))
			{
				((Humanoid)val).UnequipItem(MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedEarringItem, triggerEquipmentEffects);
				MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedEarringItem = item;
				return true;
			}
			return false;
		}

		private static void UnEquipItem(Humanoid humanoid, ItemData item)
		{
			if (!AzuExtendedPlayerInventory.API.IsLoaded())
			{
				return;
			}
			Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
			if (val != null)
			{
				if (MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedTomeItem == item)
				{
					MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedTomeItem = null;
				}
				if (MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedEarringItem == item)
				{
					MagicSlot._magicSlots[((Humanoid)val).m_visEquipment]._equippedEarringItem = null;
				}
			}
		}

		private static void AddStatusEffects(Humanoid humanoid, HashSet<StatusEffect> statusEffects)
		{
			if (!AzuExtendedPlayerInventory.API.IsLoaded())
			{
				return;
			}
			Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
			if (val != null && MagicSlot._magicSlots.TryGetValue(((Humanoid)val).m_visEquipment, out var value))
			{
				StatusEffect val2 = value._equippedTomeItem?.m_shared.m_equipStatusEffect;
				if (val2 != null)
				{
					statusEffects.Add(val2);
				}
				StatusEffect val3 = value._equippedEarringItem?.m_shared.m_equipStatusEffect;
				if (val3 != null)
				{
					statusEffects.Add(val3);
				}
			}
		}
	}
	[HarmonyPatch]
	public class ItemDataPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ItemData), "GetDamage", new Type[]
		{
			typeof(int),
			typeof(float)
		})]
		public static void GetDamage_Postfix(ItemData __instance, ref DamageTypes __result)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && ((Humanoid)localPlayer).m_inventory.m_inventory.Exists((ItemData x) => x == __instance))
			{
				float skillFactor = ((Character)localPlayer).GetSkillFactor((SkillType)9);
				if (((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bmp_hogwarts")))
				{
					float num = 1f + skillFactor * ConfigSetup._hogwartsBeltBonus.Value;
					__result.m_fire *= num;
					__result.m_frost *= num;
					__result.m_lightning *= num;
					__result.m_poison *= num;
					__result.m_spirit *= num;
				}
			}
		}
	}
	[HarmonyPatch]
	public class ItemDropPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ItemDrop), "Awake")]
		public static void ItemDropAwake_Postfix(ItemDrop __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "main" || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			string name = __instance.m_itemData.m_shared.m_name;
			if (name == null)
			{
				return;
			}
			switch (name.Length)
			{
			case 17:
				switch (name[15])
				{
				case 'e':
					if (name == "$bmp_flamescepter")
					{
						StatsSetup.FlameScepter(__instance);
					}
					break;
				case 's':
					if (name == "$bmr_seeker_chest")
					{
						StatsSetup.SeekerChest(__instance.m_itemData);
					}
					break;
				case 'p':
					if (name == "$bmr_crimson_cape")
					{
						StatsSetup.CrimsonCape(__instance.m_itemData);
					}
					break;
				case 'o':
					if (name == "$bmr_crimson_hood")
					{
						StatsSetup.CrimsonHood(__instance.m_itemData);
					}
					break;
				case 'g':
					if (name == "$bmr_crimson_legs")
					{
						StatsSetup.CrimsonLegs(__instance.m_itemData);
					}
					break;
				}
				break;
			case 15:
				switch (name[5])
				{
				case 'i':
					if (name == "$bmp_icescepter")
					{
						StatsSetup.IceScepter(__instance);
					}
					break;
				case 'd':
					if (name == "$bmp_dvergrbelt")
					{
						StatsSetup.DvergrBelt(__instance);
					}
					break;
				case 's':
					if (name == "$bmr_seeker_hat")
					{
						StatsSetup.SeekerHat(__instance.m_itemData);
					}
					break;
				}
				break;
			case 18:
				switch (name[16])
				{
				case 'p':
					if (!(name == "$bmr_tattered_cape"))
					{
						if (name == "$bmr_warlocks_cape")
						{
							StatsSetup.WarlocksCape(__instance.m_itemData);
						}
					}
					else
					{
						StatsSetup.TatteredCape(__instance.m_itemData);
					}
					break;
				case 'l':
					if (name == "$bmr_tattered_helm")
					{
						StatsSetup.TatteredHelm(__instance.m_itemData);
					}
					break;
				case 'g':
					if (name == "$bmr_tattered_legs")
					{
						StatsSetup.TatteredLegs(__instance.m_itemData);
					}
					break;
				case 'a':
					if (name == "$bmr_sorcerers_hat")
					{
						StatsSetup.SorcerersHat(__instance.m_itemData);
					}
					break;
				case 'o':
					if (name == "$bmr_warlocks_hood")
					{
						StatsSetup.WarlocksHood(__instance.m_itemData);
					}
					break;
				case 's':
					if (!(name == "$bmr_warlocks_vest"))
					{
						if (name == "$bmr_crimson_chest")
						{
							StatsSetup.CrimsonChest(__instance.m_itemData);
						}
					}
					else
					{
						StatsSetup.WarlocksVest(__instance.m_itemData);
					}
					break;
				}
				break;
			case 19:
				switch (name[17])
				{
				case 's':
					if (name == "$bmr_tattared_chest")
					{
						StatsSetup.TatteredChest(__instance.m_itemData);
					}
					break;
				case 'p':
					if (!(name == "$bmr_sorcerers_cape"))
					{
						if (name == "$bmr_polarwolf_cape")
						{
							StatsSetup.PolarWolfCape(__instance.m_itemData);
						}
					}
					else
					{
						StatsSetup.SorcerersCape(__instance.m_itemData);
					}
					break;
				case 'o':
					if (name == "$bmr_polarwolf_hood")
					{
						StatsSetup.PolarWolfHood(__instance.m_itemData);
					}
					break;
				case 'g':
					if (name == "$bmr_polarwolf_legs")
					{
						StatsSetup.PolarWolfLegs(__instance.m_itemData);
					}
					break;
				case 't':
					if (name == "$bmr_warlocks_pants")
					{
						StatsSetup.WarlocksPants(__instance.m_itemData);
					}
					break;
				}
				break;
			case 20:
				switch (name[5])
				{
				case 's':
					if (name == "$bmr_sorcerers_tunic")
					{
						StatsSetup.SorcerersTunic(__instance.m_itemData);
					}
					break;
				case 'p':
					if (name == "$bmr_polarwolf_chest")
					{
						StatsSetup.PolarWolfChest(__instance.m_itemData);
					}
					break;
				}
				break;
			case 16:
				switch (name[12])
				{
				case 'c':
					if (name == "$bmr_seeker_cape")
					{
						StatsSetup.SeekerCape(__instance.m_itemData);
					}
					break;
				case 'l':
					if (name == "$bmr_seeker_legs")
					{
						StatsSetup.SeekerLegs(__instance.m_itemData);
					}
					break;
				}
				break;
			case 22:
				if (name == "$bmp_modersinheritence")
				{
					StatsSetup.ModersHeritage(__instance);
				}
				break;
			case 24:
				if (name == "$bmp_yagluthsinheritence")
				{
					StatsSetup.YagluthsHeritage(__instance);
				}
				break;
			case 21:
				if (name == "$bmp_lightningscepter")
				{
					StatsSetup.LightningScepter(__instance);
				}
				break;
			case 23:
				if (name == "$bmr_sorcerers_trousers")
				{
					StatsSetup.SorcerersTrousers(__instance.m_itemData);
				}
				break;
			}
		}
	}
	[HarmonyPatch]
	public class MineRock5Patch
	{
		[HarmonyPatch(typeof(MineRock5), "RPC_Damage")]
		public static class RpcDamagePatch
		{
			private static void Prefix(MineRock5 __instance, HitData hit)
			{
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData)
				{
					int quality = ((Humanoid)val).GetCurrentWeapon().m_quality;
					if ((!(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_EikthyrsStaff") || !(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_LightningStaff")) && quality >= __instance.m_minToolTier && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
					{
						hit.m_toolTier = (short)quality;
						((Character)val).RaiseSkill((SkillType)12, 0.2f);
					}
				}
			}
		}

		[HarmonyPatch(typeof(MineRock5), "DamageArea")]
		public static class DamageAreaPatch
		{
			private static void Prefix(MineRock5 __instance, HitData hit)
			{
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData)
				{
					int quality = ((Humanoid)val).GetCurrentWeapon().m_quality;
					if ((!(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_EikthyrsStaff") || !(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_LightningStaff")) && quality >= __instance.m_minToolTier && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
					{
						hit.m_toolTier = (short)quality;
						((Character)val).RaiseSkill((SkillType)12, 0.2f);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public class MineRockPatch
	{
		[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
		public static class RpcHitPatch
		{
			private static void Prefix(MineRock __instance, HitData hit)
			{
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData)
				{
					int? num = ((Humanoid)val).GetCurrentWeapon()?.m_quality;
					if ((!(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_EikthyrsStaff") || !(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_LightningStaff")) && !(num < __instance.m_minToolTier) && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
					{
						hit.m_toolTier = (short)num.Value;
						((Character)val).RaiseSkill((SkillType)12, 0.2f);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public class ObjectDBPatch
	{
		[HarmonyPriority(700)]
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static void Awake_Postfix(ObjectDB __instance)
		{
			RegisterToFeaster(__instance);
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("necktotem_cooldown", "$bmp_necktotem", PrefabsSetup._neckTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("wolftotem_cooldown", "$bmp_wolftotem", PrefabsSetup._wolfTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("crystaltotem_cooldown", "$bmp_crystaltotem", PrefabsSetup._crystalTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("skulltotem_cooldown", "$bmp_skulltotem", PrefabsSetup._skullTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("modersheritage_cooldown", "$bmp_modersinheritence", PrefabsSetup._modersIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("yagluthsheritage_cooldown", "$bmp_yagluthsinheritence", PrefabsSetup._yagluthsIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("asksvintotem_cooldown", "$bmp_askvintotem", PrefabsSetup._asksvinTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("charredtotem_cooldown", "$bmp_charredtotem", PrefabsSetup._charredTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("draketotem_cooldown", "$bmp_draketotem", PrefabsSetup._drakeTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("seekertotem_cooldown", "$bmp_seekerbrutetotem", PrefabsSetup._seekerTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("valkyrietotem_cooldown", "$bmp_valkyrietotem", PrefabsSetup._valkyrieTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("bjorntotem_cooldown", "$bmp_bjorntotem", PrefabsSetup._bjornTotemIcon));
			__instance.m_StatusEffects.Add((StatusEffect)(object)Helper.CreateCooldown("viletotem_cooldown", "$bmp_viletotem", PrefabsSetup._vileTotemIcon));
		}

		private static void RegisterToFeaster(ObjectDB objectDB)
		{
			if (Helper.ObjectDBAwake())
			{
				objectDB.AddToFeaster(PrefabsSetup._magicBundle.LoadAsset<GameObject>("BMP_MountainSoup"));
				objectDB.AddToFeaster(PrefabsSetup._magicBundle.LoadAsset<GameObject>("BMP_MountainStew"));
				objectDB.AddToFeaster(PrefabsSetup._magicBundle.LoadAsset<GameObject>("BMP_MushroomJam"));
				objectDB.AddToFeaster(PrefabsSetup._magicBundle.LoadAsset<GameObject>("BMP_MushroomPie"));
				objectDB.AddToFeaster(PrefabsSetup._magicBundle.LoadAsset<GameObject>("BMP_MushroomPuff"));
				objectDB.AddToFeaster(PrefabsSetup._magicBundle.LoadAsset<GameObject>("BMP_SautedMeatMushroom"));
			}
		}
	}
	[HarmonyPatch]
	public class PlayerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
		private static bool UpdateEnvStatusEffect_Prefix(Player __instance)
		{
			if (!((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Arctic Buff")))
			{
				return true;
			}
			if (EnvMan.IsCold())
			{
				((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("Cold"), false);
			}
			if (EnvMan.IsFreezing())
			{
				((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("Freezing"), false);
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
		public static void GetTotalFoodValue_Postfix(ref Player __instance, ref float eitr)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				SetEitr(__instance, "bmr_tatteredcape", ConfigSetup._tatteredCapeEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_tatteredchest", ConfigSetup._tatteredChestEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_tatteredhelm", ConfigSetup._tatteredHelmEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_tatteredlegs", ConfigSetup._tatteredLegsEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_sorcererscape", ConfigSetup._sorcerersCapeEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_sorcerershat", ConfigSetup._sorcerersHatEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_sorcererstrousers", ConfigSetup._sorcerersTrousersEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_sorcererstunic", ConfigSetup._sorcerersTunicEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_warlockscape", ConfigSetup._warlocksCapeEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_warlockshood", ConfigSetup._warlocksHoodEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_warlockspants", ConfigSetup._warlocksPantsEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_warlocksvest", ConfigSetup._warlocksVestEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_polarwolfcape", ConfigSetup._polarWolfCapeEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_polarwolfchest", ConfigSetup._polarWolfChestEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_polarwolfhood", ConfigSetup._polarWolfHoodEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_polarwolflegs", ConfigSetup._polarWolfLegEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_seekercape", ConfigSetup._seekerCapeEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_seekerchest", ConfigSetup._seekerChestEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_seekerhat", ConfigSetup._seekerHatEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_seekerlegs", ConfigSetup._seekerLegsEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_crimsoncape", ConfigSetup._crimsonCapeEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_crimsonchest", ConfigSetup._crimsonChestEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_crimsonhood", ConfigSetup._crimsonHoodEitr.Value, ref eitr);
				SetEitr(__instance, "bmr_crimsonlegs", ConfigSetup._crimsonLegsEitr.Value, ref eitr);
				SetEitr(__instance, "bmp_eitrbelt", ConfigSetup._eitrBeltEitrBonus.Value, ref eitr);
				SetEitr(__instance, "bmp_eitr_earring", ConfigSetup._eitrEarringEitr.Value, ref eitr);
				SetEitr(__instance, "bmp_beginners_magicbook", ConfigSetup._beginnersBookEitr.Value, ref eitr);
				SetEitr(__instance, "bmp_advance_magicbook", ConfigSetup._advanceBookEitr.Value, ref eitr);
				SetEitr(__instance, "bmp_druidstome", ConfigSetup._druidsTomeEitr.Value, ref eitr);
				if (Jewelcrafting.API.IsLoaded())
				{
					SetEitr(__instance, "bmp_eitr_ring", RingsAndNecklaces._eitrRingEitr.Value, ref eitr);
					SetEitr(__instance, "bmp_eitr_necklace", RingsAndNecklaces._eitrNecklaceEitr.Value, ref eitr);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })]
		public static void UpdateStats_Postfix(Player __instance)
		{
			if (!((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("healstaff_cooldown")))
			{
				return;
			}
			foreach (string item in Enumerable.Where(new List<string> { "Frost", "Smoked", "Burning", "Poison", "Tared", "Freezing", "Frost" }, (string se) => ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode(se))))
			{
				((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode(item), false);
			}
		}

		[HarmonyPriority(800)]
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "Awake")]
		private static void Awake_Prefix(Player __instance)
		{
			if (Jewelcrafting.API.IsLoaded())
			{
				MagicSlot._magicSlots.Add(((Component)__instance).GetComponent<VisEquipment>(), new MagicSlot(((Component)__instance).GetComponent<VisEquipment>()));
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetEquipmentEitrRegenModifier")]
		public static void GetEquipmentEitrRegenModifier_Postfix(ref Player __instance, ref float __result)
		{
			__result += Enumerable.Sum(Enumerable.Where(((Humanoid)__instance).GetInventory().GetEquippedItems(), MagicSlot.IsTomeItem), (ItemData item) => item.m_shared.m_eitrRegenModifier);
			__result += Enumerable.Sum(Enumerable.Where(((Humanoid)__instance).GetInventory().GetEquippedItems(), MagicSlot.IsEarringItem), (ItemData item) => item.m_shared.m_eitrRegenModifier);
			if (Jewelcrafting.API.IsLoaded())
			{
				__result += Enumerable.Sum(Enumerable.Where(((Humanoid)__instance).GetInventory().GetEquippedItems(), (ItemData i) => i.m_shared.m_name.StartsWith("$jc_ring_") || i.m_shared.m_name.StartsWith("$jc_necklace_")), (ItemData i) => i.m_shared.m_eitrRegenModifier);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "SetControls")]
		private static void SetControls_Prefix(Player __instance, ref bool jump, ref bool attack, ref bool secondaryAttack)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (((Character)__instance).IsRiding() & jump)
			{
				Sadle val = (Sadle)__instance.m_doodadController;
				if (!((Object)(object)val == (Object)null))
				{
					((BaseAI)val.m_monsterAI).m_character.Jump(false);
					jump = false;
				}
			}
			else if (((Character)__instance).IsRiding())
			{
				jump = false;
				attack = false;
				secondaryAttack = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "TeleportTo")]
		private static void TeleportTo_Postfix(Player __instance, ref Vector3 pos, ref Quaternion rot)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			foreach (Character item in Enumerable.Select(Enumerable.Where(Enumerable.Select(Character.GetAllCharacters(), (Character character) => new
			{
				character = character,
				tamable = ((Component)character).GetComponent<Tameable>()
			}), <>h__TransparentIdentifier0 => (Object)(object)<>h__TransparentIdentifier0.character != (Object)null && <>h__TransparentIdentifier0.character.m_nview.IsValid() && <>h__TransparentIdentifier0.character.IsTamed() && (Object)(object)<>h__TransparentIdentifier0.tamable != (Object)null && (Object)(object)<>h__TransparentIdentifier0.tamable.m_monsterAI.GetFollowTarget() != (Object)null && (Object)(object)<>h__TransparentIdentifier0.tamable.m_monsterAI.GetFollowTarget() == (Object)(object)((Component)__instance).gameObject && ((Object)((Component)<>h__TransparentIdentifier0.character).gameObject).name.StartsWith("BMP_")), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.character))
			{
				((Component)item).transform.position = pos + ((Component)__instance).transform.forward;
				((Component)item).transform.rotation = rot;
			}
		}

		private static void SetEitr(Player player, string statEffect, float amount, ref float eitr)
		{
			if (((Character)player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode(statEffect)))
			{
				eitr += amount;
			}
		}
	}
	[HarmonyPatch]
	public class SaddlePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Sadle), "ApplyControlls")]
		private static void ApplyControls_Prefix(Sadle __instance, ref bool run)
		{
			if (__instance.m_character.m_name.Contains("asksvin_summon") && Plugin._autoRun)
			{
				run = Plugin._autoRun;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Sadle), "ResetControlls")]
		private static void ResetControls_Postfix()
		{
			Plugin._autoRun = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Sadle), "GetHoverText")]
		private static void GetHoverText_Postfix(Sadle __instance, ref string __result)
		{
			if (__instance.m_character.m_name.Contains("asksvin_summon"))
			{
				if (!__instance.InUseDistance((Humanoid)(object)Player.m_localPlayer))
				{
					__result = Localization.instance.Localize("<color=#888888>$piece_toofar</color>");
				}
				string text = Localization.instance.Localize(__instance.m_hoverText);
				text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use");
				__result = text;
			}
		}
	}
	[HarmonyPatch]
	public class SEManPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(SEMan), "Internal_AddStatusEffect")]
		public static bool InternalAddStatusEffect_Prefix(SEMan __instance, ref int nameHash)
		{
			if (!__instance.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Arctic Buff")))
			{
				return true;
			}
			if (nameHash != StringExtensionMethods.GetStableHashCode("Freezing"))
			{
				return nameHash != StringExtensionMethods.GetStableHashCode("Cold");
			}
			return false;
		}
	}
	[HarmonyPatch]
	public static class SkillsPatch
	{
		[HarmonyPatch(typeof(Skills), "RaiseSkill")]
		public static class RaiseSkillPatch
		{
			public static void Prefix(ref SkillType skillType, ref float factor)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Invalid comparison between Unknown and I4
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Invalid comparison between Unknown and I4
				if (Plugin._enableExpMultiplier.Value != MagicPlugin.Functions.Toggle.On)
				{
					return;
				}
				SkillType val = skillType;
				if ((int)val != 9)
				{
					if ((int)val == 10)
					{
						factor *= Plugin._bmExpMultiplier.Value;
					}
				}
				else
				{
					factor *= Plugin._emExpMultiplier.Value;
				}
			}

			public static void Postfix(Skills __instance, SkillType skillType)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Invalid comparison between Unknown and I4
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Invalid comparison between Unknown and I4
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				if (Plugin._enableExpMultiplier.Value != MagicPlugin.Functions.Toggle.On || Plugin._displayExpGained.Value != MagicPlugin.Functions.Toggle.On || ((int)skillType != 10 && (int)skillType != 9))
				{
					return;
				}
				try
				{
					if (__instance.GetSkillLevel((SkillType)10) < 100f || __instance.GetSkillLevel((SkillType)9) < 100f)
					{
						Skill skill = __instance.GetSkill(skillType);
						float value = skill.m_accumulator / (skill.GetNextLevelRequirement() / 100f);
						((Character)__instance.m_player).Message((MessageType)1, $"Level {skill.m_level.tFloat(0)} {skill.m_info.m_skill} [{skill.m_accumulator.tFloat(2)}/{skill.GetNextLevelRequirement().tFloat(2)}] ({value.tFloat(0)}%)", 0, skill.m_info.m_icon);
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Skills), "GetSkillLevel")]
		public static void GetSkillLevel_Postfix(Skills __instance, SkillType skillType, ref float __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0063: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if ((int)skillType != 9)
			{
				if ((int)skillType == 10)
				{
					float level = __instance.GetSkill(skillType).m_level;
					if (((Character)__instance.m_player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bmp_necromancer")))
					{
						level += ConfigSetup._necromancerBeltBonus.Value;
						((Character)__instance.m_player).GetSEMan().ModifySkillLevel(skillType, ref level);
						__result = level;
					}
					else
					{
						((Character)__instance.m_player).GetSEMan().ModifySkillLevel(skillType, ref level);
						__result = level;
					}
				}
			}
			else
			{
				float level2 = __instance.GetSkill(skillType).m_level;
				if (((Character)__instance.m_player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bmp_elementalist")))
				{
					level2 += ConfigSetup._elementalistBeltBonus.Value;
					((Character)__instance.m_player).GetSEMan().ModifySkillLevel(skillType, ref level2);
					__result = level2;
				}
				else
				{
					((Character)__instance.m_player).GetSEMan().ModifySkillLevel(skillType, ref level2);
					__result = level2;
				}
			}
		}
	}
	[HarmonyPatch]
	public class SpawnAbilityPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(SpawnAbility), "Spawn")]
		private static bool Spawn_Prefix(SpawnAbility __instance)
		{
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)null) && __instance.m_weapon != null)
			{
				Character owner = __instance.m_owner;
				Player val = (Player)(object)((owner is Player) ? owner : null);
				if (val != null)
				{
					switch (__instance.m_weapon.m_shared.m_name)
					{
					case "$bmp_necktotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("necktotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready.</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("necktotem_cooldown"));
						ConfigSetup._neckTotemCooldown.SettingChanged += delegate
						{
							statusEffect.m_ttl = ConfigSetup._neckTotemCooldown.Value;
						};
						statusEffect.m_ttl = ConfigSetup._neckTotemCooldown.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect, false, 0, 0f);
						return true;
					}
					case "$bmp_wolftotem":
					{
						if (((Character)val).GetSkillLevel((SkillType)10) < (float)ConfigSetup._wolfTotemLevel.Value)
						{
							((Character)val).Message((MessageType)2, "<size=28>You're not worthy to summon the <color=red>God of Flames</color></size>", 0, (Sprite)null);
							return false;
						}
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("wolftotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect6 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("wolftotem_cooldown"));
						ConfigSetup._wolfTotemCooldown.SettingChanged += delegate
						{
							statusEffect6.m_ttl = ConfigSetup._wolfTotemCooldown.Value;
						};
						statusEffect6.m_ttl = ConfigSetup._wolfTotemCooldown.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect6, false, 0, 0f);
						return true;
					}
					case "$bmp_crystaltotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("crystaltotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect7 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("crystaltotem_cooldown"));
						ConfigSetup._crystalTotemCooldown.SettingChanged += delegate
						{
							statusEffect7.m_ttl = ConfigSetup._crystalTotemCooldown.Value;
						};
						statusEffect7.m_ttl = ConfigSetup._crystalTotemCooldown.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect7, false, 0, 0f);
						return true;
					}
					case "$bmp_skulltotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("skulltotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect8 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("skulltotem_cooldown"));
						ConfigSetup._skullTotemCooldown.SettingChanged += delegate
						{
							statusEffect8.m_ttl = ConfigSetup._skullTotemCooldown.Value;
						};
						statusEffect8.m_ttl = ConfigSetup._skullTotemCooldown.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect8, false, 0, 0f);
						return true;
					}
					case "$bmp_modersinheritence":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("modersheritage_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Attack not ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect9 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("modersheritage_cooldown"));
						ConfigSetup._modersCooldown.SettingChanged += delegate
						{
							statusEffect9.m_ttl = ConfigSetup._modersCooldown.Value;
						};
						statusEffect9.m_ttl = ConfigSetup._modersCooldown.Value;
						if (ConfigSetup._modersCooldown.Value > 0f)
						{
							((Character)val).GetSEMan().AddStatusEffect(statusEffect9, false, 0, 0f);
						}
						Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("fx_himminafl_aoe"), ((Character)val).GetCenterPoint(), Quaternion.identity);
						return true;
					}
					case "$bmp_yagluthsinheritence":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("yagluthsheritage_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Attack not ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect10 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("yagluthsheritage_cooldown"));
						ConfigSetup._yagluthsCooldown.SettingChanged += delegate
						{
							statusEffect10.m_ttl = ConfigSetup._yagluthsCooldown.Value;
						};
						statusEffect10.m_ttl = ConfigSetup._yagluthsCooldown.Value;
						if (ConfigSetup._yagluthsCooldown.Value > 0f)
						{
							((Character)val).GetSEMan().AddStatusEffect(statusEffect10, false, 0, 0f);
						}
						Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("fx_himminafl_aoe"), ((Character)val).GetCenterPoint(), Quaternion.identity);
						return true;
					}
					case "$bmp_askvintotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("asksvintotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect11 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("asksvintotem_cooldown"));
						ConfigSetup._asksvinTotemCD.SettingChanged += delegate
						{
							statusEffect11.m_ttl = ConfigSetup._asksvinTotemCD.Value;
						};
						statusEffect11.m_ttl = ConfigSetup._asksvinTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect11, false, 0, 0f);
						return true;
					}
					case "$bmp_charredtotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("charredtotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect12 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("charredtotem_cooldown"));
						ConfigSetup._charredTotemCD.SettingChanged += delegate
						{
							statusEffect12.m_ttl = ConfigSetup._charredTotemCD.Value;
						};
						statusEffect12.m_ttl = ConfigSetup._charredTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect12, false, 0, 0f);
						return true;
					}
					case "$bmp_draketotem":
					{
						if (((Character)val).GetSkillLevel((SkillType)10) < (float)ConfigSetup._drakeTotemLevel.Value)
						{
							((Character)val).Message((MessageType)2, "<size=28>You're not worthy to summon the <color=red>God of Flames</color></size>", 0, (Sprite)null);
							return false;
						}
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("draketotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect13 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("draketotem_cooldown"));
						ConfigSetup._drakeTotemCD.SettingChanged += delegate
						{
							statusEffect13.m_ttl = ConfigSetup._drakeTotemCD.Value;
						};
						statusEffect13.m_ttl = ConfigSetup._drakeTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect13, false, 0, 0f);
						return true;
					}
					case "$bmp_seekerbrutetotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("seekertotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect2 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("seekertotem_cooldown"));
						ConfigSetup._seekerTotemCD.SettingChanged += delegate
						{
							statusEffect2.m_ttl = ConfigSetup._seekerTotemCD.Value;
						};
						statusEffect2.m_ttl = ConfigSetup._seekerTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect2, false, 0, 0f);
						return true;
					}
					case "$bmp_valkyrietotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("valkyrietotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect3 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("valkyrietotem_cooldown"));
						ConfigSetup._valkyrieTotemCD.SettingChanged += delegate
						{
							statusEffect3.m_ttl = ConfigSetup._valkyrieTotemCD.Value;
						};
						statusEffect3.m_ttl = ConfigSetup._valkyrieTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect3, false, 0, 0f);
						return true;
					}
					case "$bmp_bjorntotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bjorntotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect4 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("bjorntotem_cooldown"));
						ConfigSetup._bjornTotemCD.SettingChanged += delegate
						{
							statusEffect4.m_ttl = ConfigSetup._bjornTotemCD.Value;
						};
						statusEffect4.m_ttl = ConfigSetup._bjornTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect4, false, 0, 0f);
						return true;
					}
					case "$bmp_viletotem":
					{
						if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("viletotem_cooldown")))
						{
							((Character)val).Message((MessageType)2, "<size=28>Gate of Valhalla is not yet ready!</size>", 0, (Sprite)null);
							return false;
						}
						StatusEffect statusEffect5 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("viletotem_cooldown"));
						ConfigSetup._vileTotemCD.SettingChanged += delegate
						{
							statusEffect5.m_ttl = ConfigSetup._vileTotemCD.Value;
						};
						statusEffect5.m_ttl = ConfigSetup._vileTotemCD.Value;
						((Character)val).GetSEMan().AddStatusEffect(statusEffect5, false, 0, 0f);
						return true;
					}
					default:
						return true;
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch]
	public class TameablePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Tameable), "Awake")]
		private static void Awake_Postfix(Tameable __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && ((Object)((Component)__instance).gameObject).name.Contains("AsksvinFriendly"))
			{
				__instance.m_nview.GetZDO().Set(ZDOVars.s_haveSaddleHash, true);
				__instance.m_nview.InvokeRPC(ZNetView.Everybody, "SetSaddle", new object[1] { true });
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		private static void GetHoverText_Postfix(Tameable __instance, ref string __result)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.m_character == (Object)null) && !__instance.m_character.IsDead() && __instance.m_character.IsTamed() && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner() && ((Object)((Component)__instance).gameObject).name.StartsWith("BMP_"))
			{
				string obj = __result;
				Localization instance = Localization.instance;
				KeyboardShortcut value = Plugin._unSummonKey.Value;
				__result = obj + instance.Localize("\n[<color=yellow><b>" + ((object)(KeyboardShortcut)(ref value)).ToString() + "</b></color>] $bmp_unsummon");
			}
		}
	}
	[HarmonyPatch]
	public class TreeBasePatch
	{
		[HarmonyPatch(typeof(TreeBase), "RPC_Damage")]
		public static class RpcDamagePatch
		{
			private static void Prefix(TreeBase __instance, HitData hit)
			{
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData)
				{
					int quality = ((Humanoid)val).GetCurrentWeapon().m_quality;
					if (!(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_SurtlingStaff") && quality >= __instance.m_minToolTier && hit.m_damage.m_chop > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
					{
						hit.m_toolTier = (short)quality;
						((Character)val).RaiseSkill((SkillType)13, 0.2f);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public class TreeLogPatch
	{
		[HarmonyPatch(typeof(TreeLog), "RPC_Damage")]
		public static class RpcDamagePatch
		{
			private static void Prefix(TreeLog __instance, HitData hit)
			{
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData)
				{
					int quality = ((Humanoid)val).GetCurrentWeapon().m_quality;
					if (!(((Object)((Humanoid)val).GetCurrentWeapon().m_dropPrefab).name != "BMP_SurtlingStaff") && quality >= __instance.m_minToolTier && hit.m_damage.m_chop > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
					{
						hit.m_toolTier = (short)quality;
						((Character)val).RaiseSkill((SkillType)13, 0.2f);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public class VisEquipmentPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(VisEquipment), "OnEnable")]
		private static void OnEnable_Postfix(VisEquipment __instance)
		{
			if (!MagicSlot._magicSlots.ContainsKey(__instance) && __instance.m_isPlayer)
			{
				MagicSlot._magicSlots[__instance] = new MagicSlot(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(VisEquipment), "OnDisable")]
		private static void OnDisable_Postfix(VisEquipment __instance)
		{
			MagicSlot._magicSlots.Remove(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")]
		private static void UpdateEquipmentVisuals_Postfix(VisEquipment __instance)
		{
			if (__instance.m_isPlayer)
			{
				MagicSlot._magicSlots[__instance].UpdateEquipmentVisuals();
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public class ZNetScenePatch
	{
		public static void Postfix(ZNetScene __instance)
		{
			SummonHelper.CreateSummons(__instance);
			SummonHelper.LinkSummons(__instance);
		}
	}
}
namespace MagicPlugin.JCAdditions
{
	public static class RingsAndNecklaces
	{
		public static ConfigEntry<float> _eitrRingEitr;

		public static ConfigEntry<float> _eitrNecklaceEitr;

		public static void Init()
		{
			if (Jewelcrafting.API.IsLoaded())
			{
				DvergrRing();
				EitrRing();
				FireResistRing();
				FrostResistRing();
				PoisonResistRing();
				DvergrNecklace();
				EitrNecklace();
				FireResistNecklace();
				FrostResistNecklace();
				PoisonResistNecklace();
			}
		}

		private static void DvergrRing()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Item item = new Item(Jewelcrafting.API.CreateRingFromTemplate("Blue", Color.blue));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_ring_dvergrring";
			component.m_itemData.m_shared.m_description = "$jc_ring_dvergrring_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			component.m_itemData.m_shared.m_eitrRegenModifier = 0.25f;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Blue_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("Eitr", 16);
			item.Configurable = Configurability.Recipe | Configurability.Stats;
		}

		private static void EitrRing()
		{
			//IL_001a: 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_00cb: Expected O, but got Unknown
			Item item = new Item(Jewelcrafting.API.CreateRingFromTemplate("Purple", new Color(128f, 0f, 128f)));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_ring_eitrring";
			component.m_itemData.m_shared.m_description = "$jc_ring_eitrring_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			string group = Plugin.english.Localize("$jc_ring_eitrring");
			_eitrRingEitr = Plugin._Instance.config(group, "Eitr Bonus", 46f, new ConfigDescription("Eitr ring eitr bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1]
			{
				new MagicPlugin.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Purple_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("Eitr", 16);
			item.Configurable = Configurability.Recipe;
			AddEitr statusEffect = ScriptableObject.CreateInstance<AddEitr>();
			((Object)statusEffect).name = "bmp_eitr_ring";
			((StatusEffect)statusEffect).m_name = component.m_itemData.m_shared.m_name;
			AddEitr addEitr = statusEffect;
			ItemData itemData = component.m_itemData;
			((StatusEffect)addEitr).m_icon = ((itemData != null) ? itemData.GetIcon() : null);
			_eitrRingEitr.SettingChanged += delegate
			{
				statusEffect.SetEitr(_eitrRingEitr.Value);
			};
			statusEffect.SetEitr(_eitrRingEitr.Value);
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void FireResistRing()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			Item item = new Item(Jewelcrafting.API.CreateRingFromTemplate("Red", Color.red));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_ring_fireresistring";
			component.m_itemData.m_shared.m_description = "$jc_ring_fireresistring_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Red_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("TrophySurtling", 1);
			item.Configurable = Configurability.Recipe;
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "bmp_fireresist_ring";
			((StatusEffect)val).m_name = component.m_itemData.m_shared.m_name;
			((StatusEffect)val).m_icon = component.m_itemData.GetIcon();
			val.m_mods = new List<DamageModPair>(1)
			{
				new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)5
				}
			};
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}

		private static void FrostResistRing()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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)
			Item item = new Item(Jewelcrafting.API.CreateRingFromTemplate("Cyan", Color.cyan));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_ring_frostresistring";
			component.m_itemData.m_shared.m_description = "$jc_ring_frostresistring_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Blue_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("FreezeGland", 16);
			item.Configurable = Configurability.Recipe;
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "bmp_frostresist_ring";
			((StatusEffect)val).m_name = component.m_itemData.m_shared.m_name;
			((StatusEffect)val).m_icon = component.m_itemData.GetIcon();
			val.m_mods = new List<DamageModPair>(1)
			{
				new DamageModPair
				{
					m_type = (DamageType)64,
					m_modifier = (DamageModifier)5
				}
			};
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}

		private static void PoisonResistRing()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			Item item = new Item(Jewelcrafting.API.CreateRingFromTemplate("Green", Color.green));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_ring_poisonresistring";
			component.m_itemData.m_shared.m_description = "$jc_ring_poisonresistring_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Green_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("Guck", 16);
			item.Configurable = Configurability.Recipe;
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "bmp_poisonresist_ring";
			((StatusEffect)val).m_name = component.m_itemData.m_shared.m_name;
			((StatusEffect)val).m_icon = component.m_itemData.GetIcon();
			val.m_mods = new List<DamageModPair>(1)
			{
				new DamageModPair
				{
					m_type = (DamageType)256,
					m_modifier = (DamageModifier)5
				}
			};
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}

		private static void DvergrNecklace()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Item item = new Item(Jewelcrafting.API.CreateNecklaceFromTemplate("Blue", Color.blue));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_necklace_dvergrnecklace";
			component.m_itemData.m_shared.m_description = "$jc_necklace_dvergrnecklace_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			component.m_itemData.m_shared.m_eitrRegenModifier = 0.25f;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Blue_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.Configurable = Configurability.Recipe | Configurability.Stats;
		}

		private static void EitrNecklace()
		{
			//IL_001a: 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_00cb: Expected O, but got Unknown
			Item item = new Item(Jewelcrafting.API.CreateNecklaceFromTemplate("Purple", new Color(128f, 0f, 128f)));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_necklace_eitrnecklace";
			component.m_itemData.m_shared.m_description = "$jc_necklace_eitrnecklace_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			string group = Plugin.english.Localize("$jc_necklace_eitrnecklace");
			_eitrNecklaceEitr = Plugin._Instance.config(group, "Eitr Bonus", 42f, new ConfigDescription("Eitr necklace eitr bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1]
			{
				new MagicPlugin.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Purple_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("Eitr", 16);
			item.Configurable = Configurability.Recipe;
			AddEitr statusEffect = ScriptableObject.CreateInstance<AddEitr>();
			((Object)statusEffect).name = "bmp_eitr_necklace";
			((StatusEffect)statusEffect).m_name = component.m_itemData.m_shared.m_name;
			((StatusEffect)statusEffect).m_icon = component.m_itemData.GetIcon();
			_eitrNecklaceEitr.SettingChanged += delegate
			{
				statusEffect.SetEitr(_eitrNecklaceEitr.Value);
			};
			statusEffect.SetEitr(_eitrNecklaceEitr.Value);
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)statusEffect;
		}

		private static void FireResistNecklace()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			Item item = new Item(Jewelcrafting.API.CreateNecklaceFromTemplate("Red", Color.red));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_necklace_fireresistnecklace";
			component.m_itemData.m_shared.m_description = "$jc_necklace_fireresistnecklace_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Red_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("TrophySurtling", 1);
			item.Configurable = Configurability.Recipe;
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "bmp_fireresist_necklace";
			((StatusEffect)val).m_name = component.m_itemData.m_shared.m_name;
			((StatusEffect)val).m_icon = component.m_itemData.GetIcon();
			val.m_mods = new List<DamageModPair>(1)
			{
				new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)5
				}
			};
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}

		private static void FrostResistNecklace()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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)
			Item item = new Item(Jewelcrafting.API.CreateNecklaceFromTemplate("Cyan", Color.cyan));
			ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "$jc_necklace_frostresistnecklace";
			component.m_itemData.m_shared.m_description = "$jc_necklace_frostresistnecklace_description";
			component.m_itemData.m_shared.m_maxQuality = 1;
			item.Crafting.Add(((Object)Jewelcrafting.API.GetGemcuttersTable()).name, 3);
			item.MaximumRequiredStationLevel = 3;
			item.RequiredItems.Add("Perfect_Blue_Socket", 5);
			item.RequiredItems.Add("Chain", 2);
			item.RequiredItems.Add("FreezeGland", 16);
			item.Configurable = Configurability.Recipe;
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "bmp_frostresist_necklace";
			((StatusEffect)val).m_name = component.m_itemData.m_shared.m_name;
			((StatusEffect)val).m_icon = component.m_itemData.GetIcon();
			val.m_mods = new List<DamageModPair>(1)
			{
				new DamageModPair
				{
					m_type = (DamageType)64,
					m_modifier = (DamageModifier)5
				}
			};
			component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}

		private static void PoisonResistNecklace()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or