Decompiled source of EpicLoot v0.10.6

plugins/EpicLoot.dll

Decompiled 2 weeks ago
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Configuration;
using System.Runtime.Serialization.Diagnostics;
using System.Runtime.Serialization.Diagnostics.Application;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Json;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.XPath;
using AdventureBackpacks.API;
using Auga;
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.Crafting;
using EpicLoot.CraftingV2;
using EpicLoot.Data;
using EpicLoot.GatedItemType;
using EpicLoot.Healing;
using EpicLoot.LegendarySystem;
using EpicLoot.LootBeams;
using EpicLoot.MagicItemEffects;
using EpicLoot.Patching;
using EpicLoot_UnityLib;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq.JsonPath;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: Guid("963cf4f8-ba02-49fc-8884-97e781e6bc18")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[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: AssemblyFileVersion("0.10.6")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.10.6.0")]
[module: UnverifiableCode]
[module: <96a40f52-64db-463f-bbd1-e733ea2e7336>RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[<8ba3e0e0-ae75-4921-8926-2ef1e9d188ce>Embedded]
	[CompilerGenerated]
	internal sealed class <8ba3e0e0-ae75-4921-8926-2ef1e9d188ce>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<8ba3e0e0-ae75-4921-8926-2ef1e9d188ce>Embedded]
	[CompilerGenerated]
	internal sealed class <dd159757-bc1a-4143-9133-445be4f0e0bd>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <dd159757-bc1a-4143-9133-445be4f0e0bd>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <dd159757-bc1a-4143-9133-445be4f0e0bd>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<8ba3e0e0-ae75-4921-8926-2ef1e9d188ce>Embedded]
	internal sealed class <23926492-2d90-4483-97ae-deb1b77a5139>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <23926492-2d90-4483-97ae-deb1b77a5139>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[<8ba3e0e0-ae75-4921-8926-2ef1e9d188ce>Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <96a40f52-64db-463f-bbd1-e733ea2e7336>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <96a40f52-64db-463f-bbd1-e733ea2e7336>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 Sprite LoadSpriteFromFile(string spritePath)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			spritePath = Path.Combine(Paths.PluginPath, spritePath);
			if (File.Exists(spritePath))
			{
				byte[] array = File.ReadAllBytes(spritePath);
				Texture2D val = new Texture2D(20, 20);
				if (ImageConversion.LoadImage(val, array))
				{
					return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), default(Vector2), 100f);
				}
			}
			return null;
		}

		public static Sprite LoadSpriteFromFile(string modFolder, string iconName)
		{
			return LoadSpriteFromFile(Path.Combine(modFolder, iconName));
		}

		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;
		}
	}
	public class WeightedRandomCollection<T>
	{
		private readonly Random _random;

		private List<T> _list;

		private Func<T, float> _weightSelector;

		private bool _removeOnSelect;

		public float TotalWeight { get; private set; }

		public WeightedRandomCollection(Random random)
		{
			_random = random;
		}

		public WeightedRandomCollection(Random random, IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false)
		{
			_random = random ?? new Random();
			Setup(collection, weightSelector, removeOnSelect);
		}

		public void Setup(IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false)
		{
			_list = collection.ToList();
			_weightSelector = weightSelector;
			_removeOnSelect = removeOnSelect;
			TotalWeight = _list.Sum(_weightSelector);
		}

		public T Roll()
		{
			if (_list == null)
			{
				return default(T);
			}
			float num = (float)_random.NextDouble() * TotalWeight;
			float num2 = 0f;
			T val = default(T);
			foreach (var item in _list.Select((T weightedItem) => new
			{
				Value = weightedItem,
				Weight = _weightSelector(weightedItem)
			}))
			{
				num2 += item.Weight;
				if (num2 >= num)
				{
					val = item.Value;
					break;
				}
			}
			if (_removeOnSelect)
			{
				_list.Remove(val);
				TotalWeight = _list.Sum(_weightSelector);
			}
			return val;
		}

		public List<T> Roll(int numberOfRolls)
		{
			if (_list == null)
			{
				return null;
			}
			List<T> list = new List<T>();
			for (int i = 0; i < numberOfRolls; i++)
			{
				T x = Roll();
				if (!EqualityComparer<T>.Default.Equals(x, default(T)))
				{
					list.Add(Roll());
				}
			}
			return list;
		}

		public void Reset()
		{
			_list = null;
			_weightSelector = null;
			_removeOnSelect = false;
			TotalWeight = 0f;
		}
	}
}
namespace EpicLoot
{
	public static class EpicLootAuga
	{
		public static Button ReplaceButton(Button button, bool icon = false, bool keepListeners = false)
		{
			return ReplaceButtonInternal(API.MediumButton_Create(((Component)button).transform.parent, ((Object)button).name, string.Empty), button, icon, keepListeners);
		}

		public static Button ReplaceButtonFancy(Button button, bool icon = false, bool keepListeners = false)
		{
			return ReplaceButtonInternal(API.FancyButton_Create(((Component)button).transform.parent, ((Object)button).name, string.Empty), 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 (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (icon)
			{
				Object.Destroy((Object)(object)((Component)((Component)newButton).GetComponentInChildren<TMP_Text>()).gameObject);
				((Object)Object.Instantiate<Transform>(((Component)button).transform.Find("Icon"), ((Component)newButton).transform)).name = "Icon";
			}
			else
			{
				string text = ((Component)button).GetComponentInChildren<Text>().text;
				((Component)newButton).GetComponentInChildren<TMP_Text>().text = text;
			}
			RectTransform val = (RectTransform)((Component)button).transform;
			RectTransform val2 = (RectTransform)((Component)newButton).transform;
			val2.anchorMin = val.anchorMin;
			val2.anchorMax = val.anchorMax;
			val2.pivot = val.pivot;
			val2.anchoredPosition = val.anchoredPosition;
			Rect rect = val.rect;
			val2.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width);
			if (keepListeners)
			{
				newButton.onClick = button.onClick;
				button.onClick = new ButtonClickedEvent();
			}
			UIGamePad component = ((Component)button).GetComponent<UIGamePad>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.m_hint != (Object)null)
			{
				component.m_hint.transform.SetParent(((Component)newButton).transform);
				UIGamePad obj = ((Component)newButton).gameObject.AddComponent<UIGamePad>();
				obj.m_keyCode = component.m_keyCode;
				obj.m_zinputKey = component.m_zinputKey;
				obj.m_hint = component.m_hint;
				obj.m_blockingElements = component.m_blockingElements.ToList();
			}
			Object.DestroyImmediate((Object)(object)((Component)button).gameObject);
			return newButton;
		}

		public static void MakeSimpleTooltip(GameObject obj)
		{
			API.Tooltip_MakeSimpleTooltip(obj);
		}

		public static void ReplaceBackground(GameObject obj, bool withCornerDecoration)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Object.Destroy((Object)(object)obj.GetComponent<Image>());
			RectTransform val = (RectTransform)API.Panel_Create(obj.transform, Vector2.one, "AugaBackground", withCornerDecoration).transform;
			((Transform)val).SetSiblingIndex(0);
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.pivot = new Vector2(0.5f, 0.5f);
			val.sizeDelta = new Vector2(40f, 40f);
		}

		public static void FixItemBG(GameObject obj)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			Transform val = obj.transform.Find("MagicBG");
			if ((Object)(object)val != (Object)null)
			{
				Image component = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					component.sprite = EpicLoot.GetMagicItemBgSprite();
				}
			}
			bool flag = false;
			Transform val2 = obj.transform.Find("ItemBG");
			Image val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Image>() : null);
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = obj.GetComponent<Image>();
			}
			if ((Object)(object)val3 != (Object)null)
			{
				val3.sprite = API.GetItemBackgroundSprite();
				((Graphic)val3).color = new Color(0f, 0f, 0f, 0.5f);
				flag = true;
			}
			if (!flag)
			{
				Transform val4 = obj.transform.Find("Icon");
				if ((Object)(object)val4 != (Object)null)
				{
					Transform obj2 = Object.Instantiate<Transform>(val4, val4.parent);
					obj2.SetSiblingIndex(2);
					Image component2 = ((Component)obj2).GetComponent<Image>();
					component2.sprite = API.GetItemBackgroundSprite();
					((Graphic)component2).color = new Color(0f, 0f, 0f, 0.5f);
				}
			}
		}

		public static void FixListElementColors(GameObject obj)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Transform val = obj.transform.Find("Selected");
			if ((Object)(object)val != (Object)null)
			{
				Image component = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					Color color = default(Color);
					ColorUtility.TryParseHtmlString(API.Blue, ref color);
					((Graphic)component).color = color;
				}
			}
			Transform val2 = obj.transform.Find("Background");
			if ((Object)(object)val2 != (Object)null)
			{
				Image component2 = ((Component)val2).GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Graphic)component2).color = new Color(0f, 0f, 0f, 0.5f);
				}
			}
			Button component3 = obj.GetComponent<Button>();
			if ((Object)(object)component3 != (Object)null)
			{
				((Selectable)component3).colors = ColorBlock.defaultColorBlock;
			}
		}

		public static void FixFonts(GameObject obj)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			TMP_Text[] componentsInChildren = obj.GetComponentsInChildren<TMP_Text>(true);
			Color color = default(Color);
			Color color2 = default(Color);
			foreach (TMP_Text val in componentsInChildren)
			{
				if (((Object)val.font).name == "Norsebold")
				{
					ColorUtility.TryParseHtmlString(API.Brown1, ref color);
					((Graphic)val).color = color;
					val.text = Localization.instance.Localize(val.text).ToUpperInvariant();
				}
				if (((Object)val).name == "Count" || ((Object)val).name == "RewardLabel" || ((Object)val).name.EndsWith("Count"))
				{
					ColorUtility.TryParseHtmlString(API.BrightGold, ref color2);
					((Graphic)val).color = color2;
				}
				val.text = val.text.Replace("<color=yellow>", "<color=" + API.BrightGold + ">");
			}
		}

		public static Button ReplaceVerticalLargeTab(Button button)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0073: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(EpicLoot.LoadAsset<GameObject>("EnchantingTabAuga"), ((Component)button).transform.parent);
			((Object)obj).name = ((Object)button).name;
			FixFonts(obj);
			int siblingIndex = ((Component)button).transform.GetSiblingIndex();
			RectTransform val = (RectTransform)((Component)button).transform;
			RectTransform val2 = (RectTransform)obj.transform;
			val2.anchorMin = val.anchorMin;
			val2.anchorMax = val.anchorMax;
			val2.pivot = val.pivot;
			val2.anchoredPosition = val.anchoredPosition;
			Rect rect = val.rect;
			val2.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width);
			((Component)obj.transform.Find("Text")).GetComponent<TMP_Text>().text = ((Component)((Component)button).transform.Find("Text")).GetComponent<TMP_Text>().text;
			((Component)obj.transform.Find("Image")).GetComponent<Image>().sprite = ((Component)((Component)button).transform.Find("Image")).GetComponent<Image>().sprite;
			FeatureStatus component = obj.GetComponent<FeatureStatus>();
			FeatureStatus component2 = ((Component)button).GetComponent<FeatureStatus>();
			if ((Object)(object)component2 == (Object)null && (Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
			{
				component.Feature = component2.Feature;
				component.Refresh();
			}
			Object.DestroyImmediate((Object)(object)((Component)button).gameObject);
			obj.transform.SetSiblingIndex(siblingIndex);
			return obj.GetComponent<Button>();
		}

		public static void FixupScrollbar(Scrollbar scrollbar)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			Object.Destroy((Object)(object)((Component)scrollbar).GetComponent<Image>());
			((Selectable)scrollbar).colors = ColorBlock.defaultColorBlock;
			Image component = ((Component)scrollbar.handleRect).GetComponent<Image>();
			Color val = default(Color);
			if (ColorUtility.TryParseHtmlString("#8B7C6A", ref val))
			{
				((Graphic)component).color = new Color(val.r, val.g, val.b, 1f);
			}
		}
	}
	[HarmonyPatch]
	public static class Attack_Patch
	{
		public static Attack ActiveAttack;

		[HarmonyPriority(0)]
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
		public static void Attack_DoMeleeAttack_Prefix(Attack __instance)
		{
			ActiveAttack = __instance;
		}

		[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
		[HarmonyPostfix]
		public static void Attack_DoMeleeAttack_Postfix()
		{
			ActiveAttack = null;
		}
	}
	public static class EpicLootDropsHelper
	{
		public static bool InstantDropsEnabled { get; set; }
	}
	[HarmonyPatch(typeof(CharacterDrop), "OnDeath")]
	public static class CharacterDrop_OnDeath_Patch
	{
		public static void Postfix(CharacterDrop __instance)
		{
			if (EpicLootDropsHelper.InstantDropsEnabled)
			{
				EpicLoot.OnCharacterDeath(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Ragdoll), "Setup")]
	public static class Ragdoll_Setup_Patch
	{
		public static void Postfix(Ragdoll __instance, CharacterDrop characterDrop)
		{
			if (!((Object)(object)characterDrop == (Object)null) && !((Object)(object)characterDrop.m_character == (Object)null) && !characterDrop.m_character.IsPlayer() && EpicLoot.CanCharacterDropLoot(characterDrop.m_character))
			{
				EpicLootDropsHelper.InstantDropsEnabled = false;
				string characterCleanName = EpicLoot.GetCharacterCleanName(characterDrop.m_character);
				int level = characterDrop.m_character.GetLevel();
				__instance.m_nview.m_zdo.Set("characterName", characterCleanName);
				__instance.m_nview.m_zdo.Set("level", level);
			}
		}
	}
	[HarmonyPatch(typeof(Ragdoll), "SpawnLoot")]
	public static class Ragdoll_SpawnLoot_Patch
	{
		public static void Postfix(Ragdoll __instance, Vector3 center)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			string @string = __instance.m_nview.m_zdo.GetString("characterName", "");
			int @int = __instance.m_nview.m_zdo.GetInt("level", 0);
			if (!string.IsNullOrEmpty(@string))
			{
				EpicLoot.OnCharacterDeath(@string, @int, center + Vector3.up * 0.75f);
			}
		}
	}
	[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
	public static class CharacterDrop_GenerateDropList_DropsEnabled
	{
		[HarmonyBefore(new string[] { "org.bepinex.plugins.creaturelevelcontrol" })]
		[HarmonyPriority(800)]
		public static void Postfix(CharacterDrop __instance)
		{
			EpicLootDropsHelper.InstantDropsEnabled = __instance.m_dropsEnabled;
		}
	}
	[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
	public static class CharacterDrop_GenerateDropList_Patch
	{
		public static void Prefix(CharacterDrop __instance)
		{
			if (!((Object)(object)__instance.m_character != (Object)null) || !__instance.m_character.IsBoss() || EpicLoot.GetBossTrophyDropMode() == BossDropMode.Default)
			{
				return;
			}
			foreach (Drop drop in __instance.m_drops)
			{
				if (!((Object)(object)drop.m_prefab == (Object)null) && ((((Object)drop.m_prefab).name.Equals("Wishbone") && EpicLoot.GetBossWishboneDropMode() != 0) || (((Object)drop.m_prefab).name.Equals("CryptKey") && EpicLoot.GetBossCryptKeyDropMode() != 0)) && drop.m_onePerPlayer)
				{
					drop.m_onePerPlayer = false;
				}
			}
		}

		public static void Postfix(CharacterDrop __instance, ref List<KeyValuePair<GameObject, int>> __result)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance.m_character != (Object)null) || !__instance.m_character.IsBoss() || EpicLoot.GetBossTrophyDropMode() == BossDropMode.Default)
			{
				return;
			}
			for (int i = 0; i < __result.Count; i++)
			{
				GameObject key = __result[i].Key;
				ItemDrop component = key.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null) && component.m_itemData != null && ((int)component.m_itemData.m_shared.m_itemType == 13 || ((Object)key).name.Equals("Wishbone") || ((Object)key).name.Equals("CryptKey")))
				{
					List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
					int num = EpicLoot.GetBossTrophyDropMode() switch
					{
						BossDropMode.OnePerPlayerOnServer => playerList.Count, 
						BossDropMode.OnePerPlayerNearBoss => Math.Max(Player.GetPlayersInRangeXZ(((Component)__instance.m_character).transform.position, EpicLoot.GetBossTrophyDropPlayerRange()), playerList.Count((PlayerInfo x) => Vector3.Distance(x.m_position, ((Component)__instance.m_character).transform.position) <= EpicLoot.GetBossTrophyDropPlayerRange())), 
						_ => 1, 
					};
					EpicLoot.Log($"Dropping trophies: {num} (mode={EpicLoot.GetBossTrophyDropMode()})");
					__result[i] = new KeyValuePair<GameObject, int>(key, num);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Container), "AddDefaultItems")]
	public static class Container_AddDefaultItems_Patch
	{
		public static void Postfix(Container __instance)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_piece == (Object)null)
			{
				return;
			}
			string text = ((Object)__instance.m_piece).name.Replace("(Clone)", "").Trim();
			List<LootTable> lootTable = LootRoller.GetLootTable(text);
			if (lootTable == null || lootTable.Count <= 0)
			{
				return;
			}
			List<ItemData> list = LootRoller.RollLootTable(lootTable, 1, ((Object)__instance.m_piece).name, ((Component)__instance).transform.position);
			object arg = list.Count;
			Vector3 position = ((Component)__instance).transform.position;
			EpicLoot.Log(string.Format("Rolling on loot table: {0}, spawned {1} items at drop point({2}).", text, arg, ((Vector3)(ref position)).ToString("0")));
			foreach (ItemData item in list)
			{
				__instance.m_inventory.AddItem(item);
				EpicLoot.Log("  - " + item.m_shared.m_name + (item.IsMagic() ? (": " + string.Join(", ", item.GetMagicItem().Effects.Select((MagicItemEffect x) => x.EffectType.ToString()))) : ""));
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	public static class GameCamera_UpdateCamera_Patch
	{
		public static bool Prefix(GameCamera __instance)
		{
			if (__instance.m_freeFly)
			{
				__instance.UpdateFreeFly(1f / 30f);
				__instance.UpdateCameraShake(1f / 30f);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Humanoid))]
	public class Humanoid_Patch
	{
		[HarmonyPatch("SetupVisEquipment")]
		[HarmonyPrefix]
		public static bool SetupVisEquipment_Prefix(Humanoid __instance, VisEquipment visEq, bool isRagdoll)
		{
			if (!isRagdoll)
			{
				object obj;
				if (__instance.m_leftItem == null)
				{
					obj = "";
				}
				else
				{
					ItemData leftItem = __instance.m_leftItem;
					if (leftItem == null)
					{
						obj = null;
					}
					else
					{
						GameObject dropPrefab = leftItem.m_dropPrefab;
						obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
					}
				}
				visEq.SetLeftItem((string)obj, __instance.m_leftItem?.m_variant ?? 0);
				object rightItem;
				if (__instance.m_rightItem == null)
				{
					rightItem = "";
				}
				else
				{
					ItemData rightItem2 = __instance.m_rightItem;
					if (rightItem2 == null)
					{
						rightItem = null;
					}
					else
					{
						GameObject dropPrefab2 = rightItem2.m_dropPrefab;
						rightItem = ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null);
					}
				}
				visEq.SetRightItem((string)rightItem);
				if (((Character)__instance).IsPlayer())
				{
					object obj2;
					if (__instance.m_hiddenLeftItem == null)
					{
						obj2 = "";
					}
					else
					{
						GameObject dropPrefab3 = __instance.m_hiddenLeftItem.m_dropPrefab;
						obj2 = ((dropPrefab3 != null) ? ((Object)dropPrefab3).name : null);
					}
					visEq.SetLeftBackItem((string)obj2, __instance.m_hiddenLeftItem?.m_variant ?? 0);
					object rightBackItem;
					if (__instance.m_hiddenRightItem == null)
					{
						rightBackItem = "";
					}
					else
					{
						GameObject dropPrefab4 = __instance.m_hiddenRightItem.m_dropPrefab;
						rightBackItem = ((dropPrefab4 != null) ? ((Object)dropPrefab4).name : null);
					}
					visEq.SetRightBackItem((string)rightBackItem);
				}
			}
			object chestItem;
			if (__instance.m_chestItem == null)
			{
				chestItem = "";
			}
			else
			{
				ItemData chestItem2 = __instance.m_chestItem;
				if (chestItem2 == null)
				{
					chestItem = null;
				}
				else
				{
					GameObject dropPrefab5 = chestItem2.m_dropPrefab;
					chestItem = ((dropPrefab5 != null) ? ((Object)dropPrefab5).name : null);
				}
			}
			visEq.SetChestItem((string)chestItem);
			object legItem;
			if (__instance.m_legItem == null)
			{
				legItem = "";
			}
			else
			{
				ItemData legItem2 = __instance.m_legItem;
				if (legItem2 == null)
				{
					legItem = null;
				}
				else
				{
					GameObject dropPrefab6 = legItem2.m_dropPrefab;
					legItem = ((dropPrefab6 != null) ? ((Object)dropPrefab6).name : null);
				}
			}
			visEq.SetLegItem((string)legItem);
			object helmetItem;
			if (__instance.m_helmetItem == null)
			{
				helmetItem = "";
			}
			else
			{
				ItemData helmetItem2 = __instance.m_helmetItem;
				if (helmetItem2 == null)
				{
					helmetItem = null;
				}
				else
				{
					GameObject dropPrefab7 = helmetItem2.m_dropPrefab;
					helmetItem = ((dropPrefab7 != null) ? ((Object)dropPrefab7).name : null);
				}
			}
			visEq.SetHelmetItem((string)helmetItem);
			object obj3;
			if (__instance.m_shoulderItem == null)
			{
				obj3 = "";
			}
			else
			{
				ItemData shoulderItem = __instance.m_shoulderItem;
				if (shoulderItem == null)
				{
					obj3 = null;
				}
				else
				{
					GameObject dropPrefab8 = shoulderItem.m_dropPrefab;
					obj3 = ((dropPrefab8 != null) ? ((Object)dropPrefab8).name : null);
				}
			}
			visEq.SetShoulderItem((string)obj3, __instance.m_shoulderItem?.m_variant ?? 0);
			object utilityItem;
			if (__instance.m_utilityItem == null)
			{
				utilityItem = "";
			}
			else
			{
				ItemData utilityItem2 = __instance.m_utilityItem;
				if (utilityItem2 == null)
				{
					utilityItem = null;
				}
				else
				{
					GameObject dropPrefab9 = utilityItem2.m_dropPrefab;
					utilityItem = ((dropPrefab9 != null) ? ((Object)dropPrefab9).name : null);
				}
			}
			visEq.SetUtilityItem((string)utilityItem);
			if (!((Character)__instance).IsPlayer())
			{
				return false;
			}
			visEq.SetBeardItem(__instance.m_beardItem);
			visEq.SetHairItem(__instance.m_hairItem);
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemDrop), "Awake")]
	public static class ItemDrop_Awake_Patch
	{
		public static void Postfix(ItemDrop __instance)
		{
			((Component)__instance).gameObject.AddComponent<LootBeam>();
			GameObject val = __instance.m_itemData.InitializeCustomData();
			if ((Object)(object)val != (Object)null)
			{
				__instance.m_itemData.m_dropPrefab = val;
				__instance.Save();
			}
		}
	}
	[HarmonyPatch(typeof(Inventory), "Load")]
	public static class Inventory_Load_Patch
	{
		public static void Postfix(Inventory __instance)
		{
			foreach (ItemData item in __instance.m_inventory)
			{
				GameObject val = item.InitializeCustomData();
				if ((Object)(object)val != (Object)null)
				{
					item.m_dropPrefab = val;
				}
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGrid), "CreateItemTooltip", new Type[]
	{
		typeof(ItemData),
		typeof(UITooltip)
	})]
	public static class InventoryGrid_CreateItemTooltip_MagicItemComponent_Patch
	{
		[HarmonyAfter(new string[] { "kg.ValheimEnchantmentSystem" })]
		public static bool Prefix(ItemData item, UITooltip tooltip, out string __state)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			__state = null;
			string text;
			if (item.IsEquipable() && !item.m_equipped && (Object)(object)Player.m_localPlayer != (Object)null && Player.m_localPlayer.HasEquipmentOfType(item.m_shared.m_itemType) && ZInput.GetKey((KeyCode)306, true))
			{
				ItemData equipmentOfType = Player.m_localPlayer.GetEquipmentOfType(item.m_shared.m_itemType);
				text = item.GetTooltip(-1) + "<color=#AAA><i>$mod_epicloot_currentlyequipped:</i></color>\n<size=18>" + equipmentOfType.GetDecoratedName() + "</size>\n" + equipmentOfType.GetTooltip(-1);
			}
			else
			{
				text = item.GetTooltip(-1);
			}
			tooltip.Set(item.GetDecoratedName(), text, (RectTransform)null, default(Vector2));
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
	{
		typeof(ItemData),
		typeof(int),
		typeof(bool),
		typeof(float),
		typeof(int)
	})]
	public static class MagicItemTooltip_ItemDrop_Patch
	{
		[UsedImplicitly]
		private static bool Prefix(ref string __result, ItemData item, int qualityLevel)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Expected I4, but got Unknown
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad3: Unknown result type (might be due to invalid IL or missing references)
			if (item == null)
			{
				return true;
			}
			Player localPlayer = Player.m_localPlayer;
			StringBuilder stringBuilder = new StringBuilder(256);
			MagicItem magicItem = item.GetMagicItem();
			if (magicItem == null)
			{
				return true;
			}
			string colorString = magicItem.GetColorString();
			string itemTypeName = magicItem.GetItemTypeName(item.Extended());
			float skillLevel = ((Character)localPlayer).GetSkillLevel(item.m_shared.m_skillType);
			stringBuilder.Append("<color=" + colorString + ">" + magicItem.GetRarityDisplay() + " " + itemTypeName + "</color>\n");
			if (item.IsLegendarySetItem())
			{
				stringBuilder.Append("<color=" + EpicLoot.GetSetItemColor() + ">$mod_epicloot_legendarysetlabel</color>\n");
			}
			stringBuilder.Append(item.GetDescription());
			stringBuilder.Append("\n");
			if (item.m_shared.m_dlc.Length > 0)
			{
				stringBuilder.Append("\n<color=#00ffffff>$item_dlc</color>");
			}
			ItemData.AddHandedTip(item, stringBuilder);
			if (item.m_crafterID != 0L)
			{
				stringBuilder.AppendFormat("\n$item_crafter: <color=orange>{0}</color>", item.GetCrafterName());
			}
			if (!item.m_shared.m_teleportable)
			{
				stringBuilder.Append("\n<color=orange>$item_noteleport</color>");
			}
			if (item.m_shared.m_value > 0)
			{
				stringBuilder.AppendFormat("\n$item_value: <color=orange>{0} ({1})</color>", item.GetValue(), item.m_shared.m_value);
			}
			string arg = ((magicItem.HasEffect(MagicEffectType.ReduceWeight) || magicItem.HasEffect(MagicEffectType.Weightless)) ? colorString : "orange");
			stringBuilder.Append($"\n$item_weight: <color={arg}>{item.GetWeight(-1):0.0}</color>");
			if (item.m_shared.m_maxQuality > 1)
			{
				stringBuilder.AppendFormat("\n$item_quality: <color=orange>{0}</color>", qualityLevel);
			}
			bool flag = magicItem.HasEffect(MagicEffectType.Indestructible);
			if (!flag && item.m_shared.m_useDurability)
			{
				string text = (magicItem.HasEffect(MagicEffectType.ModifyDurability) ? colorString : "orange");
				string text2 = (magicItem.HasEffect(MagicEffectType.ModifyDurability) ? colorString : "yellow");
				float maxDurability = item.GetMaxDurability(qualityLevel);
				float durability = item.m_durability;
				string text3 = (item.GetDurabilityPercentage() * 100f).ToString("0");
				string text4 = durability.ToString("0");
				string text5 = maxDurability.ToString("0");
				stringBuilder.Append("\n$item_durability: <color=" + text + ">" + text3 + "%</color> <color=" + text2 + ">(" + text4 + "/" + text5 + ")</color>");
				if (item.m_shared.m_canBeReparied)
				{
					Recipe recipe = ObjectDB.instance.GetRecipe(item);
					if ((Object)(object)recipe != (Object)null)
					{
						int minStationLevel = recipe.m_minStationLevel;
						stringBuilder.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", minStationLevel.ToString());
					}
				}
			}
			else if (flag)
			{
				stringBuilder.Append("\n$item_durability: <color=" + colorString + ">$mod_epicloot_me_indestructible_display</color>");
			}
			bool num = magicItem.HasEffect(MagicEffectType.ModifyBlockPower);
			string arg2 = (num ? colorString : "orange");
			string text6 = (num ? colorString : "yellow");
			bool flag2 = magicItem.HasEffect(MagicEffectType.ModifyParry);
			float totalEffectValue = magicItem.GetTotalEffectValue(MagicEffectType.ModifyParry, 0.01f);
			string arg3 = (flag2 ? colorString : "orange");
			ItemType itemType = item.m_shared.m_itemType;
			switch (itemType - 2)
			{
			case 0:
			{
				if ((double)item.m_shared.m_food > 0.0)
				{
					stringBuilder.AppendFormat("\n$item_food_health: <color=orange>{0}</color>", item.m_shared.m_food);
					stringBuilder.AppendFormat("\n$item_food_stamina: <color=orange>{0}</color>", item.m_shared.m_foodStamina);
					stringBuilder.AppendFormat("\n$item_food_duration: <color=orange>{0}s</color>", item.m_shared.m_foodBurnTime);
					stringBuilder.AppendFormat("\n$item_food_regen: <color=orange>{0} hp/tick</color>", item.m_shared.m_foodRegen);
				}
				string statusEffectTooltip2 = item.GetStatusEffectTooltip(qualityLevel, skillLevel);
				if (statusEffectTooltip2.Length > 0)
				{
					stringBuilder.Append("\n\n");
					stringBuilder.Append(statusEffectTooltip2);
				}
				break;
			}
			case 1:
			case 2:
			case 12:
			case 13:
			case 20:
			{
				stringBuilder.Append(GetDamageTooltipString(magicItem, item.GetDamage(qualityLevel, (float)Game.m_worldLevel), item.m_shared.m_skillType, colorString));
				string arg5 = ((magicItem.HasEffect(MagicEffectType.ModifyAttackStaminaUse) || magicItem.HasEffect(MagicEffectType.ModifyBlockStaminaUse)) ? colorString : "orange");
				float num3 = (1f - magicItem.GetTotalEffectValue(MagicEffectType.ModifyAttackStaminaUse, 0.01f)) * item.m_shared.m_attack.m_attackStamina;
				if ((double)item.m_shared.m_attack.m_attackStamina > 0.0 && !magicItem.HasEffect(MagicEffectType.Bloodlust))
				{
					stringBuilder.Append($"\n$item_staminause: <color={arg5}>{num3:#.#}</color>");
				}
				bool num4 = magicItem.HasEffect(MagicEffectType.ModifyAttackEitrUse) || magicItem.HasEffect(MagicEffectType.DoubleMagicShot);
				bool flag3 = magicItem.HasEffect(MagicEffectType.DoubleMagicShot);
				string arg6 = (num4 ? colorString : "orange");
				float num5 = 1f - magicItem.GetTotalEffectValue(MagicEffectType.ModifyAttackEitrUse, 0.01f);
				float num6 = (flag3 ? (num5 * (item.m_shared.m_attack.m_attackEitr * 2f)) : (num5 * item.m_shared.m_attack.m_attackEitr));
				if ((double)item.m_shared.m_attack.m_attackEitr > 0.0)
				{
					stringBuilder.Append($"\n$item_eitruse: <color={arg6}>{num6:#.#}</color>");
				}
				bool num7 = magicItem.HasEffect(MagicEffectType.Bloodlust);
				string arg7 = (num7 ? colorString : "orange");
				float attackStamina = item.m_shared.m_attack.m_attackStamina;
				if (num7)
				{
					stringBuilder.Append($"\n$item_healthuse: <color={arg7}>{attackStamina:#.#}</color>");
				}
				else if ((double)item.m_shared.m_attack.m_attackHealth > 0.0)
				{
					stringBuilder.Append("\n$item_healthuse: " + $"<color=orange>{item.m_shared.m_attack.m_attackHealth}</color>");
				}
				string arg8 = (magicItem.HasEffect(MagicEffectType.ModifyAttackHealthUse) ? colorString : "orange");
				float num8 = (1f - magicItem.GetTotalEffectValue(MagicEffectType.ModifyAttackHealthUse, 0.01f)) * item.m_shared.m_attack.m_attackHealthPercentage;
				if ((double)item.m_shared.m_attack.m_attackHealthPercentage > 0.0)
				{
					stringBuilder.Append($"\n$item_healthuse: <color={arg8}>{num8 / 100f:##.#%}</color>");
				}
				string arg9 = (magicItem.HasEffect(MagicEffectType.ModifyDrawStaminaUse) ? colorString : "orange");
				float num9 = (1f - magicItem.GetTotalEffectValue(MagicEffectType.ModifyDrawStaminaUse, 0.01f)) * item.m_shared.m_attack.m_drawStaminaDrain;
				if ((double)item.m_shared.m_attack.m_drawStaminaDrain > 0.0)
				{
					stringBuilder.Append("\n$item_staminahold: " + $"<color={arg9}>{num9:#.#}/s");
				}
				float baseBlockPower2 = item.GetBaseBlockPower(qualityLevel);
				string text8 = item.GetBlockPowerTooltip(qualityLevel).ToString("0");
				stringBuilder.Append($"\n$item_blockpower: <color={arg2}>{baseBlockPower2}</color> " + "<color=" + text6 + ">(" + text8 + ")</color>");
				if ((double)item.m_shared.m_timedBlockBonus > 1.0)
				{
					stringBuilder.Append("\n$item_deflection: " + $"<color={arg3}>{item.GetDeflectionForce(qualityLevel)}</color>");
					float num10 = item.m_shared.m_timedBlockBonus;
					if (flag2)
					{
						num10 *= 1f + totalEffectValue;
					}
					stringBuilder.Append($"\n$item_parrybonus: <color={arg3}>{num10:0.#}x</color>");
				}
				stringBuilder.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);
				bool num11 = magicItem.HasEffect(MagicEffectType.ModifyBackstab);
				float totalEffectValue2 = magicItem.GetTotalEffectValue(MagicEffectType.ModifyBackstab, 0.01f);
				string arg10 = (num11 ? colorString : "orange");
				float num12 = item.m_shared.m_backstabBonus * (1f + totalEffectValue2);
				stringBuilder.Append($"\n$item_backstab: <color={arg10}>{num12:0.#}x</color>");
				string projectileTooltip = item.GetProjectileTooltip(qualityLevel);
				if (projectileTooltip.Length > 0)
				{
					stringBuilder.Append("\n\n");
					stringBuilder.Append(projectileTooltip);
				}
				string statusEffectTooltip3 = item.GetStatusEffectTooltip(qualityLevel, skillLevel);
				if (statusEffectTooltip3.Length > 0)
				{
					stringBuilder.Append("\n\n");
					stringBuilder.Append(statusEffectTooltip3);
				}
				break;
			}
			case 3:
			{
				float baseBlockPower = item.GetBaseBlockPower(qualityLevel);
				string text7 = item.GetBlockPowerTooltip(qualityLevel).ToString("0");
				stringBuilder.Append($"\n$item_blockpower: <color={arg2}>{baseBlockPower}</color> " + "<color=" + text6 + ">(" + text7 + ")</color>");
				if ((double)item.m_shared.m_timedBlockBonus > 1.0)
				{
					stringBuilder.Append("\n$item_deflection: " + $"<color={arg3}>{item.GetDeflectionForce(qualityLevel)}</color>");
					float num2 = item.m_shared.m_timedBlockBonus;
					if (flag2)
					{
						num2 *= 1f + totalEffectValue;
					}
					stringBuilder.Append($"\n$item_parrybonus: <color={arg3}>{num2:0.#}x</color>");
				}
				break;
			}
			case 4:
			case 5:
			case 9:
			case 15:
			{
				string arg4 = (magicItem.HasEffect(MagicEffectType.ModifyArmor) ? colorString : "orange");
				stringBuilder.Append("\n$item_armor: " + $"<color={arg4}>{item.GetArmor(qualityLevel, (float)Game.m_worldLevel):0.#}</color>");
				string damageModifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(item.m_shared.m_damageModifiers);
				if (damageModifiersTooltipString.Length > 0)
				{
					stringBuilder.Append(damageModifiersTooltipString);
				}
				string statusEffectTooltip = item.GetStatusEffectTooltip(qualityLevel, skillLevel);
				if (statusEffectTooltip.Length > 0)
				{
					stringBuilder.Append("\n");
					stringBuilder.Append(statusEffectTooltip);
				}
				break;
			}
			case 7:
			{
				DamageTypes damage = item.GetDamage(qualityLevel, (float)Game.m_worldLevel);
				stringBuilder.Append(((DamageTypes)(ref damage)).GetTooltipString(item.m_shared.m_skillType));
				stringBuilder.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);
				break;
			}
			}
			bool flag4 = magicItem.HasEffect(MagicEffectType.ModifyEitrRegen);
			bool magicEitrRegen;
			if ((flag4 || item.m_shared.m_eitrRegenModifier != 0f) && (Object)(object)localPlayer != (Object)null)
			{
				string eitrRegenModifier = GetEitrRegenModifier(item, magicItem, out magicEitrRegen);
				float num13 = localPlayer.GetEquipmentEitrRegenModifier() * 100f;
				float totalActiveMagicEffectValue = localPlayer.GetTotalActiveMagicEffectValue(MagicEffectType.ModifyEitrRegen);
				float num14 = num13 + totalActiveMagicEffectValue;
				string text9 = (flag4 ? colorString : "orange");
				string arg11 = ((totalActiveMagicEffectValue > 0f) ? colorString : "yellow");
				stringBuilder.Append("\n$item_eitrregen_modifier: <color=" + text9 + ">" + eitrRegenModifier + "</color> " + $"($item_total: <color={arg11}>{num14:+0;-0}%</color>)");
			}
			bool flag5 = magicItem.HasEffect(MagicEffectType.ModifyMovementSpeed);
			if ((flag5 || item.m_shared.m_movementModifier != 0f) && (Object)(object)localPlayer != (Object)null)
			{
				bool removePenalty;
				string movementModifier = GetMovementModifier(item, magicItem, out magicEitrRegen, out removePenalty);
				float num15 = ((Character)localPlayer).GetEquipmentMovementModifier() * 100f;
				string text10 = ((removePenalty || flag5) ? colorString : "orange");
				stringBuilder.Append("\n$item_movement_modifier: <color=" + text10 + ">" + movementModifier + "</color> " + $"($item_total:<color=yellow>{num15:+0;-0}%</color>)");
			}
			stringBuilder.AppendLine(magicItem.GetTooltip());
			if (item.IsSetItem())
			{
				stringBuilder.Append(item.GetSetTooltip());
			}
			__result = stringBuilder.ToString();
			return false;
		}

		[UsedImplicitly]
		[HarmonyPriority(0)]
		public static void Postfix(ref string __result, ItemData item)
		{
			if (item == null)
			{
				return;
			}
			__result = EIDFLegacy.FormatCrafterName(__result);
			if (item.IsMagicCraftingMaterial() || item.IsRunestone())
			{
				string rarityDisplayName = EpicLoot.GetRarityDisplayName(item.GetCraftingMaterialRarity());
				__result = "<color=" + item.GetCraftingMaterialRarityColor() + ">" + rarityDisplayName + " $mod_epicloot_craftingmaterial\n</color>" + __result;
			}
			if (!item.IsMagic())
			{
				StringBuilder stringBuilder = new StringBuilder();
				if (item.IsSetItem())
				{
					int num = __result.IndexOf("\n\n$item_seteffect", StringComparison.InvariantCulture);
					if (num >= 0)
					{
						__result = __result.Remove(num);
					}
					stringBuilder.Append(item.GetSetTooltip());
				}
				__result += stringBuilder.ToString();
			}
			__result = __result.Replace("<color=orange>", "<color=#add8e6ff>");
			__result = __result.Replace("<color=yellow>", "<color=#add8e6ff>");
			__result = __result.Replace("\n\n\n", "\n\n");
		}

		public static string GetDamageTooltipString(MagicItem item, DamageTypes instance, SkillType skillType, string magicColor)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return "";
			}
			bool flag = item.HasEffect(MagicEffectType.ModifyDamage);
			bool flag2 = item.HasEffect(MagicEffectType.ModifyPhysicalDamage);
			bool flag3 = item.HasEffect(MagicEffectType.ModifyElementalDamage);
			bool flag4 = item.HasEffect(MagicEffectType.AddBluntDamage);
			bool flag5 = item.HasEffect(MagicEffectType.AddSlashingDamage);
			bool flag6 = item.HasEffect(MagicEffectType.AddPiercingDamage);
			bool flag7 = item.HasEffect(MagicEffectType.AddFireDamage);
			bool flag8 = item.HasEffect(MagicEffectType.AddFrostDamage);
			bool flag9 = item.HasEffect(MagicEffectType.AddLightningDamage);
			bool flag10 = item.HasEffect(MagicEffectType.AddPoisonDamage);
			bool flag11 = item.HasEffect(MagicEffectType.AddSpiritDamage);
			float coinHoarderDamageMultiplier;
			bool flag12 = CoinHoarder.HasCoinHoarder(out coinHoarderDamageMultiplier);
			float minFactor = default(float);
			float maxFactor = default(float);
			((Character)Player.m_localPlayer).GetSkills().GetRandomSkillRange(ref minFactor, ref maxFactor, skillType);
			string text = "";
			if ((double)instance.m_damage != 0.0)
			{
				text = text + "\n$inventory_damage: " + DamageRange(instance.m_damage, minFactor, maxFactor, flag, magicColor);
			}
			if ((double)instance.m_blunt != 0.0)
			{
				bool magic = flag || flag2 || flag4 || flag12;
				text = text + "\n$inventory_blunt: " + DamageRange(instance.m_blunt, minFactor, maxFactor, magic, magicColor);
			}
			if ((double)instance.m_slash != 0.0)
			{
				bool magic2 = flag || flag2 || flag5 || flag12;
				text = text + "\n$inventory_slash: " + DamageRange(instance.m_slash, minFactor, maxFactor, magic2, magicColor);
			}
			if ((double)instance.m_pierce != 0.0)
			{
				bool magic3 = flag || flag2 || flag6 || flag12;
				text = text + "\n$inventory_pierce: " + DamageRange(instance.m_pierce, minFactor, maxFactor, magic3, magicColor);
			}
			if ((double)instance.m_fire != 0.0)
			{
				bool magic4 = flag || flag3 || flag7 || flag12;
				text = text + "\n$inventory_fire: " + DamageRange(instance.m_fire, minFactor, maxFactor, magic4, magicColor);
			}
			if ((double)instance.m_frost != 0.0)
			{
				bool magic5 = flag || flag3 || flag8 || flag12;
				text = text + "\n$inventory_frost: " + DamageRange(instance.m_frost, minFactor, maxFactor, magic5, magicColor);
			}
			if ((double)instance.m_lightning != 0.0)
			{
				bool magic6 = flag || flag3 || flag9 || flag12;
				text = text + "\n$inventory_lightning: " + DamageRange(instance.m_lightning, minFactor, maxFactor, magic6, magicColor);
			}
			if ((double)instance.m_poison != 0.0)
			{
				bool magic7 = flag || flag3 || flag10 || flag12;
				text = text + "\n$inventory_poison: " + DamageRange(instance.m_poison, minFactor, maxFactor, magic7, magicColor);
			}
			if ((double)instance.m_spirit != 0.0)
			{
				bool magic8 = flag || flag3 || flag11 || flag12;
				text = text + "\n$inventory_spirit: " + DamageRange(instance.m_spirit, minFactor, maxFactor, magic8, magicColor);
			}
			return text;
		}

		public static string DamageRange(float damage, float minFactor, float maxFactor, bool magic = false, string magicColor = "")
		{
			int num = Mathf.RoundToInt(damage * minFactor);
			int num2 = Mathf.RoundToInt(damage * maxFactor);
			string arg = (magic ? magicColor : "orange");
			string arg2 = (magic ? magicColor : "yellow");
			return $"<color={arg}>{Mathf.RoundToInt(damage)}</color> " + $"<color={arg2}>({num}-{num2}) </color>";
		}

		public static string GetEitrRegenModifier(ItemData item, MagicItem magicItem, out bool magicEitrRegen)
		{
			magicEitrRegen = magicItem?.HasEffect(MagicEffectType.ModifyEitrRegen) ?? false;
			float num = item.m_shared.m_eitrRegenModifier * 100f;
			if (magicEitrRegen && magicItem != null)
			{
				num += magicItem.GetTotalEffectValue(MagicEffectType.ModifyEitrRegen);
			}
			if (num != 0f)
			{
				return $"{num:+0;-0}%";
			}
			return "0%";
		}

		public static string GetMovementModifier(ItemData item, MagicItem magicItem, out bool magicMovement, out bool removePenalty)
		{
			magicMovement = magicItem.HasEffect(MagicEffectType.ModifyMovementSpeed);
			removePenalty = magicItem.HasEffect(MagicEffectType.RemoveSpeedPenalty);
			float num = (removePenalty ? 0f : (item.m_shared.m_movementModifier * 100f));
			if (magicMovement)
			{
				num += magicItem.GetTotalEffectValue(MagicEffectType.ModifyMovementSpeed);
			}
			if (num != 0f)
			{
				return $"{num:+0;-0}%";
			}
			return "0%";
		}
	}
	public static class AugaTooltipPreprocessor
	{
		public static Tuple<string, string> PreprocessTooltipStat(ItemData item, string label, string value)
		{
			Player localPlayer = Player.m_localPlayer;
			bool magicEitrRegen;
			if (item.IsMagic(out var magicItem))
			{
				string colorString = magicItem.GetColorString();
				bool flag = magicItem.HasEffect(MagicEffectType.ModifyDamage);
				bool flag2 = magicItem.HasEffect(MagicEffectType.ModifyPhysicalDamage);
				bool flag3 = magicItem.HasEffect(MagicEffectType.ModifyElementalDamage);
				bool flag4 = magicItem.HasEffect(MagicEffectType.AddBluntDamage);
				bool flag5 = magicItem.HasEffect(MagicEffectType.AddSlashingDamage);
				bool flag6 = magicItem.HasEffect(MagicEffectType.AddPiercingDamage);
				bool flag7 = magicItem.HasEffect(MagicEffectType.AddFireDamage);
				bool flag8 = magicItem.HasEffect(MagicEffectType.AddFrostDamage);
				bool flag9 = magicItem.HasEffect(MagicEffectType.AddLightningDamage);
				bool flag10 = magicItem.HasEffect(MagicEffectType.AddPoisonDamage);
				bool flag11 = magicItem.HasEffect(MagicEffectType.AddSpiritDamage);
				switch (label)
				{
				case "$item_durability":
					if (magicItem.HasEffect(MagicEffectType.Indestructible))
					{
						value = "<color=" + colorString + ">Indestructible</color>";
					}
					else if (magicItem.HasEffect(MagicEffectType.ModifyDurability))
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$item_weight":
					if (magicItem.HasEffect(MagicEffectType.ReduceWeight) || magicItem.HasEffect(MagicEffectType.Weightless))
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_damage":
					if (flag)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_blunt":
					if (flag || flag2 || flag4)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_slash":
					if (flag || flag2 || flag5)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_pierce":
					if (flag || flag2 || flag6)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_fire":
					if (flag || flag3 || flag7)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_frost":
					if (flag || flag3 || flag8)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_lightning":
					if (flag || flag3 || flag9)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_poison":
					if (flag || flag3 || flag10)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$inventory_spirit":
					if (flag || flag3 || flag11)
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$item_backstab":
					if (magicItem.HasEffect(MagicEffectType.ModifyBackstab))
					{
						float totalEffectValue2 = magicItem.GetTotalEffectValue(MagicEffectType.ModifyBackstab, 0.01f);
						float num2 = item.m_shared.m_backstabBonus * (1f + totalEffectValue2);
						value = $"<color={colorString}>{num2:0.#}x</color>";
					}
					break;
				case "$item_blockpower":
					if (magicItem.HasEffect(MagicEffectType.ModifyBlockPower))
					{
						float baseBlockPower = item.GetBaseBlockPower(item.m_quality);
						string text = item.GetBlockPowerTooltip(item.m_quality).ToString("0");
						value = $"<color={colorString}>{baseBlockPower}</color> " + "<color=" + colorString + ">(" + text + ")</color>";
					}
					break;
				case "$item_deflection":
					if (magicItem.HasEffect(MagicEffectType.ModifyParry))
					{
						value = $"<color={colorString}>{item.GetDeflectionForce(item.m_quality)}</color>";
					}
					break;
				case "$item_parrybonus":
					if (magicItem.HasEffect(MagicEffectType.ModifyParry))
					{
						float totalEffectValue = magicItem.GetTotalEffectValue(MagicEffectType.ModifyParry, 0.01f);
						float num = item.m_shared.m_timedBlockBonus * (1f + totalEffectValue);
						value = $"<color={colorString}>{num:0.#}x</color>";
					}
					break;
				case "$item_armor":
					if (magicItem.HasEffect(MagicEffectType.ModifyArmor))
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$item_staminause":
					if (magicItem.HasEffect(MagicEffectType.ModifyAttackStaminaUse) || magicItem.HasEffect(MagicEffectType.ModifyBlockStaminaUse))
					{
						value = "<color=" + colorString + ">" + value + "</color>";
					}
					break;
				case "$item_crafter":
					value = EIDFLegacy.GetCrafterName(value);
					break;
				}
				if (label.StartsWith("$item_movement_modifier") && (magicItem.HasEffect(MagicEffectType.RemoveSpeedPenalty) || magicItem.HasEffect(MagicEffectType.ModifyMovementSpeed)))
				{
					int num3 = label.IndexOf("<color", StringComparison.Ordinal);
					if (num3 >= 0)
					{
						StringBuilder stringBuilder = new StringBuilder(label);
						stringBuilder.Remove(num3, "<color=#XXXXXX>".Length);
						stringBuilder.Insert(num3, "<color=" + colorString + ">");
						bool magicMovement;
						string movementModifier = MagicItemTooltip_ItemDrop_Patch.GetMovementModifier(item, magicItem, out magicMovement, out magicEitrRegen);
						int num4 = num3 + "<color=#XXXXXX>".Length;
						int num5 = label.IndexOf("%", num4, StringComparison.Ordinal);
						stringBuilder.Remove(num4, num5 - num4 + 1);
						stringBuilder.Insert(num4, movementModifier);
						label = stringBuilder.ToString();
					}
				}
			}
			bool flag12 = magicItem?.HasEffect(MagicEffectType.ModifyEitrRegen) ?? false;
			if (label.StartsWith("$item_eitrregen_modifier") && (flag12 || item.m_shared.m_eitrRegenModifier != 0f) && (Object)(object)localPlayer != (Object)null)
			{
				string text2 = MagicItemTooltip_ItemDrop_Patch.GetEitrRegenModifier(item, magicItem, out magicEitrRegen);
				float num6 = localPlayer.GetEquipmentEitrRegenModifier() * 100f;
				float totalActiveMagicEffectValue = localPlayer.GetTotalActiveMagicEffectValue(MagicEffectType.ModifyEitrRegen);
				float num7 = num6 + totalActiveMagicEffectValue;
				if (flag12 && magicItem != null)
				{
					text2 = "<color=" + magicItem.GetColorString() + ">" + text2 + "</color>";
				}
				label = "$item_eitrregen_modifier: " + text2 + " " + $"($item_total: <color={API.Brown3}>{num7:+0;-0}%</color>)";
			}
			if (label == "$item_crafter")
			{
				value = EIDFLegacy.GetCrafterName(value);
			}
			return new Tuple<string, string>(label, value);
		}
	}
	public class Multiplayer_Player_Patch
	{
		[HarmonyPatch]
		public static class Humanoid_Patch
		{
			[HarmonyPatch(typeof(Humanoid), "EquipItem")]
			public class AttachExtendedDataToZDO_Humanoid_EquipItem_Patch
			{
				[UsedImplicitly]
				private static void Postfix(ItemData item, bool __result, Humanoid __instance)
				{
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Expected O, but got Unknown
					if (__result && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && item != null)
					{
						UpdatePlayerZDOForEquipment((Player)__instance, item, equip: true);
					}
				}
			}

			[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
			public class AttachExtendedDataToZDO_Humanoid_UnequipItem_Patch
			{
				[UsedImplicitly]
				private static void Prefix(Humanoid __instance, ItemData item)
				{
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_002a: Expected O, but got Unknown
					if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && item != null && ((Humanoid)Player.m_localPlayer).IsItemEquiped(item))
					{
						UpdatePlayerZDOForEquipment((Player)__instance, item, equip: false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		public static class WatchLegendaryEquipment_Player_Update_Patch
		{
			private static float _updateEventTime;

			[UsedImplicitly]
			public static void Postfix(Player __instance)
			{
				_updateEventTime -= Time.deltaTime;
				if ((double)_updateEventTime > 0.0)
				{
					return;
				}
				_updateEventTime = 10f;
				if ((Object)(object)__instance != (Object)null && (Object)(object)__instance != (Object)(object)Player.m_localPlayer && (Object)(object)((Character)__instance).m_nview != (Object)null)
				{
					ZDO zDO = ((Character)__instance).m_nview.GetZDO();
					if (zDO != null && (DoCheck(__instance, zDO, "LeftItem", "lf-ell", ref ((Humanoid)__instance).m_leftItem) || DoCheck(__instance, zDO, "RightItem", "ri-ell", ref ((Humanoid)__instance).m_rightItem) || DoCheck(__instance, zDO, "ChestItem", "ch-ell", ref ((Humanoid)__instance).m_chestItem) || DoCheck(__instance, zDO, "LegItem", "lg-ell", ref ((Humanoid)__instance).m_legItem) || DoCheck(__instance, zDO, "HelmetItem", "hl-ell", ref ((Humanoid)__instance).m_helmetItem) || DoCheck(__instance, zDO, "ShoulderItem", "sh-ell", ref ((Humanoid)__instance).m_shoulderItem) || DoCheck(__instance, zDO, "UtilityItem", "ut-ell", ref ((Humanoid)__instance).m_utilityItem)))
					{
						((Humanoid)__instance).SetupVisEquipment(((Humanoid)__instance).m_visEquipment, false);
					}
				}
			}

			private static bool DoCheck(Player player, ZDO zdo, string equipKey, string legendaryDataKey, ref ItemData itemData)
			{
				string @string = zdo.GetString(legendaryDataKey, "");
				if (string.IsNullOrEmpty(@string))
				{
					bool num = itemData != null;
					if (num)
					{
						ForceResetVisEquipment((Humanoid)(object)player, itemData);
					}
					itemData = null;
					return num;
				}
				if (itemData?.GetMagicItem()?.LegendaryID == @string)
				{
					return false;
				}
				int @int = zdo.GetInt(equipKey, 0);
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(@int);
				ItemData val = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData);
				if (val != null)
				{
					itemData = val.Clone();
					itemData.m_durability = float.PositiveInfinity;
					MagicItemComponent orCreate = itemData.Data().GetOrCreate<MagicItemComponent>();
					MagicItem magicItem = new MagicItem
					{
						Rarity = ItemRarity.Legendary,
						LegendaryID = @string
					};
					orCreate.SetMagicItem(magicItem);
					ForceResetVisEquipment((Humanoid)(object)player, itemData);
				}
				return false;
			}

			public static void ForceResetVisEquipment(Humanoid humanoid, ItemData item)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Expected I4, but got Unknown
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Invalid comparison between Unknown and I4
				if ((Object)(object)humanoid == (Object)null || (Object)(object)humanoid.m_visEquipment == (Object)null || item == null)
				{
					return;
				}
				ItemType itemType = item.m_shared.m_itemType;
				switch (itemType - 3)
				{
				case 0:
					if (humanoid.m_rightItem != null && (int)humanoid.m_rightItem.m_shared.m_itemType == 15 && humanoid.m_leftItem == null)
					{
						humanoid.m_visEquipment.m_currentLeftItemHash = -1;
					}
					humanoid.m_visEquipment.m_currentRightItemHash = -1;
					break;
				case 1:
				case 2:
					humanoid.m_visEquipment.m_currentLeftItemHash = -1;
					break;
				case 11:
				case 19:
					humanoid.m_visEquipment.m_currentRightItemHash = -1;
					humanoid.m_visEquipment.m_currentLeftItemHash = -1;
					break;
				case 4:
					humanoid.m_visEquipment.m_currentChestItemHash = -1;
					break;
				case 8:
					humanoid.m_visEquipment.m_currentLegItemHash = -1;
					break;
				case 3:
					humanoid.m_visEquipment.m_currentHelmetItemHash = -1;
					break;
				case 14:
					humanoid.m_visEquipment.m_currentShoulderItemHash = -1;
					break;
				case 15:
					humanoid.m_visEquipment.m_currentUtilityItemHash = -1;
					break;
				case 16:
					humanoid.m_visEquipment.m_currentRightItemHash = -1;
					break;
				case 5:
				case 6:
				case 7:
				case 9:
				case 10:
				case 12:
				case 13:
				case 17:
				case 18:
					break;
				}
			}
		}

		[HarmonyPatch]
		public static class WatchMultiplayerMagicEffects_Player_Patch
		{
			[HarmonyPatch(typeof(Humanoid), "EquipItem")]
			[HarmonyPostfix]
			public static void EquipItem_Postfix(Humanoid __instance)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					UpdateRichesAndLuck(val);
				}
			}

			[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
			[HarmonyPostfix]
			public static void UnequipItem_Postfix(Humanoid __instance)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					UpdateRichesAndLuck(val);
				}
			}

			public static void UpdateRichesAndLuck(Player player)
			{
				if (!((Object)(object)player == (Object)(object)Player.m_localPlayer))
				{
					return;
				}
				ZNetView nview = ((Character)player).m_nview;
				ZDO val = ((nview != null) ? nview.GetZDO() : null);
				if (val != null)
				{
					int @int = val.GetInt("el-luk", 0);
					int int2 = val.GetInt("el-rch", 0);
					int num = (int)player.GetTotalActiveMagicEffectValue(MagicEffectType.Luck);
					int num2 = (int)player.GetTotalActiveMagicEffectValue(MagicEffectType.Riches);
					if (num != @int)
					{
						val.Set("el-luk", num);
					}
					if (num2 != int2)
					{
						val.Set("el-rch", num2);
					}
				}
			}
		}

		public static void UpdatePlayerZDOForEquipment(Player player, ItemData item, bool equip)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected I4, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			object obj;
			if (player == null)
			{
				obj = null;
			}
			else
			{
				ZNetView nview = ((Character)player).m_nview;
				obj = ((nview != null) ? nview.GetZDO() : null);
			}
			ZDO val = (ZDO)obj;
			if (val == null)
			{
				return;
			}
			MagicItem magicItem = item.GetMagicItem();
			string text = ((!equip) ? "" : ((magicItem != null && magicItem.IsUniqueLegendary()) ? magicItem.LegendaryID : ""));
			ItemType itemType = item.m_shared.m_itemType;
			switch (itemType - 3)
			{
			default:
				if ((int)itemType != 22)
				{
					break;
				}
				goto case 0;
			case 0:
			case 1:
			case 2:
			case 11:
			{
				ItemData leftItem = ((Humanoid)player).m_leftItem;
				if (((leftItem != null) ? ((Object)leftItem.m_dropPrefab).name : null) == ((Object)item.m_dropPrefab).name)
				{
					val.Set("lf-ell", text);
				}
				ItemData rightItem = ((Humanoid)player).m_rightItem;
				if (((rightItem != null) ? ((Object)rightItem.m_dropPrefab).name : null) == ((Object)item.m_dropPrefab).name)
				{
					val.Set("ri-ell", text);
				}
				break;
			}
			case 4:
				val.Set("ch-ell", text);
				break;
			case 8:
				val.Set("lg-ell", text);
				break;
			case 3:
				val.Set("hl-ell", text);
				break;
			case 14:
				val.Set("sh-ell", text);
				break;
			case 15:
				val.Set("ut-ell", text);
				break;
			case 5:
			case 6:
			case 7:
			case 9:
			case 10:
			case 12:
			case 13:
				break;
			}
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class ObjectDB_CopyOtherDB_Patch
	{
		public static void Postfix()
		{
			EpicLoot.TryRegisterItems();
			EpicLoot.TryRegisterRecipes();
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class ObjectDB_Awake_Patch
	{
		public static void Postfix()
		{
			EpicLoot.TryRegisterItems();
			EpicLoot.TryRegisterRecipes();
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public static class Terminal_Patch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__1_0;

			public static ConsoleEvent <>9__1_1;

			public static ConsoleEvent <>9__1_2;

			public static ConsoleEvent <>9__1_3;

			public static ConsoleEvent <>9__1_4;

			public static ConsoleEvent <>9__1_5;

			public static ConsoleEvent <>9__1_6;

			public static ConsoleEvent <>9__1_7;

			public static ConsoleEvent <>9__1_8;

			public static ConsoleEvent <>9__1_9;

			public static ConsoleEvent <>9__1_10;

			public static ConsoleEvent <>9__1_11;

			public static ConsoleEvent <>9__1_12;

			public static ConsoleEvent <>9__1_13;

			public static ConsoleEvent <>9__1_14;

			public static ConsoleEvent <>9__1_15;

			public static ConsoleEvent <>9__1_16;

			public static ConsoleEvent <>9__1_17;

			public static ConsoleEvent <>9__1_18;

			public static ConsoleEvent <>9__1_19;

			public static ConsoleEvent <>9__1_20;

			public static ConsoleEvent <>9__1_21;

			public static ConsoleEvent <>9__1_22;

			public static ConsoleEvent <>9__1_23;

			public static ConsoleEvent <>9__1_24;

			public static ConsoleEvent <>9__1_25;

			public static ConsoleEvent <>9__1_26;

			public static ConsoleEvent <>9__1_27;

			public static ConsoleEvent <>9__1_28;

			public static ConsoleEvent <>9__1_29;

			public static ConsoleEvent <>9__1_30;

			public static ConsoleEvent <>9__1_31;

			public static ConsoleEvent <>9__1_32;

			public static Func<TreasureMapChestInfo, int> <>9__4_0;

			public static Func<GameObject, bool> <>9__8_0;

			public static Func<GameObject, bool> <>9__8_1;

			public static Func<GameObject, string> <>9__8_2;

			public static Func<string, float> <>9__8_3;

			internal void <Postfix>b__1_0(ConsoleEventArgs args)
			{
				MagicItem(args.Context, args.Args);
			}

			internal void <Postfix>b__1_1(ConsoleEventArgs args)
			{
				MagicItem(args.Context, args.Args);
			}

			internal void <Postfix>b__1_2(ConsoleEventArgs args)
			{
				SpawnMagicItemWithEffect(args.Context, args.Args);
			}

			internal void <Postfix>b__1_3(ConsoleEventArgs args)
			{
				SpawnMagicItemWithEffect(args.Context, args.Args);
			}

			internal void <Postfix>b__1_4(ConsoleEventArgs args)
			{
				SpawnLegendaryMagicItem(args.Context, args.Args);
			}

			internal void <Postfix>b__1_5(ConsoleEventArgs args)
			{
				SpawnLegendaryMagicItem(args.Context, args.Args);
			}

			internal void <Postfix>b__1_6(ConsoleEventArgs args)
			{
				SpawnLegendaryMagicItem(args.Context, args.Args, ItemRarity.Mythic);
			}

			internal void <Postfix>b__1_7(ConsoleEventArgs args)
			{
				SpawnLegendaryMagicItem(args.Context, args.Args, ItemRarity.Mythic);
			}

			internal void <Postfix>b__1_8(ConsoleEventArgs args)
			{
				SpawnMagicItemSet(args.Context, args.Args);
			}

			internal void <Postfix>b__1_9(ConsoleEventArgs args)
			{
				SpawnMagicItemSet(args.Context, args.Args);
			}

			internal void <Postfix>b__1_10(ConsoleEventArgs args)
			{
				CheckStackQuality(args.Context);
			}

			internal void <Postfix>b__1_11(ConsoleEventArgs args)
			{
				SpawnMagicCraftingMaterials();
			}

			internal void <Postfix>b__1_12(ConsoleEventArgs args)
			{
				ToggleAlwaysDrop(args.Context);
			}

			internal void <Postfix>b__1_13(ConsoleEventArgs args)
			{
				LootRoller.CheatDisableGating = !LootRoller.CheatDisableGating;
				args.Context.AddString($"> Disable gating for magic item drops: {LootRoller.CheatDisableGating}");
			}

			internal void <Postfix>b__1_14(ConsoleEventArgs args)
			{
				TestTreasureMap(args.Args);
			}

			internal void <Postfix>b__1_15(ConsoleEventArgs args)
			{
				TestTreasureMap(args.Args);
			}

			internal void <Postfix>b__1_16(ConsoleEventArgs args)
			{
				AdventureSaveData adventureSaveData = Player.m_localPlayer.GetAdventureSaveData();
				adventureSaveData.TreasureMaps.Clear();
				adventureSaveData.NumberOfTreasureMapsOrBountiesStarted = 0;
				ResetMinimap();
			}

			internal void <Postfix>b__1_17(ConsoleEventArgs args)
			{
				AdventureSaveData adventureSaveData = Player.m_localPlayer.GetAdventureSaveData();
				adventureSaveData.TreasureMaps.Clear();
				adventureSaveData.NumberOfTreasureMapsOrBountiesStarted = 0;
				ResetMinimap();
			}

			internal void <Postfix>b__1_18(ConsoleEventArgs args)
			{
				MinimapController.DebugMode = !MinimapController.DebugMode;
				args.Context.AddString($"> Treasure Map Debug Mode: {MinimapController.DebugMode}");
			}

			internal void <Postfix>b__1_19(ConsoleEventArgs args)
			{
				MinimapController.DebugMode = !MinimapController.DebugMode;
				args.Context.AddString($"> Treasure Map Debug Mode: {MinimapController.DebugMode}");
			}

			internal void <Postfix>b__1_20(ConsoleEventArgs args)
			{
				Player.m_localPlayer.GetAdventureSaveData().Bounties.Clear();
				ResetMinimap();
			}

			internal void <Postfix>b__1_21(ConsoleEventArgs args)
			{
				Random random = new Random();
				int num = ((args.Length >= 2) ? int.Parse(args[1]) : 10);
				for (int i = 0; i < num; i++)
				{
					string text = BountiesAdventureFeature.GenerateTargetName(random);
					args.Context.AddString(text);
				}
			}

			internal void <Postfix>b__1_22(ConsoleEventArgs args)
			{
				((Component)Player.m_localPlayer).GetComponent<AdventureComponent>().SaveData = new AdventureSaveDataList();
				ResetMinimap();
			}

			internal void <Postfix>b__1_23(ConsoleEventArgs args)
			{
				int num = ((args.Length >= 2) ? int.Parse(args[1]) : AdventureDataManager.Bounties.GetCurrentInterval());
				List<BountyInfo> availableBounties = AdventureDataManager.Bounties.GetAvailableBounties(num, removeAcceptedBounties: false);
				BountiesAdventureFeature.PrintBounties($"Bounties for Interval {num}:", availableBounties);
			}

			internal void <Postfix>b__1_24(ConsoleEventArgs args)
			{
				List<BountyInfo> bounties = Player.m_localPlayer.GetAdventureSaveData().Bounties;
				BountiesAdventureFeature.PrintBounties("Player Bounties:", bounties);
			}

			internal void <Postfix>b__1_25(ConsoleEventArgs args)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				LocationInstance val = default(LocationInstance);
				if (ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)localPlayer).transform.position, ref val))
				{
					((Terminal)Console.instance).AddString(((object)(Vector3)(ref val.m_position)).ToString());
					((Character)localPlayer).TeleportTo(val.m_position + Vector3.right * 5f, ((Component)localPlayer).transform.rotation, true);
				}
			}

			internal void <Postfix>b__1_26(ConsoleEventArgs args)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				LocationInstance val = default(LocationInstance);
				if (ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)localPlayer).transform.position, ref val))
				{
					((Terminal)Console.instance).AddString(((object)(Vector3)(ref val.m_position)).ToString());
					((Character)localPlayer).TeleportTo(val.m_position + Vector3.right * 5f, ((Component)localPlayer).transform.rotation, true);
				}
			}

			internal void <Postfix>b__1_27(ConsoleEventArgs args)
			{
				if (!((Object)(object)ZoneSystem.instance != (Object)null))
				{
					return;
				}
				args.Context.AddString("> Print Global Keys:");
				foreach (string globalKey in ZoneSystem.instance.GetGlobalKeys())
				{
					args.Context.AddString("> " + globalKey);
				}
			}

			internal void <Postfix>b__1_28(ConsoleEventArgs args)
			{
				FixResistances(Player.m_localPlayer);
			}

			internal void <Postfix>b__1_29(ConsoleEventArgs args)
			{
				string lootTableName = ((args.Length > 1) ? args[1] : "Greydwarf");
				float luckFactor = ((args.Length > 2) ? float.Parse(args[2]) : 0f);
				LootRoller.PrintLuckTest(lootTableName, luckFactor);
			}

			internal void <Postfix>b__1_30(ConsoleEventArgs args)
			{
				string lootTableName = ((args.Length > 1) ? args[1] : "Greydwarf");
				int level = ((args.Length <= 2) ? 1 : int.Parse(args[2]));
				int itemIndex = ((args.Length > 3) ? int.Parse(args[3]) : 0);
				LootRoller.PrintLootResolutionTest(lootTableName, level, itemIndex);
			}

			internal void <Postfix>b__1_31(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer != (Object)null))
				{
					return;
				}
				AbilityController component = ((Component)localPlayer).GetComponent<AbilityController>();
				if (!((Object)(object)component != (Object)null))
				{
					return;
				}
				foreach (Ability currentAbility in component.CurrentAbilities)
				{
					currentAbility.ResetCooldown();
				}
			}

			internal void <Postfix>b__1_32(ConsoleEventArgs args)
			{
				LootRoller.DebugLuckFactor();
			}

			internal int <TestTreasureMapCoroutine>b__4_0(TreasureMapChestInfo x)
			{
				return x.Interval;
			}

			internal bool <MagicItem>b__8_0(GameObject x)
			{
				return EpicLoot.CanBeMagicItem(x.GetComponent<ItemDrop>().m_itemData);
			}

			internal bool <MagicItem>b__8_1(GameObject x)
			{
				if (((Object)x).name != "HelmetDverger" && ((Object)x).name != "BeltStrength")
				{
					return ((Object)x).name != "Wishbone";
				}
				return false;
			}

			internal string <MagicItem>b__8_2(GameObject x)
			{
				return ((Object)x).name;
			}

			internal float <MagicItem>b__8_3(string x)
			{
				return 1f;
			}
		}

		private static readonly Random _random = new Random();

		public static void Postfix()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown