Decompiled source of Rustheim v0.2.7

RustyLoot.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EpicLootAPI;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using RustyLoot.Managers;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("RustyLoot")]
[assembly: AssemblyCompany("RustyMods")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("RustyLoot")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("0.0.2")]
[assembly: AssemblyConfiguration("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<8392a56d-ead9-4ec9-aa2f-e181e9fcce15>Embedded]
	internal sealed class <8392a56d-ead9-4ec9-aa2f-e181e9fcce15>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<8392a56d-ead9-4ec9-aa2f-e181e9fcce15>Embedded]
	internal sealed class <4fdc30f7-b68c-418d-93b5-c88926ee132e>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <4fdc30f7-b68c-418d-93b5-c88926ee132e>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <4fdc30f7-b68c-418d-93b5-c88926ee132e>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<8392a56d-ead9-4ec9-aa2f-e181e9fcce15>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LocalizationManager
{
	[PublicAPI]
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	public class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

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

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

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

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static readonly List<string> fileExtensions;

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		private static void UpdatePlaceholderText(Localization localization, string key)
		{
			localizationLanguage.TryGetValue(localization, out var value);
			string text = loadedTexts[value][key];
			if (PlaceholderProcessors.TryGetValue(key, out var value2))
			{
				text = value2.Aggregate(text, [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdatePlaceholder();
			};
			if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
			{
				UpdatePlaceholder();
			}
			void UpdatePlaceholder()
			{
				PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value);
				UpdatePlaceholderText(Localization.instance, key);
			}
		}

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

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

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

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

		[return: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private static byte[] LoadTranslationFromAssembly(string language)
		{
			foreach (string fileExtension in fileExtensions)
			{
				byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
				if (array != null)
				{
					return array;
				}
			}
			return null;
		}

		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
}
namespace RustyLoot
{
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	[PublicAPI]
	public static class AssetBundleManager
	{
		private static readonly Dictionary<string, AssetBundle> CachedBundles = new Dictionary<string, AssetBundle>();

		[return: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		public static T LoadAsset<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)] T>(string assetBundle, string prefab) where T : Object
		{
			AssetBundle assetBundle2 = GetAssetBundle(assetBundle);
			return (assetBundle2 == null) ? default(T) : assetBundle2.LoadAsset<T>(prefab);
		}

		public static AssetBundle GetAssetBundle(string fileName)
		{
			if (CachedBundles.TryGetValue(fileName, out var value))
			{
				return value;
			}
			AssetBundle val = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)([<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (AssetBundle b) => ((Object)b).name == fileName));
			if (val != null)
			{
				CachedBundles[fileName] = val;
				return val;
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single([<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (string str) => str.EndsWith(fileName));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			AssetBundle val2 = AssetBundle.LoadFromStream(stream);
			CachedBundles[fileName] = val2;
			return val2;
		}
	}
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	public class Clone
	{
		internal static readonly Dictionary<string, GameObject> registeredPrefabs = new Dictionary<string, GameObject>();

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private GameObject Prefab;

		private readonly string PrefabName;

		private readonly string NewName;

		private bool Loaded;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private GameObject Source;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1 })]
		[method: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1 })]
		[field: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1 })]
		public event Action<GameObject> OnCreated;

		public Clone(string prefabName, string newName)
		{
			PrefabName = prefabName;
			NewName = newName;
			PrefabManager.Clones.Add(this);
		}

		public Clone(GameObject source, string newName)
		{
			Source = source;
			NewName = newName;
			PrefabName = ((Object)source).name;
		}

		internal void Create()
		{
			if (Loaded)
			{
				return;
			}
			if (Source == null)
			{
				GameObject prefab = Helpers.GetPrefab(PrefabName);
				if (prefab == null)
				{
					return;
				}
				Prefab = Object.Instantiate<GameObject>(prefab, RustyLootPlugin.root.transform, false);
			}
			else
			{
				Prefab = Object.Instantiate<GameObject>(Source, RustyLootPlugin.root.transform, false);
			}
			((Object)Prefab).name = NewName;
			PrefabManager.RegisterPrefab(Prefab);
			this.OnCreated?.Invoke(Prefab);
			registeredPrefabs[((Object)Prefab).name] = Prefab;
			Loaded = true;
		}
	}
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[PublicAPI]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	public static class Helpers
	{
		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		internal static ZNetScene _ZNetScene;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		internal static ObjectDB _ObjectDB;

		[return: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		internal static GameObject GetPrefab(string prefabName)
		{
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				return ZNetScene.instance.GetPrefab(prefabName);
			}
			if ((Object)(object)_ZNetScene == (Object)null)
			{
				return null;
			}
			GameObject val = _ZNetScene.m_prefabs.Find([<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (GameObject prefab) => ((Object)prefab).name == prefabName);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			GameObject value;
			return Clone.registeredPrefabs.TryGetValue(prefabName, out value) ? value : val;
		}

		public static string GetNormalizedName(string name)
		{
			return Regex.Replace(name, "\\s*\\(.*?\\)", "").Trim();
		}

		public static bool HasComponent<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)] T>(this GameObject go) where T : Component
		{
			return Object.op_Implicit((Object)(object)go.GetComponent<T>());
		}

		public static void RemoveComponent<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)] T>(this GameObject go) where T : Component
		{
			T val = default(T);
			if (go.TryGetComponent<T>(ref val))
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		public static void RemoveAllComponents<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)] T>(this GameObject go, bool includeChildren = false, params Type[] ignoreComponents) where T : MonoBehaviour
		{
			List<T> list = go.GetComponents<T>().ToList();
			if (includeChildren)
			{
				list.AddRange(go.GetComponentsInChildren<T>(true));
			}
			foreach (T item in list)
			{
				if (!ignoreComponents.Contains(((object)item).GetType()))
				{
					Object.DestroyImmediate((Object)(object)item);
				}
			}
		}

		public static bool IsValid(this ItemData item)
		{
			return item.m_shared.m_icons.Length != 0;
		}
	}
	[PublicAPI]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	public static class PrefabManager
	{
		internal static List<GameObject> PrefabsToRegister;

		internal static List<Clone> Clones;

		static PrefabManager()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			PrefabsToRegister = new List<GameObject>();
			Clones = new List<Clone>();
			Harmony val = new Harmony("org.bepinex.helpers.MWL_Manager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PrefabManager), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PrefabManager), "Patch_ZNetScene_Awake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(2)]
		public static void RegisterPrefab(GameObject prefab)
		{
			if (!((Object)(object)prefab == (Object)null))
			{
				PrefabsToRegister.Add(prefab);
			}
		}

		public static void RegisterPrefab(string assetBundleName, string prefabName)
		{
			RegisterPrefab(AssetBundleManager.LoadAsset<GameObject>(assetBundleName, prefabName));
		}

		public static void RegisterPrefab(AssetBundle assetBundle, string prefabName)
		{
			RegisterPrefab(assetBundle.LoadAsset<GameObject>(prefabName));
		}

		[HarmonyPriority(700)]
		internal static void Patch_ZNetScene_Awake(ZNetScene __instance)
		{
			foreach (GameObject item in PrefabsToRegister)
			{
				if (Object.op_Implicit((Object)(object)item.GetComponent<ZNetView>()))
				{
					__instance.m_prefabs.Add(item);
				}
			}
		}

		[HarmonyPriority(700)]
		internal static void Patch_FejdStartup(FejdStartup __instance)
		{
			Helpers._ZNetScene = __instance.m_objectDBPrefab.GetComponent<ZNetScene>();
			Helpers._ObjectDB = __instance.m_objectDBPrefab.GetComponent<ObjectDB>();
			foreach (Clone clone in Clones)
			{
				clone.Create();
			}
		}
	}
	public static class SpriteManager
	{
		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
		[return: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		public static Sprite RegisterSprite(string fileName, string folderName = "icons")
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = "RustyLoot." + folderName + "." + fileName;
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2);
			Sprite val2 = (ImageConversion.LoadImage(val, array) ? Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero) : null);
			if ((Object)(object)val2 != (Object)null)
			{
				((Object)val2).name = fileName;
			}
			return val2;
		}
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("RustyMods.RustyLoot", "RustyLoot", "0.0.2")]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	public class RustyLootPlugin : BaseUnityPlugin
	{
		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order = null;

			[UsedImplicitly]
			public bool? Browsable = null;

			[UsedImplicitly]
			[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
			public string Category = null;

			[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer = null;
		}

		internal const string ModName = "RustyLoot";

		internal const string ModVersion = "0.0.2";

		internal const string Author = "RustyMods";

		private const string ModGUID = "RustyMods.RustyLoot";

		private static readonly string ConfigFileName = "RustyMods.RustyLoot.cfg";

		private static readonly string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("RustyMods.RustyLoot");

		public static readonly ManualLogSource RustyLootLogger;

		public static readonly ConfigSync ConfigSync;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		private static ConfigEntry<Toggle> _addLogs;

		public static RustyLootPlugin instance;

		public static GameObject root;

		public static bool ShowLogs => _addLogs.Value == Toggle.On;

		public static void LogDebug(string message)
		{
			if (ShowLogs)
			{
				RustyLootLogger.LogDebug((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			if (ShowLogs)
			{
				RustyLootLogger.LogWarning((object)message);
			}
		}

		public static void LogError(string message)
		{
			RustyLootLogger.LogError((object)message);
		}

		public void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			instance = this;
			SetupConfigs();
			root = new GameObject("RustyLoot_Root");
			Object.DontDestroyOnLoad((Object)(object)root);
			root.SetActive(false);
			Localizer.Load();
			EpicLoot.logger.OnWarning += LogWarning;
			EpicLoot.logger.OnError += LogError;
			SetupMagicEffects();
			SetupSets();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
			MagicEffect.SetupWatcher();
			MagicSet.SetupWatcher();
		}

		public void SetupConfigs()
		{
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_addLogs = config("1 - General", "Show logs", Toggle.On, "If on, will show logs to show details of effects");
		}

		public void SetupLegendaryItems()
		{
			Mistweaver.Setup();
			Hafrnlight.Setup();
		}

		public void SetupSets()
		{
			Wayfarer.Setup();
			Hrafnstorm.Setup();
			Ulfheonar.Setup();
			Seidrweaver.Setup();
		}

		public void SetupMagicEffects()
		{
			PiercingShot.Setup();
			MagicProjectiles.SetupMagicArrow();
			MagicProjectiles.SetupMagicBolt();
			Seasonality.Setup();
			MistVision.Setup();
			ModifyTrinketDuration.Setup();
			SeaWolf.Setup();
			Rejuvenate.Setup();
			IronMaiden.Setup();
			ModifyAdrenaline.Setup();
			ModifyAdrenalineCost.Setup();
			Honeybound.Setup();
			AddArmor.Setup();
			Lifebloom.Setup();
			ForsakenBlow.Setup();
			Sturdy.Setup();
			Bleed.Setup();
			StaminaLeech.Setup();
		}

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

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

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

		public static ConfigEntry<T> config<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)instance).Config.Bind<T>(group, name, value, val);
			SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		public static ConfigEntry<T> config<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		static RustyLootPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			RustyLootLogger = Logger.CreateLogSource("RustyLoot");
			ConfigSync = new ConfigSync("RustyMods.RustyLoot")
			{
				DisplayName = "RustyLoot",
				CurrentVersion = "0.0.2",
				MinimumRequiredVersion = "0.0.2"
			};
			_serverConfigLocked = null;
			_addLogs = null;
			instance = null;
			root = null;
		}
	}
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	public class EffectListRef
	{
		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
		public class EffectDataRef
		{
			public readonly string prefabName;

			public int variant;

			public bool attach;

			public bool follow;

			public bool inheritParentRotation;

			public bool inheritParentScale;

			public bool multiplyParentVisualScale;

			public bool randomRotation;

			public bool scale;

			public string childTransform = string.Empty;

			[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
			private EffectData _data;

			public EffectDataRef(string prefabName)
			{
				this.prefabName = prefabName;
			}

			public EffectData ToEffectData()
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: 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
				if (_data != null)
				{
					return _data;
				}
				GameObject prefab = Helpers.GetPrefab(prefabName);
				if (prefab == null)
				{
					Debug.LogError((object)("Effect Data Reference invalid: " + prefabName));
					return new EffectData();
				}
				_data = new EffectData
				{
					m_prefab = prefab,
					m_variant = variant,
					m_attach = attach,
					m_follow = follow,
					m_inheritParentRotation = inheritParentRotation,
					m_inheritParentScale = inheritParentScale,
					m_multiplyParentVisualScale = multiplyParentVisualScale,
					m_randomRotation = randomRotation,
					m_scale = scale,
					m_childTransform = childTransform
				};
				return _data;
			}
		}

		private readonly List<EffectDataRef> dataRefs = new List<EffectDataRef>();

		private readonly List<EffectData> data = new List<EffectData>();

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private EffectList _effects;

		public EffectList Effects
		{
			get
			{
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Expected O, but got Unknown
				if (_effects != null)
				{
					return _effects;
				}
				foreach (EffectDataRef dataRef in dataRefs)
				{
					data.Add(dataRef.ToEffectData());
				}
				_effects = new EffectList();
				_effects.m_effectPrefabs = data.ToArray();
				return _effects;
			}
		}

		public GameObject[] Create(Vector3 basePos, Quaternion baseRot, [<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] Transform baseParent = null, float scale = 1f, int variant = -1)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Effects.Create(basePos, baseRot, baseParent, scale, variant);
		}

		public EffectListRef(params string[] effects)
		{
			Add(effects);
		}

		public EffectListRef(params EffectDataRef[] refs)
		{
			dataRefs.AddRange(refs);
		}

		public EffectListRef()
		{
		}

		public void Add(params string[] effects)
		{
			foreach (string prefabName in effects)
			{
				dataRefs.Add(new EffectDataRef(prefabName));
			}
		}

		public void Add(params EffectDataRef[] refs)
		{
			dataRefs.AddRange(refs);
		}
	}
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	public static class Extensions
	{
		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)]
		public class IgnoreEmptyValuesResolver : DefaultContractResolver
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				JsonProperty property = ((DefaultContractResolver)this).CreateProperty(member, memberSerialization);
				if (property.PropertyType == typeof(string))
				{
					property.ShouldSerialize = [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)] (object instance) =>
					{
						IValueProvider valueProvider2 = property.ValueProvider;
						string value = ((valueProvider2 != null) ? valueProvider2.GetValue(instance) : null) as string;
						return !string.IsNullOrWhiteSpace(value);
					};
					return property;
				}
				if (typeof(IEnumerable).IsAssignableFrom(property.PropertyType))
				{
					property.ShouldSerialize = [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)] (object instance) =>
					{
						IValueProvider valueProvider = property.ValueProvider;
						object obj = ((valueProvider != null) ? valueProvider.GetValue(instance) : null);
						if (obj == null)
						{
							return false;
						}
						if (obj is IEnumerable enumerable)
						{
							IEnumerator enumerator = enumerable.GetEnumerator();
							using (enumerator as IDisposable)
							{
								return enumerator.MoveNext();
							}
						}
						return true;
					};
				}
				return property;
			}
		}

		public static readonly JsonSerializerSettings serializationSettings = new JsonSerializerSettings
		{
			NullValueHandling = (NullValueHandling)1,
			DefaultValueHandling = (DefaultValueHandling)1,
			Formatting = (Formatting)1,
			ContractResolver = (IContractResolver)(object)new IgnoreEmptyValuesResolver(),
			Converters = { (JsonConverter)new StringEnumConverter() }
		};

		public static readonly JsonSerializerSettings deserializationSettings = new JsonSerializerSettings
		{
			MissingMemberHandling = (MissingMemberHandling)0,
			NullValueHandling = (NullValueHandling)1,
			ObjectCreationHandling = (ObjectCreationHandling)2,
			DefaultValueHandling = (DefaultValueHandling)2,
			Converters = { (JsonConverter)new StringEnumConverter() }
		};

		public static void CopyFieldsFrom<[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] T>(this T target, T source)
		{
			FieldInfo[] fields = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				object value = fieldInfo.GetValue(source);
				if (value != null)
				{
					fieldInfo.SetValue(target, value);
				}
			}
		}

		public static void All(this List<ItemRarity> list)
		{
			list.Add(ItemRarity.Magic, ItemRarity.Rare, ItemRarity.Epic, ItemRarity.Legendary, ItemRarity.Mythic);
		}
	}
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	public class Legendary
	{
		public readonly LegendaryInfo info;

		private static JsonSerializerSettings serializationSettings => Extensions.serializationSettings;

		private static JsonSerializerSettings deserializationSettings => Extensions.deserializationSettings;

		private static string legendaryFolderPath => MagicSet.legendaryFolderPath;

		public Legendary(LegendaryType type, string id)
		{
			string text = id.ToLower();
			info = new LegendaryInfo(type, id, "$mod_epicloot_" + text, "$mod_epicloot_" + text + "_desc");
		}

		public void Register(bool serialize = true)
		{
			info.Register();
			if (serialize)
			{
				Serialize();
			}
		}

		public void Serialize()
		{
			string path = info.ID + ".json";
			string text = Path.Combine(legendaryFolderPath, path);
			MagicSet.legendaries[text] = info;
			CustomSyncedValue<string> sync = new CustomSyncedValue<string>(RustyLootPlugin.ConfigSync, "RustyLoot.SyncedFiles.LegendaryItems." + info.ID);
			sync.ValueChanged += delegate
			{
				if (Object.op_Implicit((Object)(object)ZNet.instance) && !ZNet.instance.IsServer() && !string.IsNullOrEmpty(sync.Value))
				{
					LegendaryInfo legendaryInfo = JsonConvert.DeserializeObject<LegendaryInfo>(sync.Value, deserializationSettings);
					if (legendaryInfo != null)
					{
						info.CopyFieldsFrom(legendaryInfo);
						info.Update();
						RustyLootPlugin.LogDebug("Updated " + info.ID);
					}
				}
			};
			MagicSet.syncedItems[info] = sync;
			if (File.Exists(text))
			{
				MagicSet.DeserializeItem(text);
				return;
			}
			string contents = JsonConvert.SerializeObject((object)info, serializationSettings);
			File.WriteAllText(text, contents);
		}
	}
	public static class Hafrnlight
	{
		public static void Setup()
		{
			Legendary legendary = new Legendary(LegendaryType.Legendary, "Hafrnlight");
			legendary.info.GuaranteedEffectCount = 6;
			legendary.info.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect("MistVision"));
			legendary.info.Requirements.AllowedItemNames.Add("$item_demister");
			legendary.info.Requirements.AllowedRarities.Add(ItemRarity.Legendary, ItemRarity.Mythic);
			legendary.Register();
		}
	}
	public static class Mistweaver
	{
		public static void Setup()
		{
			Legendary legendary = new Legendary(LegendaryType.Legendary, "Mistweaver");
			legendary.info.GuaranteedEffectCount = 6;
			legendary.info.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect("MagicArrow"), new GuaranteedMagicEffect(EffectType.Weightless), new GuaranteedMagicEffect(EffectType.AddBowsSkill, 10f, 20f));
			legendary.info.Requirements.AllowedSkillTypes.Add((SkillType)8);
			legendary.info.Requirements.AllowedRarities.Add(ItemRarity.Legendary, ItemRarity.Mythic);
			legendary.Register();
		}
	}
	public static class Hrafnstorm
	{
		[HarmonyPatch(typeof(Projectile), "OnHit")]
		private static class Projectile_OnHit_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Prefix(Projectile __instance)
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Invalid comparison between Unknown and I4
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Expected O, but got Unknown
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				Character owner = __instance.m_owner;
				Player val = (Player)(object)((owner is Player) ? owner : null);
				if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && (int)__instance.m_type == 1)
				{
					Projectile obj = __instance;
					obj.m_onHit = (OnProjectileHit)Delegate.Combine((Delegate?)(object)obj.m_onHit, (Delegate?)(OnProjectileHit)delegate(Collider collider, Vector3 point, bool water)
					{
						//IL_0013: Unknown result type (might be due to invalid IL or missing references)
						Hrafnstorm.OnHit?.Invoke(__instance, collider, point, water);
					});
				}
			}
		}

		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
		public class HrafnstormProxy : Proxy
		{
			public override void Initialize(Player player, string id, float cooldown)
			{
				base.Initialize(player, id, cooldown);
				OnHit += OnProjectileHit;
			}

			public override void OnRemoved()
			{
				OnHit -= OnProjectileHit;
			}

			private void OnProjectileHit(Projectile source, [<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] Collider collider, Vector3 hitPoint, bool water)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: 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_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				GameObject prefab = ZNetScene.instance.GetPrefab(((Object)source).name.Replace("(Clone)", string.Empty));
				if (prefab != null)
				{
					HitData val = new HitData
					{
						m_damage = source.m_originalHitData.m_damage,
						m_pushForce = source.m_originalHitData.m_pushForce,
						m_backstabBonus = source.m_originalHitData.m_backstabBonus,
						m_ranged = true,
						m_hitType = (HitType)2
					};
					val.SetAttacker((Character)(object)Player);
					val.ApplyModifier(0.5f);
					if (TryTrigger(prefab, hitPoint, val))
					{
						SetCooldownEndTime(Proxy.GetTime() - Cooldown);
					}
				}
			}

			private static bool TryTrigger(GameObject projectile, Vector3 pos, HitData hitData)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//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)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				Projectile val4 = default(Projectile);
				for (int i = 0; i < 10; i++)
				{
					float num = Random.Range(3f, 10f);
					Vector2 val = Random.insideUnitCircle * num;
					Vector3 val2 = pos + new Vector3(val.x, Random.Range(35f, 55f), val.y);
					GameObject val3 = Object.Instantiate<GameObject>(projectile.gameObject, val2, Quaternion.identity);
					if (val3.TryGetComponent<Projectile>(ref val4))
					{
						Vector3 val5 = pos - val2;
						Vector3 normalized = ((Vector3)(ref val5)).normalized;
						float num2 = Random.Range(25f, 35f);
						Vector3 val6 = normalized * num2;
						val4.Setup((Character)null, val6, 10f, hitData, (ItemData)null, (ItemData)null);
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static class ObjectDB_Awake_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(ObjectDB __instance)
			{
				GameObject itemPrefab = __instance.GetItemPrefab("ArrowWood");
				ItemDrop val = default(ItemDrop);
				if (itemPrefab != null && itemPrefab.TryGetComponent<ItemDrop>(ref val))
				{
					EpicLoot.RegisterAsset("ArrowWood", val.m_itemData.GetIcon());
				}
			}
		}

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1, 2 })]
		[method: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1, 2 })]
		[field: <4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(new byte[] { 2, 1, 2 })]
		public static event Action<Projectile, Collider, Vector3, bool> OnHit;

		public static void Setup()
		{
			Sprite asset = SpriteManager.RegisterSprite("bow_wood1.png");
			EpicLoot.RegisterAsset("HunterBow", asset);
			AbilityProxyDefinition abilityProxyDefinition = new AbilityProxyDefinition("ArrowRain", AbilityActivationMode.Triggerable, typeof(HrafnstormProxy));
			abilityProxyDefinition.Ability.IconAsset = "HunterBow";
			abilityProxyDefinition.Ability.Cooldown = 10f;
			abilityProxyDefinition.Register();
			MagicEffect magicEffect = new MagicEffect("ArrowRain");
			magicEffect.Requirements.NoRoll = true;
			magicEffect.Ability = "ArrowRain";
			magicEffect.Register();
			LegendaryInfo legendaryInfo = new LegendaryInfo(LegendaryType.Legendary, "HunterChest", "$mod_epicloot_hunterchest", "$mod_epicloot_hunterchest_desc");
			legendaryInfo.Requirements.AddAllowedItemTypes((ItemType)7);
			legendaryInfo.GuaranteedEffectCount = 6;
			LegendaryInfo legendaryInfo2 = new LegendaryInfo(LegendaryType.Legendary, "HunterLegs", "$mod_epicloot_hunterlegs", "$mod_epicloot_hunterlegs_desc");
			legendaryInfo2.Requirements.AddAllowedItemTypes((ItemType)11);
			legendaryInfo2.GuaranteedEffectCount = 6;
			LegendaryInfo legendaryInfo3 = new LegendaryInfo(LegendaryType.Legendary, "HunterCape", "$mod_epicloot_huntercape", "$mod_epicloot_huntercape_desc");
			legendaryInfo3.Requirements.AddAllowedItemTypes((ItemType)17);
			legendaryInfo3.GuaranteedEffectCount = 6;
			LegendaryInfo legendaryInfo4 = new LegendaryInfo(LegendaryType.Legendary, "HunterHelmet", "$mod_epicloot_hunterhelmet", "$mod_epicloot_hunterhelmet_desc");
			legendaryInfo4.Requirements.AddAllowedItemTypes((ItemType)6);
			legendaryInfo4.GuaranteedEffectCount = 6;
			MagicSet magicSet = new MagicSet("HunterSet", LegendaryType.Mythic);
			magicSet.AddItems(legendaryInfo4, legendaryInfo, legendaryInfo2, legendaryInfo3);
			magicSet.SetBonuses.Add(2, EffectType.AddBowsSkill, 10f, 20f);
			magicSet.SetBonuses.Add(3, EffectType.ModifyDodgeStaminaUse, 10f, 20f);
			magicSet.SetBonuses.Add(4, "ArrowRain");
			magicSet.Register();
			magicSet.Serialize();
		}
	}
	public static class Seidrweaver
	{
		public class SE_Seidrweaver : SE_Stats
		{
		}

		public class SiedrweaverProxy : Proxy
		{
			public override void Activate()
			{
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				if (!((Character)Player).HaveEitr(30f))
				{
					Hud.instance.EitrBarEmptyFlash();
				}
				else
				{
					if (IsOnCooldown())
					{
						return;
					}
					SetCooldownEndTime(Proxy.GetTime() + Cooldown);
					List<Player> list = new List<Player>();
					Player.GetPlayersInRange(((Component)Player).transform.position, 50f, list);
					list.Add(Player);
					foreach (Player item in list)
					{
						((Character)item).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Seidrweaver"), true, 0, 0f);
					}
					healEffect.Create(((Character)Player).GetHeadPoint(), Quaternion.identity);
				}
			}
		}

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(1)]
		private static readonly EffectListRef healEffect = new EffectListRef("fx_DvergerMage_Nova_ring");

		public static void Setup()
		{
			Sprite val = SpriteManager.RegisterSprite("mushroom_big_red.png");
			SE_Seidrweaver sE_Seidrweaver = ScriptableObject.CreateInstance<SE_Seidrweaver>();
			((Object)sE_Seidrweaver).name = "SE_Seidrweaver";
			((StatusEffect)sE_Seidrweaver).m_name = "$mod_epicloot_siedrweaver";
			((StatusEffect)sE_Seidrweaver).m_tooltip = "$mod_epicloot_siedrweaver_desc";
			((SE_Stats)sE_Seidrweaver).m_healthOverTime = 200f;
			((SE_Stats)sE_Seidrweaver).m_healthOverTimeInterval = 1f;
			((StatusEffect)sE_Seidrweaver).m_ttl = 120f;
			((StatusEffect)sE_Seidrweaver).m_icon = val;
			((StatusEffect)(object)sE_Seidrweaver).Register();
			EpicLoot.RegisterAsset("Siedrweaver", val);
			LegendaryInfo legendaryInfo = new LegendaryInfo(LegendaryType.Mythic, "SiedrweaverHelmet", "$mod_epicloot_siedrweaver_helm", "$mod_epicloot_siedrweaver_helm_desc");
			legendaryInfo.Requirements.AddAllowedItemTypes((ItemType)6);
			legendaryInfo.GuaranteedEffectCount = 6;
			legendaryInfo.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.IncreaseEitr, 15f, 20f), new GuaranteedMagicEffect(EffectType.ModifyEitrRegen, 10f, 20f));
			LegendaryInfo legendaryInfo2 = new LegendaryInfo(LegendaryType.Mythic, "SiedrweaverCape", "$mod_epicloot_siedrweaver_cape", "$mod_epicloot_siedrweaver_cape_desc");
			legendaryInfo2.Requirements.AddAllowedItemTypes((ItemType)17);
			legendaryInfo2.GuaranteedEffectCount = 6;
			legendaryInfo2.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.AddBloodMagicSkill, 10f, 20f), new GuaranteedMagicEffect(EffectType.ModifyAttackEitrUse, 10f, 20f));
			LegendaryInfo legendaryInfo3 = new LegendaryInfo(LegendaryType.Mythic, "SiedrweaverLegs", "$mod_epicloot_siedrweaver_legs", "$mod_epicloot_siedrweaver_legs_desc");
			legendaryInfo3.Requirements.AddAllowedItemTypes((ItemType)11);
			legendaryInfo3.GuaranteedEffectCount = 6;
			legendaryInfo3.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.ModifyEitrRegenLowHealth, 10f, 20f), new GuaranteedMagicEffect(EffectType.EitrWeave, 10f, 20f));
			LegendaryInfo legendaryInfo4 = new LegendaryInfo(LegendaryType.Mythic, "SiedrweaverChest", "$mod_epicloot_siedrweaver_chest", "$mod_epicloot_siedrweaver_chest_desc");
			legendaryInfo4.Requirements.AddAllowedItemTypes((ItemType)7);
			legendaryInfo4.GuaranteedEffectCount = 6;
			legendaryInfo4.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.ModifyElementalDamage, 10f, 20f), new GuaranteedMagicEffect(EffectType.AddElementalResistancePercentage, 10f, 20f));
			MagicSet magicSet = new MagicSet("Siedrweaver", LegendaryType.Mythic);
			magicSet.AddItems(legendaryInfo, legendaryInfo4, legendaryInfo3, legendaryInfo2);
			magicSet.SetBonuses.Add(2, EffectType.IncreaseEitr, 10f, 20f);
			magicSet.SetBonuses.Add(2, EffectType.ModifyEitrRegen, 10f, 20f);
			magicSet.SetBonuses.Add(3, EffectType.AddBloodMagicSkill, 10f, 25f);
			magicSet.SetBonuses.Add(4, "Siedrweaver");
			magicSet.Register();
			magicSet.Serialize();
			AbilityProxyDefinition abilityProxyDefinition = new AbilityProxyDefinition("Siedrweaver", AbilityActivationMode.Activated, typeof(SiedrweaverProxy));
			abilityProxyDefinition.Ability.Cooldown = 600f;
			abilityProxyDefinition.Ability.IconAsset = "Siedrweaver";
			abilityProxyDefinition.Register();
			MagicItemEffectDefinition magicItemEffectDefinition = new MagicItemEffectDefinition("Siedrweaver", "$mod_epicloot_siedrweaver_desc", "$mod_epicloot_siedrweaver_desc");
			magicItemEffectDefinition.Requirements.NoRoll = true;
			magicItemEffectDefinition.Ability = "Siedrweaver";
			magicItemEffectDefinition.Register();
		}
	}
	public static class Ulfheonar
	{
		public class UlfheonarProxy : Proxy
		{
			public override void Activate()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				if (IsOnCooldown())
				{
					return;
				}
				SetCooldownEndTime(Proxy.GetTime() + Cooldown);
				List<Player> list = new List<Player>();
				Player.GetPlayersInRange(((Component)Player).transform.position, 50f, list);
				list.Add(Player);
				foreach (Player item in list)
				{
					((Character)item).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Flamethrower"), true, 0, 0f);
				}
			}
		}

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
		[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
		public class SE_Flamethrower : SE_Stats
		{
			public float damageModifier = 1.1f;

			public override void Setup(Character character)
			{
				((SE_Stats)this).Setup(character);
				Trigger();
			}

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

			public override string GetTooltipString()
			{
				string tooltipString = ((SE_Stats)this).GetTooltipString();
				return tooltipString + $"\n$mod_epicloot_damage_taken: <color=orange>+{(damageModifier - 1f) * 100f}</color>%";
			}

			public void Trigger()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: 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)
				Vector3 headPoint = ((StatusEffect)this).m_character.GetHeadPoint();
				Quaternion lookYaw = ((StatusEffect)this).m_character.GetLookYaw();
				Vector3 val = lookYaw * Vector3.forward;
				HitData val2 = new HitData();
				val2.SetAttacker(((StatusEffect)this).m_character);
				val2.m_damage.m_fire = 50f;
				val2.m_damage.m_chop = 20f;
				flamethrowerEffects.Create(headPoint, lookYaw, ((StatusEffect)this).m_character.m_head, 1f, -1);
				Collider[] array = (Collider[])(object)new Collider[10];
				int num = Physics.OverlapSphereNonAlloc(headPoint + val * 5f, 3f, array);
				for (int i = 0; i < num; i++)
				{
					Collider val3 = array[i];
					IDestructible componentInParent = ((Component)val3).GetComponentInParent<IDestructible>();
					if (componentInParent == null)
					{
						continue;
					}
					Vector3 val4 = ((Component)val3).transform.position - headPoint;
					Vector3 normalized = ((Vector3)(ref val4)).normalized;
					float num2 = Vector3.Angle(val, normalized);
					if (num2 <= 45f)
					{
						float num3 = Vector3.Distance(headPoint, ((Component)val3).transform.position);
						if (num3 <= 10f)
						{
							componentInParent.Damage(val2);
						}
					}
				}
			}
		}

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(1)]
		private static readonly EffectList flamethrowerEffects = new EffectList();

		public static void Setup()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			GameObject val = AssetBundleManager.LoadAsset<GameObject>("ascension_bundle", "vfx_flamethrower_purple");
			Transform transform = val.transform;
			transform.localScale *= 1.2f;
			PrefabManager.RegisterPrefab(val);
			flamethrowerEffects.m_effectPrefabs = new List<EffectData>
			{
				new EffectData
				{
					m_prefab = val,
					m_attach = true
				}
			}.ToArray();
			Sprite val2 = SpriteManager.RegisterSprite("bone_skull.png");
			EpicLoot.RegisterAsset("BoneSkull", val2);
			SE_Flamethrower sE_Flamethrower = ScriptableObject.CreateInstance<SE_Flamethrower>();
			((Object)sE_Flamethrower).name = "SE_Flamethrower";
			((StatusEffect)sE_Flamethrower).m_name = "$mod_epicloot_ulfheonar";
			((StatusEffect)sE_Flamethrower).m_tooltip = "$mod_epicloot_ulfheonar_desc";
			((SE_Stats)sE_Flamethrower).m_speedModifier = 0.2f;
			((SE_Stats)sE_Flamethrower).m_percentigeDamageModifiers.m_blunt = 0.5f;
			((SE_Stats)sE_Flamethrower).m_percentigeDamageModifiers.m_pierce = 0.5f;
			((SE_Stats)sE_Flamethrower).m_percentigeDamageModifiers.m_slash = 0.5f;
			((StatusEffect)sE_Flamethrower).m_ttl = 300f;
			((StatusEffect)sE_Flamethrower).m_icon = val2;
			((StatusEffect)(object)sE_Flamethrower).Register();
			LegendaryInfo legendaryInfo = new LegendaryInfo(LegendaryType.Mythic, "UlfheonarHelmet", "$mod_epicloot_ulfheonar_helm", "$mod_epicloot_ulfheonar_helm_desc");
			legendaryInfo.Requirements.AddAllowedItemTypes((ItemType)6);
			legendaryInfo.GuaranteedEffectCount = 6;
			legendaryInfo.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.ModifyDamageLowHealth, 15f, 20f), new GuaranteedMagicEffect(EffectType.AvoidDamageTakenLowHealth, 10f, 20f));
			LegendaryInfo legendaryInfo2 = new LegendaryInfo(LegendaryType.Mythic, "UlfheonarCape", "$mod_epicloot_ulfheonar_cape", "$mod_epicloot_ulfheonar_cape_desc");
			legendaryInfo2.Requirements.AddAllowedItemTypes((ItemType)7);
			legendaryInfo2.GuaranteedEffectCount = 6;
			legendaryInfo2.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.ModifyPhysicalDamage, 10f, 20f), new GuaranteedMagicEffect(EffectType.ModifyStaggerDuration, 10f, 20f));
			LegendaryInfo legendaryInfo3 = new LegendaryInfo(LegendaryType.Mythic, "UlfheonarLegs", "$mod_epicloot_ulfheonar_legs", "$mod_epicloot_ulfheonar_legs_desc");
			legendaryInfo3.Requirements.AddAllowedItemTypes((ItemType)11);
			legendaryInfo3.GuaranteedEffectCount = 6;
			legendaryInfo3.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.ModifyMovementSpeedLowHealth, 10f, 20f), new GuaranteedMagicEffect(EffectType.AvoidDamageTakenLowHealth, 10f, 20f));
			LegendaryInfo legendaryInfo4 = new LegendaryInfo(LegendaryType.Mythic, "UlfheonarClaws", "$mod_epicloot_ulfheonar_claws", "$mod_epicloot_ulfheonar_claws_desc");
			legendaryInfo4.Requirements.AddAllowedItemTypes((ItemType)14);
			legendaryInfo4.Requirements.AllowedSkillTypes.Add((SkillType)11);
			legendaryInfo4.GuaranteedEffectCount = 6;
			legendaryInfo4.GuaranteedMagicEffects.Add(new GuaranteedMagicEffect(EffectType.AddUnarmedSkill, 10f, 20f), new GuaranteedMagicEffect(EffectType.ModifyAttackSpeed, 10f, 20f));
			MagicSet magicSet = new MagicSet("Ulfheonar", LegendaryType.Mythic);
			magicSet.AddItems(legendaryInfo, legendaryInfo4, legendaryInfo3, legendaryInfo2);
			magicSet.SetBonuses.Add(2, EffectType.AddMovementSkills, 10f, 20f);
			magicSet.SetBonuses.Add(2, EffectType.IncreaseHeatResistance, 10f, 20f);
			magicSet.SetBonuses.Add(3, EffectType.ModifyDamage, 10f, 25f);
			magicSet.SetBonuses.Add(4, "Ulfheonar");
			magicSet.Register();
			magicSet.Serialize();
			AbilityProxyDefinition abilityProxyDefinition = new AbilityProxyDefinition("Ulfheonar", AbilityActivationMode.Activated, typeof(UlfheonarProxy));
			abilityProxyDefinition.Ability.Cooldown = 600f;
			abilityProxyDefinition.Ability.IconAsset = "BoneSkull";
			abilityProxyDefinition.Register();
			MagicItemEffectDefinition magicItemEffectDefinition = new MagicItemEffectDefinition("Ulfheonar", "$mod_epicloot_ulfheonar_desc", "$mod_epicloot_ulfheonar_desc");
			magicItemEffectDefinition.Requirements.NoRoll = true;
			magicItemEffectDefinition.Ability = "Ulfheonar";
			magicItemEffectDefinition.Register();
		}
	}
	public static class Wayfarer
	{
		public class WayfarerProxy : Proxy
		{
			public override void Activate()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				if (IsOnCooldown())
				{
					return;
				}
				SetCooldownEndTime(Proxy.GetTime() + Cooldown);
				List<Player> list = new List<Player>();
				Player.GetPlayersInRange(((Component)Player).transform.position, 10f, list);
				list.Add(Player);
				foreach (Player item in list)
				{
					((Character)item).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Wayfarer"), true, 0, 0f);
				}
			}
		}

		public class SE_Wayfarer : SE_Stats
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			public override void Setup(Character character)
			{
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null)
				{
					((StatusEffect)this).m_startEffects = val.m_skillLevelupEffects;
				}
				((SE_Stats)this).Setup(character);
			}
		}

		[HarmonyPatch(typeof(Player), "GetEquipmentMovementModifier")]
		private static class Wayfarer_Player_GetEquipmentMovementModifier
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Player __instance, ref float __result)
			{
				if (!(__result > 0f) && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Wayfarer")))
				{
					__result = 0f;
				}
			}
		}

		public static void Setup()
		{
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			LegendaryInfo legendaryInfo = new LegendaryInfo(LegendaryType.Mythic, "WayfarerHelmet", "$mod_epicloot_wayfarer_helm", "$mod_epicloot_wayfarer_helm_desc");
			legendaryInfo.Requirements.AddAllowedItemTypes((ItemType)6);
			legendaryInfo.GuaranteedEffectCount = 6;
			LegendaryInfo legendaryInfo2 = new LegendaryInfo(LegendaryType.Mythic, "WayfarerChest", "$mod_epicloot_wayfarer_chest", "$mod_epicloot_wayfarer_chest_desc");
			legendaryInfo2.Requirements.AddAllowedItemTypes((ItemType)7);
			legendaryInfo2.GuaranteedEffectCount = 6;
			LegendaryInfo legendaryInfo3 = new LegendaryInfo(LegendaryType.Mythic, "WayfarerLegs", "$mod_epicloot_wayfarer_legs", "$mod_epicloot_wayfarer_legs_desc");
			legendaryInfo3.Requirements.AddAllowedItemTypes((ItemType)11);
			legendaryInfo3.GuaranteedEffectCount = 6;
			LegendaryInfo legendaryInfo4 = new LegendaryInfo(LegendaryType.Mythic, "WayfarerCape", "$mod_epicloot_wayfarer_cape", "$mod_epicloot_wayfarer_cape_desc");
			legendaryInfo4.Requirements.AddAllowedItemTypes((ItemType)17);
			legendaryInfo4.GuaranteedEffectCount = 6;
			MagicSet magicSet = new MagicSet("Wayfarer", LegendaryType.Mythic);
			magicSet.AddItems(legendaryInfo, legendaryInfo2, legendaryInfo3, legendaryInfo4);
			magicSet.SetBonuses.Add(2, EffectType.AddMovementSkills, 10f, 20f);
			magicSet.SetBonuses.Add(2, EffectType.AddPhysicalResistancePercentage, 10f, 20f);
			magicSet.SetBonuses.Add(3, EffectType.ModifyDiscoveryRadius, 10f, 25f);
			magicSet.SetBonuses.Add(4, "Wayfarer");
			magicSet.Register();
			magicSet.Serialize();
			Sprite val = SpriteManager.RegisterSprite("cape_hood_darkyellow.png");
			EpicLoot.RegisterAsset("CapeHood", val);
			AbilityProxyDefinition abilityProxyDefinition = new AbilityProxyDefinition("Wayfarer", AbilityActivationMode.Activated, typeof(WayfarerProxy));
			abilityProxyDefinition.Ability.Cooldown = 600f;
			abilityProxyDefinition.Ability.IconAsset = "CapeHood";
			abilityProxyDefinition.Register();
			MagicItemEffectDefinition magicItemEffectDefinition = new MagicItemEffectDefinition("Wayfarer", "$mod_epicloot_wayfarer_desc", "$mod_epicloot_wayfarer_desc");
			magicItemEffectDefinition.Requirements.NoRoll = true;
			magicItemEffectDefinition.Ability = "Wayfarer";
			magicItemEffectDefinition.Register();
			SE_Wayfarer sE_Wayfarer = ScriptableObject.CreateInstance<SE_Wayfarer>();
			((Object)sE_Wayfarer).name = "SE_Wayfarer";
			((StatusEffect)sE_Wayfarer).m_ttl = 300f;
			((StatusEffect)sE_Wayfarer).m_name = "$mod_epicloot_wayfarer";
			((StatusEffect)sE_Wayfarer).m_tooltip = "$mod_epicloot_wayfarer_desc";
			((SE_Stats)sE_Wayfarer).m_addMaxCarryWeight = 300f;
			((StatusEffect)sE_Wayfarer).m_attributes = (StatusAttribute)4;
			((StatusEffect)sE_Wayfarer).m_icon = val;
			((StatusEffect)(object)sE_Wayfarer).Register();
		}
	}
	[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
	[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(0)]
	public class MagicEffect
	{
		private const string folderName = "RustyLoot";

		private const string effectFolderName = "MagicEffects";

		private static readonly string folderPath = Path.Combine(Paths.ConfigPath, "RustyLoot");

		private static readonly string effectFolderPath = Path.Combine(folderPath, "MagicEffects");

		private static readonly Dictionary<string, MagicItemEffectDefinition> effects = new Dictionary<string, MagicItemEffectDefinition>();

		private static readonly Dictionary<string, ConfigEntry<Toggle>> noRollConfigs = new Dictionary<string, ConfigEntry<Toggle>>();

		private static readonly Dictionary<string, ConfigEntry<Toggle>> showLogConfigs = new Dictionary<string, ConfigEntry<Toggle>>();

		public static readonly List<MagicEffect> MagicEffects = new List<MagicEffect>();

		public static Dictionary<MagicItemEffectDefinition, CustomSyncedValue<string>> syncedEffects = new Dictionary<MagicItemEffectDefinition, CustomSyncedValue<string>>();

		public readonly MagicItemEffectDefinition definition;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		public ConfigEntry<Toggle> noRollConfig;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		public ConfigEntry<Toggle> showLogs;

		private static JsonSerializerSettings serializationSettings => Extensions.serializationSettings;

		private static JsonSerializerSettings deserializationSettings => Extensions.deserializationSettings;

		public MagicItemEffectRequirements Requirements => definition.Requirements;

		public ValuesPerRarityDef ValuesPerRarity => definition.ValuesPerRarity;

		public string Ability
		{
			set
			{
				definition.Ability = value;
			}
		}

		public MagicEffect(string effectType)
		{
			string text = effectType.ToLower();
			string displayText = "$mod_epicloot_" + text;
			string description = "$mod_epicloot_" + text + "_desc";
			definition = new MagicItemEffectDefinition(effectType, displayText, description);
			MagicEffects.Add(this);
		}

		public bool IsEnabled()
		{
			Toggle? toggle = noRollConfig?.Value;
			return toggle.HasValue && toggle.GetValueOrDefault() == Toggle.On;
		}

		public bool ShowLogs()
		{
			Toggle? toggle = showLogs?.Value;
			return toggle.HasValue && toggle.GetValueOrDefault() == Toggle.On;
		}

		public void Register(bool serialize = true, bool configs = true)
		{
			definition.Register();
			if (serialize)
			{
				Serialize();
			}
			if (configs)
			{
				SetupConfigs();
			}
		}

		private void SetupConfigs()
		{
			noRollConfig = RustyLootPlugin.config("Magic Effects", definition.Type, Toggle.On, "If on, " + definition.Type + " has chance to roll");
			noRollConfig.SettingChanged += [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (object _, EventArgs _) =>
			{
				definition.Requirements.NoRoll = noRollConfig.Value == Toggle.Off;
				definition.Update();
			};
			noRollConfigs[definition.Type] = noRollConfig;
			showLogs = RustyLootPlugin.config("Logs", definition.Type, Toggle.Off, "If on, " + definition.Type + " will display detailed logs");
			showLogConfigs[definition.Type] = showLogs;
		}

		private void Serialize()
		{
			if (!Directory.Exists(folderPath))
			{
				Directory.CreateDirectory(folderPath);
			}
			if (!Directory.Exists(effectFolderPath))
			{
				Directory.CreateDirectory(effectFolderPath);
			}
			string path = definition.Type + ".json";
			string text = Path.Combine(effectFolderPath, path);
			effects[text] = definition;
			CustomSyncedValue<string> customSyncedValue = new CustomSyncedValue<string>(RustyLootPlugin.ConfigSync, "RustyLoot.SyncedFiles.MagicEffects." + definition.Type, "");
			customSyncedValue.ValueChanged += delegate
			{
				OnServerSyncFileChanged(definition);
			};
			syncedEffects[definition] = customSyncedValue;
			if (File.Exists(text))
			{
				DeserializeEffect(text);
				return;
			}
			string contents = JsonConvert.SerializeObject((object)definition, serializationSettings);
			File.WriteAllText(text, contents);
		}

		public static void SyncEffect(MagicItemEffectDefinition definition)
		{
			if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer() && syncedEffects.TryGetValue(definition, out var value))
			{
				string value2 = JsonConvert.SerializeObject((object)definition, Extensions.serializationSettings);
				value.Value = value2;
			}
		}

		private static void OnServerSyncFileChanged(MagicItemEffectDefinition definition)
		{
			if (Object.op_Implicit((Object)(object)ZNet.instance) && !ZNet.instance.IsServer() && syncedEffects.TryGetValue(definition, out var value) && !string.IsNullOrEmpty(value.Value))
			{
				MagicItemEffectDefinition magicItemEffectDefinition = JsonConvert.DeserializeObject<MagicItemEffectDefinition>(value.Value, deserializationSettings);
				if (magicItemEffectDefinition != null)
				{
					definition.CopyFieldsFrom(magicItemEffectDefinition);
					definition.Update();
					RustyLootPlugin.LogDebug("Updated " + definition.Type);
				}
			}
		}

		private static void DeserializeEffect(string filePath)
		{
			if (File.Exists(filePath) && effects.TryGetValue(filePath, out var value))
			{
				string text = File.ReadAllText(filePath);
				MagicItemEffectDefinition source = JsonConvert.DeserializeObject<MagicItemEffectDefinition>(text, deserializationSettings);
				value.CopyFieldsFrom(source);
				value.Update();
				SyncEffect(value);
			}
		}

		public static void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(effectFolderPath, "*.json");
			fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
			fileSystemWatcher.EnableRaisingEvents = true;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.Changed += [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(0)] (object _, FileSystemEventArgs e) =>
			{
				RustyLootPlugin.RustyLootLogger.LogDebug((object)("File changed: " + Path.GetFileName(e.FullPath)));
				DeserializeEffect(e.FullPath);
			};
		}

		public static bool IsEnabled(string effectType)
		{
			ConfigEntry<Toggle> value;
			return noRollConfigs.TryGetValue(effectType, out value) && value.Value == Toggle.On;
		}

		public static bool ShowLogs(string effectType)
		{
			ConfigEntry<Toggle> value;
			return showLogConfigs.TryGetValue(effectType, out value) && value.Value == Toggle.On;
		}
	}
	public static class AddArmor
	{
		[HarmonyPatch(typeof(ItemData), "GetArmor", new Type[]
		{
			typeof(int),
			typeof(float)
		})]
		private static class AddArmor_ItemData_GetAmor_Patch
		{
			[HarmonyPriority(800)]
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(ItemData __instance, ref float __result)
			{
				if (!effect.IsEnabled())
				{
					return;
				}
				MagicItem magicItem = __instance.GetMagicItem();
				if (magicItem == null)
				{
					return;
				}
				MagicItemEffect magicItemEffect = magicItem.Effects.FirstOrDefault((MagicItemEffect x) => x.EffectType == "AddArmor");
				if (magicItemEffect != null)
				{
					float effectValue = magicItemEffect.EffectValue;
					float num = __result;
					__result += effectValue;
					if (effect.ShowLogs())
					{
						RustyLootPlugin.LogDebug($"[AddArmor] item:{__instance.m_shared.m_name} base:{num:0.#} +{effectValue:0.#} => {__result:0.#}");
					}
				}
			}
		}

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(1)]
		private static MagicEffect effect;

		public static void Setup()
		{
			effect = new MagicEffect("AddArmor");
			MagicItemEffectRequirements requirements = effect.Requirements;
			ItemType[] array = new ItemType[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			requirements.AddAllowedItemTypes((ItemType[])(object)array);
			effect.Requirements.AllowedRarities.All();
			effect.ValuesPerRarity.Magic.Set(1f, 2f);
			effect.ValuesPerRarity.Rare = new ValueDef(1f, 3f, 1f);
			effect.ValuesPerRarity.Epic = new ValueDef(1f, 4f, 1f);
			effect.ValuesPerRarity.Legendary = new ValueDef(1f, 5f, 1f);
			effect.ValuesPerRarity.Mythic = new ValueDef(1f, 6f, 1f);
			effect.Register();
		}
	}
	public static class Bleed
	{
		public class SE_Bleed : StatusEffect
		{
			public float damageTimer;

			public float damagePerTick = 1f;

			public float maxDamagePerTick = 10f;

			[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
			public Character attacker;

			public override void UpdateStatusEffect(float dt)
			{
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Expected O, but got Unknown
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				((StatusEffect)this).UpdateStatusEffect(dt);
				if (damagePerTick <= 0f)
				{
					return;
				}
				damageTimer += dt;
				if (!(damageTimer < 1f))
				{
					damageTimer = 0f;
					HitData val = new HitData();
					val.m_hitType = (HitType)14;
					if ((Object)(object)attacker != (Object)null)
					{
						val.SetAttacker(attacker);
					}
					val.m_damage.m_damage = damagePerTick;
					base.m_character.Damage(val);
					WorldText.instance?.ShowText(base.m_character.GetTopPoint(), $"{damagePerTick} $mod_epicloot_bleed_msg", Color.red);
					damagePerTick -= 1f;
					if (damagePerTick <= 0f)
					{
						base.m_ttl = 0f;
					}
				}
			}

			public void Increment()
			{
				damagePerTick = Mathf.Max(damagePerTick + 1f, maxDamagePerTick);
				((StatusEffect)this).ResetTime();
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class Bleed_Character_RPC_Damage
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Character __instance, HitData hit)
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Invalid comparison between Unknown and I4
				if (!MagicEffect.IsEnabled("Bleed"))
				{
					return;
				}
				Character attacker = hit.GetAttacker();
				Player val = (Player)(object)((attacker is Player) ? attacker : null);
				if (val == null || (int)hit.m_hitType == 14 || !val.HasActiveMagicEffect("Bleed", out var effectValue, 0.01f))
				{
					return;
				}
				float num = Mathf.Clamp01(effectValue);
				float value = Random.value;
				bool flag = num > value;
				if (flag)
				{
					if (__instance.GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Bleed")) is SE_Bleed sE_Bleed)
					{
						sE_Bleed.Increment();
						sE_Bleed.attacker = (Character)(object)val;
					}
					else
					{
						SE_Bleed sE_Bleed2 = (SE_Bleed)(object)__instance.GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Bleed"), false, 0, 0f);
						sE_Bleed2.attacker = (Character)(object)val;
					}
				}
				if (MagicEffect.ShowLogs("Bleed"))
				{
					RustyLootPlugin.LogDebug($"[Bleed]: attacker: {val.GetPlayerName()}, chance: {num}({num * 100f}), roll: {value}, trigger: {flag}");
				}
			}
		}

		public static void Setup()
		{
			SE_Bleed sE_Bleed = ScriptableObject.CreateInstance<SE_Bleed>();
			((Object)sE_Bleed).name = "SE_Bleed";
			((StatusEffect)sE_Bleed).m_name = "$mod_epicloot_bleed";
			((StatusEffect)sE_Bleed).m_tooltip = "$mod_epicloot_bleed_desc";
			sE_Bleed.damagePerTick = 1f;
			sE_Bleed.maxDamagePerTick = 10f;
			((StatusEffect)sE_Bleed).m_ttl = 10f;
			((StatusEffect)(object)sE_Bleed).Register();
			MagicEffect magicEffect = new MagicEffect("Bleed");
			MagicItemEffectRequirements requirements = magicEffect.Requirements;
			ItemType[] array = new ItemType[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			requirements.AddAllowedItemTypes((ItemType[])(object)array);
			magicEffect.Requirements.AllowedRarities.Add(ItemRarity.Magic, ItemRarity.Rare, ItemRarity.Epic, ItemRarity.Legendary, ItemRarity.Mythic);
			magicEffect.ValuesPerRarity.Magic = new ValueDef(5f, 8f, 1f);
			magicEffect.ValuesPerRarity.Rare = new ValueDef(7f, 12f, 1f);
			magicEffect.ValuesPerRarity.Epic = new ValueDef(11f, 15f, 1f);
			magicEffect.ValuesPerRarity.Legendary = new ValueDef(14f, 19f, 1f);
			magicEffect.ValuesPerRarity.Mythic = new ValueDef(18f, 25f, 1f);
			magicEffect.Register();
		}
	}
	public static class ForsakenBlow
	{
		[HarmonyPatch(typeof(Character), "BlockAttack")]
		private static class ForsakenBlow_Character_BlockAttack_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Character __instance)
			{
				if (!MagicEffect.IsEnabled("ForsakenBlow"))
				{
					return;
				}
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && val.HasActiveMagicEffect("ForsakenBlow", out var effectValue))
				{
					float guardianPowerCooldown = val.m_guardianPowerCooldown;
					val.m_guardianPowerCooldown -= effectValue;
					float guardianPowerCooldown2 = val.m_guardianPowerCooldown;
					if (MagicEffect.ShowLogs("ForsakenBlow"))
					{
						RustyLootPlugin.LogDebug($"[ForsakenBlow] block: cooldown {guardianPowerCooldown:0.#} -{effectValue:0.#} => {guardianPowerCooldown2:0.#}");
					}
				}
			}
		}

		public static void Setup()
		{
			MagicEffect magicEffect = new MagicEffect("ForsakenBlow");
			magicEffect.Requirements.AddAllowedItemTypes((ItemType)5);
			magicEffect.Requirements.AllowedRarities.All();
			magicEffect.ValuesPerRarity.Magic = new ValueDef(1f, 5f, 1f);
			magicEffect.ValuesPerRarity.Rare = new ValueDef(3f, 8f, 1f);
			magicEffect.ValuesPerRarity.Epic = new ValueDef(6f, 12f, 1f);
			magicEffect.ValuesPerRarity.Legendary = new ValueDef(10f, 15f, 1f);
			magicEffect.ValuesPerRarity.Mythic = new ValueDef(13f, 20f, 1f);
			magicEffect.Register();
		}
	}
	public static class Honeybound
	{
		[HarmonyPatch(typeof(Player), "EatFood")]
		private static class Player_EatFood_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Player __instance, ItemData item, bool __result)
			{
				if (!MagicEffect.IsEnabled("Honeybound") || !__result || !__instance.HasActiveMagicEffect("Honeybound", out var effectValue))
				{
					return;
				}
				foreach (Food food in __instance.m_foods)
				{
					if (food.m_item.m_shared.m_name != item.m_shared.m_name)
					{
						continue;
					}
					float time = food.m_time;
					food.m_time *= 1f + effectValue / 100f;
					float time2 = food.m_time;
					if (MagicEffect.ShowLogs("Honeybound"))
					{
						RustyLootPlugin.LogDebug($"[Honeybound] food:{item.m_shared.m_name} time {time:0.#} +{time2 - time:0.#} => {time2:0.#} ({effectValue:0.#}%)");
					}
					break;
				}
			}
		}

		public static void Setup()
		{
			MagicEffect magicEffect = new MagicEffect("Honeybound");
			MagicItemEffectRequirements requirements = magicEffect.Requirements;
			ItemType[] array = new ItemType[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			requirements.AddAllowedItemTypes((ItemType[])(object)array);
			magicEffect.Requirements.AllowedRarities.Add(ItemRarity.Magic, ItemRarity.Rare, ItemRarity.Epic, ItemRarity.Legendary, ItemRarity.Mythic);
			magicEffect.ValuesPerRarity.Magic = new ValueDef(1f, 3f, 1f);
			magicEffect.ValuesPerRarity.Rare = new ValueDef(2f, 4f, 1f);
			magicEffect.ValuesPerRarity.Epic = new ValueDef(3f, 5f, 1f);
			magicEffect.ValuesPerRarity.Legendary = new ValueDef(4f, 6f, 1f);
			magicEffect.ValuesPerRarity.Mythic = new ValueDef(7f, 10f, 1f);
			magicEffect.Register();
		}
	}
	public static class IronMaiden
	{
		public class SE_IronMaiden : SE_Stats
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			public override void Setup(Character character)
			{
				((SE_Stats)this).Setup(character);
				SetupIronMaiden();
			}

			public void SetupIronMaiden()
			{
				Character character = ((StatusEffect)this).m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && val.HasActiveMagicEffect("IronMaiden", out var effectValue))
				{
					base.m_addArmor = effectValue;
					((StatusEffect)this).m_name = string.Format(Localization.instance.Localize(((StatusEffect)this).m_name), base.m_addArmor);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnDamaged")]
		private static class Player_OnDamaged_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Player __instance, HitData hit)
			{
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				if (MagicEffect.IsEnabled("IronMaiden") && __instance.HasActiveMagicEffect("IronMaiden", out var effectValue))
				{
					float totalDamage = hit.GetTotalDamage();
					float maxHealth = ((Character)__instance).GetMaxHealth();
					float num = maxHealth * 0.25f;
					bool flag = totalDamage > num;
					if (flag)
					{
						((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_IronMaiden"), true, 0, 0f);
						__instance.m_adrenalinePopEffects.Create(((Component)__instance).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
					}
					if (MagicEffect.ShowLogs("IronMaiden"))
					{
						RustyLootPlugin.LogDebug($"[IronMaiden] dmg:{totalDamage:0.#} thresh:{num:0.#} trig:{flag} mod:{effectValue:0.#}");
					}
				}
			}
		}

		public static void Setup()
		{
			MagicEffect magicEffect = new MagicEffect("IronMaiden");
			MagicItemEffectRequirements requirements = magicEffect.Requirements;
			ItemType[] array = new ItemType[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			requirements.AddAllowedItemTypes((ItemType[])(object)array);
			magicEffect.Requirements.AllowedRarities.Add(ItemRarity.Epic, ItemRarity.Legendary, ItemRarity.Mythic);
			magicEffect.ValuesPerRarity.Epic = new ValueDef(5f, 10f, 1f);
			magicEffect.ValuesPerRarity.Legendary = new ValueDef(8f, 12f, 1f);
			magicEffect.ValuesPerRarity.Mythic = new ValueDef(10f, 15f, 1f);
			magicEffect.Register();
			Sprite icon = SpriteManager.RegisterSprite("iron_maiden.png");
			SE_IronMaiden sE_IronMaiden = ScriptableObject.CreateInstance<SE_IronMaiden>();
			((Object)sE_IronMaiden).name = "SE_IronMaiden";
			((StatusEffect)sE_IronMaiden).m_name = "$mod_epicloot_ironmaiden";
			((StatusEffect)sE_IronMaiden).m_tooltip = "$mod_epicloot_ironmaiden_desc";
			((StatusEffect)sE_IronMaiden).m_ttl = 180f;
			((SE_Stats)sE_IronMaiden).m_addArmor = 5f;
			((StatusEffect)sE_IronMaiden).m_icon = icon;
			((StatusEffect)(object)sE_IronMaiden).Register();
		}
	}
	public static class Lifebloom
	{
		public class SE_Lifebloom : SE_Stats
		{
			public override void SetLevel(int itemLevel, float skillLevel)
			{
				base.m_healthOverTime = skillLevel;
				base.m_healthOverTimeDuration = 12f;
				base.m_healthOverTimeTicks = base.m_healthOverTimeDuration / base.m_healthOverTimeInterval;
				base.m_healthOverTimeTickHP = base.m_healthOverTime / base.m_healthOverTimeTicks;
				((StatusEffect)this).m_name = string.Format(Localization.instance.Localize(((StatusEffect)this).m_name), skillLevel).Replace("%", string.Empty);
				if (MagicEffect.ShowLogs("Lifebloom"))
				{
					RustyLootPlugin.LogDebug($"[SE_Lifebloom]: item lvl: {itemLevel}, heal amount: {skillLevel}, duration: {base.m_healthOverTimeDuration}, hp/tick: {base.m_healthOverTimeTickHP}");
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnDamaged")]
		private static class Lifebloom_Player_OnDamaged_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Player __instance, HitData hit)
			{
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				if (MagicEffect.IsEnabled("Lifebloom") && __instance.HasActiveMagicEffect("Lifebloom", out var effectValue, 0.01f))
				{
					float totalDamage = hit.GetTotalDamage();
					float num = totalDamage * 0.15f;
					float num2 = Mathf.Clamp01(effectValue);
					float value = Random.value;
					bool flag = num2 > value;
					if (flag)
					{
						((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_Lifebloom"), true, 0, num);
						__instance.m_adrenalinePopEffects.Create(((Component)__instance).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
					}
					if (MagicEffect.ShowLogs("Lifebloom"))
					{
						RustyLootPlugin.LogDebug($"[Lifebloom] dmg:{totalDamage:0.#} heal:{num:0.#} chance:{num2:0.###} roll:{value:0.###} trig:{flag}");
					}
				}
			}
		}

		public static void Setup()
		{
			MagicEffect magicEffect = new MagicEffect("Lifebloom");
			magicEffect.Requirements.AddAllowedItemTypes((ItemType)5);
			magicEffect.Requirements.AllowedRarities.Add(ItemRarity.Magic, ItemRarity.Rare, ItemRarity.Epic, ItemRarity.Legendary, ItemRarity.Mythic);
			magicEffect.ValuesPerRarity.Magic = new ValueDef(5f, 10f, 1f);
			magicEffect.ValuesPerRarity.Rare = new ValueDef(10f, 15f, 1f);
			magicEffect.ValuesPerRarity.Epic = new ValueDef(15f, 20f, 1f);
			magicEffect.ValuesPerRarity.Legendary = new ValueDef(20f, 25f, 1f);
			magicEffect.ValuesPerRarity.Mythic = new ValueDef(25f, 30f, 1f);
			magicEffect.Register();
			SE_Lifebloom sE_Lifebloom = ScriptableObject.CreateInstance<SE_Lifebloom>();
			((Object)sE_Lifebloom).name = "SE_Lifebloom";
			((StatusEffect)sE_Lifebloom).m_name = "$mod_epicloot_lifebloom";
			((StatusEffect)sE_Lifebloom).m_tooltip = "$mod_epicloot_lifebloom_desc";
			((StatusEffect)sE_Lifebloom).m_ttl = 12f;
			((SE_Stats)sE_Lifebloom).m_healthOverTime = 5f;
			((SE_Stats)sE_Lifebloom).m_healthOverTimeInterval = 1f;
			((StatusEffect)sE_Lifebloom).m_icon = Rejuvenate.icon;
			((StatusEffect)(object)sE_Lifebloom).Register();
		}
	}
	public static class MagicProjectiles
	{
		[HarmonyPatch(typeof(Attack), "HaveAmmo")]
		private static class Attack_HaveAmmo_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static bool Prefix(Humanoid character, ItemData weapon, ref bool __result)
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Invalid comparison between Unknown and I4
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Invalid comparison between Unknown and I4
				if (!MagicEffect.IsEnabled("MagicArrow") && !MagicEffect.IsEnabled("MagicBolt"))
				{
					return true;
				}
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val == null)
				{
					return true;
				}
				SkillType skillType = weapon.m_shared.m_skillType;
				if (((int)skillType != 8 && (int)skillType != 14) || 1 == 0)
				{
					return true;
				}
				if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType))
				{
					return true;
				}
				ItemData ammoItem = ((Humanoid)val).GetAmmoItem();
				if (ammoItem != null && ((Humanoid)val).GetInventory().ContainsItem(ammoItem) && ammoItem.m_shared.m_ammoType == weapon.m_shared.m_ammoType)
				{
					return true;
				}
				float effectValue;
				if ((Object)(object)arrow != (Object)null && weapon.m_shared.m_ammoType == arrow.m_itemData.m_shared.m_ammoType)
				{
					if (!EpicLoot.HasActiveMagicEffectOnWeapon(null, weapon, "MagicArrow", out effectValue))
					{
						return true;
					}
					if (!((Character)val).HaveEitr(arrowEitrCost))
					{
						return true;
					}
				}
				else
				{
					if (!((Object)(object)bolt != (Object)null) || !(weapon.m_shared.m_ammoType == bolt.m_itemData.m_shared.m_ammoType))
					{
						return true;
					}
					if (!EpicLoot.HasActiveMagicEffectOnWeapon(null, weapon, "MagicBolt", out effectValue))
					{
						return true;
					}
					if (!((Character)val).HaveEitr(boltEitrCost))
					{
						return true;
					}
				}
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(Attack), "FindAmmo")]
		private static class Attack_FindAmmo_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static void Postfix(Humanoid character, ItemData weapon, [<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] ref ItemData __result)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Invalid comparison between Unknown and I4
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Invalid comparison between Unknown and I4
				if ((!MagicEffect.IsEnabled("MagicArrow") && !MagicEffect.IsEnabled("MagicBolt")) || __result != null)
				{
					return;
				}
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val == null)
				{
					return;
				}
				SkillType skillType = weapon.m_shared.m_skillType;
				if (((int)skillType != 8 && (int)skillType != 14) || 1 == 0)
				{
					return;
				}
				float effectValue;
				if ((Object)(object)arrow != (Object)null && arrow.m_itemData.m_shared.m_ammoType == weapon.m_shared.m_ammoType)
				{
					if (EpicLoot.HasActiveMagicEffectOnWeapon(null, weapon, "MagicArrow", out effectValue) && ((Character)val).HaveEitr(arrowEitrCost))
					{
						__result = arrow.m_itemData.Clone();
					}
				}
				else if ((Object)(object)bolt != (Object)null && bolt.m_itemData.m_shared.m_ammoType == weapon.m_shared.m_ammoType && EpicLoot.HasActiveMagicEffectOnWeapon(null, weapon, "MagicBolt", out effectValue) && ((Character)val).HaveEitr(boltEitrCost))
				{
					__result = bolt.m_itemData.Clone();
				}
			}
		}

		[HarmonyPatch(typeof(Attack), "UseAmmo")]
		private static class Attack_UseAmmo_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static bool Prefix(Attack __instance, [<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)] out ItemData ammoItem, ref bool __result)
			{
				ammoItem = __instance.m_character.GetAmmoItem();
				if (!MagicEffect.IsEnabled("MagicArrow") && !MagicEffect.IsEnabled("MagicBolt"))
				{
					return true;
				}
				Humanoid character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val == null)
				{
					return true;
				}
				ItemData ammoItem2 = ((Humanoid)val).GetAmmoItem();
				if (ammoItem2 != null && ammoItem2.m_shared.m_ammoType == __instance.m_weapon.m_shared.m_ammoType && ((Humanoid)val).GetInventory().ContainsItem(ammoItem2))
				{
					return true;
				}
				float effectValue;
				if ((Object)(object)arrow != (Object)null && __instance.m_weapon.m_shared.m_ammoType == arrow.m_itemData.m_shared.m_ammoType)
				{
					if (!EpicLoot.HasActiveMagicEffectOnWeapon(null, __instance.m_weapon, "MagicArrow", out effectValue))
					{
						return true;
					}
					if (!((Character)val).HaveEitr(arrowEitrCost))
					{
						return true;
					}
					__result = true;
					ammoItem = arrow.m_itemData.Clone();
					__instance.m_ammoItem = ammoItem;
					((Character)val).UseEitr(arrowEitrCost);
				}
				else
				{
					if (!((Object)(object)bolt != (Object)null) || !(__instance.m_weapon.m_shared.m_ammoType == bolt.m_itemData.m_shared.m_ammoType))
					{
						return true;
					}
					if (!EpicLoot.HasActiveMagicEffectOnWeapon(null, __instance.m_weapon, "MagicBolt", out effectValue))
					{
						return true;
					}
					if (!((Character)val).HaveEitr(boltEitrCost))
					{
						return true;
					}
					__result = true;
					ammoItem = bolt.m_itemData.Clone();
					__instance.m_ammoItem = ammoItem;
					((Character)val).UseEitr(boltEitrCost);
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Attack), "EquipAmmoItem")]
		private static class Attack_EquipAmmoItem_Patch
		{
			[<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)]
			private static bool Prefix(Humanoid character, ItemData weapon, ref bool __result)
			{
				if (!MagicEffect.IsEnabled("MagicArrow") && !MagicEffect.IsEnabled("MagicBolt"))
				{
					return true;
				}
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val == null)
				{
					return true;
				}
				ItemData ammoItem = ((Humanoid)val).GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null);
				if (ammoItem != null && ammoItem.m_shared.m_ammoType == weapon.m_shared.m_ammoType)
				{
					return true;
				}
				float effectValue;
				if ((Object)(object)arrow != (Object)null && weapon.m_shared.m_ammoType == arrow.m_itemData.m_shared.m_ammoType)
				{
					if (!EpicLoot.HasActiveMagicEffectOnWeapon(null, weapon, "MagicArrow", out effectValue))
					{
						return true;
					}
					if (!((Character)val).HaveEitr(arrowEitrCost))
					{
						return true;
					}
				}
				else
				{
					if (!((Object)(object)bolt != (Object)null) || !(weapon.m_shared.m_ammoType == bolt.m_itemData.m_shared.m_ammoType))
					{
						return true;
					}
					if (!EpicLoot.HasActiveMagicEffectOnWeapon(null, weapon, "MagicBolt", out effectValue))
					{
						return true;
					}
					if (!((Character)val).HaveEitr(boltEitrCost))
					{
						return true;
					}
				}
				__result = true;
				return false;
			}
		}

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private static ItemDrop arrow;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private static ItemDrop bolt;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private static ConfigEntry<float> arrowEitrUse;

		[<4fdc30f7-b68c-418d-93b5-c88926ee132e>Nullable(2)]
		private static ConfigEntry<float> boltEitrUse;

		private static float arrowEitrCost => arrowEitrUse?.Value ?? 10f;

		private static float boltEitrCost => boltEitrUse?.Value ?? 10f;

		public static void SetupMagicArrow()
		{
			Clone clone = new Clone("ArrowFrost", "RS_MagicArrow");
			clone.OnCreated += [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)] (GameObject prefab) =>
			{
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Expected O, but got Unknown
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = "$item_arrow_magic";
					val.m_itemData.m_shared.m_description = "$item_arrow_magic_desc";
					GameObject attackProjectile = val.m_itemData.m_shared.m_attack.m_attackProjectile;
					if ((Object)(object)attackProjectile == (Object)null)
					{
						Debug.LogError((object)"Magic Arrow projectile is null");
					}
					else
					{
						GameObject val2 = Object.Instantiate<GameObject>(attackProjectile, RustyLootPlugin.root.transform, false);
						((Object)val2).name = "bow_projectile_magic";
						Transform val3 = val2.transform.Find("model");
						if ((Object)(object)val3 == (Object)null)
						{
							Debug.LogError((object)"Magic Arrow model is null");
						}
						else
						{
							MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>();
							List<Material> list = new List<Material>();
							Material[] sharedMaterials = ((Renderer)component).sharedMaterials;
							foreach (Material val4 in sharedMaterials)
							{
								Material val5 = new Material(val4);
								((Object)val5).name = ((Object)val4).name + "_magic_arrow";
								Color color = val4.GetColor("_EmissionColor");
								val5.SetColor("_EmissionColor", color * 5f);
								list.Add(val5);
							}
							((Renderer)component).sharedMaterials = list.ToArray();
							((Renderer)component).materials = list.ToArray();
							Transform val6 = val2.transform.Find("Sphere");
							if ((Object)(object)val6 == (Object)null)
							{
								Debug.LogError((object)"Magic arrow tip is null");
							}
							else
							{
								MeshRenderer component2 = ((Component)val6).GetComponent<MeshRenderer>();
								((Renderer)component2).sharedMaterials = list.ToArray();
								((Renderer)component2).materials = list.ToArray();
								val.m_itemData.m_shared.m_attack.m_attackProjectile = val2;
								PrefabManager.RegisterPrefab(val2);
								arrow = val;
							}
						}
					}
				}
			};
			MagicEffect magicEffect = new MagicEffect("MagicArrow");
			magicEffect.Requirements.AllowedSkillTypes.Add((SkillType)8);
			magicEffect.Requirements.AllowedRarities.Add(ItemRarity.Epic, ItemRarity.Legendary, ItemRarity.Mythic);
			magicEffect.Register();
			ConfigEntry<float> pierceDmg = RustyLootPlugin.config("Magic Arrow", "Pierce Damage", 26f, "Set magic arrow pierce damage");
			ConfigEntry<float> frostDmg = RustyLootPlugin.config("Magic Arrow", "Frost Damage", 52f, "Set magic arrow frost damage");
			arrowEitrUse = RustyLootPlugin.config("Magic Arrow", "Eitr Use", 10f, "Set magic arrow eitr cost");
			pierceDmg.SettingChanged += delegate
			{
				OnConfigChange();
			};
			frostDmg.SettingChanged += delegate
			{
				OnConfigChange();
			};
			OnConfigChange();
			void OnConfigChange()
			{
				if (!((Object)(object)arrow == (Object)null))
				{
					arrow.m_itemData.m_shared.m_damages.m_pierce = pierceDmg.Value;
					arrow.m_itemData.m_shared.m_damages.m_frost = frostDmg.Value;
				}
			}
		}

		public static void SetupMagicBolt()
		{
			Clone clone = new Clone("BoltCarapace", "RS_MagicBolt");
			clone.OnCreated += [<8c7a10b3-c30b-4194-9ab2-10a87d388603>NullableContext(1)] (GameObject prefab) =>
			{
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Expected O, but got Unknown
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = "$item_bolt_magic";
					val.m_itemData.m_shared.m_description = "$item_bolt_magic_desc";
					GameObject attackProjectile = val.m_itemData.m_shared.m_attack.m_attackProjectile;
					if ((Object)(object)attackProjectile == (Object)null)
					{
						Debug.LogError((object)"Magic Bolt projectile is null");
					}
					else
					{
						GameObject val2 = Object.Instantiate<GameObject>(attackProjectile, RustyLootPlugin.root.transform, false);
						((Object)val2).name = "arbalest_projectile_magic";
						Transform val3 = val2.transform.Find("default");
						if ((Object)(object)val3 == (Object)null)
						{
							Debug.LogError((object)"Magic Bolt model is null");
						}
						else
						{
							MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>();
							List<Material> list = new List<Material>();
							Material[] sharedMaterials = ((Renderer)component).sharedMaterials;
							foreach (Material val4 in sharedMaterials)
							{
								Material val5 = new Material(val4);
								((Object)val5).name = ((Object)val4).name + "_magic_arrow";
								val5.EnableKeyword("_EMISSION");
								val5.SetColor("_EmissionColor", new Color(0f, 0.8f, 1f) * 5f);
								list.Add(val5);
							}
							((Renderer)component).sharedMaterials = list.ToArray();
							((Renderer)component).materials = list.ToArray();
							val.m_itemData.m_shared.m_attack.m_attackProjectile = val2;
							PrefabManager.RegisterPrefab(val2);
							bolt = val;
						}
					}
				}
			};
			MagicEffect magicEffect = new MagicEffect("MagicBolt");
			magicEffect.Requirements.AllowedSkillTypes.Add((SkillType)14);
			magicEffect.Requirements.AllowedRarities.Add(ItemRarit