Decompiled source of EpicLoot v0.12.3

plugins/EpicLoot.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Common;
using EpicLoot.Abilities;
using EpicLoot.Adventure;
using EpicLoot.Adventure.Feature;
using EpicLoot.Compendium;
using EpicLoot.Config;
using EpicLoot.Crafting;
using EpicLoot.CraftingV2;
using EpicLoot.Data;
using EpicLoot.GatedItemType;
using EpicLoot.General;
using EpicLoot.LegendarySystem;
using EpicLoot.LootBeams;
using EpicLoot.Magic;
using EpicLoot.MagicItemEffects;
using EpicLoot.Patching;
using EpicLoot_UnityLib;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EpicLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Randy Knapp Mods")]
[assembly: AssemblyProduct("EpicLoot")]
[assembly: AssemblyCopyright("Copyright © Randy Knapp 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("963cf4f8-ba02-49fc-8884-97e781e6bc18")]
[assembly: AssemblyFileVersion("0.12.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.12.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class PlayerExtensions
{
	public static ZDO GetZDO(this Player player)
	{
		return ((Character)player).m_nview.GetZDO();
	}
}
namespace Common
{
	public class ConfigPositionedElement : MonoBehaviour
	{
		public ConfigEntry<TextAnchor> AnchorConfig;

		public ConfigEntry<Vector2> PositionConfig;

		protected RectTransform _rt;

		protected TextAnchor _currentAnchor;

		public virtual void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_rt = (RectTransform)((Component)this).transform;
			EnsureCorrectPosition();
		}

		public virtual void Update()
		{
			EnsureCorrectPosition();
		}

		public virtual void EnsureCorrectPosition()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0058: 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_0083: Expected I4, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			if (AnchorConfig != null && PositionConfig != null && (_currentAnchor != AnchorConfig.Value || !(_rt.anchoredPosition == PositionConfig.Value)))
			{
				_currentAnchor = AnchorConfig.Value;
				TextAnchor currentAnchor = _currentAnchor;
				Vector2 val = default(Vector2);
				switch ((int)currentAnchor)
				{
				case 0:
				{
					RectTransform rt25 = _rt;
					RectTransform rt26 = _rt;
					RectTransform rt27 = _rt;
					((Vector2)(ref val))..ctor(0f, 1f);
					rt27.anchorMax = val;
					Vector2 pivot = (rt26.anchorMin = val);
					rt25.pivot = pivot;
					break;
				}
				case 1:
				{
					RectTransform rt22 = _rt;
					RectTransform rt23 = _rt;
					RectTransform rt24 = _rt;
					((Vector2)(ref val))..ctor(0.5f, 1f);
					rt24.anchorMax = val;
					Vector2 pivot = (rt23.anchorMin = val);
					rt22.pivot = pivot;
					break;
				}
				case 2:
				{
					RectTransform rt19 = _rt;
					RectTransform rt20 = _rt;
					RectTransform rt21 = _rt;
					((Vector2)(ref val))..ctor(1f, 1f);
					rt21.anchorMax = val;
					Vector2 pivot = (rt20.anchorMin = val);
					rt19.pivot = pivot;
					break;
				}
				case 3:
				{
					RectTransform rt16 = _rt;
					RectTransform rt17 = _rt;
					RectTransform rt18 = _rt;
					((Vector2)(ref val))..ctor(0f, 0.5f);
					rt18.anchorMax = val;
					Vector2 pivot = (rt17.anchorMin = val);
					rt16.pivot = pivot;
					break;
				}
				case 4:
				{
					RectTransform rt13 = _rt;
					RectTransform rt14 = _rt;
					RectTransform rt15 = _rt;
					((Vector2)(ref val))..ctor(0.5f, 0.5f);
					rt15.anchorMax = val;
					Vector2 pivot = (rt14.anchorMin = val);
					rt13.pivot = pivot;
					break;
				}
				case 5:
				{
					RectTransform rt10 = _rt;
					RectTransform rt11 = _rt;
					RectTransform rt12 = _rt;
					((Vector2)(ref val))..ctor(1f, 0.5f);
					rt12.anchorMax = val;
					Vector2 pivot = (rt11.anchorMin = val);
					rt10.pivot = pivot;
					break;
				}
				case 6:
				{
					RectTransform rt7 = _rt;
					RectTransform rt8 = _rt;
					RectTransform rt9 = _rt;
					((Vector2)(ref val))..ctor(0f, 0f);
					rt9.anchorMax = val;
					Vector2 pivot = (rt8.anchorMin = val);
					rt7.pivot = pivot;
					break;
				}
				case 7:
				{
					RectTransform rt4 = _rt;
					RectTransform rt5 = _rt;
					RectTransform rt6 = _rt;
					((Vector2)(ref val))..ctor(0.5f, 0f);
					rt6.anchorMax = val;
					Vector2 pivot = (rt5.anchorMin = val);
					rt4.pivot = pivot;
					break;
				}
				case 8:
				{
					RectTransform rt = _rt;
					RectTransform rt2 = _rt;
					RectTransform rt3 = _rt;
					((Vector2)(ref val))..ctor(1f, 0f);
					rt3.anchorMax = val;
					Vector2 pivot = (rt2.anchorMin = val);
					rt.pivot = pivot;
					break;
				}
				}
				_rt.anchoredPosition = PositionConfig.Value;
			}
		}
	}
	[Serializable]
	public class RecipeRequirementConfig
	{
		public string item = "";

		public int amount = 1;
	}
	[Serializable]
	public class RecipeConfig
	{
		public string name = "";

		public string item = "";

		public int amount = 1;

		public string craftingStation = "";

		public int minStationLevel = 1;

		public bool enabled = true;

		public string repairStation = "";

		public List<RecipeRequirementConfig> resources = new List<RecipeRequirementConfig>();
	}
	[Serializable]
	public class RecipesConfig
	{
		public List<RecipeConfig> recipes = new List<RecipeConfig>();
	}
	public static class GameObjectExtensions
	{
		public static RectTransform RectTransform(this GameObject go)
		{
			Transform transform = go.transform;
			return (RectTransform)(object)((transform is RectTransform) ? transform : null);
		}

		public static T RequireComponent<T>(this GameObject go) where T : Component
		{
			T component = go.GetComponent<T>();
			if (!((Object)(object)component == (Object)null))
			{
				return component;
			}
			return go.AddComponent<T>();
		}
	}
	public class GotDestroyed : MonoBehaviour
	{
		public void OnDisable()
		{
			Debug.LogError((object)("I got destroyed! (" + ((Object)((Component)this).gameObject).name + ")"));
			Debug.Log((object)Environment.StackTrace);
		}
	}
	public class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, List<TValue>>
	{
		public void Add(TKey key, TValue value)
		{
			if (!TryGetValue(key, out var value2))
			{
				value2 = new List<TValue>();
				Add(key, value2);
			}
			value2.Add(value);
		}

		public bool ContainsValue(TKey key, TValue value)
		{
			if (TryGetValue(key, out var value2))
			{
				return value2.Contains(value);
			}
			return false;
		}

		public void Remove(TKey key, TValue value)
		{
			if (TryGetValue(key, out var value2))
			{
				value2.Remove(value);
				if (value2.Count <= 0)
				{
					Remove(key);
				}
			}
		}

		public void Merge(MultiValueDictionary<TKey, TValue> toMergeWith)
		{
			if (toMergeWith == null)
			{
				return;
			}
			foreach (KeyValuePair<TKey, List<TValue>> item in toMergeWith)
			{
				foreach (TValue item2 in item.Value)
				{
					Add(item.Key, item2);
				}
			}
		}

		public List<TValue> GetValues(TKey key, bool returnEmptySet = false)
		{
			if (!TryGetValue(key, out var value) && returnEmptySet)
			{
				return new List<TValue>();
			}
			return value;
		}
	}
	public static class PrefabCreator
	{
		public static ManualLogSource Logger;

		public static Dictionary<string, CraftingStation> CraftingStations;

		public static T RequireComponent<T>(GameObject go) where T : Component
		{
			T val = go.GetComponent<T>();
			if ((Object)(object)val == (Object)null)
			{
				val = go.AddComponent<T>();
			}
			return val;
		}

		public static void Reset()
		{
			CraftingStations = null;
		}

		private static void InitCraftingStations()
		{
			if (CraftingStations != null)
			{
				return;
			}
			CraftingStations = new Dictionary<string, CraftingStation>();
			foreach (Recipe recipe in ObjectDB.instance.m_recipes)
			{
				if ((Object)(object)recipe.m_craftingStation != (Object)null && !CraftingStations.ContainsKey(((Object)recipe.m_craftingStation).name))
				{
					CraftingStations.Add(((Object)recipe.m_craftingStation).name, recipe.m_craftingStation);
				}
			}
		}

		public static Recipe CreateRecipe(string name, string itemId, RecipeConfig recipeConfig)
		{
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			InitCraftingStations();
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemId);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("[PrefabCreator] Could not find item prefab (" + itemId + ")"));
				}
				return null;
			}
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = name;
			val.m_amount = recipeConfig.amount;
			val.m_minStationLevel = recipeConfig.minStationLevel;
			val.m_item = itemPrefab.GetComponent<ItemDrop>();
			val.m_enabled = recipeConfig.enabled;
			if (!string.IsNullOrEmpty(recipeConfig.craftingStation))
			{
				if (!CraftingStations.ContainsKey(recipeConfig.craftingStation))
				{
					ManualLogSource logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("[PrefabCreator] Could not find crafting station (" + itemId + "): " + recipeConfig.craftingStation));
					}
					string text = string.Join(", ", CraftingStations.Keys);
					ManualLogSource logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogInfo((object)("[PrefabCreator] Available Stations: " + text));
					}
				}
				else
				{
					val.m_craftingStation = CraftingStations[recipeConfig.craftingStation];
				}
			}
			if (!string.IsNullOrEmpty(recipeConfig.repairStation))
			{
				if (!CraftingStations.ContainsKey(recipeConfig.repairStation))
				{
					ManualLogSource logger4 = Logger;
					if (logger4 != null)
					{
						logger4.LogWarning((object)("[PrefabCreator] Could not find repair station (" + itemId + "): " + recipeConfig.repairStation));
					}
					string text2 = string.Join(", ", CraftingStations.Keys);
					ManualLogSource logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogInfo((object)("[PrefabCreator] Available Stations: " + text2));
					}
				}
				else
				{
					val.m_repairStation = CraftingStations[recipeConfig.repairStation];
				}
			}
			List<Requirement> list = new List<Requirement>();
			foreach (RecipeRequirementConfig resource in recipeConfig.resources)
			{
				GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(resource.item);
				if ((Object)(object)itemPrefab2 == (Object)null)
				{
					ManualLogSource logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogError((object)("[PrefabCreator] Could not find requirement item (" + itemId + "): " + resource.item));
					}
				}
				else
				{
					list.Add(new Requirement
					{
						m_amount = resource.amount,
						m_resItem = itemPrefab2.GetComponent<ItemDrop>()
					});
				}
			}
			val.m_resources = list.ToArray();
			return val;
		}

		public static Recipe AddNewRecipe(string name, string itemId, RecipeConfig recipeConfig)
		{
			Recipe val = CreateRecipe(name, itemId, recipeConfig);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("[PrefabCreator] Failed to create recipe (" + name + ")"));
				}
				return null;
			}
			return AddNewRecipe(val);
		}

		public static Recipe AddNewRecipe(Recipe recipe)
		{
			int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name);
			if (num > 0)
			{
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"[PrefabCreator] Removed recipe ({((Object)recipe).name}): {num}");
				}
			}
			ObjectDB.instance.m_recipes.Add(recipe);
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogInfo((object)("[PrefabCreator] Added recipe: " + ((Object)recipe).name));
			}
			return recipe;
		}
	}
	[Serializable]
	public struct SerializableVector3
	{
		public float x;

		public float y;

		public float z;

		public SerializableVector3(float x, float y, float z)
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public void ToPackage(ZPackage pkg)
		{
			pkg.Write(x);
			pkg.Write(y);
			pkg.Write(z);
		}

		public static SerializableVector3 FromPackage(ZPackage pkg)
		{
			SerializableVector3 result = default(SerializableVector3);
			result.x = pkg.ReadSingle();
			result.y = pkg.ReadSingle();
			result.z = pkg.ReadSingle();
			return result;
		}

		public override string ToString()
		{
			return $"[{x}, {y}, {z}]";
		}

		public static implicit operator Vector3(SerializableVector3 s)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(s.x, s.y, s.z);
		}

		public static implicit operator SerializableVector3(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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)
			return new SerializableVector3(v.x, v.y, v.z);
		}

		public static SerializableVector3 operator +(SerializableVector3 a, SerializableVector3 b)
		{
			return new SerializableVector3(a.x + b.x, a.y + b.y, a.z + b.z);
		}

		public static SerializableVector3 operator -(SerializableVector3 a, SerializableVector3 b)
		{
			return new SerializableVector3(a.x - b.x, a.y - b.y, a.z - b.z);
		}

		public static SerializableVector3 operator -(SerializableVector3 a)
		{
			return new SerializableVector3(0f - a.x, 0f - a.y, 0f - a.z);
		}

		public static SerializableVector3 operator *(SerializableVector3 a, float m)
		{
			return new SerializableVector3(a.x * m, a.y * m, a.z * m);
		}

		public static SerializableVector3 operator *(float m, SerializableVector3 a)
		{
			return new SerializableVector3(a.x * m, a.y * m, a.z * m);
		}

		public static SerializableVector3 operator /(SerializableVector3 a, float d)
		{
			return new SerializableVector3(a.x / d, a.y / d, a.z / d);
		}
	}
	public static class Utils
	{
		public static void PrintObject(object o)
		{
			if (o == null)
			{
				Debug.Log((object)"null");
			}
			else
			{
				Debug.Log((object)(o?.ToString() + ":\n" + GetObjectString(o, "  ")));
			}
		}

		public static string GetObjectString(object obj, string indent)
		{
			string text = "";
			foreach (FieldInfo item in from f in obj.GetType().GetFields()
				where f.IsPublic
				select f)
			{
				object value = item.GetValue(obj);
				string text2 = ((value == null) ? "null" : value.ToString());
				text = text + "\n" + indent + item.Name + ": " + text2;
			}
			return text;
		}

		public static string RemoveBetween(string s, string from, string to)
		{
			int num = 0;
			while (num >= 0)
			{
				num = s.IndexOf(from, StringComparison.InvariantCulture);
				if (num < 0)
				{
					break;
				}
				int num2 = s.IndexOf(to, num, StringComparison.InvariantCulture);
				if (num2 < 0)
				{
					break;
				}
				s = s.Remove(num, num2 - num + to.Length);
			}
			return s;
		}

		public static void CopyFields(object originalObject, object cloneObject, Type typeToReflect, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public)
		{
			FieldInfo[] fields = typeToReflect.GetFields(bindingFlags);
			foreach (FieldInfo obj in fields)
			{
				object value = obj.GetValue(originalObject);
				obj.SetValue(cloneObject, value);
			}
		}

		public static bool IsServer()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			if (!ZNet.instance.IsServer() && !ZNet.instance.IsDedicated())
			{
				return (int)SystemInfo.graphicsDeviceType == 4;
			}
			return true;
		}
	}
	public static class ArrayUtils
	{
		public static bool IsNullOrEmpty<T>(T[] a)
		{
			if (a != null)
			{
				return a.Length == 0;
			}
			return true;
		}

		public static T[] Copy<T>(T[] other)
		{
			return other?.ToArray();
		}
	}
	public static class ListExtensions
	{
		public static bool TryFind<T>(this List<T> list, Predicate<T> predicate, out T result)
		{
			int num = list.FindIndex(predicate);
			if (num != -1)
			{
				result = list[num];
				return true;
			}
			result = default(T);
			return false;
		}
	}
}
namespace Auga
{
	public enum RequirementWireState
	{
		Absent,
		Have,
		DontHave
	}
	public class PlayerPanelTabData
	{
		public int Index;

		public Text TabTitle;

		public GameObject TabButtonGO;

		public GameObject ContentGO;
	}
	public class WorkbenchTabData
	{
		public int Index;

		public Text TabTitle;

		public GameObject TabButtonGO;

		public GameObject RequirementsPanelGO;

		public GameObject ItemInfoGO;
	}
	public static class API
	{
		[CompilerGenerated]
		private sealed class <Transpiler>d__2 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private MethodBase original;

			public MethodBase <>3__original;

			private Type[] <parameters>5__2;

			private MethodBase <originalMethod>5__3;

			private int <i>5__4;

			CodeInstruction IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Transpiler>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<parameters>5__2 = null;
				<originalMethod>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Expected O, but got Unknown
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Expected O, but got Unknown
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<parameters>5__2 = original.GetParameters().Select(delegate(ParameterInfo p)
					{
						Type type = p.ParameterType;
						if (type.Assembly == Assembly.GetExecutingAssembly() && _targetAssembly != null)
						{
							type = _targetAssembly.GetType(type.FullName ?? string.Empty);
						}
						return type;
					}).ToArray();
					<originalMethod>5__3 = _targetAssembly.GetType("Auga.API").GetMethod(original.Name, <parameters>5__2);
					<i>5__4 = 0;
					goto IL_00cf;
				case 1:
				{
					<>1__state = -1;
					int num = <i>5__4 + 1;
					<i>5__4 = num;
					goto IL_00cf;
				}
				case 2:
					<>1__state = -1;
					<>2__current = new CodeInstruction(OpCodes.Ret, (object)null);
					<>1__state = 3;
					return true;
				case 3:
					{
						<>1__state = -1;
						return false;
					}
					IL_00cf:
					if (<i>5__4 < <parameters>5__2.Length)
					{
						<>2__current = new CodeInstruction(OpCodes.Ldarg, (object)<i>5__4);
						<>1__state = 1;
						return true;
					}
					<>2__current = new CodeInstruction(OpCodes.Call, (object)<originalMethod>5__3);
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<Transpiler>d__2 <Transpiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Transpiler>d__ = this;
				}
				else
				{
					<Transpiler>d__ = new <Transpiler>d__2(0);
				}
				<Transpiler>d__.original = <>3__original;
				return <Transpiler>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		private static readonly Assembly _targetAssembly;

		public static string RedText;

		public static string Red;

		public static string Brown1;

		public static string Brown2;

		public static string Brown3;

		public static string Brown4;

		public static string Brown5;

		public static string Brown6;

		public static string Brown7;

		public static string Blue;

		public static string LightBlue;

		public static string Gold;

		public static string BrightGold;

		public static string BrightestGold;

		public static string GoldDark;

		public static string Green;

		static API()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			RedText = "#CD2121";
			Red = "#AD1616";
			Brown1 = "#EAE1D9";
			Brown2 = "#D1C9C2";
			Brown3 = "#A39689";
			Brown4 = "#706457";
			Brown5 = "#2E2620";
			Brown6 = "#EAE1D9";
			Brown7 = "#181410";
			Blue = "#216388";
			LightBlue = "#1AACEF";
			Gold = "#B98A12";
			BrightGold = "#EAA800";
			BrightestGold = "#FFBF1B";
			GoldDark = "#755608";
			Green = "#1B9B37";
			_targetAssembly = LoadAssembly();
			if (!(_targetAssembly != null))
			{
				return;
			}
			Harmony val = new Harmony("mods.randyknapp.auga.API");
			foreach (MethodInfo item in from m in typeof(API).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public)
				where m.Name != "IsLoaded" && m.Name != "LoadAssembly"
				select m)
			{
				val.Patch((MethodBase)item, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(API), "Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		[IteratorStateMachine(typeof(<Transpiler>d__2))]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> _, MethodBase original)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Transpiler>d__2(-2)
			{
				<>3__original = original
			};
		}

		public static Assembly LoadAssembly()
		{
			return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.GetName().Name == "Auga");
		}

		public static bool IsLoaded()
		{
			return LoadAssembly() != null;
		}

		public static Font GetBoldFont()
		{
			return null;
		}

		public static Font GetSemiBoldFont()
		{
			return null;
		}

		public static Font GetRegularFont()
		{
			return null;
		}

		public static Sprite GetItemBackgroundSprite()
		{
			return null;
		}

		public static GameObject Panel_Create(Transform parent, Vector2 size, string name, bool withCornerDecoration)
		{
			return null;
		}

		public static Button SmallButton_Create(Transform parent, string name, string labelText)
		{
			return null;
		}

		public static Button MediumButton_Create(Transform parent, string name, string labelText)
		{
			return null;
		}

		public static Button FancyButton_Create(Transform parent, string name, string labelText)
		{
			return null;
		}

		public static Button SettingsButton_Create(Transform parent, string name, string labelText)
		{
			return null;
		}

		public static Button DiamondButton_Create(Transform parent, string name, [CanBeNull] Sprite icon)
		{
			return null;
		}

		public static GameObject Divider_CreateSmall(Transform parent, string name, float width = -1f)
		{
			return null;
		}

		public static Tuple<GameObject, GameObject> Divider_CreateMedium(Transform parent, string name, float width = -1f)
		{
			return null;
		}

		public static Tuple<GameObject, GameObject> Divider_CreateLarge(Transform parent, string name, float width = -1f)
		{
			return null;
		}

		public static void Button_SetTextColors(Button button, Color normal, Color highlighted, Color pressed, Color selected, Color disabled, Color baseTextColor)
		{
		}

		public static void Button_OverrideTextColor(Button button, Color color)
		{
		}

		public static void Tooltip_MakeSimpleTooltip(GameObject obj)
		{
		}

		public static void Tooltip_MakeItemTooltip(GameObject obj, ItemData item)
		{
		}

		public static bool PlayerPanel_HasTab(string tabID)
		{
			return false;
		}

		public static PlayerPanelTabData PlayerPanel_AddTab(string tabID, Sprite tabIcon, string tabTitleText, Action<int> onTabSelected)
		{
			return null;
		}

		public static bool PlayerPanel_IsTabActive(GameObject tabButton)
		{
			return false;
		}

		public static Button PlayerPanel_GetTabButton(int index)
		{
			return null;
		}

		public static bool Workbench_HasWorkbenchTab(string tabID)
		{
			return false;
		}

		public static WorkbenchTabData Workbench_AddWorkbenchTab(string tabID, Sprite tabIcon, string tabTitleText, Action<int> onTabSelected)
		{
			return null;
		}

		public static WorkbenchTabData Workbench_AddVanillaWorkbenchTab(string tabID, Sprite tabIcon, string tabTitleText, Action<int> onTabSelected)
		{
			return null;
		}

		public static bool Workbench_IsTabActive(GameObject tabButton)
		{
			return false;
		}

		public static Button Workbench_GetCraftingTabButton()
		{
			return null;
		}

		public static Button Workbench_GetUpgradeTabButton()
		{
			return null;
		}

		public static GameObject Workbench_CreateNewResultsPanel()
		{
			return null;
		}

		public static void TooltipTextBox_AddLine(GameObject tooltipTextBoxGO, Text t, object s, bool localize = true, bool overwrite = false)
		{
		}

		public static void TooltipTextBox_AddLine(GameObject tooltipTextBoxGO, object a, bool localize = true, bool overwrite = false)
		{
		}

		public static void TooltipTextBox_AddLine(GameObject tooltipTextBoxGO, object a, object b, bool localize = true, bool overwrite = false)
		{
		}

		public static void TooltipTextBox_AddLine(GameObject tooltipTextBoxGO, object a, object b, object parenthetical, bool localize = true, bool overwrite = false)
		{
		}

		public static void TooltipTextBox_AddUpgradeLine(GameObject tooltipTextBoxGO, object label, object value1, object value2, string color2, bool localize = true, bool overwrite = false)
		{
		}

		public static void ComplexTooltip_AddItemTooltipCreatedListener(Action<GameObject, ItemData> listener)
		{
		}

		public static void ComplexTooltip_AddFoodTooltipCreatedListener(Action<GameObject, Food> listener)
		{
		}

		public static void ComplexTooltip_AddStatusEffectTooltipCreatedListener(Action<GameObject, StatusEffect> listener)
		{
		}

		public static void ComplexTooltip_AddSkillTooltipCreatedListener(Action<GameObject, Skill> listener)
		{
		}

		public static void ComplexTooltip_AddItemStatPreprocessor(Func<ItemData, string, string, Tuple<string, string>> itemStatPreprocessor)
		{
		}

		public static void ComplexTooltip_ClearTextBoxes(GameObject complexTooltipGO)
		{
		}

		public static GameObject ComplexTooltip_AddTwoColumnTextBox(GameObject complexTooltipGO)
		{
			return null;
		}

		public static GameObject ComplexTooltip_AddCenteredTextBox(GameObject complexTooltipGO)
		{
			return null;
		}

		public static GameObject ComplexTooltip_AddUpgradeLabels(GameObject complexTooltipGO)
		{
			return null;
		}

		public static GameObject ComplexTooltip_AddUpgradeTwoColumnTextBox(GameObject complexTooltipGO)
		{
			return null;
		}

		public static GameObject ComplexTooltip_AddCheckBoxTextBox(GameObject complexTooltipGO)
		{
			return null;
		}

		public static GameObject ComplexTooltip_AddDivider(GameObject complexTooltipGO)
		{
			return null;
		}

		public static void ComplexTooltip_SetTopic(GameObject complexTooltipGO, string topic)
		{
		}

		public static void ComplexTooltip_SetSubtitle(GameObject complexTooltipGO, string topic)
		{
		}

		public static void ComplexTooltip_SetDescription(GameObject complexTooltipGO, string desc)
		{
		}

		public static void ComplexTooltip_SetIcon(GameObject complexTooltipGO, Sprite icon)
		{
		}

		public static void ComplexTooltip_EnableDescription(GameObject complexTooltipGO, bool enabled)
		{
		}

		public static string ComplexTooltip_GenerateItemSubtext(GameObject complexTooltipGO, ItemData item)
		{
			return string.Empty;
		}

		public static void ComplexTooltip_SetItem(GameObject complexTooltipGO, ItemData item, int quality = -1, int variant = -1)
		{
		}

		public static void ComplexTooltip_SetItemNoTextBoxes(GameObject complexTooltipGO, ItemData item, int quality = -1, int variant = -1)
		{
		}

		public static void ComplexTooltip_SetFood(GameObject complexTooltipGO, Food food)
		{
		}

		public static void ComplexTooltip_SetStatusEffect(GameObject complexTooltipGO, StatusEffect statusEffect)
		{
		}

		public static void ComplexTooltip_SetSkill(GameObject complexTooltipGO, Skill skill)
		{
		}

		public static Image RequirementsPanel_GetIcon(GameObject requirementsPanelGO)
		{
			return null;
		}

		public static GameObject[] RequirementsPanel_RequirementList(GameObject requirementsPanelGO)
		{
			return null;
		}

		public static void RequirementsPanel_SetWires(GameObject requirementsPanelGO, RequirementWireState[] wireStates, bool canCraft)
		{
		}

		public static Text CustomVariantPanel_Enable(string buttonLabel, Action<bool> onShow)
		{
			return null;
		}

		public static void CustomVariantPanel_SetButtonLabel(string buttonLabel)
		{
		}

		public static void CustomVariantPanel_Disable()
		{
		}
	}
}
namespace EpicLoot
{
	public static class API
	{
		private class AbilityProxyDefinition
		{
			public readonly AbilityDefinition Ability;

			public readonly Dictionary<string, Delegate> Delegates;

			public AbilityProxyDefinition(AbilityDefinition ability, Dictionary<string, Delegate> delegates)
			{
				Ability = ability;
				Delegates = delegates;
			}
		}

		public class AbilityProxy : Ability
		{
			public Dictionary<string, Delegate> _callbacks = new Dictionary<string, Delegate>();

			private T GetCallback<T>(string name) where T : Delegate
			{
				if (_callbacks.TryGetValue(name, out var value) && value is T result)
				{
					return result;
				}
				return null;
			}

			public override void Initialize(AbilityDefinition abilityDef, Player player)
			{
				base.Initialize(abilityDef, player);
				GetCallback<Action<Player, string, float>>("Initialize")?.Invoke(player, abilityDef.ID, abilityDef.Cooldown);
			}

			public override void OnUpdate()
			{
				Action callback = GetCallback<Action>("OnUpdate");
				if (callback == null)
				{
					base.OnUpdate();
				}
				else
				{
					callback();
				}
			}

			protected override bool ShouldTrigger()
			{
				return GetCallback<Func<bool>>("ShouldTrigger")?.Invoke() ?? base.ShouldTrigger();
			}

			public override bool IsOnCooldown()
			{
				return GetCallback<Func<bool>>("IsOnCooldown")?.Invoke() ?? base.IsOnCooldown();
			}

			public override float TimeUntilCooldownEnds()
			{
				return GetCallback<Func<float>>("TimeUntilCooldownEnds")?.Invoke() ?? base.TimeUntilCooldownEnds();
			}

			public override float PercentCooldownComplete()
			{
				return GetCallback<Func<float>>("PercentCooldownComplete")?.Invoke() ?? base.PercentCooldownComplete();
			}

			public override bool CanActivate()
			{
				return GetCallback<Func<bool>>("CanActivate")?.Invoke() ?? base.CanActivate();
			}

			public override void TryActivate()
			{
				Action callback = GetCallback<Action>("TryActivate");
				if (callback == null)
				{
					base.TryActivate();
				}
				else
				{
					callback();
				}
			}

			protected override void Activate()
			{
				Action callback = GetCallback<Action>("Activate");
				if (callback == null)
				{
					base.Activate();
				}
				else
				{
					callback();
				}
			}

			protected override void ActivateCustomAction()
			{
				Action callback = GetCallback<Action>("ActivateCustomAction");
				if (callback == null)
				{
					base.ActivateCustomAction();
				}
				else
				{
					callback();
				}
			}

			protected override void ActivateStatusEffectAction()
			{
				Action callback = GetCallback<Action>("ActivateStatusEffectAction");
				if (callback == null)
				{
					base.ActivateStatusEffectAction();
				}
				else
				{
					callback();
				}
			}

			protected override bool HasCooldown()
			{
				return GetCallback<Func<bool>>("HasCooldown")?.Invoke() ?? base.HasCooldown();
			}

			protected override void SetCooldownEndTime(float cooldownEndTime)
			{
				Action<float> callback = GetCallback<Action<float>>("SetCooldownEndTime");
				if (callback == null)
				{
					base.SetCooldownEndTime(cooldownEndTime);
				}
				else
				{
					callback(cooldownEndTime);
				}
			}

			public override float GetCooldownEndTime()
			{
				return GetCallback<Func<float>>("GetCooldownEndTime")?.Invoke() ?? base.GetCooldownEndTime();
			}

			public override void OnRemoved()
			{
				Action callback = GetCallback<Action>("OnRemoved");
				if (callback == null)
				{
					base.OnRemoved();
				}
				else
				{
					callback();
				}
			}
		}

		private static class RuntimeRegistry
		{
			private static readonly Dictionary<string, object> registry = new Dictionary<string, object>();

			private static int counter;

			public static string Register(object obj)
			{
				string name = obj.GetType().Name;
				string text = $"{name}_obj_{++counter}";
				registry[text] = obj;
				return text;
			}

			public static bool TryGetValue<T>(string key, out T value) where T : class
			{
				if (registry.TryGetValue(key, out var value2) && value2 is T val)
				{
					value = val;
					return true;
				}
				value = null;
				return false;
			}

			[PublicAPI]
			public static int GetCount()
			{
				return counter;
			}

			[PublicAPI]
			public static List<string> GetRegisteredKeys()
			{
				return registry.Keys.ToList();
			}
		}

		private enum SecretStashType
		{
			Materials,
			RandomItems,
			OtherItems,
			Gamble,
			Sale
		}

		private static bool ShowLogs;

		private static readonly Dictionary<string, MagicItemEffectDefinition> ExternalMagicItemEffectDefinitions;

		private static readonly Dictionary<string, AbilityDefinition> ExternalAbilities;

		private static readonly Dictionary<ItemRarity, List<LegendaryInfo>> ExternalLegendaryItems;

		private static readonly Dictionary<ItemRarity, List<LegendarySetInfo>> ExternalLegendarySets;

		private static readonly Dictionary<string, Object> ExternalAssets;

		private static readonly List<MaterialConversion> ExternalMaterialConversions;

		private static readonly List<RecipeConfig> ExternalRecipes;

		private static readonly List<DisenchantProductsConfig> ExternalSacrifices;

		private static readonly List<BountyTargetConfig> ExternalBountyTargets;

		private static readonly Dictionary<SecretStashType, List<SecretStashItemConfig>> ExternalSecretStashItems;

		private static readonly List<TreasureMapBiomeInfoConfig> ExternalTreasureMaps;

		private static readonly Dictionary<string, Dictionary<string, Delegate>> AbilityProxies;

		private static event Action<string> OnReload;

		private static event Action<string> OnError;

		private static event Action<string> OnDebug;

		[PublicAPI]
		public static string AddAbility(string json)
		{
			try
			{
				AbilityDefinition abilityDefinition = JsonConvert.DeserializeObject<AbilityDefinition>(json);
				if (abilityDefinition == null)
				{
					return null;
				}
				if (AbilityDefinitions.Abilities.ContainsKey(abilityDefinition.ID))
				{
					API.OnError?.Invoke("Duplicate entry found for Abilities: " + abilityDefinition.ID + " when adding from external plugin.");
					return null;
				}
				ExternalAbilities[abilityDefinition.ID] = abilityDefinition;
				AbilityDefinitions.Config.Abilities.Add(abilityDefinition);
				AbilityDefinitions.Abilities[abilityDefinition.ID] = abilityDefinition;
				return RuntimeRegistry.Register(abilityDefinition);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse ability definition passed in through external plugin.");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateAbility(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<AbilityDefinition>(key, out var value))
			{
				return false;
			}
			AbilityDefinition abilityDefinition = JsonConvert.DeserializeObject<AbilityDefinition>(json);
			if (abilityDefinition == null)
			{
				return false;
			}
			value.CopyFieldsFrom(abilityDefinition);
			return true;
		}

		public static bool HasCurrentAbility(Player player, string key)
		{
			if (!RuntimeRegistry.TryGetValue<AbilityDefinition>(key, out var value))
			{
				return false;
			}
			AbilityController abilityController = default(AbilityController);
			if (!((Component)player).TryGetComponent<AbilityController>(ref abilityController))
			{
				return false;
			}
			return abilityController.GetCurrentAbility(value.ID) != null;
		}

		private static bool TryGetProxyAbility(string abilityID, out Dictionary<string, Delegate> proxy)
		{
			return AbilityProxies.TryGetValue(abilityID, out proxy);
		}

		[PublicAPI]
		public static string RegisterProxyAbility(string json, Dictionary<string, Delegate> delegates)
		{
			try
			{
				AbilityDefinition abilityDefinition = JsonConvert.DeserializeObject<AbilityDefinition>(json);
				if (abilityDefinition == null)
				{
					return null;
				}
				AbilityFactory.Register(abilityDefinition.ID, typeof(AbilityProxy));
				AbilityProxies[abilityDefinition.ID] = delegates;
				AbilityProxyDefinition obj = new AbilityProxyDefinition(abilityDefinition, delegates);
				AbilityDefinitions.Config.Abilities.Add(abilityDefinition);
				AbilityDefinitions.Abilities[abilityDefinition.ID] = abilityDefinition;
				return RuntimeRegistry.Register(obj);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse ability definition from external plugin");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateProxyAbility(string key, string json, Dictionary<string, Delegate> proxy)
		{
			if (!RuntimeRegistry.TryGetValue<AbilityProxyDefinition>(key, out var value))
			{
				return false;
			}
			AbilityDefinition source = JsonConvert.DeserializeObject<AbilityDefinition>(json);
			value.Ability.CopyFieldsFrom(source);
			value.Delegates.CopyFieldsFrom(proxy);
			return true;
		}

		public static bool InjectCallbacks(this AbilityProxy proxy, string abilityID)
		{
			if (!TryGetProxyAbility(abilityID, out var proxy2))
			{
				return false;
			}
			proxy._callbacks = proxy2;
			return true;
		}

		static API()
		{
			ShowLogs = false;
			ExternalMagicItemEffectDefinitions = new Dictionary<string, MagicItemEffectDefinition>();
			ExternalAbilities = new Dictionary<string, AbilityDefinition>();
			ExternalLegendaryItems = new Dictionary<ItemRarity, List<LegendaryInfo>>();
			ExternalLegendarySets = new Dictionary<ItemRarity, List<LegendarySetInfo>>();
			ExternalAssets = new Dictionary<string, Object>();
			ExternalMaterialConversions = new List<MaterialConversion>();
			ExternalRecipes = new List<RecipeConfig>();
			ExternalSacrifices = new List<DisenchantProductsConfig>();
			ExternalBountyTargets = new List<BountyTargetConfig>();
			ExternalSecretStashItems = new Dictionary<SecretStashType, List<SecretStashItemConfig>>();
			ExternalTreasureMaps = new List<TreasureMapBiomeInfoConfig>();
			AbilityProxies = new Dictionary<string, Dictionary<string, Delegate>>();
			MagicItemEffectDefinitions.OnSetupMagicItemEffectDefinitions += ReloadExternalMagicEffects;
			UniqueLegendaryHelper.OnSetupLegendaryItemConfig += ReloadExternalLegendary;
			AbilityDefinitions.OnSetupAbilityDefinitions += ReloadExternalAbilities;
			MaterialConversions.OnSetupMaterialConversions += ReloadExternalMaterialConversions;
			RecipesHelper.OnSetupRecipeConfig += ReloadExternalRecipes;
			EnchantCostsHelper.OnSetupEnchantingCosts += ReloadExternalSacrifices;
			AdventureDataManager.OnSetupAdventureData += ReloadExternalAdventureData;
			OnReload += delegate(string message)
			{
				if (ShowLogs)
				{
					EpicLoot.Log(message);
				}
			};
			OnError += delegate(string message)
			{
				if (ShowLogs)
				{
					EpicLoot.LogWarning(message);
				}
			};
			OnDebug += delegate(string message)
			{
				if (ShowLogs)
				{
					EpicLoot.LogWarningForce(message);
				}
			};
		}

		[PublicAPI]
		public static bool RegisterAsset(string name, Object asset)
		{
			if (EpicAssets.AssetCache.ContainsKey(name))
			{
				API.OnError?.Invoke("Duplicate asset: " + name);
				return false;
			}
			EpicAssets.AssetCache[name] = asset;
			ExternalAssets[name] = asset;
			return true;
		}

		[PublicAPI]
		public static bool HasLegendaryItem(Player player, string legendaryItemID)
		{
			foreach (ItemData item in player.GetEquipment())
			{
				if (item.IsMagic(out var magicItem) && magicItem.LegendaryID == legendaryItemID)
				{
					return true;
				}
			}
			return false;
		}

		[PublicAPI]
		public static bool HasLegendarySet(Player player, string legendarySetID, ref int count)
		{
			if (!UniqueLegendaryHelper.TryGetLegendarySetInfo(legendarySetID, out var legendarySetInfo, out var _))
			{
				return false;
			}
			count = player.GetEquippedSetPieces(legendarySetID).Count;
			return count >= legendarySetInfo.LegendaryIDs.Count;
		}

		[PublicAPI]
		public static string GetMagicItemEffectDefinition(string type)
		{
			if (!MagicItemEffectDefinitions.AllDefinitions.TryGetValue(type, out var value))
			{
				return "";
			}
			return JsonConvert.SerializeObject((object)value);
		}

		[PublicAPI]
		public static float GetTotalActiveMagicEffectValue(Player player, ItemData item, string effectType, float scale)
		{
			return MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, item, effectType, scale);
		}

		[PublicAPI]
		public static float GetTotalActiveMagicEffectValueForWeapon(Player player, ItemData item, string effectType, float scale)
		{
			return MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, item, effectType, scale);
		}

		[PublicAPI]
		public static bool HasActiveMagicEffect(Player player, string effectType, ItemData item, ref float effectValue)
		{
			return MagicEffectsHelper.HasActiveMagicEffect(player, item, effectType, out effectValue);
		}

		[PublicAPI]
		public static bool HasActiveMagicEffectOnWeapon(Player player, ItemData item, string effectType, ref float effectValue)
		{
			return MagicEffectsHelper.HasActiveMagicEffectOnWeapon(player, item, effectType, out effectValue);
		}

		[PublicAPI]
		public static float GetTotalActiveSetEffectValue(Player player, string effectType, float scale)
		{
			return MagicEffectsHelper.GetTotalActiveSetEffectValue(player, effectType, scale);
		}

		[PublicAPI]
		public static List<string> GetAllActiveMagicEffects(Player player, string effectType = null)
		{
			List<MagicItemEffect> allActiveMagicEffects = player.GetAllActiveMagicEffects(effectType);
			List<string> list = new List<string>();
			foreach (MagicItemEffect item in allActiveMagicEffects)
			{
				list.Add(JsonConvert.SerializeObject((object)item));
			}
			return list;
		}

		[PublicAPI]
		public static List<string> GetAllActiveSetMagicEffects(Player player, string effectType = null)
		{
			List<MagicItemEffect> allActiveSetMagicEffects = player.GetAllActiveSetMagicEffects(effectType);
			List<string> list = new List<string>();
			foreach (MagicItemEffect item in allActiveSetMagicEffects)
			{
				list.Add(JsonConvert.SerializeObject((object)item));
			}
			return list;
		}

		[PublicAPI]
		public static float GetTotalPlayerActiveMagicEffectValue(Player player, string effectType, float scale, ItemData ignoreThisItem = null)
		{
			return player.GetTotalActiveMagicEffectValue(effectType, scale, ignoreThisItem);
		}

		[PublicAPI]
		public static bool PlayerHasActiveMagicEffect(Player player, string effectType, ref float effectValue, float scale = 1f, ItemData ignoreThisItem = null)
		{
			return player.HasActiveMagicEffect(effectType, out effectValue, scale, ignoreThisItem);
		}

		[PublicAPI]
		public static string GetMagicItemJson(ItemData itemData)
		{
			if (!itemData.IsMagic())
			{
				return null;
			}
			return JsonConvert.SerializeObject((object)itemData.GetMagicItem());
		}

		[PublicAPI]
		public static string AddBountyTarget(string json)
		{
			try
			{
				BountyTargetConfig bountyTargetConfig = JsonConvert.DeserializeObject<BountyTargetConfig>(json);
				if (bountyTargetConfig == null)
				{
					return null;
				}
				ExternalBountyTargets.Add(bountyTargetConfig);
				AdventureDataManager.Config.Bounties.Targets.Add(bountyTargetConfig);
				return RuntimeRegistry.Register(bountyTargetConfig);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse bounty target passed in through external plugin.");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateBountyTarget(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<BountyTargetConfig>(key, out var value))
			{
				return false;
			}
			BountyTargetConfig source = JsonConvert.DeserializeObject<BountyTargetConfig>(json);
			value.CopyFieldsFrom(source);
			return true;
		}

		[PublicAPI]
		public static string AddRecipe(string json)
		{
			try
			{
				RecipeConfig recipeConfig = JsonConvert.DeserializeObject<RecipeConfig>(json);
				if (recipeConfig == null)
				{
					return null;
				}
				ExternalRecipes.Add(recipeConfig);
				RecipesHelper.Config.recipes.Add(recipeConfig);
				return RuntimeRegistry.Register(recipeConfig);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse recipe passed in through external plugin.");
				return null;
			}
		}

		[PublicAPI]
		public static string AddRecipes(string json)
		{
			try
			{
				List<RecipeConfig> list = JsonConvert.DeserializeObject<List<RecipeConfig>>(json);
				if (list == null)
				{
					return null;
				}
				ExternalRecipes.AddRange(list);
				RecipesHelper.Config.recipes.AddRange(list);
				return RuntimeRegistry.Register(list);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse recipe from external plugin");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateRecipes(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<List<RecipeConfig>>(key, out var value))
			{
				return false;
			}
			List<RecipeConfig> list = JsonConvert.DeserializeObject<List<RecipeConfig>>(json);
			if (list == null)
			{
				return false;
			}
			ExternalRecipes.ReplaceThenAdd(value, list);
			RecipesHelper.Config.recipes.ReplaceThenAdd(value, list);
			return true;
		}

		private static void AddOrSet<T, V>(this Dictionary<T, List<V>> dict, T key, V value)
		{
			if (!dict.ContainsKey(key))
			{
				dict[key] = new List<V>();
			}
			dict[key].Add(value);
		}

		private static void CopyFieldsFrom<T>(this T target, T source)
		{
			FieldInfo[] fields = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo obj in fields)
			{
				obj.SetValue(value: obj.GetValue(source), obj: target);
			}
		}

		private static void ReplaceThenAdd<T>(this List<T> list, List<T> original, List<T> replacements)
		{
			list.RemoveAll(original);
			list.AddRange(replacements);
		}

		private static void RemoveAll<T>(this List<T> list, List<T> itemsToRemove)
		{
			foreach (T item in itemsToRemove)
			{
				list.Remove(item);
			}
		}

		[PublicAPI]
		public static string AddLegendaryItem(string type, string json)
		{
			try
			{
				if (!Enum.TryParse<ItemRarity>(type, ignoreCase: true, out var result))
				{
					return null;
				}
				LegendaryInfo legendaryInfo = JsonConvert.DeserializeObject<LegendaryInfo>(json);
				if (legendaryInfo == null)
				{
					return null;
				}
				switch (result)
				{
				case ItemRarity.Legendary:
					UniqueLegendaryHelper.Config.LegendaryItems.Add(legendaryInfo);
					UniqueLegendaryHelper.LegendaryInfo[legendaryInfo.ID] = legendaryInfo;
					break;
				case ItemRarity.Mythic:
					UniqueLegendaryHelper.Config.MythicItems.Add(legendaryInfo);
					UniqueLegendaryHelper.MythicInfo[legendaryInfo.ID] = legendaryInfo;
					break;
				}
				ExternalLegendaryItems.AddOrSet(result, legendaryInfo);
				return RuntimeRegistry.Register(legendaryInfo);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse legendary item from external plugin.");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateLegendaryItem(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<LegendaryInfo>(key, out var value))
			{
				return false;
			}
			LegendaryInfo legendaryInfo = JsonConvert.DeserializeObject<LegendaryInfo>(json);
			if (legendaryInfo == null)
			{
				return false;
			}
			value.CopyFieldsFrom(legendaryInfo);
			return true;
		}

		[PublicAPI]
		public static string AddLegendarySet(string type, string json)
		{
			try
			{
				if (!Enum.TryParse<ItemRarity>(type, ignoreCase: true, out var result))
				{
					return null;
				}
				LegendarySetInfo legendarySetInfo = JsonConvert.DeserializeObject<LegendarySetInfo>(json);
				if (legendarySetInfo == null)
				{
					return null;
				}
				switch (result)
				{
				case ItemRarity.Legendary:
					UniqueLegendaryHelper.LegendarySets[legendarySetInfo.ID] = legendarySetInfo;
					UniqueLegendaryHelper.Config.LegendarySets.Add(legendarySetInfo);
					foreach (string legendaryID in legendarySetInfo.LegendaryIDs)
					{
						UniqueLegendaryHelper.LegendaryItemsToSetMap[legendaryID] = legendarySetInfo;
					}
					break;
				case ItemRarity.Mythic:
					UniqueLegendaryHelper.MythicSets[legendarySetInfo.ID] = legendarySetInfo;
					UniqueLegendaryHelper.Config.MythicSets.Add(legendarySetInfo);
					foreach (string legendaryID2 in legendarySetInfo.LegendaryIDs)
					{
						UniqueLegendaryHelper.MythicItemsToSetMap[legendaryID2] = legendarySetInfo;
					}
					break;
				}
				ExternalLegendarySets.AddOrSet(result, legendarySetInfo);
				return RuntimeRegistry.Register(legendarySetInfo);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse legendary set from external plugin.");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateLegendarySet(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<LegendarySetInfo>(key, out var value))
			{
				return false;
			}
			LegendarySetInfo legendarySetInfo = JsonConvert.DeserializeObject<LegendarySetInfo>(json);
			if (legendarySetInfo == null)
			{
				return false;
			}
			value.CopyFieldsFrom(legendarySetInfo);
			return true;
		}

		[PublicAPI]
		public static string AddMagicEffect(string json)
		{
			try
			{
				MagicItemEffectDefinition magicItemEffectDefinition = JsonConvert.DeserializeObject<MagicItemEffectDefinition>(json);
				if (magicItemEffectDefinition == null)
				{
					return null;
				}
				MagicItemEffectDefinitions.Add(magicItemEffectDefinition);
				ExternalMagicItemEffectDefinitions[magicItemEffectDefinition.Type] = magicItemEffectDefinition;
				return RuntimeRegistry.Register(magicItemEffectDefinition);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse magic effect from external plugin");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateMagicEffect(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<MagicItemEffectDefinition>(key, out var value))
			{
				return false;
			}
			MagicItemEffectDefinition magicItemEffectDefinition = JsonConvert.DeserializeObject<MagicItemEffectDefinition>(json);
			if (magicItemEffectDefinition == null)
			{
				return false;
			}
			value.CopyFieldsFrom(magicItemEffectDefinition);
			return true;
		}

		[PublicAPI]
		public static string AddMaterialConversion(string json)
		{
			try
			{
				MaterialConversion materialConversion = JsonConvert.DeserializeObject<MaterialConversion>(json);
				if (materialConversion == null)
				{
					return null;
				}
				ExternalMaterialConversions.Add(materialConversion);
				MaterialConversions.Config.MaterialConversions.Add(materialConversion);
				MaterialConversions.Conversions.Add(materialConversion.Type, materialConversion);
				return RuntimeRegistry.Register(materialConversion);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse material conversion passed in through external plugin.");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateMaterialConversion(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<MaterialConversion>(key, out var value))
			{
				return false;
			}
			MaterialConversion materialConversion = JsonConvert.DeserializeObject<MaterialConversion>(json);
			if (materialConversion == null)
			{
				return false;
			}
			value.CopyFieldsFrom(materialConversion);
			return true;
		}

		private static void ReloadExternalAdventureData()
		{
			ReloadExternalBounties();
			ReloadExternalSecretStashItems();
			ReloadExternalTreasures();
		}

		private static void ReloadExternalSecretStashItems()
		{
			foreach (KeyValuePair<SecretStashType, List<SecretStashItemConfig>> externalSecretStashItem in ExternalSecretStashItems)
			{
				switch (externalSecretStashItem.Key)
				{
				case SecretStashType.Materials:
					AdventureDataManager.Config.SecretStash.Materials.AddRange(externalSecretStashItem.Value);
					break;
				case SecretStashType.OtherItems:
					AdventureDataManager.Config.SecretStash.OtherItems.AddRange(externalSecretStashItem.Value);
					break;
				case SecretStashType.RandomItems:
					AdventureDataManager.Config.SecretStash.RandomItems.AddRange(externalSecretStashItem.Value);
					break;
				case SecretStashType.Gamble:
					AdventureDataManager.Config.Gamble.GambleCosts.AddRange(externalSecretStashItem.Value);
					break;
				case SecretStashType.Sale:
					AdventureDataManager.Config.TreasureMap.SaleItems.AddRange(externalSecretStashItem.Value);
					break;
				}
			}
		}

		private static void ReloadExternalTreasures()
		{
			foreach (TreasureMapBiomeInfoConfig externalTreasureMap in ExternalTreasureMaps)
			{
				AdventureDataManager.Config.TreasureMap.BiomeInfo.Add(externalTreasureMap);
			}
			API.OnReload?.Invoke("Reloaded external treasures");
		}

		private static void ReloadExternalBounties()
		{
			AdventureDataManager.Config.Bounties.Targets.AddRange(ExternalBountyTargets);
			API.OnReload?.Invoke("Reloaded external bounties");
		}

		private static void ReloadExternalSacrifices()
		{
			EnchantCostsHelper.Config.DisenchantProducts.AddRange(ExternalSacrifices);
			API.OnReload?.Invoke("Reloaded external sacrifices");
		}

		private static void ReloadExternalRecipes()
		{
			RecipesHelper.Config.recipes.RemoveAll(ExternalRecipes);
			RecipesHelper.Config.recipes.AddRange(ExternalRecipes);
			API.OnReload?.Invoke("Reloaded external recipes");
		}

		private static void ReloadExternalMaterialConversions()
		{
			foreach (MaterialConversion externalMaterialConversion in ExternalMaterialConversions)
			{
				MaterialConversions.Config.MaterialConversions.Add(externalMaterialConversion);
			}
			API.OnReload?.Invoke("Reloaded external material conversions");
		}

		private static void ReloadExternalMagicEffects()
		{
			foreach (MagicItemEffectDefinition value in ExternalMagicItemEffectDefinitions.Values)
			{
				MagicItemEffectDefinitions.Add(value);
			}
			API.OnReload?.Invoke("Reloaded external magic effects");
		}

		private static void ReloadExternalAbilities()
		{
			foreach (KeyValuePair<string, AbilityDefinition> externalAbility in ExternalAbilities)
			{
				AbilityDefinitions.Config.Abilities.Add(externalAbility.Value);
			}
			API.OnReload?.Invoke("Reloaded external abilities");
		}

		private static void ReloadExternalLegendary()
		{
			foreach (KeyValuePair<ItemRarity, List<LegendaryInfo>> externalLegendaryItem in ExternalLegendaryItems)
			{
				switch (externalLegendaryItem.Key)
				{
				case ItemRarity.Legendary:
					UniqueLegendaryHelper.Config.LegendaryItems.AddRange(externalLegendaryItem.Value);
					break;
				case ItemRarity.Mythic:
					UniqueLegendaryHelper.Config.MythicItems.AddRange(externalLegendaryItem.Value);
					break;
				}
			}
			foreach (KeyValuePair<ItemRarity, List<LegendarySetInfo>> externalLegendarySet in ExternalLegendarySets)
			{
				switch (externalLegendarySet.Key)
				{
				case ItemRarity.Legendary:
					UniqueLegendaryHelper.Config.LegendarySets.AddRange(externalLegendarySet.Value);
					break;
				case ItemRarity.Mythic:
					UniqueLegendaryHelper.Config.MythicSets.AddRange(externalLegendarySet.Value);
					break;
				}
			}
			API.OnReload?.Invoke("Reloaded external legendary abilities");
		}

		public static void ReloadExternalAssets()
		{
			foreach (KeyValuePair<string, Object> externalAsset in ExternalAssets)
			{
				EpicAssets.AssetCache[externalAsset.Key] = externalAsset.Value;
			}
			API.OnReload?.Invoke("Reloaded external assets");
		}

		[PublicAPI]
		public static string AddSacrifice(string json)
		{
			try
			{
				DisenchantProductsConfig disenchantProductsConfig = JsonConvert.DeserializeObject<DisenchantProductsConfig>(json);
				if (disenchantProductsConfig == null)
				{
					return null;
				}
				ExternalSacrifices.Add(disenchantProductsConfig);
				EnchantCostsHelper.Config.DisenchantProducts.Add(disenchantProductsConfig);
				return RuntimeRegistry.Register(disenchantProductsConfig);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse sacrifice from external plugin");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateSacrifice(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<DisenchantProductsConfig>(key, out var value))
			{
				return false;
			}
			DisenchantProductsConfig source = JsonConvert.DeserializeObject<DisenchantProductsConfig>(json);
			value.CopyFieldsFrom(source);
			return true;
		}

		[PublicAPI]
		public static string AddSecretStashItem(string type, string json)
		{
			try
			{
				if (!Enum.TryParse<SecretStashType>(type, ignoreCase: true, out var result))
				{
					return null;
				}
				SecretStashItemConfig secretStashItemConfig = JsonConvert.DeserializeObject<SecretStashItemConfig>(json);
				if (secretStashItemConfig == null)
				{
					return null;
				}
				ExternalSecretStashItems.AddOrSet(result, secretStashItemConfig);
				switch (result)
				{
				case SecretStashType.Materials:
					AdventureDataManager.Config.SecretStash.Materials.Add(secretStashItemConfig);
					break;
				case SecretStashType.OtherItems:
					AdventureDataManager.Config.SecretStash.OtherItems.Add(secretStashItemConfig);
					break;
				case SecretStashType.RandomItems:
					AdventureDataManager.Config.SecretStash.RandomItems.Add(secretStashItemConfig);
					break;
				case SecretStashType.Gamble:
					AdventureDataManager.Config.Gamble.GambleCosts.Add(secretStashItemConfig);
					break;
				case SecretStashType.Sale:
					AdventureDataManager.Config.TreasureMap.SaleItems.Add(secretStashItemConfig);
					break;
				}
				return RuntimeRegistry.Register(secretStashItemConfig);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse secret stash from external plugin");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateSecretStashItem(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<SecretStashItemConfig>(key, out var value))
			{
				return false;
			}
			SecretStashItemConfig secretStashItemConfig = JsonConvert.DeserializeObject<SecretStashItemConfig>(json);
			if (secretStashItemConfig == null)
			{
				return false;
			}
			value.CopyFieldsFrom(secretStashItemConfig);
			return true;
		}

		[PublicAPI]
		public static string AddTreasureMap(string json)
		{
			try
			{
				TreasureMapBiomeInfoConfig treasureMapBiomeInfoConfig = JsonConvert.DeserializeObject<TreasureMapBiomeInfoConfig>(json);
				if (treasureMapBiomeInfoConfig == null)
				{
					return null;
				}
				ExternalTreasureMaps.Add(treasureMapBiomeInfoConfig);
				AdventureDataManager.Config.TreasureMap.BiomeInfo.Add(treasureMapBiomeInfoConfig);
				return RuntimeRegistry.Register(treasureMapBiomeInfoConfig);
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse treasure map from external plugin");
				return null;
			}
		}

		[PublicAPI]
		public static bool UpdateTreasureMap(string key, string json)
		{
			if (!RuntimeRegistry.TryGetValue<TreasureMapBiomeInfoConfig>(key, out var value))
			{
				return false;
			}
			try
			{
				TreasureMapBiomeInfoConfig source = JsonConvert.DeserializeObject<TreasureMapBiomeInfoConfig>(json);
				value.CopyFieldsFrom(source);
				return true;
			}
			catch
			{
				API.OnError?.Invoke("Failed to parse treasure map from external plugin");
				return false;
			}
		}
	}
	public sealed class EpicAssets
	{
		public AssetBundle AssetBundle;

		public static Dictionary<string, Object> AssetCache = new Dictionary<string, Object>();

		public Sprite EquippedSprite;

		public Sprite AugaEquippedSprite;

		public Sprite GenericSetItemSprite;

		public Sprite AugaSetItemSprite;

		public Sprite GenericItemBgSprite;

		public Sprite AugaItemBgSprite;

		public Sprite EnchantmentSparkle;

		public GameObject[] MagicItemLootBeamPrefabs = (GameObject[])(object)new GameObject[5];

		public readonly Dictionary<string, GameObject[]> CraftingMaterialPrefabs = new Dictionary<string, GameObject[]>();

		public Sprite SmallButtonEnchantOverlay;

		public Sprite DodgeBuffSprite;

		public AudioClip[] MagicItemDropSFX = (AudioClip[])(object)new AudioClip[5];

		public AudioClip ItemLoopSFX;

		public AudioClip AugmentItemSFX;

		public GameObject MerchantPanel;

		public Sprite MapIconTreasureMap;

		public Sprite MapIconBounty;

		public AudioClip AbandonBountySFX;

		public AudioClip DoubleJumpSFX;

		public AudioClip DodgeBuffSFX;

		public AudioClip OffSetSFX;

		public GameObject DebugTextPrefab;

		public GameObject AbilityBar;

		public GameObject WelcomMessagePrefab;

		public const string DummyName = "EL_DummyPrefab";

		public static GameObject DummyPrefab()
		{
			return PrefabManager.Instance.GetPrefab("EL_DummyPrefab");
		}
	}
	public sealed class PieceDef
	{
		public string Table;

		public string CraftingStation;

		public string ExtendStation;

		public List<RecipeRequirementConfig> Resources = new List<RecipeRequirementConfig>();
	}
	[BepInPlugin("randyknapp.mods.epicloot", "Epic Loot", "0.12.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class EpicLoot : BaseUnityPlugin
	{
		public const string PluginId = "randyknapp.mods.epicloot";

		public const string DisplayName = "Epic Loot";

		public const string Version = "0.12.3";

		private static string ConfigFileName = "randyknapp.mods.epicloot.cfg";

		private static string ConfigFileFullPath;

		public static readonly Dictionary<string, string> MagicItemColors;

		public static string[] MagicMaterials;

		public static string[] ItemNames;

		public static EpicAssets Assets;

		public static bool AlwaysDropCheat;

		public const PinType BountyPinType = 800;

		public const PinType TreasureMapPinType = 801;

		public static bool HasAuga;

		public static bool AugaTooltipNoTextBoxes;

		private static EpicLoot _instance;

		private Harmony _harmony;

		private float _worldLuckFactor;

		internal ELConfig cfg;

		private DateTime _lastReloadTime;

		private const long RELOAD_DELAY = 10000000L;

		public static event Action AbilitiesInitialized;

		public static event Action LootTableLoaded;

		[UsedImplicitly]
		private void Awake()
		{
			_instance = this;
			LoadEmbeddedAssembly(Assembly.GetExecutingAssembly(), "EpicLoot-UnityLib.dll");
			cfg = new ELConfig(((BaseUnityPlugin)this).Config);
			PrefabCreator.Logger = ((BaseUnityPlugin)this).Logger;
			InitializeAbilities();
			AddLocalizations();
			LoadAssets();
			EnchantingUIController.Initialize();
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "randyknapp.mods.epicloot");
			EpicLoot.LootTableLoaded?.Invoke();
			RegisterMagicEffectEvents();
			TerminalCommands.AddTerminalCommands();
			SetupWatcher();
		}

		private static void RegisterMagicEffectEvents()
		{
			MagicItemEffectDefinitions.OnSetupMagicItemEffectDefinitions += Riches_CharacterDrop_GenerateDropList_Patch.UpdateRichesOnEffectSetup;
		}

		private static void LoadEmbeddedAssembly(Assembly assembly, string assemblyName)
		{
			Stream manifestResourceStream = assembly.GetManifestResourceStream(assembly.GetName().Name + "." + assemblyName);
			if (manifestResourceStream == null)
			{
				LogErrorForce("Could not load embedded assembly (" + assemblyName + ")!");
				return;
			}
			using (manifestResourceStream)
			{
				byte[] array = new byte[manifestResourceStream.Length];
				manifestResourceStream.Read(array, 0, array.Length);
				Assembly.Load(array);
			}
		}

		private void AddLocalizations()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			Log("Loading Localizations.");
			string[] manifestResourceNames = typeof(EpicLoot).Assembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (text.Contains("localizations"))
				{
					string text2 = Regex.Replace(ReadEmbeddedResourceFile(text), "\\/\\/.*\\n", "");
					string[] array = text.Split(new char[1] { '.' });
					Log("Adding localization: " + array[2]);
					localization.AddJsonFile(array[2], text2);
				}
			}
			ELConfig.StartupProcessModifiedLocalizations();
		}

		private static void InitializeAbilities()
		{
			MagicEffectType.Initialize();
			EpicLoot.AbilitiesInitialized?.Invoke();
		}

		public static void Log(string message)
		{
			if (ELConfig._loggingEnabled.Value && ELConfig._logLevel.Value <= LogLevel.Info)
			{
				((BaseUnityPlugin)_instance).Logger.LogInfo((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			if (ELConfig._loggingEnabled.Value && ELConfig._logLevel.Value <= LogLevel.Warning)
			{
				((BaseUnityPlugin)_instance).Logger.LogWarning((object)message);
			}
		}

		public static void LogError(string message)
		{
			if (ELConfig._loggingEnabled.Value && ELConfig._logLevel.Value <= LogLevel.Error)
			{
				((BaseUnityPlugin)_instance).Logger.LogError((object)message);
			}
		}

		public static void LogWarningForce(string message)
		{
			((BaseUnityPlugin)_instance).Logger.LogWarning((object)message);
		}

		public static void LogErrorForce(string message)
		{
			((BaseUnityPlugin)_instance).Logger.LogError((object)message);
		}

		private void LoadAssets()
		{
			AssetBundle val = LoadAssetBundle("epicloot");
			if ((Object)(object)val == (Object)null || Assets == null)
			{
				LogErrorForce("Unable to load asset bundle! This mod will not behave as expected!");
				return;
			}
			Assets.AssetBundle = val;
			Assets.EquippedSprite = val.LoadAsset<Sprite>("Equipped");
			Assets.AugaEquippedSprite = val.LoadAsset<Sprite>("AugaEquipped");
			Assets.GenericSetItemSprite = val.LoadAsset<Sprite>("GenericSetItemMarker");
			Assets.AugaSetItemSprite = val.LoadAsset<Sprite>("AugaSetItem");
			Assets.GenericItemBgSprite = val.LoadAsset<Sprite>("GenericItemBg");
			Assets.AugaItemBgSprite = val.LoadAsset<Sprite>("AugaItemBG");
			Assets.EnchantmentSparkle = val.LoadAsset<Sprite>("sparkle");
			Assets.SmallButtonEnchantOverlay = val.LoadAsset<Sprite>("SmallButtonEnchantOverlay");
			Assets.DodgeBuffSprite = val.LoadAsset<Sprite>("DodgeBuff");
			Assets.MagicItemLootBeamPrefabs[0] = val.LoadAsset<GameObject>("MagicLootBeam");
			Assets.MagicItemLootBeamPrefabs[1] = val.LoadAsset<GameObject>("RareLootBeam");
			Assets.MagicItemLootBeamPrefabs[2] = val.LoadAsset<GameObject>("EpicLootBeam");
			Assets.MagicItemLootBeamPrefabs[3] = val.LoadAsset<GameObject>("LegendaryLootBeam");
			Assets.MagicItemLootBeamPrefabs[4] = val.LoadAsset<GameObject>("MythicLootBeam");
			Assets.MagicItemDropSFX[0] = val.LoadAsset<AudioClip>("MagicItemDrop");
			Assets.MagicItemDropSFX[1] = val.LoadAsset<AudioClip>("RareItemDrop");
			Assets.MagicItemDropSFX[2] = val.LoadAsset<AudioClip>("EpicItemDrop");
			Assets.MagicItemDropSFX[3] = val.LoadAsset<AudioClip>("LegendaryItemDrop");
			Assets.MagicItemDropSFX[4] = val.LoadAsset<AudioClip>("MythicItemDrop");
			Assets.ItemLoopSFX = val.LoadAsset<AudioClip>("ItemLoop");
			Assets.AugmentItemSFX = val.LoadAsset<AudioClip>("AugmentItem");
			Assets.MerchantPanel = val.LoadAsset<GameObject>("MerchantPanel");
			Assets.MapIconTreasureMap = val.LoadAsset<Sprite>("TreasureMapIcon");
			Assets.MapIconBounty = val.LoadAsset<Sprite>("MapIconBounty");
			Assets.AbandonBountySFX = val.LoadAsset<AudioClip>("AbandonBounty");
			Assets.DoubleJumpSFX = val.LoadAsset<AudioClip>("DoubleJump");
			Assets.DodgeBuffSFX = val.LoadAsset<AudioClip>("evasionbuff");
			Assets.OffSetSFX = val.LoadAsset<AudioClip>("offset");
			Assets.DebugTextPrefab = val.LoadAsset<GameObject>("DebugText");
			Assets.AbilityBar = val.LoadAsset<GameObject>("AbilityBar");
			Assets.WelcomMessagePrefab = val.LoadAsset<GameObject>("WelcomeMessage");
			LoadCraftingMaterialAssets();
			LoadPieces();
			LoadItems();
			LoadBountySpawner();
			PrefabManager.OnPrefabsRegistered += SetupAndvaranaut;
			ItemManager.OnItemsRegistered += SetupStatusEffects;
			LoadUnidentifiedItems();
			MinimapManager.OnVanillaMapDataLoaded += delegate
			{
				AutoAddEnchantableItems.CheckAndAddAllEnchantableItems();
			};
			DodgeBuff.CreateMyStatusEffect();
		}

		public static T LoadAsset<T>(string assetName) where T : Object
		{
			try
			{
				if (EpicAssets.AssetCache.ContainsKey(assetName))
				{
					return (T)(object)EpicAssets.AssetCache[assetName];
				}
				T val = Assets.AssetBundle.LoadAsset<T>(assetName);
				EpicAssets.AssetCache.Add(assetName, (Object)(object)val);
				return val;
			}
			catch (Exception ex)
			{
				LogErrorForce("Error loading asset (" + assetName + "): " + ex.Message);
				return default(T);
			}
		}

		private static void LoadPieces()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//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_0051: 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_0061: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0082: Expected O, but got Unknown
			//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)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			GameObject val = Assets.AssetBundle.LoadAsset<GameObject>("piece_enchanter");
			PieceConfig val2 = new PieceConfig();
			val2.PieceTable = "Hammer";
			val2.Category = PieceCategories.Misc;
			val2.AllowedInDungeons = false;
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
			{
				new RequirementConfig
				{
					Item = "Stone",
					Amount = 10,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SurtlingCore",
					Amount = 3,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "Copper",
					Amount = 3,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SwordCheat",
					Amount = 1,
					Recover = false
				}
			};
			PieceManager.Instance.AddPiece(new CustomPiece(val, true, val2));
			GameObject val3 = Assets.AssetBundle.LoadAsset<GameObject>("piece_augmenter");
			PieceConfig val4 = new PieceConfig();
			val4.PieceTable = "Hammer";
			val4.Category = PieceCategories.Misc;
			val4.AllowedInDungeons = false;
			val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
			{
				new RequirementConfig
				{
					Item = "Obsidian",
					Amount = 10,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "Crystal",
					Amount = 3,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "Bronze",
					Amount = 3,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SwordCheat",
					Amount = 1,
					Recover = false
				}
			};
			PieceManager.Instance.AddPiece(new CustomPiece(val3, true, val4));
			GameObject val5 = Assets.AssetBundle.LoadAsset<GameObject>("piece_enchantingtable");
			PieceConfig val6 = new PieceConfig();
			val6.PieceTable = "Hammer";
			val6.Category = PieceCategories.Crafting;
			val6.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "FineWood",
					Amount = 10,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SurtlingCore",
					Amount = 1,
					Recover = true
				}
			};
			PieceManager.Instance.AddPiece(new CustomPiece(val5, true, val6));
		}

		private static void LoadItems()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			string[] itemNames = ItemNames;
			foreach (string text in itemNames)
			{
				CustomItem val = new CustomItem(Assets.AssetBundle.LoadAsset<GameObject>(text), false);
				ItemManager.Instance.AddItem(val);
			}
			GameObject obj = PrefabManager.Instance.CreateEmptyPrefab("EL_DummyPrefab", true);
			ItemDrop obj2 = obj.AddComponent<ItemDrop>();
			obj2.m_itemData.m_shared = new SharedData();
			obj2.m_itemData.m_shared.m_name = "";
			CustomItem val2 = new CustomItem(obj, false);
			ItemManager.Instance.AddItem(val2);
		}

		private static void LoadBountySpawner()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			GameObject val = Assets.AssetBundle.LoadAsset<GameObject>("EL_SpawnController");
			if ((Object)(object)val == (Object)null)
			{
				LogErrorForce("Unable to find bounty spawner asset! This mod will not behave as expected!");
				return;
			}
			val.AddComponent<AdventureSpawnController>();
			CustomPrefab val2 = new CustomPrefab(val, false);
			PrefabManager.Instance.AddPrefab(val2);
		}

		private static void LoadCraftingMaterialAssets()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			string[] magicMaterials = MagicMaterials;
			foreach (string arg in magicMaterials)
			{
				foreach (ItemRarity value in Enum.GetValues(typeof(ItemRarity)))
				{
					string text = $"{arg}{value}";
					GameObject val = Assets.AssetBundle.LoadAsset<GameObject>(text);
					if ((Object)(object)val == (Object)null)
					{
						LogErrorForce("Tried to load asset " + text + " but it does not exist in the asset bundle!");
						continue;
					}
					ItemDrop component = val.GetComponent<ItemDrop>();
					if ((Object)(object)component != (Object)null && component.m_itemData.IsMagicCraftingMaterial())
					{
						component.m_itemData.m_variant = GetRarityIconIndex(value);
					}
					component.m_itemData.CreateMagicItem();
					CustomItem val2 = new CustomItem(val, false);
					ItemManager.Instance.AddItem(val2);
				}
			}
		}

		private static void LoadUnidentifiedItems()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_011a: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			GameObject val = Assets.AssetBundle.LoadAsset<GameObject>("_Unidentified");
			CustomItem val2 = new CustomItem(val, false);
			ItemManager.Instance.AddItem(val2);
			val.SetActive(false);
			string[] names = Enum.GetNames(typeof(Biome));
			foreach (string text in names)
			{
				if (text == "None" || text == "All")
				{
					continue;
				}
				foreach (ItemRarity value in Enum.GetValues(typeof(ItemRarity)))
				{
					GameObject val3 = Object.Instantiate<GameObject>(val);
					string prefabName = $"{text}_{value}_Unidentified";
					((Object)val3).name = prefabName;
					ItemDrop component = val3.GetComponent<ItemDrop>();
					MagicItemComponent orCreate = component.m_itemData.Data().GetOrCreate<MagicItemComponent>();
					component.m_itemData.m_dropPrefab = val3;
					orCreate.SetMagicItem(new MagicItem
					{
						Rarity = value,
						IsUnidentified = true
					});
					orCreate.Save();
					ItemConfig val4 = new ItemConfig
					{
						Name = $"$mod_epicloot_{value} $mod_epicloot_unidentified_{text}",
						Description = "$mod_epicloot_unidentified_introduce"
					};
					CustomItem val5 = new CustomItem(val3, false, val4);
					ItemManager.Instance.AddItem(val5);
					ItemManager.OnItemsRegistered += delegate
					{
						EnableUnidentified(prefabName);
					};
					void EnableUnidentified(string prefabname)
					{
						PrefabManager.Instance.GetPrefab(prefabName).SetActive(true);
						PrefabManager.Instance.GetPrefab(prefabName).GetComponent<ItemDrop>().m_itemData.m_dropPrefab = PrefabManager.Instance.GetPrefab(prefabName);
						ItemManager.OnItemsRegistered -= delegate
						{
							EnableUnidentified(prefabname);
						};
					}
				}
			}
		}

		[UsedImplicitly]
		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
			_instance = null;
		}

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

		private static void SetupAndvaranaut()
		{
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			GameObject obj = Assets.AssetBundle.LoadAsset<GameObject>("Andvaranaut");
			ItemDrop component = obj.GetComponent<ItemDrop>();
			ItemData itemData = component.m_itemData;
			ItemData itemData2 = ObjectDB.instance.GetItemPrefab("Wishbone").GetComponent<ItemDrop>().m_itemData;
			StatusEffect equipStatusEffect = itemData2.m_shared.m_equipStatusEffect;
			SE_CustomFinder sE_CustomFinder = ScriptableObject.CreateInstance<SE_CustomFinder>();
			Utils.CopyFields(equipStatusEffect, sE_CustomFinder, typeof(SE_Finder));
			((Object)sE_CustomFinder).name = "CustomWishboneFinder";
			SE_CustomFinder sE_CustomFinder2 = ScriptableObject.CreateInstance<SE_CustomFinder>();
			Utils.CopyFields(sE_CustomFinder, sE_CustomFinder2, typeof(SE_CustomFinder));
			((Object)sE_CustomFinder2).name = "Andvaranaut";
			((StatusEffect)sE_CustomFinder2).m_name = "$mod_epicloot_item_andvaranaut";
			((StatusEffect)sE_CustomFinder2).m_icon = itemData.GetIcon();
			((StatusEffect)sE_CustomFinder2).m_tooltip = "$mod_epicloot_item_andvaranaut_tooltip";
			((StatusEffect)sE_CustomFinder2).m_startMessage = "$mod_epicloot_item_andvaranaut_startmsg";
			sE_CustomFinder2.RequiredComponentTypes = new List<Type>
			{
				typeof(TreasureMapChest),
				typeof(BountyTarget)
			};
			sE_CustomFinder.DisallowedComponentTypes = new List<Type>
			{
				typeof(TreasureMapChest),
				typeof(BountyTarget)
			};
			ObjectDB.instance.m_StatusEffects.Remove(equipStatusEffect);
			ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)sE_CustomFinder2);
			ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)sE_CustomFinder);
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)sE_CustomFinder2;
			itemData2.m_shared.m_equipStatusEffect = (StatusEffect)(object)sE_CustomFinder;
			MagicItem magicItem = new MagicItem
			{
				Rarity = ItemRarity.Epic,
				TypeNameOverride = "$mod_epicloot_item_andvaranaut_type"
			};
			magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.Andvaranaut));
			component.m_itemData.SaveMagicItem(magicItem);
			CustomItem val = new CustomItem(obj, false);
			ItemManager.Instance.AddItem(val);
			PrefabManager.OnPrefabsRegistered -= SetupAndvaranaut;
		}

		private static void SetupStatusEffects()
		{
			StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect("Lightning".GetHashCode());
			SE_Paralyzed sE_Paralyzed = ScriptableObject.CreateInstance<SE_Paralyzed>();
			Utils.CopyFields(statusEffect, sE_Paralyzed, typeof(StatusEffect));
			((Object)sE_Paralyzed).name = "Paralyze";
			((StatusEffect)sE_Paralyzed).m_name = "$mod_epicloot_se_paralyze";
			ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)sE_Paralyzed);
			ItemManager.OnItemsRegistered -= SetupStatusEffects;
		}

		public static AssetBundle LoadAssetBundle(string filename)
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			return AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + "." + filename));
		}

		internal static string ReadEmbeddedResourceFile(string filename)
		{
			using Stream stream = typeof(EpicLoot).Assembly.GetManifestResourceStream(filename);
			using StreamReader streamReader = new StreamReader(stream);
			return streamReader.ReadToEnd();
		}

		internal static List<string> GetEmbeddedResourceNamesFromDirectory(string embedded_location = "EpicLoot.config.")
		{
			List<string> list = new List<string>();
			string[] manifestResourceNames = typeof(EpicLoot).Assembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (text.Contains(embedded_location))
				{
					list.Add(text.Substring(16));
				}
			}
			return list;
		}

		public static bool IsAllowedMagicItemType(ItemType itemType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected I4, but got Unknown
			switch (itemType - 3)
			{
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 8:
			case 11:
			case 12:
			case 14:
			case 15:
			case 16:
			case 19:
			case 21:
				return true;
			default:
				return false;
			}
		}

		public static bool CanBeMagicItem(ItemData item)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (item != null && IsPlayerItem(item) && Nonstackable(item) && IsNotRestrictedItem(item))
			{
				return IsAllowedMagicItemType(item.m_shared.m_itemType);
			}
			return false;
		}

		public static Sprite GetMagicItemBgSprite()
		{
			if (!HasAuga)
			{
				return Assets.GenericItemBgSprite;
			}
			return Assets.AugaItemBgSprite;
		}

		public static Sprite GetEquippedSprite()
		{
			if (!HasAuga)
			{
				return Assets.EquippedSprite;
			}
			return Assets.AugaEquippedSprite;
		}

		public static Sprite GetSetItemSprite()
		{
			if (!HasAuga)
			{
				return Assets.GenericSetItemSprite;
			}
			return Assets.AugaSetItemSprite;
		}

		public static string GetMagicEffectPip(bool hasBeenAugmented)
		{
			if (!HasAuga)
			{
				if (!hasBeenAugmented)
				{
					return "◆";
				}
				return "▼";
			}
			if (!hasBeenAugmented)
			{
				return "♦";
			}
			return "▾";
		}

		private static bool IsNotRestrictedItem(ItemData item)
		{
			if ((Object)(object)item.m_dropPrefab != (Object)null && LootRoller.Config.RestrictedItems.Contains(((Object)item.m_dropPrefab).name))
			{
				return false;
			}
			return !LootRoller.Config.RestrictedItems.Contains(item.m_shared.m_name);
		}

		private static bool Nonstackable(ItemData item)
		{
			return item.m_shared.m_maxStackSize == 1;
		}

		private static bool IsPlayerItem(ItemData item)
		{
			return item.m_shared.m_icons.Length != 0;
		}

		public static string GetCharacterCleanName(Character character)
		{
			return ((Object)character).name.Replace("(Clone)", "").Trim();
		}

		public static string GetSetItemColor()
		{
			return ELConfig._setItemColor.Value;
		}

		public static string GetRarityDisplayName(ItemRarity rarity)
		{
			return rarity switch
			{
				ItemRarity.Magic => "$mod_epicloot_Magic", 
				ItemRarity.Rare => "$mod_epicloot_Rare", 
				ItemRarity.Epic => "$mod_epicloot_Epic", 
				ItemRarity.Legendary => "$mod_epicloot_Legendary", 
				ItemRarity.Mythic => "$mod_epicloot_Mythic", 
				_ => "<non magic>", 
			};
		}

		public static string GetRarityColor(ItemRarity rarity)
		{
			return rarity switch
			{
				ItemRarity.Magic => GetColor(ELConfig._magicRarityColor.Value), 
				ItemRarity.Rare => GetColor(ELConfig._rareRarityColor.Value), 
				ItemRarity.Epic => GetColor(ELConfig._epicRarityColor.Value), 
				ItemRarity.Legendary => GetColor(ELConfig._legendaryRarityColor.Value), 
				ItemRarity.Mythic => GetColor(ELConfig._mythicRarityColor.Value), 
				_ => "#FFFFFF", 
			};
		}

		public static Color GetRarityColorARGB(ItemRarity rarity)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString(GetRarityColor(rarity), ref result))
			{
				return Color.white;
			}
			return result;
		}

		private static string GetColor(string configValue)
		{
			if (configValue.StartsWith("#"))
			{
				return configValue;
			}
			if (MagicItemColors.TryGetValue(configValue, out var value))
			{
				return value;
			}
			return "#000000";
		}

		public static int GetRarityIconIndex(ItemRarity rarity)
		{
			return rarity switch
			{
				ItemRarity.Magic => Mathf.Clamp(ELConfig._magicMaterialIconColor.Value, 0, 9), 
				ItemRarity.Rare => Mathf.Clamp(ELConfig._rareMaterialIconColor.Value, 0, 9), 
				ItemRarity.Epic => Mathf.Clamp(ELConfig._epicMaterialIconColor.Value, 0, 9), 
				ItemRarity.Legendary => Mathf.Clamp(ELConfig._legendaryMaterialIconColor.Value, 0, 9), 
				ItemRarity.Mythic => Mathf.Clamp(ELConfig._mythicMaterialIconColor.Value, 0, 9), 
				_ => throw new ArgumentOutOfRangeException("rarity", rarity, null), 
			};
		}

		public static AudioClip GetMagicItemDropSFX(ItemRarity rarity)
		{
			return Assets.MagicItemDropSFX[(int)rarity];
		}

		public static GatedItemTypeMode GetGatedItemTypeMode()
		{
			return ELConfig._gatedItemTypeModeConfig.Value;
		}

		public static BossDropMode GetBossTrophyDropMode()
		{
			return ELConfig._bossTrophyDropMode.Value;
		}

		public static float GetBossTrophyDropPlayerRange()
		{
			return ELConfig._bossTrophyDropPlayerRange.Value;
		}

		public static float GetBossCryptKeyPlayerRange()
		{
			return ELConfig._bossCryptKeyDropPlayerRange.Value;
		}

		public static BossDropMode GetBossCryptKeyDropMode()
		{
			return ELConfig._bossCryptKeyDropMode.Value;
		}

		public static BossDropMode GetBossWishboneDropMode()
		{
			return ELConfig._bossWishboneDropMode.Value;
		}

		public static float GetBossWishboneDropPlayerRange()
		{
			return ELConfig._bossWishboneDropPlayerRange.Value;
		}

		public static int GetAndvaranautRange()
		{
			return ELConfig._andvaranautRange.Value;
		}

		public static bool IsAdventureModeEnabled()
		{
			return ELConfig._adventureModeEnabled.Value;
		}

		public static float GetWorldLuckFactor()
		{
			return _instance._worldLuckFactor;
		}

		public static void SetWorldLuckFactor(float luckFactor)
		{
			_instance._worldLuckFactor = luckFactor;
		}

		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)
		{
			DateTime now = DateTime.Now;
			long num = now.Ticks - _lastReloadTime.Ticks;
			if (File.Exists(ConfigFileFullPath) && num >= 10000000)
			{
				try
				{
					Log("Attempting to reload configuration...");
					((BaseUnityPlugin)this).Config.Reload();
				}
				catch
				{
					Log("There was an issue loading " + ConfigFileName);
					return;
				}
				_lastReloadTime = now;
			}
		}

		static EpicLoot()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			MagicItemColors = new Dictionary<string, string>
			{
				{ "Red", "#ff4545" },
				{ "Orange", "#ffac59" },
				{ "Yellow", "#ffff75" },
				{ "Green", "#80fa70" },
				{ "Teal", "#18e7a9" },
				{ "Blue", "#00abff" },
				{ "Indigo", "#709bba" },
				{ "Purple", "#d078ff" },
				{ "Pink", "#ff63d6" },
				{ "Gray", "#dbcadb" }
			};
			MagicMaterials = new string[6] { "Runestone", "EtchedRunestone", "Shard", "Dust", "Reagent", "Essence" };
			ItemNames = new string[6] { "LeatherBelt", "SilverRing", "GoldRubyRing", "ForestToken", "IronBountyToken", "GoldBountyToken" };
			Assets = new EpicAssets();
			AlwaysDropCheat = false;
		}
	}
	public enum BossDropMode
	{
		Default,
		OnePerPlayerOnServer,
		OnePerPlayerNearBoss
	}
	public enum GatedBountyMode
	{
		Unlimited,
		BossKillUnlocksCurrentBiomeBounties,
		BossKillUnlocksNextBiomeBounties
	}
	public enum LogLevel
	{
		Info,
		Warning,
		Error
	}
	public static class EpicLootAuga
	{
		public static Button ReplaceButton(Button button, bool icon = false, bool keepListeners = false)
		{
			return ReplaceButtonInternal(button, button, icon, keepListeners);
		}

		public static Button ReplaceButtonFancy(Button button, bool icon = false, bool keepListeners = false)
		{
			return ReplaceButtonInternal(button, button, icon, keepListeners);
		}

		private static Button ReplaceButtonInternal(Button newButton, Button button, bool icon, bool keepListeners)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0064: 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_006b: 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_0077: Unknown result type