Decompiled source of Valheim Advance PVP v3.6.0

plugins/DasSauerkraut-Terraheim/AugaAPI.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Auga;

public static class API
{
	private static readonly Assembly _targetAssembly;

	public static string RedText;

	public static string Red;

	public static string Brown1;

	public static string Brown2;

	public static string Brown3;

	public static string Brown4;

	public static string Brown5;

	public static string Brown6;

	public static string Brown7;

	public static string Blue;

	public static string LightBlue;

	public static string Gold;

	public static string BrightGold;

	public static string BrightestGold;

	public static string GoldDark;

	public static string Green;

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

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> _, MethodBase original)
	{
		Type[] parameters = original.GetParameters().Select(delegate(ParameterInfo p)
		{
			Type type = p.ParameterType;
			if (type.Assembly == Assembly.GetExecutingAssembly() && _targetAssembly != null)
			{
				type = _targetAssembly.GetType(type.FullName ?? string.Empty);
			}
			return type;
		}).ToArray();
		MethodBase originalMethod = _targetAssembly.GetType("Auga.API").GetMethod(original.Name, parameters);
		int i = 0;
		while (i < parameters.Length)
		{
			yield return new CodeInstruction(OpCodes.Ldarg, (object)i);
			int num = i + 1;
			i = num;
		}
		yield return new CodeInstruction(OpCodes.Call, (object)originalMethod);
		yield return new CodeInstruction(OpCodes.Ret, (object)null);
	}

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

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

	public static Font GetBoldFont()
	{
		return null;
	}

	public static Font GetSemiBoldFont()
	{
		return null;
	}

	public static Font GetRegularFont()
	{
		return null;
	}

	public static Sprite GetItemBackgroundSprite()
	{
		return null;
	}

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

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

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

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

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

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

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

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

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

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

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

	public static void Tooltip_MakeSimpleTooltip(GameObject obj)
	{
	}

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

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

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

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

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

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

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

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

	public static Button Workbench_GetCraftingTabButton()
	{
		return null;
	}

	public static Button Workbench_GetUpgradeTabButton()
	{
		return null;
	}

	public static GameObject Workbench_CreateNewResultsPanel()
	{
		return null;
	}

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

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

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

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

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

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

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

	public static void ComplexTooltip_ClearTextBoxes(GameObject complexTooltipGO)
	{
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public static void CustomVariantPanel_SetButtonLabel(string buttonLabel)
	{
	}

	public static void CustomVariantPanel_Disable()
	{
	}
}
public enum RequirementWireState
{
	Absent,
	Have,
	DontHave
}
public class PlayerPanelTabData
{
	public int Index;

	public Text TabTitle;

	public GameObject TabButtonGO;

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

	public Text TabTitle;

	public GameObject TabButtonGO;

	public GameObject RequirementsPanelGO;

	public GameObject ItemInfoGO;
}

plugins/DasSauerkraut-Terraheim/Newtonsoft.Json.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
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.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
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 Microsoft.CodeAnalysis;
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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Schema, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")]
[assembly: CLSCompliant(true)]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]
[assembly: AssemblyCompany("Newtonsoft")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")]
[assembly: AssemblyFileVersion("12.0.3.23909")]
[assembly: AssemblyInformationalVersion("12.0.3+7c3d7f8da7e35dde8fa74188b0decff70f8f10e3")]
[assembly: AssemblyProduct("Json.NET")]
[assembly: AssemblyTitle("Json.NET")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyVersion("12.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
}
namespace Newtonsoft.Json
{
	public enum ConstructorHandling
	{
		Default,
		AllowNonPublicDefaultConstructor
	}
	public enum DateFormatHandling
	{
		IsoDateFormat,
		MicrosoftDateFormat
	}
	public enum DateParseHandling
	{
		None,
		DateTime,
		DateTimeOffset
	}
	public enum DateTimeZoneHandling
	{
		Local,
		Utc,
		Unspecified,
		RoundtripKind
	}
	public class DefaultJsonNameTable : JsonNameTable
	{
		private class Entry
		{
			internal readonly string Value;

			internal readonly int HashCode;

			internal Entry Next;

			internal Entry(string value, int hashCode, Entry next)
			{
				Value = value;
				HashCode = hashCode;
				Next = next;
			}
		}

		private static readonly int HashCodeRandomizer;

		private int _count;

		private Entry[] _entries;

		private int _mask = 31;

		static DefaultJsonNameTable()
		{
			HashCodeRandomizer = Environment.TickCount;
		}

		public DefaultJsonNameTable()
		{
			_entries = new Entry[_mask + 1];
		}

		public override string? Get(char[] key, int start, int length)
		{
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			num += (num << 7) ^ key[start];
			int num2 = start + length;
			for (int i = start + 1; i < num2; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			int num3 = num & _mask;
			for (Entry entry = _entries[num3]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && TextEquals(entry.Value, key, start, length))
				{
					return entry.Value;
				}
			}
			return null;
		}

		public string Add(string key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			int length = key.Length;
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			for (int i = 0; i < key.Length; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal))
				{
					return entry.Value;
				}
			}
			return AddEntry(key, num);
		}

		private string AddEntry(string str, int hashCode)
		{
			int num = hashCode & _mask;
			Entry entry = new Entry(str, hashCode, _entries[num]);
			_entries[num] = entry;
			if (_count++ == _mask)
			{
				Grow();
			}
			return entry.Value;
		}

		private void Grow()
		{
			Entry[] entries = _entries;
			int num = _mask * 2 + 1;
			Entry[] array = new Entry[num + 1];
			for (int i = 0; i < entries.Length; i++)
			{
				Entry entry = entries[i];
				while (entry != null)
				{
					int num2 = entry.HashCode & num;
					Entry next = entry.Next;
					entry.Next = array[num2];
					array[num2] = entry;
					entry = next;
				}
			}
			_entries = array;
			_mask = num;
		}

		private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length)
		{
			if (str1.Length != str2Length)
			{
				return false;
			}
			for (int i = 0; i < str1.Length; i++)
			{
				if (str1[i] != str2[str2Start + i])
				{
					return false;
				}
			}
			return true;
		}
	}
	[Flags]
	public enum DefaultValueHandling
	{
		Include = 0,
		Ignore = 1,
		Populate = 2,
		IgnoreAndPopulate = 3
	}
	public enum FloatFormatHandling
	{
		String,
		Symbol,
		DefaultValue
	}
	public enum FloatParseHandling
	{
		Double,
		Decimal
	}
	public enum Formatting
	{
		None,
		Indented
	}
	public interface IArrayPool<T>
	{
		T[] Rent(int minimumLength);

		void Return(T[]? array);
	}
	public interface IJsonLineInfo
	{
		int LineNumber { get; }

		int LinePosition { get; }

		bool HasLineInfo();
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonArrayAttribute : JsonContainerAttribute
	{
		private bool _allowNullItems;

		public bool AllowNullItems
		{
			get
			{
				return _allowNullItems;
			}
			set
			{
				_allowNullItems = value;
			}
		}

		public JsonArrayAttribute()
		{
		}

		public JsonArrayAttribute(bool allowNullItems)
		{
			_allowNullItems = allowNullItems;
		}

		public JsonArrayAttribute(string id)
			: base(id)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)]
	public sealed class JsonConstructorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public abstract class JsonContainerAttribute : Attribute
	{
		internal bool? _isReference;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		private Type? _namingStrategyType;

		private object[]? _namingStrategyParameters;

		public string? Id { get; set; }

		public string? Title { get; set; }

		public string? Description { get; set; }

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType
		{
			get
			{
				return _namingStrategyType;
			}
			set
			{
				_namingStrategyType = value;
				NamingStrategyInstance = null;
			}
		}

		public object[]? NamingStrategyParameters
		{
			get
			{
				return _namingStrategyParameters;
			}
			set
			{
				_namingStrategyParameters = value;
				NamingStrategyInstance = null;
			}
		}

		internal NamingStrategy? NamingStrategyInstance { get; set; }

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		protected JsonContainerAttribute()
		{
		}

		protected JsonContainerAttribute(string id)
		{
			Id = id;
		}
	}
	public static class JsonConvert
	{
		public static readonly string True = "true";

		public static readonly string False = "false";

		public static readonly string Null = "null";

		public static readonly string Undefined = "undefined";

		public static readonly string PositiveInfinity = "Infinity";

		public static readonly string NegativeInfinity = "-Infinity";

		public static readonly string NaN = "NaN";

		public static Func<JsonSerializerSettings>? DefaultSettings { get; set; }

		public static string ToString(DateTime value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind);
		}

		public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
		{
			DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling);
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(DateTimeOffset value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat);
		}

		public static string ToString(DateTimeOffset value, DateFormatHandling format)
		{
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(bool value)
		{
			if (!value)
			{
				return False;
			}
			return True;
		}

		public static string ToString(char value)
		{
			return ToString(char.ToString(value));
		}

		public static string ToString(Enum value)
		{
			return value.ToString("D");
		}

		public static string ToString(int value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(short value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ushort value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(uint value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(long value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		private static string ToStringInternal(BigInteger value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ulong value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(float value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value)))
			{
				return text;
			}
			if (floatFormatHandling == FloatFormatHandling.DefaultValue)
			{
				if (nullable)
				{
					return Null;
				}
				return "0.0";
			}
			return quoteChar + text + quoteChar;
		}

		public static string ToString(double value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureDecimalPlace(double value, string text)
		{
			if (double.IsNaN(value) || double.IsInfinity(value) || text.IndexOf('.') != -1 || text.IndexOf('E') != -1 || text.IndexOf('e') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		private static string EnsureDecimalPlace(string text)
		{
			if (text.IndexOf('.') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		public static string ToString(byte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(sbyte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(decimal value)
		{
			return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture));
		}

		public static string ToString(Guid value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(Guid value, char quoteChar)
		{
			string text = value.ToString("D", CultureInfo.InvariantCulture);
			string text2 = quoteChar.ToString(CultureInfo.InvariantCulture);
			return text2 + text + text2;
		}

		public static string ToString(TimeSpan value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(TimeSpan value, char quoteChar)
		{
			return ToString(value.ToString(), quoteChar);
		}

		public static string ToString(Uri? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ToString(value, '"');
		}

		internal static string ToString(Uri value, char quoteChar)
		{
			return ToString(value.OriginalString, quoteChar);
		}

		public static string ToString(string? value)
		{
			return ToString(value, '"');
		}

		public static string ToString(string? value, char delimiter)
		{
			return ToString(value, delimiter, StringEscapeHandling.Default);
		}

		public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling)
		{
			if (delimiter != '"' && delimiter != '\'')
			{
				throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter");
			}
			return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling);
		}

		public static string ToString(object? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ConvertUtils.GetTypeCode(value.GetType()) switch
			{
				PrimitiveTypeCode.String => ToString((string)value), 
				PrimitiveTypeCode.Char => ToString((char)value), 
				PrimitiveTypeCode.Boolean => ToString((bool)value), 
				PrimitiveTypeCode.SByte => ToString((sbyte)value), 
				PrimitiveTypeCode.Int16 => ToString((short)value), 
				PrimitiveTypeCode.UInt16 => ToString((ushort)value), 
				PrimitiveTypeCode.Int32 => ToString((int)value), 
				PrimitiveTypeCode.Byte => ToString((byte)value), 
				PrimitiveTypeCode.UInt32 => ToString((uint)value), 
				PrimitiveTypeCode.Int64 => ToString((long)value), 
				PrimitiveTypeCode.UInt64 => ToString((ulong)value), 
				PrimitiveTypeCode.Single => ToString((float)value), 
				PrimitiveTypeCode.Double => ToString((double)value), 
				PrimitiveTypeCode.DateTime => ToString((DateTime)value), 
				PrimitiveTypeCode.Decimal => ToString((decimal)value), 
				PrimitiveTypeCode.DBNull => Null, 
				PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), 
				PrimitiveTypeCode.Guid => ToString((Guid)value), 
				PrimitiveTypeCode.Uri => ToString((Uri)value), 
				PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), 
				PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), 
				_ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), 
			};
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value)
		{
			return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting)
		{
			return SerializeObject(value, formatting, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, JsonSerializerSettings settings)
		{
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			jsonSerializer.Formatting = formatting;
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer)
		{
			StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture);
			using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter))
			{
				jsonTextWriter.Formatting = jsonSerializer.Formatting;
				jsonSerializer.Serialize(jsonTextWriter, value, type);
			}
			return stringWriter.ToString();
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value)
		{
			return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, JsonSerializerSettings settings)
		{
			return DeserializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, Type type)
		{
			return DeserializeObject(value, type, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static T DeserializeObject<T>(string value)
		{
			return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
		{
			return DeserializeObject<T>(value);
		}

		[DebuggerStepThrough]
		public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
		{
			return DeserializeObject<T>(value, settings);
		}

		[DebuggerStepThrough]
		[return: MaybeNull]
		public static T DeserializeObject<T>(string value, params JsonConverter[] converters)
		{
			return (T)DeserializeObject(value, typeof(T), converters);
		}

		[DebuggerStepThrough]
		[return: MaybeNull]
		public static T DeserializeObject<T>(string value, JsonSerializerSettings? settings)
		{
			return (T)DeserializeObject(value, typeof(T), settings);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return DeserializeObject(value, type, settings);
		}

		public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings)
		{
			ValidationUtils.ArgumentNotNull(value, "value");
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			if (!jsonSerializer.IsCheckAdditionalContentSet())
			{
				jsonSerializer.CheckAdditionalContent = true;
			}
			using JsonTextReader reader = new JsonTextReader(new StringReader(value));
			return jsonSerializer.Deserialize(reader, type);
		}

		[DebuggerStepThrough]
		public static void PopulateObject(string value, object target)
		{
			PopulateObject(value, target, null);
		}

		public static void PopulateObject(string value, object target, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			using JsonReader jsonReader = new JsonTextReader(new StringReader(value));
			jsonSerializer.Populate(jsonReader, target);
			if (settings == null || !settings.CheckAdditionalContent)
			{
				return;
			}
			while (jsonReader.Read())
			{
				if (jsonReader.TokenType != JsonToken.Comment)
				{
					throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object.");
				}
			}
		}

		public static string SerializeXmlNode(XmlNode? node)
		{
			return SerializeXmlNode(node, Formatting.None);
		}

		public static string SerializeXmlNode(XmlNode? node, Formatting formatting)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static XmlDocument? DeserializeXmlNode(string value)
		{
			return DeserializeXmlNode(value, null);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter);
		}

		public static string SerializeXNode(XObject? node)
		{
			return SerializeXNode(node, Formatting.None);
		}

		public static string SerializeXNode(XObject? node, Formatting formatting)
		{
			return SerializeXNode(node, formatting, omitRootObject: false);
		}

		public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static XDocument? DeserializeXNode(string value)
		{
			return DeserializeXNode(value, null);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter);
		}
	}
	public abstract class JsonConverter
	{
		public virtual bool CanRead => true;

		public virtual bool CanWrite => true;

		public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer);

		public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer);

		public abstract bool CanConvert(Type objectType);
	}
	public abstract class JsonConverter<T> : JsonConverter
	{
		public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
		{
			if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T))))
			{
				throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			WriteJson(writer, (T)value, serializer);
		}

		public abstract void WriteJson(JsonWriter writer, [AllowNull] T value, JsonSerializer serializer);

		public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
		{
			bool flag = existingValue == null;
			if (!flag && !(existingValue is T))
			{
				throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer);
		}

		public abstract T ReadJson(JsonReader reader, Type objectType, [AllowNull] T existingValue, bool hasExistingValue, JsonSerializer serializer);

		public sealed override bool CanConvert(Type objectType)
		{
			return typeof(T).IsAssignableFrom(objectType);
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)]
	public sealed class JsonConverterAttribute : Attribute
	{
		private readonly Type _converterType;

		public Type ConverterType => _converterType;

		public object[]? ConverterParameters { get; }

		public JsonConverterAttribute(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			_converterType = converterType;
		}

		public JsonConverterAttribute(Type converterType, params object[] converterParameters)
			: this(converterType)
		{
			ConverterParameters = converterParameters;
		}
	}
	public class JsonConverterCollection : Collection<JsonConverter>
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonDictionaryAttribute : JsonContainerAttribute
	{
		public JsonDictionaryAttribute()
		{
		}

		public JsonDictionaryAttribute(string id)
			: base(id)
		{
		}
	}
	[Serializable]
	public class JsonException : Exception
	{
		public JsonException()
		{
		}

		public JsonException(string message)
			: base(message)
		{
		}

		public JsonException(string message, Exception? innerException)
			: base(message, innerException)
		{
		}

		public JsonException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			return new JsonException(message);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public class JsonExtensionDataAttribute : Attribute
	{
		public bool WriteData { get; set; }

		public bool ReadData { get; set; }

		public JsonExtensionDataAttribute()
		{
			WriteData = true;
			ReadData = true;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public sealed class JsonIgnoreAttribute : Attribute
	{
	}
	public abstract class JsonNameTable
	{
		public abstract string? Get(char[] key, int start, int length);
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonObjectAttribute : JsonContainerAttribute
	{
		private MemberSerialization _memberSerialization;

		internal MissingMemberHandling? _missingMemberHandling;

		internal Required? _itemRequired;

		internal NullValueHandling? _itemNullValueHandling;

		public MemberSerialization MemberSerialization
		{
			get
			{
				return _memberSerialization;
			}
			set
			{
				_memberSerialization = value;
			}
		}

		public MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling.GetValueOrDefault();
			}
			set
			{
				_missingMemberHandling = value;
			}
		}

		public NullValueHandling ItemNullValueHandling
		{
			get
			{
				return _itemNullValueHandling.GetValueOrDefault();
			}
			set
			{
				_itemNullValueHandling = value;
			}
		}

		public Required ItemRequired
		{
			get
			{
				return _itemRequired.GetValueOrDefault();
			}
			set
			{
				_itemRequired = value;
			}
		}

		public JsonObjectAttribute()
		{
		}

		public JsonObjectAttribute(MemberSerialization memberSerialization)
		{
			MemberSerialization = memberSerialization;
		}

		public JsonObjectAttribute(string id)
			: base(id)
		{
		}
	}
	internal enum JsonContainerType
	{
		None,
		Object,
		Array,
		Constructor
	}
	internal struct JsonPosition
	{
		private static readonly char[] SpecialCharacters = new char[18]
		{
			'.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t',
			'\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029'
		};

		internal JsonContainerType Type;

		internal int Position;

		internal string? PropertyName;

		internal bool HasIndex;

		public JsonPosition(JsonContainerType type)
		{
			Type = type;
			HasIndex = TypeHasIndex(type);
			Position = -1;
			PropertyName = null;
		}

		internal int CalculateLength()
		{
			switch (Type)
			{
			case JsonContainerType.Object:
				return PropertyName.Length + 5;
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				return MathUtils.IntLength((ulong)Position) + 2;
			default:
				throw new ArgumentOutOfRangeException("Type");
			}
		}

		internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer)
		{
			switch (Type)
			{
			case JsonContainerType.Object:
			{
				string propertyName = PropertyName;
				if (propertyName.IndexOfAny(SpecialCharacters) != -1)
				{
					sb.Append("['");
					if (writer == null)
					{
						writer = new StringWriter(sb);
					}
					JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer);
					sb.Append("']");
				}
				else
				{
					if (sb.Length > 0)
					{
						sb.Append('.');
					}
					sb.Append(propertyName);
				}
				break;
			}
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				sb.Append('[');
				sb.Append(Position);
				sb.Append(']');
				break;
			}
		}

		internal static bool TypeHasIndex(JsonContainerType type)
		{
			if (type != JsonContainerType.Array)
			{
				return type == JsonContainerType.Constructor;
			}
			return true;
		}

		internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition)
		{
			int num = 0;
			if (positions != null)
			{
				for (int i = 0; i < positions.Count; i++)
				{
					num += positions[i].CalculateLength();
				}
			}
			if (currentPosition.HasValue)
			{
				num += currentPosition.GetValueOrDefault().CalculateLength();
			}
			StringBuilder stringBuilder = new StringBuilder(num);
			StringWriter writer = null;
			char[] buffer = null;
			if (positions != null)
			{
				foreach (JsonPosition position in positions)
				{
					position.WriteTo(stringBuilder, ref writer, ref buffer);
				}
			}
			currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer);
			return stringBuilder.ToString();
		}

		internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message)
		{
			if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal))
			{
				message = message.Trim();
				if (!StringUtils.EndsWith(message, '.'))
				{
					message += ".";
				}
				message += " ";
			}
			message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path);
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition);
			}
			message += ".";
			return message;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
	public sealed class JsonPropertyAttribute : Attribute
	{
		internal NullValueHandling? _nullValueHandling;

		internal DefaultValueHandling? _defaultValueHandling;

		internal ReferenceLoopHandling? _referenceLoopHandling;

		internal ObjectCreationHandling? _objectCreationHandling;

		internal TypeNameHandling? _typeNameHandling;

		internal bool? _isReference;

		internal int? _order;

		internal Required? _required;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType { get; set; }

		public object[]? NamingStrategyParameters { get; set; }

		public NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling.GetValueOrDefault();
			}
			set
			{
				_nullValueHandling = value;
			}
		}

		public DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling.GetValueOrDefault();
			}
			set
			{
				_defaultValueHandling = value;
			}
		}

		public ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_referenceLoopHandling = value;
			}
		}

		public ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling.GetValueOrDefault();
			}
			set
			{
				_objectCreationHandling = value;
			}
		}

		public TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling.GetValueOrDefault();
			}
			set
			{
				_typeNameHandling = value;
			}
		}

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public int Order
		{
			get
			{
				return _order.GetValueOrDefault();
			}
			set
			{
				_order = value;
			}
		}

		public Required Required
		{
			get
			{
				return _required.GetValueOrDefault();
			}
			set
			{
				_required = value;
			}
		}

		public string? PropertyName { get; set; }

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public JsonPropertyAttribute()
		{
		}

		public JsonPropertyAttribute(string propertyName)
		{
			PropertyName = propertyName;
		}
	}
	public abstract class JsonReader : IDisposable
	{
		protected internal enum State
		{
			Start,
			Complete,
			Property,
			ObjectStart,
			Object,
			ArrayStart,
			Array,
			Closed,
			PostValue,
			ConstructorStart,
			Constructor,
			Error,
			Finished
		}

		private JsonToken _tokenType;

		private object? _value;

		internal char _quoteChar;

		internal State _currentState;

		private JsonPosition _currentPosition;

		private CultureInfo? _culture;

		private DateTimeZoneHandling _dateTimeZoneHandling;

		private int? _maxDepth;

		private bool _hasExceededMaxDepth;

		internal DateParseHandling _dateParseHandling;

		internal FloatParseHandling _floatParseHandling;

		private string? _dateFormatString;

		private List<JsonPosition>? _stack;

		protected State CurrentState => _currentState;

		public bool CloseInput { get; set; }

		public bool SupportMultipleContent { get; set; }

		public virtual char QuoteChar
		{
			get
			{
				return _quoteChar;
			}
			protected internal set
			{
				_quoteChar = value;
			}
		}

		public DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling;
			}
			set
			{
				if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateTimeZoneHandling = value;
			}
		}

		public DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling;
			}
			set
			{
				if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateParseHandling = value;
			}
		}

		public FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling;
			}
			set
			{
				if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_floatParseHandling = value;
			}
		}

		public string? DateFormatString
		{
			get
			{
				return _dateFormatString;
			}
			set
			{
				_dateFormatString = value;
			}
		}

		public int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
			}
		}

		public virtual JsonToken TokenType => _tokenType;

		public virtual object? Value => _value;

		public virtual Type? ValueType => _value?.GetType();

		public virtual int Depth
		{
			get
			{
				int num = _stack?.Count ?? 0;
				if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None)
				{
					return num;
				}
				return num + 1;
			}
		}

		public virtual string Path
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null);
				return JsonPosition.BuildPath(_stack, currentPosition);
			}
		}

		public CultureInfo Culture
		{
			get
			{
				return _culture ?? CultureInfo.InvariantCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync();
		}

		public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			if (TokenType == JsonToken.PropertyName)
			{
				await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth)
				{
				}
			}
		}

		internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken)
		{
			if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
			{
				throw CreateUnexpectedEndException();
			}
		}

		public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean());
		}

		public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes());
		}

		internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken)
		{
			List<byte> buffer = new List<byte>();
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(buffer));
			byte[] array = buffer.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime());
		}

		public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset());
		}

		public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal());
		}

		public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return Task.FromResult(ReadAsDouble());
		}

		public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32());
		}

		public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString());
		}

		internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken)
		{
			bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (flag)
			{
				flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			return flag;
		}

		internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType = TokenType;
			if (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				return MoveToContentFromNonContentAsync(cancellationToken);
			}
			return AsyncUtils.True;
		}

		private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType;
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					return false;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.None || tokenType == JsonToken.Comment);
			return true;
		}

		internal JsonPosition GetPosition(int depth)
		{
			if (_stack != null && depth < _stack.Count)
			{
				return _stack[depth];
			}
			return _currentPosition;
		}

		protected JsonReader()
		{
			_currentState = State.Start;
			_dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
			_dateParseHandling = DateParseHandling.DateTime;
			_floatParseHandling = FloatParseHandling.Double;
			CloseInput = true;
		}

		private void Push(JsonContainerType value)
		{
			UpdateScopeWithFinishedValue();
			if (_currentPosition.Type == JsonContainerType.None)
			{
				_currentPosition = new JsonPosition(value);
				return;
			}
			if (_stack == null)
			{
				_stack = new List<JsonPosition>();
			}
			_stack.Add(_currentPosition);
			_currentPosition = new JsonPosition(value);
			if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth)
			{
				return;
			}
			_hasExceededMaxDepth = true;
			throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth));
		}

		private JsonContainerType Pop()
		{
			JsonPosition currentPosition;
			if (_stack != null && _stack.Count > 0)
			{
				currentPosition = _currentPosition;
				_currentPosition = _stack[_stack.Count - 1];
				_stack.RemoveAt(_stack.Count - 1);
			}
			else
			{
				currentPosition = _currentPosition;
				_currentPosition = default(JsonPosition);
			}
			if (_maxDepth.HasValue && Depth <= _maxDepth)
			{
				_hasExceededMaxDepth = false;
			}
			return currentPosition.Type;
		}

		private JsonContainerType Peek()
		{
			return _currentPosition.Type;
		}

		public abstract bool Read();

		public virtual int? ReadAsInt32()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is int)
				{
					return (int)value;
				}
				int num;
				if (value is BigInteger bigInteger)
				{
					num = (int)bigInteger;
				}
				else
				{
					try
					{
						num = Convert.ToInt32(value, CultureInfo.InvariantCulture);
					}
					catch (Exception ex)
					{
						throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
					}
				}
				SetToken(JsonToken.Integer, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
			{
				string s = (string)Value;
				return ReadInt32String(s);
			}
			default:
				throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal int? ReadInt32String(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (int.TryParse(s, NumberStyles.Integer, Culture, out var result))
			{
				SetToken(JsonToken.Integer, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual string? ReadAsString()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.String:
				return (string)Value;
			default:
				if (JsonTokenUtils.IsPrimitiveToken(contentToken))
				{
					object value = Value;
					if (value != null)
					{
						string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture));
						SetToken(JsonToken.String, text, updateIndex: false);
						return text;
					}
				}
				throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		public virtual byte[]? ReadAsBytes()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.StartObject:
			{
				ReadIntoWrappedTypeObject();
				byte[] array2 = ReadAsBytes();
				ReaderReadAndAssert();
				if (TokenType != JsonToken.EndObject)
				{
					throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
				}
				SetToken(JsonToken.Bytes, array2, updateIndex: false);
				return array2;
			}
			case JsonToken.String:
			{
				string text = (string)Value;
				Guid g;
				byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray()));
				SetToken(JsonToken.Bytes, array3, updateIndex: false);
				return array3;
			}
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Bytes:
				if (Value is Guid guid)
				{
					byte[] array = guid.ToByteArray();
					SetToken(JsonToken.Bytes, array, updateIndex: false);
					return array;
				}
				return (byte[])Value;
			case JsonToken.StartArray:
				return ReadArrayIntoByteArray();
			default:
				throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal byte[] ReadArrayIntoByteArray()
		{
			List<byte> list = new List<byte>();
			do
			{
				if (!Read())
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(list));
			byte[] array = list.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer)
		{
			switch (TokenType)
			{
			case JsonToken.None:
				throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
			case JsonToken.Integer:
				buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture));
				return false;
			case JsonToken.EndArray:
				return true;
			case JsonToken.Comment:
				return false;
			default:
				throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
			}
		}

		public virtual double? ReadAsDouble()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is double)
				{
					return (double)value;
				}
				double num = ((!(value is BigInteger bigInteger)) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger));
				SetToken(JsonToken.Float, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
				return ReadDoubleString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal double? ReadDoubleString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result))
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual bool? ReadAsBoolean()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				bool flag = ((!(Value is BigInteger bigInteger)) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L));
				SetToken(JsonToken.Boolean, flag, updateIndex: false);
				return flag;
			}
			case JsonToken.String:
				return ReadBooleanString((string)Value);
			case JsonToken.Boolean:
				return (bool)Value;
			default:
				throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal bool? ReadBooleanString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (bool.TryParse(s, out var result))
			{
				SetToken(JsonToken.Boolean, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual decimal? ReadAsDecimal()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is decimal)
				{
					return (decimal)value;
				}
				decimal num;
				if (value is BigInteger bigInteger)
				{
					num = (decimal)bigInteger;
				}
				else
				{
					try
					{
						num = Convert.ToDecimal(value, CultureInfo.InvariantCulture);
					}
					catch (Exception ex)
					{
						throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
					}
				}
				SetToken(JsonToken.Float, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
				return ReadDecimalString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal decimal? ReadDecimalString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result))
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success)
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual DateTime? ReadAsDateTime()
		{
			switch (GetContentToken())
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Date:
				if (Value is DateTimeOffset dateTimeOffset)
				{
					SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false);
				}
				return (DateTime)Value;
			case JsonToken.String:
				return ReadDateTimeString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
			}
		}

		internal DateTime? ReadDateTimeString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt))
			{
				dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
			{
				dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual DateTimeOffset? ReadAsDateTimeOffset()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Date:
				if (Value is DateTime dateTime)
				{
					SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false);
				}
				return (DateTimeOffset)Value;
			case JsonToken.String:
			{
				string s = (string)Value;
				return ReadDateTimeOffsetString(s);
			}
			default:
				throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal DateTimeOffset? ReadDateTimeOffsetString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt))
			{
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
			{
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		internal void ReaderReadAndAssert()
		{
			if (!Read())
			{
				throw CreateUnexpectedEndException();
			}
		}

		internal JsonReaderException CreateUnexpectedEndException()
		{
			return JsonReaderException.Create(this, "Unexpected end when reading JSON.");
		}

		internal void ReadIntoWrappedTypeObject()
		{
			ReaderReadAndAssert();
			if (Value != null && Value.ToString() == "$type")
			{
				ReaderReadAndAssert();
				if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal))
				{
					ReaderReadAndAssert();
					if (Value.ToString() == "$value")
					{
						return;
					}
				}
			}
			throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject));
		}

		public void Skip()
		{
			if (TokenType == JsonToken.PropertyName)
			{
				Read();
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (Read() && depth < Depth)
				{
				}
			}
		}

		protected void SetToken(JsonToken newToken)
		{
			SetToken(newToken, null, updateIndex: true);
		}

		protected void SetToken(JsonToken newToken, object? value)
		{
			SetToken(newToken, value, updateIndex: true);
		}

		protected void SetToken(JsonToken newToken, object? value, bool updateIndex)
		{
			_tokenType = newToken;
			_value = value;
			switch (newToken)
			{
			case JsonToken.StartObject:
				_currentState = State.ObjectStart;
				Push(JsonContainerType.Object);
				break;
			case JsonToken.StartArray:
				_currentState = State.ArrayStart;
				Push(JsonContainerType.Array);
				break;
			case JsonToken.StartConstructor:
				_currentState = State.ConstructorStart;
				Push(JsonContainerType.Constructor);
				break;
			case JsonToken.EndObject:
				ValidateEnd(JsonToken.EndObject);
				break;
			case JsonToken.EndArray:
				ValidateEnd(JsonToken.EndArray);
				break;
			case JsonToken.EndConstructor:
				ValidateEnd(JsonToken.EndConstructor);
				break;
			case JsonToken.PropertyName:
				_currentState = State.Property;
				_currentPosition.PropertyName = (string)value;
				break;
			case JsonToken.Raw:
			case JsonToken.Integer:
			case JsonToken.Float:
			case JsonToken.String:
			case JsonToken.Boolean:
			case JsonToken.Null:
			case JsonToken.Undefined:
			case JsonToken.Date:
			case JsonToken.Bytes:
				SetPostValueState(updateIndex);
				break;
			case JsonToken.Comment:
				break;
			}
		}

		internal void SetPostValueState(bool updateIndex)
		{
			if (Peek() != 0 || SupportMultipleContent)
			{
				_currentState = State.PostValue;
			}
			else
			{
				SetFinished();
			}
			if (updateIndex)
			{
				UpdateScopeWithFinishedValue();
			}
		}

		private void UpdateScopeWithFinishedValue()
		{
			if (_currentPosition.HasIndex)
			{
				_currentPosition.Position++;
			}
		}

		private void ValidateEnd(JsonToken endToken)
		{
			JsonContainerType jsonContainerType = Pop();
			if (GetTypeForCloseToken(endToken) != jsonContainerType)
			{
				throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType));
			}
			if (Peek() != 0 || SupportMultipleContent)
			{
				_currentState = State.PostValue;
			}
			else
			{
				SetFinished();
			}
		}

		protected void SetStateBasedOnCurrent()
		{
			JsonContainerType jsonContainerType = Peek();
			switch (jsonContainerType)
			{
			case JsonContainerType.Object:
				_currentState = State.Object;
				break;
			case JsonContainerType.Array:
				_currentState = State.Array;
				break;
			case JsonContainerType.Constructor:
				_currentState = State.Constructor;
				break;
			case JsonContainerType.None:
				SetFinished();
				break;
			default:
				throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType));
			}
		}

		private void SetFinished()
		{
			_currentState = ((!SupportMultipleContent) ? State.Finished : State.Start);
		}

		private JsonContainerType GetTypeForCloseToken(JsonToken token)
		{
			return token switch
			{
				JsonToken.EndObject => JsonContainerType.Object, 
				JsonToken.EndArray => JsonContainerType.Array, 
				JsonToken.EndConstructor => JsonContainerType.Constructor, 
				_ => throw JsonReaderException.Create(this, "Not a valid close JsonToken: {0}".FormatWith(CultureInfo.InvariantCulture, token)), 
			};
		}

		void IDisposable.Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (_currentState != State.Closed && disposing)
			{
				Close();
			}
		}

		public virtual void Close()
		{
			_currentState = State.Closed;
			_tokenType = JsonToken.None;
			_value = null;
		}

		internal void ReadAndAssert()
		{
			if (!Read())
			{
				throw JsonSerializationException.Create(this, "Unexpected end when reading JSON.");
			}
		}

		internal void ReadForTypeAndAssert(JsonContract? contract, bool hasConverter)
		{
			if (!ReadForType(contract, hasConverter))
			{
				throw JsonSerializationException.Create(this, "Unexpected end when reading JSON.");
			}
		}

		internal bool ReadForType(JsonContract? contract, bool hasConverter)
		{
			if (hasConverter)
			{
				return Read();
			}
			switch (contract?.InternalReadType ?? ReadType.Read)
			{
			case ReadType.Read:
				return ReadAndMoveToContent();
			case ReadType.ReadAsInt32:
				ReadAsInt32();
				break;
			case ReadType.ReadAsInt64:
			{
				bool result = ReadAndMoveToContent();
				if (TokenType == JsonToken.Undefined)
				{
					throw JsonReaderException.Create(this, "An undefined token is not a valid {0}.".FormatWith(CultureInfo.InvariantCulture, contract?.UnderlyingType ?? typeof(long)));
				}
				return result;
			}
			case ReadType.ReadAsDecimal:
				ReadAsDecimal();
				break;
			case ReadType.ReadAsDouble:
				ReadAsDouble();
				break;
			case ReadType.ReadAsBytes:
				ReadAsBytes();
				break;
			case ReadType.ReadAsBoolean:
				ReadAsBoolean();
				break;
			case ReadType.ReadAsString:
				ReadAsString();
				break;
			case ReadType.ReadAsDateTime:
				ReadAsDateTime();
				break;
			case ReadType.ReadAsDateTimeOffset:
				ReadAsDateTimeOffset();
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
			return TokenType != JsonToken.None;
		}

		internal bool ReadAndMoveToContent()
		{
			if (Read())
			{
				return MoveToContent();
			}
			return false;
		}

		internal bool MoveToContent()
		{
			JsonToken tokenType = TokenType;
			while (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				if (!Read())
				{
					return false;
				}
				tokenType = TokenType;
			}
			return true;
		}

		private JsonToken GetContentToken()
		{
			JsonToken tokenType;
			do
			{
				if (!Read())
				{
					SetToken(JsonToken.None);
					return JsonToken.None;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.Comment);
			return tokenType;
		}
	}
	[Serializable]
	public class JsonReaderException : JsonException
	{
		public int LineNumber { get; }

		public int LinePosition { get; }

		public string? Path { get; }

		public JsonReaderException()
		{
		}

		public JsonReaderException(string message)
			: base(message)
		{
		}

		public JsonReaderException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		public JsonReaderException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception? innerException)
			: base(message, innerException)
		{
			Path = path;
			LineNumber = lineNumber;
			LinePosition = linePosition;
		}

		internal static JsonReaderException Create(JsonReader reader, string message)
		{
			return Create(reader, message, null);
		}

		internal static JsonReaderException Create(JsonReader reader, string message, Exception? ex)
		{
			return Create(reader as IJsonLineInfo, reader.Path, message, ex);
		}

		internal static JsonReaderException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			int lineNumber;
			int linePosition;
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				lineNumber = lineInfo.LineNumber;
				linePosition = lineInfo.LinePosition;
			}
			else
			{
				lineNumber = 0;
				linePosition = 0;
			}
			return new JsonReaderException(message, path, lineNumber, linePosition, ex);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public sealed class JsonRequiredAttribute : Attribute
	{
	}
	[Serializable]
	public class JsonSerializationException : JsonException
	{
		public int LineNumber { get; }

		public int LinePosition { get; }

		public string? Path { get; }

		public JsonSerializationException()
		{
		}

		public JsonSerializationException(string message)
			: base(message)
		{
		}

		public JsonSerializationException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		public JsonSerializationException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		public JsonSerializationException(string message, string path, int lineNumber, int linePosition, Exception? innerException)
			: base(message, innerException)
		{
			Path = path;
			LineNumber = lineNumber;
			LinePosition = linePosition;
		}

		internal static JsonSerializationException Create(JsonReader reader, string message)
		{
			return Create(reader, message, null);
		}

		internal static JsonSerializationException Create(JsonReader reader, string message, Exception? ex)
		{
			return Create(reader as IJsonLineInfo, reader.Path, message, ex);
		}

		internal static JsonSerializationException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			int lineNumber;
			int linePosition;
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				lineNumber = lineInfo.LineNumber;
				linePosition = lineInfo.LinePosition;
			}
			else
			{
				lineNumber = 0;
				linePosition = 0;
			}
			return new JsonSerializationException(message, path, lineNumber, linePosition, ex);
		}
	}
	public class JsonSerializer
	{
		internal TypeNameHandling _typeNameHandling;

		internal TypeNameAssemblyFormatHandling _typeNameAssemblyFormatHandling;

		internal PreserveReferencesHandling _preserveReferencesHandling;

		internal ReferenceLoopHandling _referenceLoopHandling;

		internal MissingMemberHandling _missingMemberHandling;

		internal ObjectCreationHandling _objectCreationHandling;

		internal NullValueHandling _nullValueHandling;

		internal DefaultValueHandling _defaultValueHandling;

		internal ConstructorHandling _constructorHandling;

		internal MetadataPropertyHandling _metadataPropertyHandling;

		internal JsonConverterCollection? _converters;

		internal IContractResolver _contractResolver;

		internal ITraceWriter? _traceWriter;

		internal IEqualityComparer? _equalityComparer;

		internal ISerializationBinder _serializationBinder;

		internal StreamingContext _context;

		private IReferenceResolver? _referenceResolver;

		private Formatting? _formatting;

		private DateFormatHandling? _dateFormatHandling;

		private DateTimeZoneHandling? _dateTimeZoneHandling;

		private DateParseHandling? _dateParseHandling;

		private FloatFormatHandling? _floatFormatHandling;

		private FloatParseHandling? _floatParseHandling;

		private StringEscapeHandling? _stringEscapeHandling;

		private CultureInfo _culture;

		private int? _maxDepth;

		private bool _maxDepthSet;

		private bool? _checkAdditionalContent;

		private string? _dateFormatString;

		private bool _dateFormatStringSet;

		public virtual IReferenceResolver? ReferenceResolver
		{
			get
			{
				return GetReferenceResolver();
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Reference resolver cannot be null.");
				}
				_referenceResolver = value;
			}
		}

		[Obsolete("Binder is obsolete. Use SerializationBinder instead.")]
		public virtual SerializationBinder Binder
		{
			get
			{
				if (_serializationBinder is SerializationBinder result)
				{
					return result;
				}
				if (_serializationBinder is SerializationBinderAdapter serializationBinderAdapter)
				{
					return serializationBinderAdapter.SerializationBinder;
				}
				throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set.");
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Serialization binder cannot be null.");
				}
				_serializationBinder = (value as ISerializationBinder) ?? new SerializationBinderAdapter(value);
			}
		}

		public virtual ISerializationBinder SerializationBinder
		{
			get
			{
				return _serializationBinder;
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Serialization binder cannot be null.");
				}
				_serializationBinder = value;
			}
		}

		public virtual ITraceWriter? TraceWriter
		{
			get
			{
				return _traceWriter;
			}
			set
			{
				_traceWriter = value;
			}
		}

		public virtual IEqualityComparer? EqualityComparer
		{
			get
			{
				return _equalityComparer;
			}
			set
			{
				_equalityComparer = value;
			}
		}

		public virtual TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling;
			}
			set
			{
				if (value < TypeNameHandling.None || value > TypeNameHandling.Auto)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameHandling = value;
			}
		}

		[Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
		public virtual FormatterAssemblyStyle TypeNameAssemblyFormat
		{
			get
			{
				return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling;
			}
			set
			{
				if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value;
			}
		}

		public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling
		{
			get
			{
				return _typeNameAssemblyFormatHandling;
			}
			set
			{
				if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameAssemblyFormatHandling = value;
			}
		}

		public virtual PreserveReferencesHandling PreserveReferencesHandling
		{
			get
			{
				return _preserveReferencesHandling;
			}
			set
			{
				if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_preserveReferencesHandling = value;
			}
		}

		public virtual ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling;
			}
			set
			{
				if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_referenceLoopHandling = value;
			}
		}

		public virtual MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling;
			}
			set
			{
				if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_missingMemberHandling = value;
			}
		}

		public virtual NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling;
			}
			set
			{
				if (value < NullValueHandling.Include || value > NullValueHandling.Ignore)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_nullValueHandling = value;
			}
		}

		public virtual DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling;
			}
			set
			{
				if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_defaultValueHandling = value;
			}
		}

		public virtual ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling;
			}
			set
			{
				if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_objectCreationHandling = value;
			}
		}

		public virtual ConstructorHandling ConstructorHandling
		{
			get
			{
				return _constructorHandling;
			}
			set
			{
				if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_constructorHandling = value;
			}
		}

		public virtual MetadataPropertyHandling MetadataPropertyHandling
		{
			get
			{
				return _metadataPropertyHandling;
			}
			set
			{
				if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_metadataPropertyHandling = value;
			}
		}

		public virtual JsonConverterCollection Converters
		{
			get
			{
				if (_converters == null)
				{
					_converters = new JsonConverterCollection();
				}
				return _converters;
			}
		}

		public virtual IContractResolver ContractResolver
		{
			get
			{
				return _contractResolver;
			}
			set
			{
				_contractResolver = value ?? DefaultContractResolver.Instance;
			}
		}

		public virtual StreamingContext Context
		{
			get
			{
				return _context;
			}
			set
			{
				_context = value;
			}
		}

		public virtual Formatting Formatting
		{
			get
			{
				return _formatting.GetValueOrDefault();
			}
			set
			{
				_formatting = value;
			}
		}

		public virtual DateFormatHandling DateFormatHandling
		{
			get
			{
				return _dateFormatHandling.GetValueOrDefault();
			}
			set
			{
				_dateFormatHandling = value;
			}
		}

		public virtual DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling ?? DateTimeZoneHandling.RoundtripKind;
			}
			set
			{
				_dateTimeZoneHandling = value;
			}
		}

		public virtual DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling ?? DateParseHandling.DateTime;
			}
			set
			{
				_dateParseHandling = value;
			}
		}

		public virtual FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling.GetValueOrDefault();
			}
			set
			{
				_floatParseHandling = value;
			}
		}

		public virtual FloatFormatHandling FloatFormatHandling
		{
			get
			{
				return _floatFormatHandling.GetValueOrDefault();
			}
			set
			{
				_floatFormatHandling = value;
			}
		}

		public virtual StringEscapeHandling StringEscapeHandling
		{
			get
			{
				return _stringEscapeHandling.GetValueOrDefault();
			}
			set
			{
				_stringEscapeHandling = value;
			}
		}

		public virtual string DateFormatString
		{
			get
			{
				return _dateFormatString ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
			}
			set
			{
				_dateFormatString = value;
				_dateFormatStringSet = true;
			}
		}

		public virtual CultureInfo Culture
		{
			get
			{
				return _culture ?? JsonSerializerSettings.DefaultCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
				_maxDepthSet = true;
			}
		}

		public virtual bool CheckAdditionalContent
		{
			get
			{
				return _checkAdditionalContent.GetValueOrDefault();
			}
			set
			{
				_checkAdditionalContent = value;
			}
		}

		public virtual event EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>? Error;

		internal bool IsCheckAdditionalContentSet()
		{
			return _checkAdditionalContent.HasValue;
		}

		public JsonSerializer()
		{
			_referenceLoopHandling = ReferenceLoopHandling.Error;
			_missingMemberHandling = MissingMemberHandling.Ignore;
			_nullValueHandling = NullValueHandling.Include;
			_defaultValueHandling = DefaultValueHandling.Include;
			_objectCreationHandling = ObjectCreationHandling.Auto;
			_preserveReferencesHandling = PreserveReferencesHandling.None;
			_constructorHandling = ConstructorHandling.Default;
			_typeNameHandling = TypeNameHandling.None;
			_metadataPropertyHandling = MetadataPropertyHandling.Default;
			_context = JsonSerializerSettings.DefaultContext;
			_serializationBinder = DefaultSerializationBinder.Instance;
			_culture = JsonSerializerSettings.DefaultCulture;
			_contractResolver = DefaultContractResolver.Instance;
		}

		public static JsonSerializer Create()
		{
			return new JsonSerializer();
		}

		public static JsonSerializer Create(JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = Create();
			if (settings != null)
			{
				ApplySerializerSettings(jsonSerializer, settings);
			}
			return jsonSerializer;
		}

		public static JsonSerializer CreateDefault()
		{
			return Create(JsonConvert.DefaultSettings?.Invoke());
		}

		public static JsonSerializer CreateDefault(JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = CreateDefault();
			if (settings != null)
			{
				ApplySerializerSettings(jsonSerializer, settings);
			}
			return jsonSerializer;
		}

		private static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings)
		{
			if (!CollectionUtils.IsNullOrEmpty(settings.Converters))
			{
				for (int i = 0; i < settings.Converters.Count; i++)
				{
					serializer.Converters.Insert(i, settings.Converters[i]);
				}
			}
			if (settings._typeNameHandling.HasValue)
			{
				serializer.TypeNameHandling = settings.TypeNameHandling;
			}
			if (settings._metadataPropertyHandling.HasValue)
			{
				serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling;
			}
			if (settings._typeNameAssemblyFormatHandling.HasValue)
			{
				serializer.TypeNameAssemblyFormatHandling = settings.TypeNameAssemblyFormatHandling;
			}
			if (settings._preserveReferencesHandling.HasValue)
			{
				serializer.PreserveReferencesHandling = settings.PreserveReferencesHandling;
			}
			if (settings._referenceLoopHandling.HasValue)
			{
				serializer.ReferenceLoopHandling = settings.ReferenceLoopHandling;
			}
			if (settings._missingMemberHandling.HasValue)
			{
				serializer.MissingMemberHandling = settings.MissingMemberHandling;
			}
			if (settings._objectCreationHandling.HasValue)
			{
				serializer.ObjectCreationHandling = settings.ObjectCreationHandling;
			}
			if (settings._nullValueHandling.HasValue)
			{
				serializer.NullValueHandling = settings.NullValueHandling;
			}
			if (settings._defaultValueHandling.HasValue)
			{
				serializer.DefaultValueHandling = settings.DefaultValueHandling;
			}
			if (settings._constructorHandling.HasValue)
			{
				serializer.ConstructorHandling = settings.ConstructorHandling;
			}
			if (settings._context.HasValue)
			{
				serializer.Context = settings.Context;
			}
			if (settings._checkAdditionalContent.HasValue)
			{
				serializer._checkAdditionalContent = settings._checkAdditionalContent;
			}
			if (settings.Error != null)
			{
				serializer.Error += settings.Error;
			}
			if (settings.ContractResolver != null)
			{
				serializer.ContractResolver = settings.ContractResolver;
			}
			if (settings.ReferenceResolverProvider != null)
			{
				serializer.ReferenceResolver = settings.ReferenceResolverProvider();
			}
			if (settings.TraceWriter != null)
			{
				serializer.TraceWriter = settings.TraceWriter;
			}
			if (settings.EqualityComparer != null)
			{
				serializer.EqualityComparer = settings.EqualityComparer;
			}
			if (settings.SerializationBinder != null)
			{
				serializer.SerializationBinder = settings.SerializationBinder;
			}
			if (settings._formatting.HasValue)
			{
				serializer._formatting = settings._formatting;
			}
			if (settings._dateFormatHandling.HasValue)
			{
				serializer._dateFormatHandling = settings._dateFormatHandling;
			}
			if (settings._dateTimeZoneHandling.HasValue)
			{
				serializer._dateTimeZoneHandling = settings._dateTimeZoneHandling;
			}
			if (settings._dateParseHandling.HasValue)
			{
				serializer._dateParseHandling = settings._dateParseHandling;
			}
			if (settings._dateFormatStringSet)
			{
				serializer._dateFormatString = settings._dateFormatString;
				serializer._dateFormatStringSet = settings._dateFormatStringSet;
			}
			if (settings._floatFormatHandling.HasValue)
			{
				serializer._floatFormatHandling = settings._floatFormatHandling;
			}
			if (settings._floatParseHandling.HasValue)
			{
				serializer._floatParseHandling = settings._floatParseHandling;
			}
			if (settings._stringEscapeHandling.HasValue)
			{
				serializer._stringEscapeHandling = settings._stringEscapeHandling;
			}
			if (settings._culture != null)
			{
				serializer._culture = settings._culture;
			}
			if (settings._maxDepthSet)
			{
				serializer._maxDepth = settings._maxDepth;
				serializer._maxDepthSet = settings._maxDepthSet;
			}
		}

		[DebuggerStepThrough]
		public void Populate(TextReader reader, object target)
		{
			Populate(new JsonTextReader(reader), target);
		}

		[DebuggerStepThrough]
		public void Populate(JsonReader reader, object target)
		{
			PopulateInternal(reader, target);
		}

		internal virtual void PopulateInternal(JsonReader reader, object target)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			ValidationUtils.ArgumentNotNull(target, "target");
			SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString);
			TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null);
			new JsonSerializerInternalReader(this).Populate(traceJsonReader ?? reader, target);
			if (traceJsonReader != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null);
			}
			ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString);
		}

		[DebuggerStepThrough]
		public object? Deserialize(JsonReader reader)
		{
			return Deserialize(reader, null);
		}

		[DebuggerStepThrough]
		public object? Deserialize(TextReader reader, Type objectType)
		{
			return Deserialize(new JsonTextReader(reader), objectType);
		}

		[DebuggerStepThrough]
		[return: MaybeNull]
		public T Deserialize<T>(JsonReader reader)
		{
			return (T)Deserialize(reader, typeof(T));
		}

		[DebuggerStepThrough]
		public object? Deserialize(JsonReader reader, Type? objectType)
		{
			return DeserializeInternal(reader, objectType);
		}

		internal virtual object? DeserializeInternal(JsonReader reader, Type? objectType)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString);
			TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null);
			object? result = new JsonSerializerInternalReader(this).Deserialize(traceJsonReader ?? reader, objectType, CheckAdditionalContent);
			if (traceJsonReader != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null);
			}
			ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString);
			return result;
		}

		private void SetupReader(JsonReader reader, out CultureInfo? previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string? previousDateFormatString)
		{
			if (_culture != null && !_culture.Equals(reader.Culture))
			{
				previousCulture = reader.Culture;
				reader.Culture = _culture;
			}
			else
			{
				previousCulture = null;
			}
			if (_dateTimeZoneHandling.HasValue && reader.DateTimeZoneHandling != _dateTimeZoneHandling)
			{
				previousDateTimeZoneHandling = reader.DateTimeZoneHandling;
				reader.DateTimeZoneHandling = _dateTimeZoneHandling.GetValueOrDefault();
			}
			else
			{
				previousDateTimeZoneHandling = null;
			}
			if (_dateParseHandling.HasValue && reader.DateParseHandling != _dateParseHandling)
			{
				previousDateParseHandling = reader.DateParseHandling;
				reader.DateParseHandling = _dateParseHandling.GetValueOrDefault();
			}
			else
			{
				previousDateParseHandling = null;
			}
			if (_floatParseHandling.HasValue && reader.FloatParseHandling != _floatParseHandling)
			{
				previousFloatParseHandling = reader.FloatParseHandling;
				reader.FloatParseHandling = _floatParseHandling.GetValueOrDefault();
			}
			else
			{
				previousFloatParseHandling = null;
			}
			if (_maxDepthSet && reader.MaxDepth != _maxDepth)
			{
				previousMaxDepth = reader.MaxDepth;
				reader.MaxDepth = _maxDepth;
			}
			else
			{
				previousMaxDepth = null;
			}
			if (_dateFormatStringSet && reader.DateFormatString != _dateFormatString)
			{
				previousDateFormatString = reader.DateFormatString;
				reader.DateFormatString = _dateFormatString;
			}
			else
			{
				previousDateFormatString = null;
			}
			if (reader is JsonTextReader jsonTextReader && jsonTextReader.PropertyNameTable == null && _contractResolver is DefaultContractResolver defaultContractResolver)
			{
				jsonTextReader.PropertyNameTable = defaultContractResolver.GetNameTable();
			}
		}

		private void ResetReader(JsonReader reader, CultureInfo? previousCulture, DateTimeZoneHandling? previousDateTimeZoneHandling, DateParseHandling? previousDateParseHandling, FloatParseHandling? previousFloatParseHandling, int? previousMaxDepth, string? previousDateFormatString)
		{
			if (previousCulture != null)
			{
				reader.Culture = previousCulture;
			}
			if (previousDateTimeZoneHandling.HasValue)
			{
				reader.DateTimeZoneHandling = previousDateTimeZoneHandling.GetValueOrDefault();
			}
			if (previousDateParseHandling.HasValue)
			{
				reader.DateParseHandling = previousDateParseHandling.GetValueOrDefault();
			}
			if (previousFloatParseHandling.HasValue)
			{
				reader.FloatParseHandling = previousFloatParseHandling.GetValueOrDefault();
			}
			if (_maxDepthSet)
			{
				reader.MaxDepth = previousMaxDepth;
			}
			if (_dateFormatStringSet)
			{
				reader.DateFormatString = previousDateFormatString;
			}
			if (reader is JsonTextReader jsonTextReader && jsonTextReader.PropertyNameTable != null && _contractResolver is DefaultContractResolver defaultContractResolver && jsonTextReader.PropertyNameTable == defaultContractResolver.GetNameTable())
			{
				jsonTextReader.PropertyNameTable = null;
			}
		}

		public void Serialize(TextWriter textWriter, object? value)
		{
			Serialize(new JsonTextWriter(textWriter), value);
		}

		public void Serialize(JsonWriter jsonWriter, object? value, Type? objectType)
		{
			SerializeInternal(jsonWriter, value, objectType);
		}

		public void Serialize(TextWriter textWriter, object? value, Type objectType)
		{
			Serialize(new JsonTextWriter(textWriter), value, objectType);
		}

		public void Serialize(JsonWriter jsonWriter, object? value)
		{
			SerializeInternal(jsonWriter, value, null);
		}

		private TraceJsonReader CreateTraceJsonReader(JsonReader reader)
		{
			TraceJsonReader traceJsonReader = new TraceJsonReader(reader);
			if (reader.TokenType != 0)
			{
				traceJsonReader.WriteCurrentToken();
			}
			return traceJsonReader;
		}

		internal virtual void SerializeInternal(JsonWriter jsonWriter, object? value, Type? objectType)
		{
			ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter");
			Formatting? formatting = null;
			if (_formatting.HasValue && jsonWriter.Formatting != _formatting)
			{
				formatting = jsonWriter.Formatting;
				jsonWriter.Formatting = _formatting.GetValueOrDefault();
			}
			DateFormatHandling? dateFormatHandling = null;
			if (_dateFormatHandling.HasValue && jsonWriter.DateFormatHandling != _dateFormatHandling)
			{
				dateFormatHandling = jsonWriter.DateFormatHandling;
				jsonWriter.DateFormatHandling = _dateFormatHandling.GetValueOrDefault();
			}
			DateTimeZoneHandling? dateTimeZoneHandling = null;
			if (_dateTimeZoneHandling.HasValue && jsonWriter.DateTimeZoneHandling != _dateTimeZoneHandling)
			{
				dateTimeZoneHandling = jsonWriter.DateTimeZoneHandling;
				jsonWriter.DateTimeZoneHandling = _dateTimeZoneHandling.GetValueOrDefault();
			}
			FloatFormatHandling? floatFormatHandling = null;
			if (_floatFormatHandling.HasValue && jsonWriter.FloatFormatHandling != _floatFormatHandling)
			{
				floatFormatHandling = jsonWriter.FloatFormatHandling;
				jsonWriter.FloatFormatHandling = _floatFormatHandling.GetValueOrDefault();
			}
			StringEscapeHandling? stringEscapeHandling = null;
			if (_stringEscapeHandling.HasValue && jsonWriter.StringEscapeHandling != _stringEscapeHandling)
			{
				stringEscapeHandling = jsonWriter.StringEscapeHandling;
				jsonWriter.StringEscapeHandling = _stringEscapeHandling.GetValueOrDefault();
			}
			CultureInfo cultureInfo = null;
			if (_culture != null && !_culture.Equals(jsonWriter.Culture))
			{
				cultureInfo = jsonWriter.Culture;
				jsonWriter.Culture = _culture;
			}
			string dateFormatString = null;
			if (_dateFormatStringSet && jsonWriter.DateFormatString != _dateFormatString)
			{
				dateFormatString = jsonWriter.DateFormatString;
				jsonWriter.DateFormatString = _dateFormatString;
			}
			TraceJsonWriter traceJsonWriter = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? new TraceJsonWriter(jsonWriter) : null);
			new JsonSerializerInternalWriter(this).Serialize(traceJsonWriter ?? jsonWriter, value, objectType);
			if (traceJsonWriter != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonWriter.GetSerializedJsonMessage(), null);
			}
			if (formatting.HasValue)
			{
				jsonWriter.Formatting = formatting.GetValueOrDefault();
			}
			if (dateFormatHandling.HasValue)
			{
				jsonWriter.DateFormatHandling = dateFormatHandling.GetValueOrDefault();
			}
			if (dateTimeZoneHandling.HasValue)
			{
				jsonWriter.DateTimeZoneHandling = dateTimeZoneHandling.GetValueOrDefault();
			}
			if (floatFormatHandling.HasValue)
			{
				jsonWriter.FloatFormatHandling = floatFormatHandling.GetValueOrDefault();
			}
			if (stringEscapeHandling.HasValue)
			{
				jsonWriter.StringEscapeHandling = stringEscapeHandling.GetValueOrDefault();
			}
			if (_dateFormatStringSet)
			{
				jsonWriter.DateFormatString = dateFormatString;
			}
			if (cultureInfo != null)
			{
				jsonWriter.Culture = cultureInfo;
			}
		}

		internal IReferenceResolver GetReferenceResolver()
		{
			if (_referenceResolver == null)
			{
				_referenceResolver = new DefaultReferenceResolver();
			}
			return _referenceResolver;
		}

		internal JsonConverter? GetMatchingConverter(Type type)
		{
			return GetMatchingConverter(_converters, type);
		}

		internal static JsonConverter? GetMatchingConverter(IList<JsonConverter>? converters, Type objectType)
		{
			if (converters != null)
			{
				for (int i = 0; i < converters.Count; i++)
				{
					JsonConverter jsonConverter = converters[i];
					if (jsonConverter.CanConvert(objectType))
					{
						return jsonConverter;
					}
				}
			}
			return null;
		}

		internal void OnError(Newtonsoft.Json.Serialization.ErrorEventArgs e)
		{
			this.Error?.Invoke(this, e);
		}
	}
	public class JsonSerializerSettings
	{
		internal const ReferenceLoopHandling DefaultReferenceLoopHandling = ReferenceLoopHandling.Error;

		internal const MissingMemberHandling DefaultMissingMemberHandling = MissingMemberHandling.Ignore;

		internal const NullValueHandling DefaultNullValueHandling = NullValueHandling.Include;

		internal const DefaultValueHandling DefaultDefaultValueHandling = DefaultValueHandling.Include;

		internal const ObjectCreationHandling DefaultObjectCreationHandling = ObjectCreationHandling.Auto;

		internal const PreserveReferencesHandling DefaultPreserveReferencesHandling = PreserveReferencesHandling.None;

		internal const ConstructorHandling DefaultConstructorHandling = ConstructorHandling.Default;

		internal const TypeNameHandling DefaultTypeNameHandling = TypeNameHandling.None;

		internal const MetadataPropertyHandling DefaultMetadataPropertyHandling = MetadataPropertyHandling.Default;

		internal static readonly StreamingContext DefaultContext;

		internal const Formatting DefaultFormatting = Formatting.None;

		internal const DateFormatHandling DefaultDateFormatHandling = DateFormatHandling.IsoDateFormat;

		internal const DateTimeZoneHandling DefaultDateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;

		internal const DateParseHandling DefaultDateParseHandling = DateParseHandling.DateTime;

		internal const FloatParseHandling DefaultFloatParseHandling = FloatParseHandling.Double;

		internal const FloatFormatHandling DefaultFloatFormatHandling = FloatFormatHandling.String;

		internal const StringEscapeHandling DefaultStringEscapeHandling = StringEscapeHandling.Default;

		internal const TypeNameAssemblyFormatHandling DefaultTypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple;

		internal static readonly CultureInfo DefaultCulture;

		internal const bool DefaultCheckAdditionalContent = false;

		internal const string DefaultDateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";

		internal Formatting? _formatting;

		internal DateFormatHandling? _dateFormatHandling;

		internal DateTimeZoneHandling? _dateTimeZoneHandling;

		internal DateParseHandling? _dateParseHandling;

		internal FloatFormatHandling? _floatFormatHandling;

		internal FloatParseHandling? _floatParseHandling;

		internal StringEscapeHandling? _stringEscapeHandling;

		internal CultureInfo? _culture;

		internal bool? _checkAdditionalContent;

		internal int? _maxDepth;

		internal bool _maxDepthSet;

		internal string? _dateFormatString;

		internal bool _dateFormatStringSet;

		internal TypeNameAssemblyFormatHandling? _typeNameAssemblyFormatHandling;

		internal DefaultValueHandling? _defaultValueHandling;

		internal PreserveReferencesHandling? _preserveReferencesHandling;

		internal NullValueHandling? _nullValueHandling;

		internal ObjectCreationHandling? _objectCreationHandling;

		internal MissingMemberHandling? _missingMemberHandling;

		internal ReferenceLoopHandling? _referenceLoopHandling;

		internal StreamingContext? _context;

		internal ConstructorHandling? _constructorHandling;

		internal TypeNameHandling? _typeNameHandling;

		internal MetadataPropertyHandling? _metadataPropertyHandling;

		public ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_referenceLoopHandling = value;
			}
		}

		public MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling.GetValueOrDefault();
			}
			set
			{
				_missingMemberHandling = value;
			}
		}

		public ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling.GetValueOrDefault();
			}
			set
			{
				_objectCreationHandling = value;
			}
		}

		public NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling.GetValueOrDefault();
			}
			set
			{
				_nullValueHandling = value;
			}
		}

		public DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling.GetValueOrDefault();
			}
			set
			{
				_defaultValueHandling = value;
			}
		}

		public IList<JsonConverter> Converters { get; set; }

		public PreserveReferencesHandling PreserveReferencesHandling
		{
			get
			{
				return _preserveReferencesHandling.GetValueOrDefault();
			}
			set
			{
				_preserveReferencesHandling = value;
			}
		}

		public TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling.GetVa

plugins/DasSauerkraut-Terraheim/Terraheim.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Auga;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Newtonsoft.Json.Linq;
using Terraheim.Armor;
using Terraheim.ArmorEffects;
using Terraheim.Utility;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Terraheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Terraheim")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6ce0c5eb-d5b9-41f7-8ea6-ad6b5a20b5bb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TerraheimItems.Patches
{
	[HarmonyPatch]
	internal class AnimationSpeedPatches
	{
		public static Dictionary<string, float> baseAnimationSpeeds = new Dictionary<string, float>();

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterAnimEvent), "CustomFixedUpdate")]
		private static void CharacterAnimFixedUpdatePrefix(ref Animator ___m_animator, Character ___m_character)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || !___m_character.IsPlayer() || (___m_character.IsPlayer() && ((Player)((___m_character is Player) ? ___m_character : null)).GetPlayerID() != Player.m_localPlayer.GetPlayerID()))
			{
				return;
			}
			Animator obj = ___m_animator;
			if (obj != null && obj.GetCurrentAnimatorClipInfo(0)?.Any() == true && !((Object)(object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip == (Object)null) && !((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Idle") && !((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Jog") && !((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Run") && !((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Walk") && !((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Standing") && !((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("jump") && (!baseAnimationSpeeds.ContainsKey(((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name) || baseAnimationSpeeds[((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name] == ___m_animator.speed))
			{
				float num = 0f;
				if (___m_character.GetSEMan().HaveStatusEffect("Attack Speed"))
				{
					num += (UtilityFunctions.GetStatusEffectFromName("Attack Speed", ___m_character.GetSEMan()) as SE_AttackSpeed).GetSpeed();
				}
				if (num != 0f)
				{
					___m_animator.speed = ChangeSpeed(___m_character, ___m_animator, 0f, num);
				}
			}
		}

		public static float ChangeSpeed(Character character, Animator animator, float speed, float speedMod)
		{
			string name = ((Object)((AnimatorClipInfo)(ref animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name;
			if (!baseAnimationSpeeds.ContainsKey(name))
			{
				baseAnimationSpeeds.Add(name, animator.speed);
			}
			if (speed < 1f)
			{
				speed += 1f;
			}
			speedMod += 1f;
			return baseAnimationSpeeds[name] * speed * speedMod;
		}
	}
}
namespace Terraheim
{
	internal static class Log
	{
		internal static void LogDebug(object data)
		{
			Logger.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			Logger.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			Logger.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			Logger.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			Logger.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			Logger.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("DasSauerkraut.Terraheim", "Terraheim", "2.3.9")]
	internal class Terraheim : BaseUnityPlugin
	{
		public const string ModGuid = "DasSauerkraut.Terraheim";

		private const string AuthorName = "DasSauerkraut";

		private const string ModName = "Terraheim";

		private const string ModVer = "2.3.9";

		public static readonly string ModPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		public static bool hasBarbarianArmor = false;

		public static bool hasJudesEquipment = false;

		public static bool hasChaosArmor = false;

		public static bool hasAuga = false;

		public static bool hasBowPlugin = false;

		public static JObject balance = UtilityFunctions.GetBalanceFile();

		private ConfigEntry<KeyCode> KenningConfig;

		public static ButtonConfig KenningButton;

		private readonly Harmony harmony = new Harmony("DasSauerkraut.Terraheim");

		internal static Terraheim Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			TranslationUtils.LoadTranslations();
			SetupStatusEffects();
			harmony.PatchAll();
			AssetHelper.Init();
			AssetHelper.SetupVFX();
			Pieces.Init();
			AddResources();
			AddButtonConfig();
			hasAuga = API.IsLoaded();
			hasChaosArmor = UtilityFunctions.CheckChaos();
			hasJudesEquipment = UtilityFunctions.CheckJudes();
			hasBarbarianArmor = UtilityFunctions.CheckBarbarian();
			if (hasBarbarianArmor && hasJudesEquipment)
			{
				Log.LogWarning("Both the Barbarian Armor and Judes Equipment are installed! Consider removing Barbarian Armor as it is included in Judes_Equipment!");
			}
			if ((bool)balance["armorChangesEnabled"])
			{
				ModExistingSets.Init();
				AddNewSets.Init();
			}
			else
			{
				ModExistingSets.RunWeapons();
				Log.LogInfo("Terraheim armor changes disabled!");
			}
			if (hasAuga)
			{
				Log.LogInfo("Auga detected, modifying Auga tooltips for Terraheim.");
				API.ComplexTooltip_AddItemTooltipCreatedListener((Action<GameObject, ItemData>)AugaTooltipsForItemEffects);
			}
			Log.LogInfo("Patching complete");
		}

		public static void AugaTooltipsForItemEffects(GameObject complexTooltip, ItemData item)
		{
			if (!UtilityFunctions.IsArmor(item) || !((Object)(object)item.m_shared.m_equipStatusEffect != (Object)null))
			{
				return;
			}
			API.ComplexTooltip_SetTopic(complexTooltip, item.m_shared.m_name);
			string text = "";
			foreach (KeyValuePair<string, Data.ArmorSet> armorSet in Data.ArmorSets)
			{
				if (armorSet.Value.HelmetID == ((Object)item.m_dropPrefab).name || armorSet.Value.ChestID == ((Object)item.m_dropPrefab).name || armorSet.Value.LegsID == ((Object)item.m_dropPrefab).name)
				{
					text = armorSet.Value.ClassName;
					break;
				}
			}
			if (text != "")
			{
				API.ComplexTooltip_SetSubtitle(complexTooltip, text);
			}
			GameObject val = API.ComplexTooltip_AddTwoColumnTextBox(complexTooltip);
			API.TooltipTextBox_AddLine(val, (object)"$item_effect_title", (object)"", (object)"$item_effect_equipped", true);
			API.TooltipTextBox_AddLine(val, (object)"", (object)item.m_shared.m_equipStatusEffect.m_tooltip, true);
		}

		private void AddButtonConfig()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			KenningConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Client config", "Kenning Keybind", (KeyCode)98, new ConfigDescription("Key to activate Ken Mode when using a set with the Kenning effect.", (AcceptableValueBase)null, Array.Empty<object>()));
			KenningButton = new ButtonConfig
			{
				Name = "KenningButton",
				Config = KenningConfig,
				HintToken = "$kenning_button"
			};
			InputManager.Instance.AddButton("DasSauerkraut.Terraheim", KenningButton);
		}

		private void AddResources()
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			JObject val2 = balance;
			val.m_item = AssetHelper.ItemSalamanderFurPrefab.GetComponent<ItemDrop>();
			List<Requirement> list = new List<Requirement>();
			int num = 0;
			foreach (JToken item in (IEnumerable<JToken>)val2["salamanderFur"][(object)"crafting"][(object)"items"])
			{
				list.Add(MockRequirement.Create((string)item[(object)"item"], (int)item[(object)"amount"], true));
				list[num].m_amountPerLevel = (int)item[(object)"perLevel"];
				num++;
			}
			((Object)val).name = "Recipe_" + val2["salamanderFur"].Path;
			val.m_resources = list.ToArray();
			val.m_craftingStation = Mock<CraftingStation>.Create((string)val2["salamanderFur"][(object)"crafting"][(object)"station"]);
			val.m_amount = (int)val2["salamanderFur"][(object)"crafting"][(object)"amountCrafted"];
			CustomRecipe val3 = new CustomRecipe(val, true, true);
			ItemManager.Instance.AddRecipe(val3);
			SharedResources.SalamanderItem = new CustomItem(AssetHelper.ItemSalamanderFurPrefab, true);
			ItemManager.Instance.AddItem(SharedResources.SalamanderItem);
		}

		private void SetupStatusEffects()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Expected O, but got Unknown
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Expected O, but got Unknown
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Expected O, but got Unknown
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Expected O, but got Unknown
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Expected O, but got Unknown
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Expected O, but got Unknown
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Expected O, but got Unknown
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Expected O, but got Unknown
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Expected O, but got Unknown
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Expected O, but got Unknown
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Expected O, but got Unknown
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Expected O, but got Unknown
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Expected O, but got Unknown
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Expected O, but got Unknown
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Expected O, but got Unknown
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Expected O, but got Unknown
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Expected O, but got Unknown
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Expected O, but got Unknown
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Expected O, but got Unknown
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Expected O, but got Unknown
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Expected O, but got Unknown
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Expected O, but got Unknown
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Expected O, but got Unknown
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Expected O, but got Unknown
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Expected O, but got Unknown
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Expected O, but got Unknown
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Expected O, but got Unknown
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ee: Expected O, but got Unknown
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Expected O, but got Unknown
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Expected O, but got Unknown
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Expected O, but got Unknown
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Expected O, but got Unknown
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Expected O, but got Unknown
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Expected O, but got Unknown
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Expected O, but got Unknown
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Expected O, but got Unknown
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Expected O, but got Unknown
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Expected O, but got Unknown
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Expected O, but got Unknown
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Expected O, but got Unknown
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Expected O, but got Unknown
			//IL_0718: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Expected O, but got Unknown
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0738: Expected O, but got Unknown
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Expected O, but got Unknown
			//IL_075a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0764: Expected O, but got Unknown
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RangedDmgBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_DaggerSpearDmgBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_OneHandDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MeleeDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_TwoHandedDmgBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_SilverDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_SpiritDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_TreeDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MiningBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ThrowingDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_DamageVSLowHP>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RangerWeaponBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_PoisonVulnerable>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MageDamage>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_DodgeStamUse>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_BlockStamUse>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ExtraStamina>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_StaminaRegen>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AttackStaminaUse>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MageCost>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AmmoConsumption>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_BackstabBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_HealthIncrease>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_DrawMoveSpeed>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ParryBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_BlockPowerBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_FoodUsage>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_HealOnBlock>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_WetImmunity>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_IncreaseHarvest>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_SneakMovement>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ThrowingWeaponVelocity>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MoveSpeedOnKill>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MoveSpeedOnKillListener>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Hyperarmor>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_TwoHandAttackSpeed>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AttackSpeed>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_BowDrawSpeed>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ShieldFireHeal>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AfterburnCooldown>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_CoinDrop>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RestoreResources>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_StaggerCapacity>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_StaggerDamage>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_SetBonusIncrease>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_HPOnHit>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Pinning>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Pinned>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_PinnedCooldown>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_HPRegen>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ArmorOnHitListener>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ArmorOnHit>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_CritChance>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_FullHPDamageBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_FullHPDamageBonusFX>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Wolftears>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_WolftearsFX>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_WolftearsProtectionExhausted>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AoECounter>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AoECounterFX>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_AoECounterExhausted>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Thorns>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_DeathMark>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MarkedForDeath>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MarkedForDeathFX>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Mercenary>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Retaliation>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RetaliationTimer>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_BloodPact>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Rooting>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RootingFX>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RootingExhausted>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Rooted>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_RootedListener>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Chosen>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Bloodlust>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Bloated>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_HiddenKnowledge>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Adrenaline>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_BlindingRage>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Pestilence>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_MaddeningVisions>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_Withdrawals>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ChallengeMoveSpeed>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ChallengeDodgeBonus>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ChallengeSprinter>(), true));
			Log.LogInfo("Status Effects Injected");
		}
	}
}
namespace Terraheim.Utility
{
	internal class ArmorHelper
	{
		private static readonly JObject balance = Terraheim.balance;

		public static StatusEffect GetSetEffect(string name, JToken values)
		{
			switch (name)
			{
			case "battlefuror":
			{
				SE_FullHPDamageBonus sE_FullHPDamageBonus = ScriptableObject.CreateInstance<SE_FullHPDamageBonus>();
				sE_FullHPDamageBonus.SetDamageBonus((float)values[(object)"setBonusVal"]);
				sE_FullHPDamageBonus.SetActivationHP((float)values[(object)"setActivationHP"]);
				sE_FullHPDamageBonus.InitIcon();
				return (StatusEffect)(object)sE_FullHPDamageBonus;
			}
			case "hpregen":
			{
				SE_HPRegen sE_HPRegen = ScriptableObject.CreateInstance<SE_HPRegen>();
				sE_HPRegen.setHealPercent((float)values[(object)"setBonusVal"]);
				sE_HPRegen.SetIcon();
				return (StatusEffect)(object)sE_HPRegen;
			}
			case "wolftears":
			{
				SE_Wolftears sE_Wolftears = ScriptableObject.CreateInstance<SE_Wolftears>();
				sE_Wolftears.SetDamageBonus((float)values[(object)"setBonusVal"]);
				sE_Wolftears.SetActivationHP((float)values[(object)"setActivationHP"]);
				return (StatusEffect)(object)sE_Wolftears;
			}
			case "wyrdarrow":
			{
				SE_AoECounter sE_AoECounter = ScriptableObject.CreateInstance<SE_AoECounter>();
				sE_AoECounter.SetDamageBonus((float)values[(object)"setBonusVal"]);
				sE_AoECounter.SetActivationCount((int)values[(object)"setActivationCount"]);
				sE_AoECounter.SetAoESize((float)values[(object)"setAoESize"]);
				sE_AoECounter.SetIcon();
				return (StatusEffect)(object)sE_AoECounter;
			}
			case "thorns":
			{
				SE_Thorns sE_Thorns = ScriptableObject.CreateInstance<SE_Thorns>();
				sE_Thorns.SetReflectPercent((float)values[(object)"setBonusVal"]);
				sE_Thorns.SetIcon();
				return (StatusEffect)(object)sE_Thorns;
			}
			case "deathmark":
			{
				SE_DeathMark sE_DeathMark = ScriptableObject.CreateInstance<SE_DeathMark>();
				sE_DeathMark.SetDamageBonus((float)values[(object)"setBonusVal"]);
				sE_DeathMark.SetThreshold((int)values[(object)"setBonusThreshold"]);
				sE_DeathMark.SetHitDuration((int)values[(object)"setBonusDuration"]);
				sE_DeathMark.SetIcon();
				return (StatusEffect)(object)sE_DeathMark;
			}
			case "brassflesh":
			{
				SE_ArmorOnHitListener sE_ArmorOnHitListener = ScriptableObject.CreateInstance<SE_ArmorOnHitListener>();
				sE_ArmorOnHitListener.SetMaxArmor((float)values[(object)"setBonusVal"]);
				return (StatusEffect)(object)sE_ArmorOnHitListener;
			}
			case "pinning":
			{
				SE_Pinning sE_Pinning = ScriptableObject.CreateInstance<SE_Pinning>();
				sE_Pinning.SetPinTTL((float)values[(object)"setBonusVal"]);
				sE_Pinning.SetPinCooldownTTL((float)values[(object)"setBonusCooldown"]);
				sE_Pinning.SetIcon();
				return (StatusEffect)(object)sE_Pinning;
			}
			case "crit":
			{
				SE_CritChance sE_CritChance = ScriptableObject.CreateInstance<SE_CritChance>();
				sE_CritChance.SetCritChance((float)values[(object)"setBonusChance"]);
				sE_CritChance.SetCritBonus((float)values[(object)"setBonusVal"]);
				sE_CritChance.SetIcon();
				return (StatusEffect)(object)sE_CritChance;
			}
			case "sprinter":
			{
				SE_ChallengeSprinter sE_ChallengeSprinter = ScriptableObject.CreateInstance<SE_ChallengeSprinter>();
				sE_ChallengeSprinter.SetTotalStamina((float)values[(object)"setBonusVal"]);
				sE_ChallengeSprinter.SetRegen((float)values[(object)"setRegenBonusVal"]);
				sE_ChallengeSprinter.SetIcon();
				return (StatusEffect)(object)sE_ChallengeSprinter;
			}
			case "chosen":
			{
				SE_Chosen sE_Chosen = ScriptableObject.CreateInstance<SE_Chosen>();
				sE_Chosen.SetBoonTTLIncrease((int)values[(object)"setBoonVal"]);
				sE_Chosen.SetBaneTTLIncrease((int)values[(object)"setBaneVal"]);
				return (StatusEffect)(object)sE_Chosen;
			}
			case "mercenary":
			{
				SE_Mercenary sE_Mercenary = ScriptableObject.CreateInstance<SE_Mercenary>();
				sE_Mercenary.SetCoinThreshold((int)values[(object)"setCoinThreshold"]);
				sE_Mercenary.SetCoinUse((int)values[(object)"setCoinUse"]);
				sE_Mercenary.SetMaxDamage((float)values[(object)"setMaxDmg"]);
				sE_Mercenary.SetIcon();
				return (StatusEffect)(object)sE_Mercenary;
			}
			case "retaliation":
			{
				SE_Retaliation sE_Retaliation = ScriptableObject.CreateInstance<SE_Retaliation>();
				sE_Retaliation.SetAbsorb((float)values[(object)"setBonusVal"]);
				sE_Retaliation.SetIcon();
				return (StatusEffect)(object)sE_Retaliation;
			}
			case "bloodpact":
			{
				SE_BloodPact sE_BloodPact = ScriptableObject.CreateInstance<SE_BloodPact>();
				sE_BloodPact.SetDamageBonus((float)values[(object)"setBonusVal"]);
				sE_BloodPact.SetRatio((int)values[(object)"setBonusRatio"]);
				sE_BloodPact.SetIcon();
				return (StatusEffect)(object)sE_BloodPact;
			}
			case "rooting":
			{
				SE_Rooting sE_Rooting = ScriptableObject.CreateInstance<SE_Rooting>();
				sE_Rooting.SetDamageBonus((float)values[(object)"setBonusDmg"]);
				sE_Rooting.SetRootedDuration((int)values[(object)"setBonusDuration"]);
				sE_Rooting.SetActivationCount((int)values[(object)"setBonusCount"]);
				sE_Rooting.SetIcon();
				return (StatusEffect)(object)sE_Rooting;
			}
			default:
				return null;
			}
		}

		public static StatusEffect GetArmorEffect(string name, JToken values, string location, ref string description)
		{
			switch (name)
			{
			case "onehanddmg":
			{
				SE_OneHandDamageBonus sE_OneHandDamageBonus = ScriptableObject.CreateInstance<SE_OneHandDamageBonus>();
				sE_OneHandDamageBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nDamage with one handed and fist weapons is increased by <color=cyan>{sE_OneHandDamageBonus.getDamageBonus() * 100f}%</color> when you do not have a shield equipped.";
				return (StatusEffect)(object)sE_OneHandDamageBonus;
			}
			case "dodgestamuse":
			{
				SE_DodgeStamUse sE_DodgeStamUse = ScriptableObject.CreateInstance<SE_DodgeStamUse>();
				sE_DodgeStamUse.setDodgeStaminaUse((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nDodge stamina cost is reduced by <color=cyan>{sE_DodgeStamUse.getDodgeStaminaUse() * 100f}%</color>.";
				return (StatusEffect)(object)sE_DodgeStamUse;
			}
			case "lifesteal":
			{
				SE_HPOnHit sE_HPOnHit = ScriptableObject.CreateInstance<SE_HPOnHit>();
				sE_HPOnHit.setHealAmount((float)values[(object)(location + "EffectVal")]);
				description = description + "\n\n<color=cyan>Heal " + sE_HPOnHit.getHealAmount() * 100f + "%</color> of damage dealt as HP on hitting an enemy with a melee weapon.";
				return (StatusEffect)(object)sE_HPOnHit;
			}
			case "rangeddmg":
			{
				SE_RangedDmgBonus sE_RangedDmgBonus = ScriptableObject.CreateInstance<SE_RangedDmgBonus>();
				sE_RangedDmgBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nBow Damage is increased by <color=cyan>{sE_RangedDmgBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_RangedDmgBonus;
			}
			case "daggerspeardmg":
			{
				SE_DaggerSpearDmgBonus sE_DaggerSpearDmgBonus = ScriptableObject.CreateInstance<SE_DaggerSpearDmgBonus>();
				sE_DaggerSpearDmgBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description = description + $"\n\nDagger Damage is increased by <color=cyan>{sE_DaggerSpearDmgBonus.getDamageBonus() * 100f}%</color>." + $"\nSpear Damage is increased by <color=cyan>{sE_DaggerSpearDmgBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_DaggerSpearDmgBonus;
			}
			case "ammoconsumption":
			{
				SE_AmmoConsumption sE_AmmoConsumption = ScriptableObject.CreateInstance<SE_AmmoConsumption>();
				sE_AmmoConsumption.setAmmoConsumption((int)values[(object)(location + "EffectVal")]);
				description += $"\n\n<color=cyan>{sE_AmmoConsumption.getAmmoConsumption()}%</color> chance to not consume ammo.";
				return (StatusEffect)(object)sE_AmmoConsumption;
			}
			case "meleedmg":
			{
				SE_MeleeDamageBonus sE_MeleeDamageBonus = ScriptableObject.CreateInstance<SE_MeleeDamageBonus>();
				sE_MeleeDamageBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nMelee Damage is increased by <color=cyan>{sE_MeleeDamageBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_MeleeDamageBonus;
			}
			case "blockstam":
			{
				SE_BlockStamUse sE_BlockStamUse = ScriptableObject.CreateInstance<SE_BlockStamUse>();
				sE_BlockStamUse.setBlockStaminaUse((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nBase block stamina cost is reduced by <color=cyan>{sE_BlockStamUse.getBlockStaminaUse() * 100f}%</color>.";
				return (StatusEffect)(object)sE_BlockStamUse;
			}
			case "hpbonus":
			{
				SE_HealthIncrease sE_HealthIncrease = ScriptableObject.CreateInstance<SE_HealthIncrease>();
				sE_HealthIncrease.setHealthBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nMax HP is increased by <color=cyan>{sE_HealthIncrease.getHealthBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_HealthIncrease;
			}
			case "twohanddmg":
			{
				SE_TwoHandedDmgBonus sE_TwoHandedDmgBonus = ScriptableObject.CreateInstance<SE_TwoHandedDmgBonus>();
				sE_TwoHandedDmgBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nTwo-Handed weapons damage is increased by <color=cyan>{sE_TwoHandedDmgBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_TwoHandedDmgBonus;
			}
			case "staminabns":
			{
				SE_ExtraStamina sE_ExtraStamina = ScriptableObject.CreateInstance<SE_ExtraStamina>();
				sE_ExtraStamina.SetStaminaBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nStamina is increased by <color=cyan>{sE_ExtraStamina.GetStaminaBonus()}</color> points.";
				return (StatusEffect)(object)sE_ExtraStamina;
			}
			case "staminaregen":
			{
				SE_StaminaRegen sE_StaminaRegen = ScriptableObject.CreateInstance<SE_StaminaRegen>();
				sE_StaminaRegen.SetRegenPercent((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nStamina regen is increased by <color=cyan>{sE_StaminaRegen.GetRegenPercent() * 100f}%</color>.";
				return (StatusEffect)(object)sE_StaminaRegen;
			}
			case "bowdaggerspearsilverdmg":
			{
				SE_SilverDamageBonus sE_SilverDamageBonus = ScriptableObject.CreateInstance<SE_SilverDamageBonus>();
				sE_SilverDamageBonus.SetDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nBows, daggers, and spears gain <color=cyan>{sE_SilverDamageBonus.GetDamageBonus() * 100f}%</color> damage as spirit and frost damage.";
				return (StatusEffect)(object)sE_SilverDamageBonus;
			}
			case "drawmovespeed":
			{
				SE_DrawMoveSpeed sE_DrawMoveSpeed = ScriptableObject.CreateInstance<SE_DrawMoveSpeed>();
				sE_DrawMoveSpeed.SetDrawMoveSpeed((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nMove <color=cyan>{sE_DrawMoveSpeed.GetDrawMoveSpeed() * 100f}%</color> faster with a drawn bow.";
				return (StatusEffect)(object)sE_DrawMoveSpeed;
			}
			case "blockpower":
			{
				SE_BlockPowerBonus sE_BlockPowerBonus = ScriptableObject.CreateInstance<SE_BlockPowerBonus>();
				sE_BlockPowerBonus.SetBlockPower((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nBlock power increased by <color=cyan>{sE_BlockPowerBonus.GetBlockPower() * 100f}%</color>.";
				return (StatusEffect)(object)sE_BlockPowerBonus;
			}
			case "healonblock":
			{
				SE_HealOnBlock sE_HealOnBlock = ScriptableObject.CreateInstance<SE_HealOnBlock>();
				sE_HealOnBlock.SetHealBonus((float)values[(object)(location + "EffectVal")]);
				description += "\n\nWhile using a tower shield, a successful block <color=cyan>heals</color> you.\nWhile using a normal shield, a successful parry <color=cyan>heals</color> you.";
				return (StatusEffect)(object)sE_HealOnBlock;
			}
			case "backstabdmg":
			{
				SE_BackstabBonus sE_BackstabBonus = ScriptableObject.CreateInstance<SE_BackstabBonus>();
				sE_BackstabBonus.setBackstabBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nSneak Attack Damage is increased by <color=cyan>{sE_BackstabBonus.getBackstabBonus()}x</color>.";
				return (StatusEffect)(object)sE_BackstabBonus;
			}
			case "spiritdmg":
			{
				SE_SpiritDamageBonus sE_SpiritDamageBonus = ScriptableObject.CreateInstance<SE_SpiritDamageBonus>();
				sE_SpiritDamageBonus.SetDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nAll weapons gain <color=cyan>{sE_SpiritDamageBonus.GetDamageBonus()}</color> spirit damage.";
				return (StatusEffect)(object)sE_SpiritDamageBonus;
			}
			case "fooduse":
			{
				SE_FoodUsage sE_FoodUsage = ScriptableObject.CreateInstance<SE_FoodUsage>();
				sE_FoodUsage.SetFoodUsage((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nFood fullness degrades <color=cyan>{sE_FoodUsage.GetFoodUsage() * 100f}%</color> slower.";
				return (StatusEffect)(object)sE_FoodUsage;
			}
			case "attackstamina":
			{
				SE_AttackStaminaUse sE_AttackStaminaUse = ScriptableObject.CreateInstance<SE_AttackStaminaUse>();
				sE_AttackStaminaUse.SetStaminaUse((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nReduce stamina use for melee weapons by <color=cyan>{sE_AttackStaminaUse.GetStaminaUse() * 100f}%</color>.";
				return (StatusEffect)(object)sE_AttackStaminaUse;
			}
			case "throwdmg":
			{
				SE_ThrowingDamageBonus sE_ThrowingDamageBonus = ScriptableObject.CreateInstance<SE_ThrowingDamageBonus>();
				sE_ThrowingDamageBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nDamage with throwing weapons is increased by <color=cyan>{sE_ThrowingDamageBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_ThrowingDamageBonus;
			}
			case "throwvel":
			{
				SE_ThrowingWeaponVelocity sE_ThrowingWeaponVelocity = ScriptableObject.CreateInstance<SE_ThrowingWeaponVelocity>();
				sE_ThrowingWeaponVelocity.SetVelocityBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nThrowing weapons velocity is increased by <color=cyan>{sE_ThrowingWeaponVelocity.GetVelocityBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_ThrowingWeaponVelocity;
			}
			case "dmgvslowhp":
			{
				SE_DamageVSLowHP sE_DamageVSLowHP = ScriptableObject.CreateInstance<SE_DamageVSLowHP>();
				sE_DamageVSLowHP.SetDamageBonus((float)values[(object)(location + "EffectVal")]);
				sE_DamageVSLowHP.SetHealthThreshold((float)values[(object)(location + "EffectThreshold")]);
				description = description + "\n\nDamage against enemies with less than <color=cyan>" + sE_DamageVSLowHP.GetHealthThreshold() * 100f + "%</color> HP is increased by <color=cyan>" + sE_DamageVSLowHP.GetDamageBonus() * 100f + "%</color>.";
				return (StatusEffect)(object)sE_DamageVSLowHP;
			}
			case "speedonkill":
			{
				SE_MoveSpeedOnKillListener sE_MoveSpeedOnKillListener = ScriptableObject.CreateInstance<SE_MoveSpeedOnKillListener>();
				sE_MoveSpeedOnKillListener.SetSpeedBonus((float)values[(object)(location + "EffectVal")]);
				description = description + string.Format("\n\nAfter killing an enemy, gain a stacking <color=cyan>+{0}%</color> movement speed bonus for {1}", sE_MoveSpeedOnKillListener.GetSpeedBonus() * 100f, (float)balance["bloodrushTTL"]) + " seconds. Killing an enemy resets the countdown.";
				return (StatusEffect)(object)sE_MoveSpeedOnKillListener;
			}
			case "woodsman":
			{
				SE_TreeDamageBonus sE_TreeDamageBonus = ScriptableObject.CreateInstance<SE_TreeDamageBonus>();
				sE_TreeDamageBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"Weland's designs raises your effectiveness at woodcutting.\nDamage against trees is increased by <color=yellow>{sE_TreeDamageBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_TreeDamageBonus;
			}
			case "miner":
			{
				SE_MiningBonus sE_MiningBonus = ScriptableObject.CreateInstance<SE_MiningBonus>();
				sE_MiningBonus.setDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"An artifact of Brokkr, crushing earth comes easily now.\nDamage against rocks and ores is increased by <color=yellow>{sE_MiningBonus.getDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_MiningBonus;
			}
			case "waterproof":
			{
				SE_WetImmunity result4 = ScriptableObject.CreateInstance<SE_WetImmunity>();
				description += "A gift from Freyr.\nYou will not gain the <color=cyan>Wet</color> Ailment.";
				return (StatusEffect)(object)result4;
			}
			case "farmer":
			{
				SE_IncreaseHarvest result3 = ScriptableObject.CreateInstance<SE_IncreaseHarvest>();
				description += "A blessing from Freyr.\nWhen you harvest wild plants, gain <color=cyan>2</color> more items from each harvest.\nWhen you harvest grown plants, gain <color=cyan>1</color> more item from each harvest.";
				return (StatusEffect)(object)result3;
			}
			case "thief":
			{
				SE_SneakMovement sE_SneakMovement = ScriptableObject.CreateInstance<SE_SneakMovement>();
				sE_SneakMovement.SetBonus((float)values[(object)(location + "EffectVal")]);
				description += $"A blessing from Loki.\nMove <color=cyan>{sE_SneakMovement.GetBonus() * 100f}%</color> faster while using <color=cyan>{sE_SneakMovement.GetBonus() * 100f}%</color> less stamina while sneaking.";
				return (StatusEffect)(object)sE_SneakMovement;
			}
			case "setbns":
			{
				SE_SetBonusIncrease result2 = ScriptableObject.CreateInstance<SE_SetBonusIncrease>();
				description += "A relic of Acca.\nThis belt counts as a piece of an armor set, allowing you to get the set bonus while wearing only two items.";
				return (StatusEffect)(object)result2;
			}
			case "rangerweapondmg":
			{
				SE_RangerWeaponBonus sE_RangerWeaponBonus = ScriptableObject.CreateInstance<SE_RangerWeaponBonus>();
				sE_RangerWeaponBonus.SetDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nDamage with bows, daggers, and spears is increased by <color=cyan>{sE_RangerWeaponBonus.GetDamageBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_RangerWeaponBonus;
			}
			case "poisonvuln":
			{
				SE_PoisonVulnerable sE_PoisonVulnerable = ScriptableObject.CreateInstance<SE_PoisonVulnerable>();
				sE_PoisonVulnerable.SetDamageBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nStriking an enemy with a damage type it is vulnerable deals <color=cyan>{sE_PoisonVulnerable.GetDamageBonus() * 100f}%</color> of the damage dealt as poison damage.";
				return (StatusEffect)(object)sE_PoisonVulnerable;
			}
			case "challengemvespd":
			{
				SE_ChallengeMoveSpeed result = ScriptableObject.CreateInstance<SE_ChallengeMoveSpeed>();
				description = description + string.Format("\n\nMovement speed is increased by <color=cyan>{0}%</color>.\n", (float)values[(object)(location + "EffectVal")] * 100f) + "Suffer <color=red>100%</color> more damage.";
				return (StatusEffect)(object)result;
			}
			case "challengedodgecost":
			{
				SE_ChallengeDodgeBonus sE_ChallengeDodgeBonus = ScriptableObject.CreateInstance<SE_ChallengeDodgeBonus>();
				sE_ChallengeDodgeBonus.SetDodgeBonus((float)values[(object)(location + "EffectVal")]);
				description = description + $"\n\nStamina cost for dodging is reduced by <color=cyan>{sE_ChallengeDodgeBonus.GetDodgeBonus() * 100f}%</color>.\n" + "Food fullness degrades <color=red>2x</color> faster.";
				return (StatusEffect)(object)sE_ChallengeDodgeBonus;
			}
			case "hyperarmor":
			{
				SE_Hyperarmor sE_Hyperarmor = ScriptableObject.CreateInstance<SE_Hyperarmor>();
				sE_Hyperarmor.SetArmor((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nWhen hit during an attack, damage suffered is reduced by <color=cyan>{sE_Hyperarmor.GetArmor() * 100f}%</color> and you will suffer no knockback or stagger.";
				return (StatusEffect)(object)sE_Hyperarmor;
			}
			case "2hattackspeed":
			{
				SE_TwoHandAttackSpeed sE_TwoHandAttackSpeed = ScriptableObject.CreateInstance<SE_TwoHandAttackSpeed>();
				sE_TwoHandAttackSpeed.SetSpeed((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nAttack speed for Two-Handed weapons is increased by <color=cyan>{sE_TwoHandAttackSpeed.GetSpeed() * 100f}%</color>.";
				return (StatusEffect)(object)sE_TwoHandAttackSpeed;
			}
			case "parrybns":
			{
				SE_ParryBonus sE_ParryBonus = ScriptableObject.CreateInstance<SE_ParryBonus>();
				sE_ParryBonus.SetParryBonus((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nParry Bonus is increased by <color=cyan>{sE_ParryBonus.GetParryBonus() * 100f}%</color>.";
				return (StatusEffect)(object)sE_ParryBonus;
			}
			case "coindrop":
			{
				SE_CoinDrop sE_CoinDrop = ScriptableObject.CreateInstance<SE_CoinDrop>();
				sE_CoinDrop.SetChance((float)values[(object)(location + "EffectChance")]);
				sE_CoinDrop.SetCoinAmount((float)values[(object)(location + "EffectAmount")]);
				description += $"\n\n<color=cyan>{sE_CoinDrop.GetChance()}%</color> chance to drop <color=cyan>{sE_CoinDrop.GetCoinAmount()} coins</color> when striking an enemy.";
				return (StatusEffect)(object)sE_CoinDrop;
			}
			case "restoreresources":
			{
				SE_RestoreResources sE_RestoreResources = ScriptableObject.CreateInstance<SE_RestoreResources>();
				sE_RestoreResources.SetChance((float)values[(object)(location + "EffectChance")]);
				sE_RestoreResources.SetStaminaAmount((int)values[(object)(location + "EffectStamina")]);
				description += $"\n\nOn hit, restore <color=cyan>{sE_RestoreResources.GetStaminaAmount()}</color> Stamina, {sE_RestoreResources.GetChance()}% chance to <color=cyan>refund ammo</color>.";
				return (StatusEffect)(object)sE_RestoreResources;
			}
			case "staggercap":
			{
				SE_StaggerCapacity sE_StaggerCapacity = ScriptableObject.CreateInstance<SE_StaggerCapacity>();
				sE_StaggerCapacity.SetStaggerCap((float)values[(object)(location + "EffectVal")]);
				description += $"\n\nStagger Capacity increased by <color=cyan>{sE_StaggerCapacity.GetStaggerCap() * 100f}%</color>";
				return (StatusEffect)(object)sE_StaggerCapacity;
			}
			case "staggerdmg":
			{
				SE_StaggerDamage sE_StaggerDamage = ScriptableObject.CreateInstance<SE_StaggerDamage>();
				sE_StaggerDamage.SetStaggerDmg((float)values[(object)(location + "EffectVal")]);
				sE_StaggerDamage.SetStaggerBns((float)values[(object)(location + "EffectDmg")]);
				description = description + $"\n\nDeal an addtional <color=cyan>{sE_StaggerDamage.GetStaggerDmg() * 100f}%</color> Stagger Damage.\n" + $"Deal an additional <color=cyan>{sE_StaggerDamage.GetStaggerBns() * 100f}%</color> damage to Staggered enemies.";
				return (StatusEffect)(object)sE_StaggerDamage;
			}
			case "magedmg":
			{
				SE_MageDamage sE_MageDamage = ScriptableObject.CreateInstance<SE_MageDamage>();
				sE_MageDamage.SetMageBns((float)values[(object)(location + "EffectVal")]);
				sE_MageDamage.SetMageDmg((float)values[(object)(location + "EffectDmg")]);
				description = description + $"\n\nEitr Regen is increased by <color=cyan>{sE_MageDamage.GetMageBns() * 100f}%</color>.\n" + $"Magic damage is increased by <color=cyan>{sE_MageDamage.GetMageDmg() * 100f}%</color>.";
				return (StatusEffect)(object)sE_MageDamage;
			}
			case "magecost":
			{
				SE_MageCost sE_MageCost = ScriptableObject.CreateInstance<SE_MageCost>();
				sE_MageCost.SetMageBns((float)values[(object)(location + "EffectVal")]);
				sE_MageCost.SetMageCst((float)values[(object)(location + "EffectCost")]);
				description = description + $"\n\nEitr Regen is increased by <color=cyan>{sE_MageCost.GetMageBns() * 100f}%</color>.\n" + $"<color=cyan>{sE_MageCost.GetMageCst() * 100f}%</color> less HP/Eitr consumed when using Magic.";
				return (StatusEffect)(object)sE_MageCost;
			}
			case "mageregen":
				description += string.Format("\n\nEitr Regen is increased by <color=cyan>{0}%</color>.\n", (float)values[(object)(location + "EffectVal")] * 100f);
				return null;
			case "attackspeed":
			{
				description += string.Format("\n\nMelee attack speed is increased by <color=cyan>{0}%</color>.\n", (float)values[(object)(location + "EffectVal")] * 100f);
				SE_AttackSpeed sE_AttackSpeed = ScriptableObject.CreateInstance<SE_AttackSpeed>();
				sE_AttackSpeed.SetSpeed((float)values[(object)(location + "EffectVal")]);
				return (StatusEffect)(object)sE_AttackSpeed;
			}
			case "bowdrawspeed":
			{
				description += string.Format("\n\nBow draw speed is increased by <color=cyan>{0}%</color>.\n", (float)values[(object)(location + "EffectVal")] * 100f);
				SE_BowDrawSpeed sE_BowDrawSpeed = ScriptableObject.CreateInstance<SE_BowDrawSpeed>();
				sE_BowDrawSpeed.SetSpeed((float)values[(object)(location + "EffectVal")]);
				return (StatusEffect)(object)sE_BowDrawSpeed;
			}
			default:
				return null;
			}
		}

		public static void ModArmorSet(string setName, ref ItemData helmet, ref ItemData chest, ref ItemData legs, JToken values, bool isNewSet, int i)
		{
			JToken val = values[(object)"armorSet"];
			List<ItemData> list = new List<ItemData> { helmet, chest, legs };
			JToken val2;
			if (isNewSet)
			{
				val2 = values[(object)"upgrades"][(object)$"t{i}"];
			}
			else
			{
				val2 = values;
				helmet.m_shared.m_name = ((object)val[(object)"HelmetName"])?.ToString() + "0";
				chest.m_shared.m_name = ((object)val[(object)"ChestName"])?.ToString() + "0";
				legs.m_shared.m_name = ((object)val[(object)"LegsName"])?.ToString() + "0";
			}
			StatusEffect setEffect = GetSetEffect((string)values[(object)"setEffect"], val2);
			foreach (ItemData item in list)
			{
				item.m_shared.m_armor = (float)val2[(object)"baseArmor"];
				item.m_shared.m_armorPerLevel = (float)val2[(object)"armorPerLevel"];
				if ((Object)(object)setEffect != (Object)null)
				{
					item.m_shared.m_setStatusEffect = setEffect;
				}
				else
				{
					Log.LogWarning(setName + " - No set effect found for provided effect: " + (string)values[(object)"setEffect"]);
				}
				item.m_shared.m_setSize = 3;
				item.m_shared.m_setName = (string)values[(object)"name"];
				if (!item.m_shared.m_name.Contains("helmet"))
				{
					item.m_shared.m_movementModifier = (float)val2[(object)"globalMoveMod"];
				}
				item.m_shared.m_eitrRegenModifier = 0f;
				item.m_shared.m_description = "<i>" + ((object)val[(object)"ClassName"])?.ToString() + "</i>\n" + item.m_shared.m_description;
			}
			SharedData shared = helmet.m_shared;
			shared.m_armor += (float)val[(object)"HelmetArmor"];
			StatusEffect armorEffect = GetArmorEffect((string)values[(object)"headEffect"], val2, "head", ref helmet.m_shared.m_description);
			StatusEffect armorEffect2 = GetArmorEffect((string)values[(object)"chestEffect"], val2, "chest", ref chest.m_shared.m_description);
			StatusEffect armorEffect3 = GetArmorEffect((string)values[(object)"legsEffect"], val2, "legs", ref legs.m_shared.m_description);
			if ((string)values[(object)"headEffect"] == "challengemvespd")
			{
				SharedData shared2 = helmet.m_shared;
				shared2.m_movementModifier += (float)values[(object)"headEffectVal"];
			}
			if ((string)values[(object)"chestEffect"] == "challengemvespd")
			{
				SharedData shared3 = chest.m_shared;
				shared3.m_movementModifier += (float)values[(object)"chestEffectVal"];
			}
			if ((string)values[(object)"legsEffect"] == "challengemvespd")
			{
				SharedData shared4 = legs.m_shared;
				shared4.m_movementModifier += (float)values[(object)"legsEffectVal"];
			}
			if ((string)values[(object)"headEffect"] == "magedmg" || (string)values[(object)"legsEffect"] == "magecost" || (string)values[(object)"legsEffect"] == "mageregen")
			{
				SharedData shared5 = helmet.m_shared;
				shared5.m_eitrRegenModifier += (float)values[(object)"headEffectVal"];
			}
			if ((string)values[(object)"chestEffect"] == "magedmg" || (string)values[(object)"legsEffect"] == "magecost" || (string)values[(object)"legsEffect"] == "mageregen")
			{
				SharedData shared6 = chest.m_shared;
				shared6.m_eitrRegenModifier += (float)values[(object)"chestEffectVal"];
			}
			if ((string)values[(object)"legsEffect"] == "magedmg" || (string)values[(object)"legsEffect"] == "magecost" || (string)values[(object)"legsEffect"] == "mageregen")
			{
				SharedData shared7 = legs.m_shared;
				shared7.m_eitrRegenModifier += (float)values[(object)"legsEffectVal"];
			}
			if ((Object)(object)armorEffect != (Object)null)
			{
				helmet.m_shared.m_equipStatusEffect = armorEffect;
			}
			else if ((string)values[(object)"headEffect"] != "mageregen" && (string)values[(object)"headEffect"] != "mageregen")
			{
				Log.LogWarning(setName + " Head - No status effect found for provided effect: " + (string)values[(object)"headEffect"]);
			}
			if ((Object)(object)armorEffect2 != (Object)null)
			{
				chest.m_shared.m_equipStatusEffect = armorEffect2;
			}
			else if ((string)values[(object)"chestEffect"] != "mageregen" && (string)values[(object)"chestEffect"] != "mageregen")
			{
				Log.LogWarning(setName + " Chest - No status effect found for provided effect: " + (string)values[(object)"chestEffect"]);
			}
			if ((Object)(object)armorEffect3 != (Object)null)
			{
				legs.m_shared.m_equipStatusEffect = armorEffect3;
			}
			else if ((string)values[(object)"headEffect"] != "legsEffect" && (string)values[(object)"legsEffect"] != "mageregen")
			{
				Log.LogWarning(setName + " Legs - No status effect found for provided effect: " + (string)values[(object)"legsEffect"]);
			}
		}

		public static void ModArmorPiece(string setName, string location, ref ItemData piece, JToken values, bool isNewSet, int i)
		{
			JToken val = values[(object)"armorSet"];
			JToken val2;
			if (isNewSet)
			{
				val2 = values[(object)"upgrades"][(object)$"t{i}"];
			}
			else
			{
				val2 = values;
				if (setName != "barbarian")
				{
					piece.m_shared.m_name = ((object)val[(object)"HelmetName"])?.ToString() + "0";
				}
			}
			StatusEffect setEffect = GetSetEffect((string)values[(object)"setEffect"], val2);
			piece.m_shared.m_armor = (float)val2[(object)"baseArmor"];
			piece.m_shared.m_armorPerLevel = (float)val2[(object)"armorPerLevel"];
			if ((Object)(object)setEffect != (Object)null)
			{
				piece.m_shared.m_setStatusEffect = setEffect;
			}
			else
			{
				Log.LogWarning(setName + " - No set effect found for provided effect: " + (string)values[(object)"setEffect"]);
			}
			piece.m_shared.m_setSize = ((setName != "rags") ? 3 : 2);
			if ((bool)balance["setsAreLockedByTier"])
			{
				piece.m_shared.m_setName = (string)values[(object)"name"] + " T" + i;
			}
			else
			{
				piece.m_shared.m_setName = (string)values[(object)"name"];
			}
			if (!piece.m_shared.m_name.Contains("helmet"))
			{
				piece.m_shared.m_movementModifier = (float)val2[(object)"globalMoveMod"];
			}
			piece.m_shared.m_description = "<i>" + ((object)val[(object)"ClassName"])?.ToString() + "</i>\n" + piece.m_shared.m_description;
			if (location == "head")
			{
				SharedData shared = piece.m_shared;
				shared.m_armor += (float)val[(object)"HelmetArmor"];
			}
			StatusEffect armorEffect = GetArmorEffect((string)values[(object)(location + "Effect")], val2, location, ref piece.m_shared.m_description);
			if ((string)values[(object)(location + "Effect")] == "challengemvespd")
			{
				SharedData shared2 = piece.m_shared;
				shared2.m_movementModifier += (float)values[(object)(location + "EffectVal")];
			}
			if ((string)values[(object)(location + "Effect")] == "magedmg" || (string)values[(object)(location + "Effect")] == "magecost" || (string)values[(object)(location + "Effect")] == "mageregen")
			{
				SharedData shared3 = piece.m_shared;
				shared3.m_eitrRegenModifier += (float)values[(object)(location + "EffectVal")];
			}
			if ((Object)(object)armorEffect != (Object)null)
			{
				piece.m_shared.m_equipStatusEffect = armorEffect;
			}
			else if ((string)values[(object)(location + "Effect")] != "mageregen")
			{
				Log.LogWarning(setName + " " + location + " - No status effect found for provided effect: " + (string)values[(object)(location + "Effect")]);
			}
		}

		public static void AddArmorPiece(string setName, string location, JToken armor)
		{
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Expected O, but got Unknown
			JToken val = armor[(object)"armorSet"];
			for (int i = (int)armor[(object)"upgrades"][(object)"startingTier"]; i <= 7; i++)
			{
				JToken val2 = armor[(object)"upgrades"][(object)$"t{i}"];
				string text = "";
				string arg = "";
				switch (location)
				{
				case "head":
					text = (string)val[(object)"HelmetID"];
					arg = (string)val[(object)"HelmetName"];
					break;
				case "chest":
					text = (string)val[(object)"ChestID"];
					arg = (string)val[(object)"ChestName"];
					break;
				case "legs":
					text = (string)val[(object)"LegsID"];
					arg = (string)val[(object)"LegsName"];
					break;
				}
				GameObject val3 = PrefabManager.Instance.CreateClonedPrefab($"{text}T{i}", text);
				if (setName != "barbarian")
				{
					string arg2 = char.ToUpper(setName[0]) + setName.Substring(1);
					((Object)val3).name = $"{text}T{i}_Terraheim_AddNewSets_Add{arg2}Armor";
				}
				else
				{
					((Object)val3).name = $"{text}T{i}_Terraheim_BarbarianArmor_AddNewSets";
				}
				CustomItem val4 = new CustomItem(val3, true);
				val4.ItemDrop.m_itemData.m_shared.m_name = $"{arg}{i}";
				ModArmorPiece(setName, location, ref val4.ItemDrop.m_itemData, armor, isNewSet: true, i);
				Recipe val5 = ScriptableObject.CreateInstance<Recipe>();
				((Object)val5).name = $"Recipe_{text}T{i}";
				List<Requirement> list = new List<Requirement>();
				int num = 0;
				if (i == (int)armor[(object)"upgrades"][(object)"startingTier"])
				{
					list.Add(MockRequirement.Create(text, 1, false));
					num++;
					list[0].m_amountPerLevel = 0;
				}
				JToken val6 = balance["upgradePath"][(object)$"t{i}"];
				int num2 = num;
				foreach (JObject item2 in (IEnumerable<JToken>)val6[(object)location])
				{
					JObject val7 = item2;
					if ((string)val7["item"] == "SalamanderFur")
					{
						Requirement item = new Requirement
						{
							m_resItem = SharedResources.SalamanderItem.ItemDrop,
							m_amount = (int)val7["amount"]
						};
						list.Add(item);
					}
					else
					{
						list.Add(MockRequirement.Create((string)val7["item"], (int)val7["amount"], true));
					}
					list[num2].m_amountPerLevel = (int)val7["perLevel"];
					num2++;
				}
				val5.m_craftingStation = Mock<CraftingStation>.Create((string)val6[(object)"station"]);
				val5.m_minStationLevel = (int)val6[(object)"minLevel"];
				val5.m_resources = list.ToArray();
				val5.m_item = val4.ItemDrop;
				CustomRecipe val8 = new CustomRecipe(val5, true, true);
				ItemManager.Instance.AddItem(val4);
				ItemManager.Instance.AddRecipe(val8);
			}
		}

		public static void AddCape(string setName, string balanceId)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: 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_028e: 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)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Expected O, but got Unknown
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Expected O, but got Unknown
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Expected O, but got Unknown
			JToken val = balance["capes"];
			for (int i = 0; i < 2; i++)
			{
				if ((setName.Contains("Wolf") || setName.Contains("Lox")) && i == 0)
				{
					continue;
				}
				GameObject val2 = PrefabManager.Instance.CreateClonedPrefab($"{setName}T{i}TH", setName);
				CustomItem val3 = new CustomItem(val2, true);
				val3.ItemDrop.m_itemData.m_shared.m_name = $"{val3.ItemDrop.m_itemData.m_shared.m_name}T{i}";
				if (setName.Contains("Deer"))
				{
					SharedData shared = val3.ItemDrop.m_itemData.m_shared;
					shared.m_description += string.Format("\nMovement speed is increased by <color=cyan>{0}%</color>.", (float)balance["capes"][(object)"leather"][(object)"capeEffectVal"] * 100f);
					val3.ItemDrop.m_itemData.m_shared.m_movementModifier = (float)balance["capes"][(object)"leather"][(object)"capeEffectVal"];
				}
				else
				{
					val3.ItemDrop.m_itemData.m_shared.m_equipStatusEffect = GetArmorEffect((string)balance["capes"][(object)balanceId][(object)"effect"], balance["capes"][(object)balanceId], "cape", ref val3.ItemDrop.m_itemData.m_shared.m_description);
				}
				if (i == 0)
				{
					DamageModPair val4 = default(DamageModPair);
					val4.m_type = (DamageType)64;
					val4.m_modifier = (DamageModifier)1;
					DamageModPair item = val4;
					val3.ItemDrop.m_itemData.m_shared.m_damageModifiers.Add(item);
				}
				else
				{
					DamageModPair val5 = default(DamageModPair);
					val5.m_type = (DamageType)32;
					val5.m_modifier = (DamageModifier)1;
					DamageModPair item2 = val5;
					val3.ItemDrop.m_itemData.m_shared.m_damageModifiers.Add(item2);
					if (!setName.Contains("Wolf") && !setName.Contains("Lox"))
					{
						val5 = default(DamageModPair);
						val5.m_type = (DamageType)64;
						val5.m_modifier = (DamageModifier)1;
						DamageModPair item3 = val5;
						val3.ItemDrop.m_itemData.m_shared.m_damageModifiers.Add(item3);
					}
				}
				Recipe val6 = ScriptableObject.CreateInstance<Recipe>();
				((Object)val6).name = $"Recipe_{setName}T{i}";
				List<Requirement> list = new List<Requirement>();
				int num = 0;
				string text = ((i == 0 || setName.Contains("Wolf") || setName.Contains("Lox")) ? setName : $"{setName}T{i - 1}TH");
				list.Add(MockRequirement.Create(text, 1, false));
				num++;
				list[0].m_amountPerLevel = 0;
				JToken val7 = val[(object)"upgrades"][(object)$"t{i}"];
				int num2 = num;
				foreach (JObject item5 in (IEnumerable<JToken>)val7[(object)"resources"])
				{
					JObject val8 = item5;
					if ((string)val8["item"] == "SalamanderFur")
					{
						Requirement item4 = new Requirement
						{
							m_resItem = SharedResources.SalamanderItem.ItemDrop,
							m_amount = (int)val8["amount"]
						};
						list.Add(item4);
					}
					else
					{
						list.Add(MockRequirement.Create((string)val8["item"], (int)val8["amount"], true));
					}
					list[num2].m_amountPerLevel = (int)val8["perLevel"];
					num2++;
				}
				val6.m_craftingStation = Mock<CraftingStation>.Create((string)val7[(object)"station"]);
				val6.m_minStationLevel = (int)val7[(object)"minLevel"];
				val6.m_resources = list.ToArray();
				val6.m_item = val3.ItemDrop;
				CustomRecipe val9 = new CustomRecipe(val6, true, true);
				ItemManager.Instance.AddItem(val3);
				ItemManager.Instance.AddRecipe(val9);
			}
		}

		public static void AddArmorSet(string setName, JToken armorSet)
		{
			if ((string)armorSet[(object)"armorSet"][(object)"HelmetID"] != "n/a")
			{
				AddArmorPiece(setName, "head", armorSet);
			}
			AddArmorPiece(setName, "chest", armorSet);
			AddArmorPiece(setName, "legs", armorSet);
		}

		public static void AddBelt(string name)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			JToken val = balance[name];
			Data.UtilityBelt utilityBelt = Data.UtilityBelts[name];
			GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(utilityBelt.BaseID, utilityBelt.CloneID);
			((Object)val2).name = utilityBelt.FinalID;
			CustomItem val3 = new CustomItem(val2, true);
			val3.ItemDrop.m_itemData.m_shared.m_name = utilityBelt.Name ?? "";
			val3.ItemDrop.m_itemData.m_shared.m_description = "";
			StatusEffect armorEffect = GetArmorEffect((string)val[(object)"effect"], val, "head", ref val3.ItemDrop.m_itemData.m_shared.m_description);
			if ((Object)(object)armorEffect != (Object)null)
			{
				val3.ItemDrop.m_itemData.m_shared.m_equipStatusEffect = armorEffect;
			}
			else
			{
				Log.LogWarning(name + " - No status effect found for provided effect: " + (string)val[(object)"effect"]);
			}
			Recipe val4 = ScriptableObject.CreateInstance<Recipe>();
			((Object)val4).name = "Recipe_" + utilityBelt.BaseID;
			List<Requirement> list = new List<Requirement>();
			JToken val5 = val[(object)"crafting"];
			int num = 0;
			foreach (JObject item in (IEnumerable<JToken>)val5[(object)"items"])
			{
				JObject val6 = item;
				list.Add(MockRequirement.Create((string)val6["item"], (int)val6["amount"], true));
				list[num].m_amountPerLevel = (int)val6["perLevel"];
				num++;
			}
			val4.m_craftingStation = Mock<CraftingStation>.Create((string)val5[(object)"station"]);
			val4.m_minStationLevel = (int)val5[(object)"minLevel"];
			val4.m_resources = list.ToArray();
			val4.m_item = val3.ItemDrop;
			CustomRecipe val7 = new CustomRecipe(val4, true, true);
			ItemManager.Instance.AddItem(val3);
			ItemManager.Instance.AddRecipe(val7);
		}

		public static void AddTieredRecipes(string setName, JToken armor)
		{
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: 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_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Expected O, but got Unknown
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Expected O, but got Unknown
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Expected O, but got Unknown
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Expected O, but got Unknown
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Expected O, but got Unknown
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: 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_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Expected O, but got Unknown
			JToken val = armor[(object)"armorSet"];
			bool flag = (string)val[(object)"HelmetID"] != "n/a";
			string arg = char.ToUpper(setName[0]) + setName.Substring(1);
			for (int i = (int)armor[(object)"upgrades"][(object)"startingTier"] + 1; i <= 7; i++)
			{
				Recipe val2 = null;
				Recipe recipe;
				Recipe recipe2;
				if (setName != "barbarian")
				{
					if (flag)
					{
						val2 = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_AddNewSets_Add{2}Armor", val[(object)"HelmetID"], i, arg)).GetComponent<ItemDrop>().m_itemData);
					}
					recipe = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_AddNewSets_Add{2}Armor", val[(object)"ChestID"], i, arg)).GetComponent<ItemDrop>().m_itemData);
					recipe2 = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_AddNewSets_Add{2}Armor", val[(object)"LegsID"], i, arg)).GetComponent<ItemDrop>().m_itemData);
				}
				else
				{
					if (flag)
					{
						val2 = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_BarbarianArmor_AddNewSets", val[(object)"HelmetID"], i)).GetComponent<ItemDrop>().m_itemData);
					}
					recipe = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_BarbarianArmor_AddNewSets", val[(object)"ChestID"], i)).GetComponent<ItemDrop>().m_itemData);
					recipe2 = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_BarbarianArmor_AddNewSets", val[(object)"LegsID"], i)).GetComponent<ItemDrop>().m_itemData);
				}
				List<Requirement> list = null;
				if (flag)
				{
					list = val2.m_resources.ToList();
				}
				List<Requirement> list2 = recipe.m_resources.ToList();
				List<Requirement> list3 = recipe2.m_resources.ToList();
				if (setName == "s222ilver")
				{
					if (flag)
					{
						list.Add(new Requirement
						{
							m_resItem = ObjectDB.instance.GetItemPrefab("HelmetDrake").GetComponent<ItemDrop>(),
							m_amount = 1,
							m_amountPerLevel = 0,
							m_recover = false
						});
					}
					list2.Add(new Requirement
					{
						m_resItem = ObjectDB.instance.GetItemPrefab("ArmorWolfChest").GetComponent<ItemDrop>(),
						m_amount = 1,
						m_amountPerLevel = 0,
						m_recover = false
					});
					list3.Add(new Requirement
					{
						m_resItem = ObjectDB.instance.GetItemPrefab("ArmorWolfLegs").GetComponent<ItemDrop>(),
						m_amount = 1,
						m_amountPerLevel = 0,
						m_recover = false
					});
				}
				else if (setName == "barbarian")
				{
					if (flag)
					{
						list.Add(new Requirement
						{
							m_resItem = ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_BarbarianArmor_AddNewSets", val[(object)"HelmetID"], i - 1)).GetComponent<ItemDrop>(),
							m_amount = 1,
							m_amountPerLevel = 0,
							m_recover = false
						});
					}
					list2.Add(new Requirement
					{
						m_resItem = ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_BarbarianArmor_AddNewSets", val[(object)"ChestID"], i - 1)).GetComponent<ItemDrop>(),
						m_amount = 1,
						m_amountPerLevel = 0,
						m_recover = false
					});
					list3.Add(new Requirement
					{
						m_resItem = ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_BarbarianArmor_AddNewSets", val[(object)"LegsID"], i - 1)).GetComponent<ItemDrop>(),
						m_amount = 1,
						m_amountPerLevel = 0,
						m_recover = false
					});
				}
				else
				{
					if (flag)
					{
						list.Add(new Requirement
						{
							m_resItem = ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_AddNewSets_Add{2}Armor", val[(object)"HelmetID"], i - 1, arg)).GetComponent<ItemDrop>(),
							m_amount = 1,
							m_amountPerLevel = 0,
							m_recover = false
						});
					}
					list2.Add(new Requirement
					{
						m_resItem = ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_AddNewSets_Add{2}Armor", val[(object)"ChestID"], i - 1, arg)).GetComponent<ItemDrop>(),
						m_amount = 1,
						m_amountPerLevel = 0,
						m_recover = false
					});
					list3.Add(new Requirement
					{
						m_resItem = ObjectDB.instance.GetItemPrefab(string.Format("{0}T{1}_Terraheim_AddNewSets_Add{2}Armor", val[(object)"LegsID"], i - 1, arg)).GetComponent<ItemDrop>(),
						m_amount = 1,
						m_amountPerLevel = 0,
						m_recover = false
					});
				}
				if (flag)
				{
					val2.m_resources = list.ToArray();
				}
				recipe.m_resources = list2.ToArray();
				recipe2.m_resources = list3.ToArray();
			}
		}

		public static void AddTieredCape(string setName)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			Recipe recipe = ObjectDB.instance.GetRecipe(ObjectDB.instance.GetItemPrefab($"{setName}T{1}TH").GetComponent<ItemDrop>().m_itemData);
			List<Requirement> list = recipe.m_resources.ToList();
			list.Add(new Requirement
			{
				m_resItem = ObjectDB.instance.GetItemPrefab($"{setName}T{0}TH").GetComponent<ItemDrop>(),
				m_amount = 1,
				m_amountPerLevel = 0,
				m_recover = false
			});
			recipe.m_resources = list.ToArray();
		}
	}
	internal class AssetHelper
	{
		public const string AssetBundleName = "bundle_terraheimeffects";

		public const string NewAssetBundleName = "bundle_terraheimneweffects";

		public const string SFXBundleName = "bundle_terraheim_sound";

		public static AssetBundle TerraheimAssetBundle;

		public static GameObject FXLifeSteal;

		public static GameObject FXRedTearstone;

		public static GameObject FXDamageAtFullHp;

		public static GameObject FXThorns;

		public static GameObject FXAoECharged;

		public static GameObject FXExecution;

		public static GameObject FXMarkedForDeath;

		public static GameObject FXMarkedForDeathHit;

		public static GameObject FXPinned;

		public static GameObject FXAfterburn;

		public static GameObject FXBoonGain;

		public static GameObject FXBaneGain;

		public static GameObject FXBoonLock;

		public static GameObject FXBaneLock;

		public static GameObject FXBloodPact;

		public static GameObject FXRooted;

		public static GameObject FXRooting;

		public static GameObject RootingExplosion;

		public static GameObject RootingProjectile;

		public static GameObject ItemSalamanderFurPrefab;

		public static GameObject PieceReforgerPrefab;

		public static GameObject PieceReforgerExt1Prefab;

		public static GameObject PieceReforgerExt2Prefab;

		public static GameObject PieceReforgerExt3Prefab;

		public static GameObject PieceReforgerExt4Prefab;

		public static GameObject PieceReforgerExt5Prefab;

		public static GameObject TestProjectile;

		public static GameObject TestExplosion;

		public static GameObject PestilenceExplosion;

		public static GameObject ShieldTowerFireHeal;

		public static GameObject BowFireExplosionPrefab;

		public static GameObject FlamebowWyrdExplosion;

		public static GameObject RetaliationExplosion;

		public static AudioClip AoEReady;

		public static AudioClip SFXExecution;

		public static AudioClip SFXMarkedForDeath;

		public static AudioClip SFXBoonGain;

		public static AudioClip SFXBaneGain;

		public static AudioClip SFXBoonLock;

		public static AudioClip SFXBaneLock;

		public static AudioClip SFXCoin;

		public static Sprite SpriteTempStatus;

		public static Sprite SpriteChosen;

		public static Sprite SpriteChosenBoon;

		public static Sprite SpriteChosenBane;

		public static Sprite SpriteChosenKhorneBoon;

		public static Sprite SpriteChosenKhorneBane;

		public static Sprite SpriteChosenTzeentchBoon;

		public static Sprite SpriteChosenTzeentchBane;

		public static Sprite SpriteChosenNurgleBoon;

		public static Sprite SpriteChosenNurgleBane;

		public static Sprite SpriteChosenSlaaneshBoon;

		public static Sprite SpriteChosenSlaaneshBane;

		public static void Init()
		{
			TerraheimAssetBundle = GetAssetBundleFromResources("bundle_terraheimeffects");
			FXLifeSteal = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_Life_Steal_Hit.prefab");
			FXRedTearstone = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_redtearstone.prefab");
			FXDamageAtFullHp = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_damageAtFullHP.prefab");
			FXThorns = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_Thorns_hit.prefab");
			FXAoECharged = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_AoECharge.prefab");
			FXExecution = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_Execution.prefab");
			FXMarkedForDeath = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_MarkedForDeath.prefab");
			FXMarkedForDeathHit = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_MarkedForDeathHit.prefab");
			FXPinned = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_Pinned.prefab");
			FXAfterburn = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/shield/afterburn_effect.prefab");
			TestExplosion = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/test_explosion.prefab");
			PestilenceExplosion = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/pestilence_explosion.prefab");
			ShieldTowerFireHeal = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/gshield/shieldfire_heal_aoe.prefab");
			TestProjectile = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/test_projectile.prefab");
			FlamebowWyrdExplosion = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/bow/bowFire_wyrdexplosion.prefab");
			BowFireExplosionPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/bow/bowFire_explosion1.prefab");
			ItemSalamanderFurPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/material/SalamanderFurTH.prefab");
			PieceReforgerPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/CraftingBench/reforger.prefab");
			PieceReforgerExt1Prefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/CraftingBench/ext1/reforger_ext1.prefab");
			PieceReforgerExt2Prefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/CraftingBench/ext2/reforger_ext2.prefab");
			PieceReforgerExt3Prefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/CraftingBench/ext3/reforger_ext3.prefab");
			PieceReforgerExt4Prefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/CraftingBench/ext4/reforger_ext4.prefab");
			PieceReforgerExt5Prefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/CraftingBench/ext5/reforger_ext5.prefab");
			AoEReady = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Dragon_BreathIce5.wav");
			SFXExecution = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Magic_Spell_EnergyBall8.wav");
			SFXMarkedForDeath = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/DarkMagic_SpellImpact15.wav");
			SpriteTempStatus = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/TEMPICON.png");
			SpriteChosen = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/chosen.png");
			SpriteChosenBoon = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/chosenBoonLock.png");
			SpriteChosenBane = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/chosenBaneLock.png");
			SpriteChosenKhorneBoon = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/KhorneBoon.png");
			SpriteChosenKhorneBane = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/khorneBane.png");
			SpriteChosenTzeentchBoon = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/tzeenBoon.png");
			SpriteChosenTzeentchBane = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/tzeenBane.png");
			SpriteChosenNurgleBoon = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/nurgBoon.png");
			SpriteChosenNurgleBane = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/nurgBane.png");
			SpriteChosenSlaaneshBoon = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/slaanBoon.png");
			SpriteChosenSlaaneshBane = TerraheimAssetBundle.LoadAsset<Sprite>("Assets/CustomItems/Effects/Chosen/SlaanBane.png");
			FXBoonGain = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/Chosen/vfx_boonGain.prefab");
			FXBaneGain = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/Chosen/vfx_baneGain.prefab");
			FXBoonLock = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/Chosen/vfx_boonLock.prefab");
			FXBaneLock = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/Chosen/vfx_baneLock.prefab");
			SFXBoonGain = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Chosen/boongain.wav");
			SFXBaneGain = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Chosen/baingain.wav");
			SFXBoonLock = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Chosen/boonLock.wav");
			SFXBaneLock = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Chosen/banelock.wav");
			TerraheimAssetBundle = GetAssetBundleFromResources("bundle_terraheim_sound");
			SFXCoin = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/Effects/Pickup_Coins05.wav");
			RetaliationExplosion = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/retaliation_explosion.prefab");
			RetaliationExplosion.GetComponent<Aoe>().m_statusEffect = "Retaliation Cooldown";
			TerraheimAssetBundle = GetAssetBundleFromResources("bundle_terraheimneweffects");
			FXBloodPact = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/customAssets/vfx_bloodpact.prefab");
			FXRooting = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/customAssets/fx_rootingFx.prefab");
			FXRooted = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/customAssets/fx_rooted.prefab");
			RootingProjectile = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/customAssets/rooting_projectile.prefab");
			RootingExplosion = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/customAssets/rooting_explosion.prefab");
			RootingExplosion.GetComponent<Aoe>().m_statusEffect = "Rooted Listener";
		}

		public static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		public static void SetupVFX()
		{
			//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_002d: 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_0040: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_0166: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to i

plugins/DasSauerkraut-Terraheim/TerraheimItems.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Newtonsoft.Json.Linq;
using Terraheim.ArmorEffects;
using Terraheim.Utility;
using TerraheimItems.StatusEffects;
using TerraheimItems.Utility;
using TerraheimItems.Weapons;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Terraheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Terraheim")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6ce0c5eb-d5b9-41f7-8ea6-ad6b5a20b5bb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TerraheimItems
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("DasSauerkraut.TerraheimItems", "TerraheimItems", "2.3.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class TerraheimItems : BaseUnityPlugin
	{
		public const string ModGuid = "DasSauerkraut.TerraheimItems";

		private const string AuthorName = "DasSauerkraut";

		private const string ModName = "TerraheimItems";

		private const string ModVer = "2.3.8";

		public static readonly string ModPath = Path.GetDirectoryName(typeof(TerraheimItems).Assembly.Location);

		private readonly Harmony harmony = new Harmony("DasSauerkraut.TerraheimItems");

		internal static TerraheimItems Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			TranslationUtils.LoadTranslations();
			SetupStatusEffects();
			harmony.PatchAll();
			AssetHelper.Init();
			Greatswords.Init();
			Axes.Init();
			AtgeirSilver.Init();
			Knives.Init();
			ParryingDagger.Init();
			BowBlackmetal.Init();
			PickaxeBlackmetal.Init();
			SpearBlackmetal.Init();
			Battleaxes.Init();
			FlametalWeapons.Init();
			TorchOlympia.Init();
			Bombs.Init();
			ThrowingAxes.Init();
			Log.LogInfo("Patching complete");
		}

		public static void SetupStatusEffects()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_HealthPercentDamage>(), true));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)ScriptableObject.CreateInstance<SE_ChainExplosionListener>(), true));
		}
	}
}
namespace TerraheimItems.Weapons
{
	internal class Battleaxes
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public static CustomItem customItemBronze;

		public static CustomRecipe customRecipeBronze;

		public static CustomItem customItemBM;

		public static CustomRecipe customRecipeBM;

		public static CustomItem customItemSil;

		public static CustomRecipe customRecipeSil;

		public static CustomItem customItemFlint;

		public static CustomRecipe customRecipeFlint;

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe3 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe4 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe5 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.BattleaxeBlackmetalPrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.BattleaxeBronzePrefab.GetComponent<ItemDrop>();
			recipe3.m_item = AssetHelper.GreateaxeBlackmetalPrefab.GetComponent<ItemDrop>();
			recipe4.m_item = AssetHelper.BattleaxeSilverPrefab.GetComponent<ItemDrop>();
			recipe5.m_item = AssetHelper.BattleaxeFlintPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["AxehammerBlackmetal"]);
			UtilityFunctions.GetRecipe(ref recipe3, balance["BattleaxeBlackmetal"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["BattleaxeBronze"]);
			UtilityFunctions.GetRecipe(ref recipe4, balance["BattleaxeSilver"]);
			UtilityFunctions.GetRecipe(ref recipe5, balance["BattleaxeFlint"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			customRecipeBronze = new CustomRecipe(recipe2, true, true);
			customRecipeBM = new CustomRecipe(recipe3, true, true);
			customRecipeSil = new CustomRecipe(recipe4, true, true);
			customRecipeFlint = new CustomRecipe(recipe5, true, true);
			if ((bool)balance["AxehammerBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
			if ((bool)balance["BattleaxeBronze"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeBronze);
			}
			if ((bool)balance["BattleaxeBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeBM);
			}
			if ((bool)balance["BattleaxeSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeSil);
			}
			if ((bool)balance["BattleaxeFlint"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeFlint);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.BattleaxeBlackmetalPrefab, true);
			customItemBronze = new CustomItem(AssetHelper.BattleaxeBronzePrefab, true);
			customItemBM = new CustomItem(AssetHelper.GreateaxeBlackmetalPrefab, true);
			customItemSil = new CustomItem(AssetHelper.BattleaxeSilverPrefab, true);
			customItemFlint = new CustomItem(AssetHelper.BattleaxeFlintPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItemBronze, balance["BattleaxeBronze"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemBM, balance["BattleaxeBlackmetal"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemSil, balance["BattleaxeSilver"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["AxehammerBlackmetal"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemFlint, balance["BattleaxeFlint"]);
			if ((bool)balance["AxehammerBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
			if ((bool)balance["BattleaxeBronze"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemBronze);
			}
			if ((bool)balance["BattleaxeBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemBM);
			}
			if ((bool)balance["BattleaxeSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemSil);
			}
			if ((bool)balance["BattleaxeFlint"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemFlint);
			}
		}
	}
	internal class FlametalWeapons
	{
		public static CustomItem maceItem;

		public static CustomRecipe maceRecipe;

		public static CustomItem gsItem;

		public static CustomRecipe gsRecipe;

		public static CustomItem atgeirItem;

		public static CustomRecipe atgeirRecipe;

		public static CustomItem bowItem;

		public static CustomRecipe bowRecipe;

		public static CustomItem gaxeItem;

		public static CustomRecipe gaxeRecipe;

		public static CustomItem sledgeItem;

		public static CustomRecipe sledgeRecipe;

		public static CustomItem axeItem;

		public static CustomRecipe axeRecipe;

		public static CustomItem knifeItem;

		public static CustomRecipe knifeRecipe;

		public static CustomItem spearItem;

		public static CustomRecipe spearRecipe;

		public static CustomItem taxeItem;

		public static CustomRecipe taxeRecipe;

		public static CustomItem arrowItem;

		public static CustomRecipe arrowRecipe;

		public static CustomItem swordItem;

		public static CustomRecipe swordRecipe;

		public static CustomItem shieldItem;

		public static CustomRecipe shieldRecipe;

		public static CustomItem gshieldItem;

		public static CustomRecipe gshieldRecipe;

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Expected O, but got Unknown
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Expected O, but got Unknown
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Expected O, but got Unknown
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe3 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe4 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe5 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe6 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe7 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe8 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe9 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe10 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe11 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe12 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe13 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe14 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.MaceFirePrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.GreatswordFirePrefab.GetComponent<ItemDrop>();
			recipe3.m_item = AssetHelper.AtgeirFirePrefab.GetComponent<ItemDrop>();
			recipe4.m_item = AssetHelper.BowFirePrefab.GetComponent<ItemDrop>();
			recipe5.m_item = AssetHelper.BattleaxeFirePrefab.GetComponent<ItemDrop>();
			recipe6.m_item = AssetHelper.SledgeFirePrefab.GetComponent<ItemDrop>();
			recipe7.m_item = AssetHelper.AxeFirePrefab.GetComponent<ItemDrop>();
			recipe8.m_item = AssetHelper.KnifeFirePrefab.GetComponent<ItemDrop>();
			recipe9.m_item = AssetHelper.SpearFirePrefab.GetComponent<ItemDrop>();
			recipe10.m_item = AssetHelper.ThrowingAxeFirePrefab.GetComponent<ItemDrop>();
			recipe11.m_item = AssetHelper.ArrowGreatFirePrefab.GetComponent<ItemDrop>();
			recipe12.m_item = AssetHelper.SwordFirePrefab.GetComponent<ItemDrop>();
			recipe13.m_item = AssetHelper.ShieldFirePrefab.GetComponent<ItemDrop>();
			recipe14.m_item = AssetHelper.ShieldFireTowerPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["MaceFire"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["GreatswordFire"]);
			UtilityFunctions.GetRecipe(ref recipe4, balance["AtgeirFire"]);
			UtilityFunctions.GetRecipe(ref recipe3, balance["BowFire"]);
			UtilityFunctions.GetRecipe(ref recipe5, balance["BattleaxeFire"]);
			UtilityFunctions.GetRecipe(ref recipe6, balance["SledgeFire"]);
			UtilityFunctions.GetRecipe(ref recipe7, balance["AxeFire"]);
			UtilityFunctions.GetRecipe(ref recipe8, balance["KnifeFire"]);
			UtilityFunctions.GetRecipe(ref recipe9, balance["SpearFire"]);
			UtilityFunctions.GetRecipe(ref recipe10, balance["ThrowingAxeFire"]);
			UtilityFunctions.GetRecipe(ref recipe11, balance["ArrowGreatFire"]);
			UtilityFunctions.GetRecipe(ref recipe12, balance["SwordFire"]);
			UtilityFunctions.GetRecipe(ref recipe13, balance["ShieldFire"]);
			UtilityFunctions.GetRecipe(ref recipe14, balance["ShieldFireTower"]);
			maceRecipe = new CustomRecipe(recipe, true, true);
			gsRecipe = new CustomRecipe(recipe2, true, true);
			atgeirRecipe = new CustomRecipe(recipe3, true, true);
			bowRecipe = new CustomRecipe(recipe4, true, true);
			gaxeRecipe = new CustomRecipe(recipe5, true, true);
			sledgeRecipe = new CustomRecipe(recipe6, true, true);
			axeRecipe = new CustomRecipe(recipe7, true, true);
			knifeRecipe = new CustomRecipe(recipe8, true, true);
			spearRecipe = new CustomRecipe(recipe9, true, true);
			taxeRecipe = new CustomRecipe(recipe10, true, true);
			arrowRecipe = new CustomRecipe(recipe11, true, true);
			swordRecipe = new CustomRecipe(recipe12, true, true);
			shieldRecipe = new CustomRecipe(recipe13, true, true);
			gshieldRecipe = new CustomRecipe(recipe14, true, true);
			if ((bool)balance["MaceFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(maceRecipe);
			}
			if ((bool)balance["GreatswordFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(gsRecipe);
			}
			if ((bool)balance["AtgeirFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(atgeirRecipe);
			}
			if ((bool)balance["BowFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(bowRecipe);
			}
			if ((bool)balance["BattleaxeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(gaxeRecipe);
			}
			if ((bool)balance["SledgeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(sledgeRecipe);
			}
			if ((bool)balance["AxeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(axeRecipe);
			}
			if ((bool)balance["KnifeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(knifeRecipe);
			}
			if ((bool)balance["SpearFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(spearRecipe);
			}
			if ((bool)balance["ThrowingAxeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(taxeRecipe);
			}
			if ((bool)balance["ArrowGreatFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(arrowRecipe);
			}
			if ((bool)balance["SwordFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(swordRecipe);
			}
			if ((bool)balance["ShieldFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(shieldRecipe);
			}
			if ((bool)balance["ShieldFireTower"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(gshieldRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			maceItem = new CustomItem(AssetHelper.MaceFirePrefab, true);
			gsItem = new CustomItem(AssetHelper.GreatswordFirePrefab, true);
			atgeirItem = new CustomItem(AssetHelper.AtgeirFirePrefab, true);
			bowItem = new CustomItem(AssetHelper.BowFirePrefab, true);
			gaxeItem = new CustomItem(AssetHelper.BattleaxeFirePrefab, true);
			sledgeItem = new CustomItem(AssetHelper.SledgeFirePrefab, true);
			axeItem = new CustomItem(AssetHelper.AxeFirePrefab, true);
			knifeItem = new CustomItem(AssetHelper.KnifeFirePrefab, true);
			spearItem = new CustomItem(AssetHelper.SpearFirePrefab, true);
			taxeItem = new CustomItem(AssetHelper.ThrowingAxeFirePrefab, true);
			arrowItem = new CustomItem(AssetHelper.ArrowGreatFirePrefab, true);
			swordItem = new CustomItem(AssetHelper.SwordFirePrefab, true);
			shieldItem = new CustomItem(AssetHelper.ShieldFirePrefab, true);
			gshieldItem = new CustomItem(AssetHelper.ShieldFireTowerPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref maceItem, balance["MaceFire"], "<i>Mace</i>\n", string.Format("\n\nFoes struck by its secondary attack are Pinned for <color=cyan>{0}</color> seconds. Pinned enemies are vulnerable to all damage types and have reduced movement speed.", (float)balance["MaceFire"][(object)"effectVal"]));
			UtilityFunctions.ModifyWeaponDamage(ref gsItem, balance["GreatswordFire"], "<i>Greatsword</i>\n", string.Format("\n\nIts secondary attack flings an explosive wave of fire across the battlefield, dealing <color=cyan>{0}</color> fire damage.", (float)balance["GreatswordFire"][(object)"effectVal"]));
			UtilityFunctions.ModifyWeaponDamage(ref atgeirItem, balance["AtgeirFire"], "<i>Atgeir</i>\n", string.Format("\n\nFoes struck by its secondary attack will suffer damage equal to <color=cyan>{0}%</color> of their Current HP after 1.3 seconds.", (float)balance["AtgeirFire"][(object)"effectVal"] * 100f));
			UtilityFunctions.ModifyWeaponDamage(ref bowItem, balance["BowFire"], "<i>Bow</i>\n", "\n\nArrows fired by Gwynttorrwr explode on impact. While drawing the bow, your movement speed is greatly reduced.");
			UtilityFunctions.ModifyWeaponDamage(ref gaxeItem, balance["BattleaxeFire"], "<i>Battleaxe</i>\n", string.Format("\n\nIts secondary fires a short range burst of fireballs. Each fireball deals <color=cyan>{0}</color> fire damage.", (float)balance["BattleaxeFire"][(object)"effectVal"]));
			UtilityFunctions.ModifyWeaponDamage(ref sledgeItem, balance["SledgeFire"], "<i>Sledgehammer</i>\n", "\n\nThe force at which the hammer is flung into the earth leaves a firey puddle for 5 seconds after a slam.");
			UtilityFunctions.ModifyWeaponDamage(ref axeItem, balance["AxeFire"], "<i>Axe</i>\n", string.Format("\n\nKilling a foe imbues their corpse with volatile energy, causing them to explode soon after death. The explosion deals damage equal to <color=cyan>{0}%</color> of the foes max hp. These explosions can chain.", (float)balance["AxeFire"][(object)"effectVal"] * 100f));
			axeItem.ItemDrop.m_itemData.m_shared.m_attackStatusEffect = (StatusEffect)(object)ScriptableObject.CreateInstance<SE_ChainExplosionListener>();
			UtilityFunctions.ModifyWeaponDamage(ref knifeItem, balance["KnifeFire"], "<i>Knife</i>\n", string.Format("\n\nStriking a foe with your secondary attack Marks them for 1 hit. Marked enemies suffer <color=cyan>{0}%</color> more damage.", (float)balance["KnifeFire"][(object)"effectVal"] * 100f));
			UtilityFunctions.ModifyWeaponDamage(ref spearItem, balance["SpearFire"], "<i>Spear</i>\n", "\n\nHurling Rhongomiant across the battlefield will cause you to teleport to whatever location the spear landed.");
			UtilityFunctions.ModifyWeaponDamage(ref taxeItem, balance["ThrowingAxeFire"], "<i>Throwing Axe</i>\n", "\n\nTyrfing hurls spectral versions of itself, depleting durability, not ammo.");
			UtilityFunctions.ModifyWeaponDamage(ref swordItem, balance["SwordFire"], "<i>Sword</i>\n", string.Format("\n\nThe secondary attack emits a deadly beam of fire that deals <color=cyan>{0}</color> damage on impact.", (float)balance["SwordFire"][(object)"effectVal"]));
			UtilityFunctions.ModifyWeaponDamage(ref arrowItem, balance["ArrowGreatFire"]);
			shieldItem.ItemDrop.m_itemData.m_shared.m_description = "<i>Shield</i>\n" + shieldItem.ItemDrop.m_itemData.m_shared.m_description + string.Format("\n\nParrying a foes attack reduces their damage by <color=cyan>{0}%</color> for {1}s. After this effect wears off, {2}s must pass before it can be reapplied.\nPridwen sings to Arthur's other weapons, boosting their damage.", (float)balance["ShieldFire"][(object)"effectVal"] * 100f, (float)balance["ShieldFire"][(object)"effectDur"], (float)balance["ShieldFire"][(object)"effectCooldown"]);
			gshieldItem.ItemDrop.m_itemData.m_shared.m_description = "<i>Tower Shield</i>\n" + gshieldItem.ItemDrop.m_itemData.m_shared.m_description + string.Format("\n\nKilling enemies with Svalinn equipped stores a portion of their Max HP. Once 4 enemies have been slain, a <color=cyan>healing</color> nova is released, healing you and your allies within 4m the average of the stored HP.\nWhile Svalinn is equipped, damage from projectiles is reduced by <color=cyan>{0}%</color>.", (float)balance["ShieldFireTower"][(object)"projProtection"] * 100f);
			if ((bool)balance["MaceFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(maceItem);
			}
			if ((bool)balance["GreatswordFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(gsItem);
			}
			if ((bool)balance["AtgeirFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(atgeirItem);
			}
			if ((bool)balance["BowFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(bowItem);
			}
			if ((bool)balance["BattleaxeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(gaxeItem);
			}
			if ((bool)balance["SledgeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(sledgeItem);
			}
			if ((bool)balance["AxeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(axeItem);
			}
			if ((bool)balance["KnifeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(knifeItem);
			}
			if ((bool)balance["SpearFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(spearItem);
			}
			if ((bool)balance["ThrowingAxeFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(taxeItem);
			}
			if ((bool)balance["ArrowGreatFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(arrowItem);
			}
			if ((bool)balance["SwordFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(swordItem);
			}
			if ((bool)balance["ShieldFire"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(shieldItem);
			}
			if ((bool)balance["ShieldFireTower"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(gshieldItem);
			}
		}
	}
	internal class BowBlackmetal
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public const string TokenLanguage = "English";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.BowBlackmetalPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["BowBlackmetal"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			if ((bool)balance["BowBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.BowBlackmetalPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["BowBlackmetal"]);
			if ((bool)balance["BowBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
		}
	}
	internal class ParryingDagger
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public const string TokenLanguage = "English";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.ParryingDaggerPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["ParryingDagger"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			ItemManager.Instance.AddRecipe(customRecipe);
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.ParryingDaggerPrefab, true);
			ItemManager.Instance.AddItem(customItem);
		}
	}
	internal class SpearBlackmetal
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public const string TokenLanguage = "English";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.SpearBlackmetalPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["SpearBlackmetal"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			if ((bool)balance["SpearBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.SpearBlackmetalPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["SpearBlackmetal"]);
			if ((bool)balance["SpearBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
		}
	}
	internal class PickaxeBlackmetal
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public const string CraftingStationPrefabName = "forge";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.PickaxeBlackmetalPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["PickaxeBlackmetal"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			if ((bool)balance["PickaxeBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.PickaxeBlackmetalPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["PickaxeBlackmetal"]);
			if ((bool)balance["PickaxeBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
		}
	}
	internal class Knives
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public static CustomItem customItemSil;

		public static CustomRecipe customRecipeSil;

		public const string TokenLanguage = "English";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.KnifeIronPrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.KnifeSilverPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["KnifeIron"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["KnifeSilver"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			if ((bool)balance["KnifeIron"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
			customRecipeSil = new CustomRecipe(recipe2, true, true);
			if ((bool)balance["KnifeSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeSil);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.KnifeIronPrefab, true);
			customItemSil = new CustomItem(AssetHelper.KnifeSilverPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["KnifeIron"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemSil, balance["KnifeSilver"]);
			if ((bool)balance["KnifeIron"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
			if ((bool)balance["KnifeSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemSil);
			}
		}
	}
	internal class Javelins
	{
		public static CustomItem customItemFlint;

		public static CustomRecipe customRecipeFlint;

		public static CustomItem customItemBronze;

		public static CustomRecipe customRecipeBronze;

		public const string TokenNameFlint = "$item_javelin_flint";

		public const string TokenValueFlint = "Flint Javelin";

		public const string TokenDescriptionFlintName = "$item_javelin_flint_description";

		public const string TokenDescriptionFlintValue = "A crude javelin, but it will do in a pinch.";

		public const string CraftingStationPrefabName = "piece_workbench";

		public const string TokenLanguage = "English";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.JavelinFlintPrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.JavelinBronzePrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["JavelinFlint"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["JavelinBronze"]);
			customRecipeFlint = new CustomRecipe(recipe, true, true);
			customRecipeBronze = new CustomRecipe(recipe2, true, true);
			ItemManager.Instance.AddRecipe(customRecipeFlint);
			ItemManager.Instance.AddRecipe(customRecipeBronze);
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			customItemFlint = new CustomItem(AssetHelper.JavelinFlintPrefab, true);
			customItemBronze = new CustomItem(AssetHelper.JavelinBronzePrefab, true);
			if ((bool)balance["JavelinFlint"][(object)"modified"])
			{
				UtilityFunctions.ModifyWeaponDamage(ref customItemFlint, balance["JavelinFlint"]);
			}
			if ((bool)balance["JavelinBronze"][(object)"modified"])
			{
				UtilityFunctions.ModifyWeaponDamage(ref customItemBronze, balance["JavelinBronze"]);
			}
			ItemManager.Instance.AddItem(customItemFlint);
			ItemManager.Instance.AddItem(customItemBronze);
		}
	}
	internal class ThrowingAxes
	{
		public static CustomItem customItemFlint;

		public static CustomRecipe customRecipeFlint;

		public static CustomItem customItemBronze;

		public static CustomRecipe customRecipeBronze;

		public static CustomItem customItemIron;

		public static CustomRecipe customRecipeIron;

		public static CustomItem customItemSilver;

		public static CustomRecipe customRecipeSilver;

		public static CustomItem customItemBlackmetal;

		public static CustomRecipe customRecipeBlackmetal;

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe3 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe4 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe5 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.ThrowingAxeFlintPrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.ThrowingAxeBronzePrefab.GetComponent<ItemDrop>();
			recipe3.m_item = AssetHelper.ThrowingAxeIronPrefab.GetComponent<ItemDrop>();
			recipe4.m_item = AssetHelper.ThrowingAxeSilverPrefab.GetComponent<ItemDrop>();
			recipe5.m_item = AssetHelper.ThrowingAxeBlackmetalPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["ThrowingAxeFlint"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["ThrowingAxeBronze"]);
			UtilityFunctions.GetRecipe(ref recipe3, balance["ThrowingAxeIron"]);
			UtilityFunctions.GetRecipe(ref recipe4, balance["ThrowingAxeSilver"]);
			UtilityFunctions.GetRecipe(ref recipe5, balance["ThrowingAxeBlackmetal"]);
			customRecipeFlint = new CustomRecipe(recipe, true, true);
			customRecipeBronze = new CustomRecipe(recipe2, true, true);
			customRecipeIron = new CustomRecipe(recipe3, true, true);
			customRecipeSilver = new CustomRecipe(recipe4, true, true);
			customRecipeBlackmetal = new CustomRecipe(recipe5, true, true);
			if ((bool)balance["ThrowingAxeFlint"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeFlint);
			}
			if ((bool)balance["ThrowingAxeBronze"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeBronze);
			}
			if ((bool)balance["ThrowingAxeIron"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeIron);
			}
			if ((bool)balance["ThrowingAxeSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeSilver);
			}
			if ((bool)balance["ThrowingAxeBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipeBlackmetal);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			customItemFlint = new CustomItem(AssetHelper.ThrowingAxeFlintPrefab, true);
			customItemBronze = new CustomItem(AssetHelper.ThrowingAxeBronzePrefab, true);
			customItemIron = new CustomItem(AssetHelper.ThrowingAxeIronPrefab, true);
			customItemSilver = new CustomItem(AssetHelper.ThrowingAxeSilverPrefab, true);
			customItemBlackmetal = new CustomItem(AssetHelper.ThrowingAxeBlackmetalPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItemFlint, balance["ThrowingAxeFlint"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemBronze, balance["ThrowingAxeBronze"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemIron, balance["ThrowingAxeIron"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemSilver, balance["ThrowingAxeSilver"]);
			UtilityFunctions.ModifyWeaponDamage(ref customItemBlackmetal, balance["ThrowingAxeBlackmetal"]);
			if ((bool)balance["ThrowingAxeFlint"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemFlint);
			}
			if ((bool)balance["ThrowingAxeBronze"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemBronze);
			}
			if ((bool)balance["ThrowingAxeIron"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemIron);
			}
			if ((bool)balance["ThrowingAxeSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemSilver);
			}
			if ((bool)balance["ThrowingAxeBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItemBlackmetal);
			}
		}
	}
	internal class TorchOlympia
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public const string CraftingStationPrefabName = "piece_workbench";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			val.m_item = AssetHelper.TorchOlympiaPrefab.GetComponent<ItemDrop>();
			List<Requirement> list = new List<Requirement>
			{
				MockRequirement.Create("HelmetYule", 1, true),
				MockRequirement.Create("Flametal", 70, true),
				MockRequirement.Create("YagluthDrop", 100, true),
				MockRequirement.Create("YmirRemains", 20, true)
			};
			((Object)val).name = "Recipe_Secret";
			val.m_resources = list.ToArray();
			val.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
			customRecipe = new CustomRecipe(val, true, true);
			if ((bool)balance["TorchOlympia"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.TorchOlympiaPrefab, true);
			if ((bool)balance["TorchOlympia"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
		}
	}
	internal class Axes
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public static CustomItem serpItem;

		public static CustomRecipe serpRecipe;

		public static CustomItem pufferItem;

		public static CustomRecipe pufferRecipe;

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe3 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.AxeForstascaPrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.AxeSerpentPrefab.GetComponent<ItemDrop>();
			recipe3.m_item = AssetHelper.ClubPufferfishPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["AxeForstasca"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["AxeSerpent"]);
			UtilityFunctions.GetRecipe(ref recipe3, balance["ClubPufferfish"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			serpRecipe = new CustomRecipe(recipe2, true, true);
			pufferRecipe = new CustomRecipe(recipe3, true, true);
			if ((bool)balance["AxeForstasca"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
			if ((bool)balance["AxeSerpent"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(serpRecipe);
			}
			if ((bool)balance["ClubPufferfish"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(pufferRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.AxeForstascaPrefab, true);
			serpItem = new CustomItem(AssetHelper.AxeSerpentPrefab, true);
			pufferItem = new CustomItem(AssetHelper.ClubPufferfishPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["AxeForstasca"]);
			UtilityFunctions.ModifyWeaponDamage(ref serpItem, balance["AxeSerpent"], "<i>Axe</i>\n", string.Format("\n\nThe secondary attack summons a bolt of lightning to the targeted location, dealing <color=cyan>{0}</color> damage.", (float)balance["AxeSerpent"][(object)"effectVal"]));
			UtilityFunctions.ModifyWeaponDamage(ref pufferItem, balance["ClubPufferfish"]);
			if ((bool)balance["AxeForstasca"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
			if ((bool)balance["AxeSerpent"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(serpItem);
			}
			if ((bool)balance["ClubPufferfish"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(pufferItem);
			}
		}
	}
	internal class Bombs
	{
		public static CustomItem customItemFire;

		public static CustomRecipe customRecipeFire;

		public static CustomItem customItemFrost;

		public static CustomRecipe customRecipeFrost;

		public static CustomItem customItemLightning;

		public static CustomRecipe customRecipeLightning;

		public const string CraftingStationPrefabName = "piece_workbench";

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Expected O, but got Unknown
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
			Recipe val3 = ScriptableObject.CreateInstance<Recipe>();
			val.m_item = AssetHelper.BombFirePrefab.GetComponent<ItemDrop>();
			val2.m_item = AssetHelper.BombFrostPrefab.GetComponent<ItemDrop>();
			val3.m_item = AssetHelper.BombLightningPrefab.GetComponent<ItemDrop>();
			List<Requirement> list = new List<Requirement>
			{
				MockRequirement.Create("Coal", 10, true),
				MockRequirement.Create("Ooze", 5, true),
				MockRequirement.Create("LeatherScraps", 5, true)
			};
			val.m_amount = 5;
			((Object)val).name = "Recipe_BombFire";
			List<Requirement> list2 = new List<Requirement>
			{
				MockRequirement.Create("FreezeGland", 5, true),
				MockRequirement.Create("Ooze", 5, true),
				MockRequirement.Create("LeatherScraps", 5, true)
			};
			val2.m_amount = 5;
			((Object)val2).name = "Recipe_BombFrost";
			List<Requirement> list3 = new List<Requirement>
			{
				MockRequirement.Create("HardAntler", 1, true),
				MockRequirement.Create("Ooze", 5, true),
				MockRequirement.Create("LeatherScraps", 5, true)
			};
			val3.m_amount = 5;
			((Object)val3).name = "Recipe_BombLightning";
			val.m_resources = list.ToArray();
			val2.m_resources = list2.ToArray();
			val3.m_resources = list3.ToArray();
			val.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
			val2.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
			val3.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
			customRecipeFire = new CustomRecipe(val, true, true);
			customRecipeFrost = new CustomRecipe(val2, true, true);
			customRecipeLightning = new CustomRecipe(val3, true, true);
			ItemManager.Instance.AddRecipe(customRecipeFire);
			ItemManager.Instance.AddRecipe(customRecipeFrost);
			ItemManager.Instance.AddRecipe(customRecipeLightning);
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			customItemFire = new CustomItem(AssetHelper.BombFirePrefab, true);
			customItemFrost = new CustomItem(AssetHelper.BombFrostPrefab, true);
			customItemLightning = new CustomItem(AssetHelper.BombLightningPrefab, true);
			ItemManager.Instance.AddItem(customItemFire);
			ItemManager.Instance.AddItem(customItemFrost);
			ItemManager.Instance.AddItem(customItemLightning);
		}
	}
	internal class AtgeirSilver
	{
		public static CustomItem customItem;

		public static CustomRecipe customRecipe;

		public const string CraftingStationPrefabName = "forge";

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.AtgeirSilverPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["AtgeirSilver"]);
			customRecipe = new CustomRecipe(recipe, true, true);
			if ((bool)balance["AtgeirSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(customRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			customItem = new CustomItem(AssetHelper.AtgeirSilverPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["AtgeirSilver"]);
			if ((bool)balance["AtgeirSilver"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(customItem);
			}
		}
	}
	internal class Greatswords
	{
		public static CustomItem folcbrandItem;

		public static CustomRecipe folcbrandRecipe;

		public static CustomItem ironItem;

		public static CustomRecipe ironRecipe;

		public static CustomItem blackmetalItem;

		public static CustomRecipe blackmetalRecipe;

		public static CustomItem chitinItem;

		public static CustomRecipe chitinRecipe;

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		internal static void Init()
		{
			AddRecipe();
			AddItem();
		}

		private static void AddRecipe()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			Recipe recipe = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe2 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe3 = ScriptableObject.CreateInstance<Recipe>();
			Recipe recipe4 = ScriptableObject.CreateInstance<Recipe>();
			recipe.m_item = AssetHelper.FolcbrandPrefab.GetComponent<ItemDrop>();
			recipe2.m_item = AssetHelper.GreatswordIronPrefab.GetComponent<ItemDrop>();
			recipe3.m_item = AssetHelper.GreatswordBlackmetalPrefab.GetComponent<ItemDrop>();
			recipe4.m_item = AssetHelper.GreatswordChitinPrefab.GetComponent<ItemDrop>();
			UtilityFunctions.GetRecipe(ref recipe, balance["GreatswordFolcbrand"]);
			UtilityFunctions.GetRecipe(ref recipe2, balance["GreatswordIron"]);
			UtilityFunctions.GetRecipe(ref recipe3, balance["GreatswordBlackmetal"]);
			UtilityFunctions.GetRecipe(ref recipe4, balance["GreatswordChitin"]);
			folcbrandRecipe = new CustomRecipe(recipe, true, true);
			ironRecipe = new CustomRecipe(recipe2, true, true);
			blackmetalRecipe = new CustomRecipe(recipe3, true, true);
			chitinRecipe = new CustomRecipe(recipe4, true, true);
			if ((bool)balance["GreatswordFolcbrand"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(folcbrandRecipe);
			}
			if ((bool)balance["GreatswordIron"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(ironRecipe);
			}
			if ((bool)balance["GreatswordBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(blackmetalRecipe);
			}
			if ((bool)balance["GreatswordChitin"][(object)"enabled"])
			{
				ItemManager.Instance.AddRecipe(chitinRecipe);
			}
		}

		private static void AddItem()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			folcbrandItem = new CustomItem(AssetHelper.FolcbrandPrefab, true);
			ironItem = new CustomItem(AssetHelper.GreatswordIronPrefab, true);
			blackmetalItem = new CustomItem(AssetHelper.GreatswordBlackmetalPrefab, true);
			chitinItem = new CustomItem(AssetHelper.GreatswordChitinPrefab, true);
			UtilityFunctions.ModifyWeaponDamage(ref folcbrandItem, balance["GreatswordFolcbrand"]);
			UtilityFunctions.ModifyWeaponDamage(ref ironItem, balance["GreatswordIron"]);
			UtilityFunctions.ModifyWeaponDamage(ref blackmetalItem, balance["GreatswordBlackmetal"]);
			UtilityFunctions.ModifyWeaponDamage(ref chitinItem, balance["GreatswordChitin"]);
			if ((bool)balance["GreatswordFolcbrand"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(folcbrandItem);
			}
			if ((bool)balance["GreatswordIron"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(ironItem);
			}
			if ((bool)balance["GreatswordBlackmetal"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(blackmetalItem);
			}
			if ((bool)balance["GreatswordChitin"][(object)"enabled"])
			{
				ItemManager.Instance.AddItem(chitinItem);
			}
		}
	}
}
namespace TerraheimItems.Utility
{
	internal class AssetHelper
	{
		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		public const string AssetBundleName = "bundle_terraheim";

		public const string NewAssetBundleName = "bundle_terraheimnewitems";

		public static AssetBundle TerraheimAssetBundle;

		public static GameObject FolcbrandPrefab;

		public static GameObject GreatswordIronPrefab;

		public static GameObject GreatswordBlackmetalPrefab;

		public static GameObject GreatswordChitinPrefab;

		public static GameObject AtgeirSilverPrefab;

		public static GameObject AxeForstascaPrefab;

		public static GameObject AxeSerpentPrefab;

		public static GameObject KnifeIronPrefab;

		public static GameObject KnifeSilverPrefab;

		public static GameObject BowBlackmetalPrefab;

		public static GameObject PickaxeBlackmetalPrefab;

		public static GameObject SpearBlackmetalPrefab;

		public static GameObject BattleaxeBronzePrefab;

		public static GameObject BattleaxeBlackmetalPrefab;

		public static GameObject BattleaxeSilverPrefab;

		public static GameObject GreateaxeBlackmetalPrefab;

		public static GameObject BattleaxeFlintPrefab;

		public static GameObject MaceFirePrefab;

		public static GameObject GreatswordFirePrefab;

		public static GameObject AtgeirFirePrefab;

		public static GameObject BowFirePrefab;

		public static GameObject BattleaxeFirePrefab;

		public static GameObject SledgeFirePrefab;

		public static GameObject AxeFirePrefab;

		public static GameObject KnifeFirePrefab;

		public static GameObject SpearFirePrefab;

		public static GameObject ThrowingAxeFirePrefab;

		public static GameObject ArrowGreatFirePrefab;

		public static GameObject SwordFirePrefab;

		public static GameObject ShieldFirePrefab;

		public static GameObject ShieldFireTowerPrefab;

		public static GameObject TorchOlympiaPrefab;

		public static GameObject ParryingDaggerPrefab;

		public static GameObject BombFirePrefab;

		public static GameObject BombFrostPrefab;

		public static GameObject BombLightningPrefab;

		public static GameObject ThrowingAxeFlintPrefab;

		public static GameObject ThrowingAxeBronzePrefab;

		public static GameObject ThrowingAxeIronPrefab;

		public static GameObject ThrowingAxeSilverPrefab;

		public static GameObject ThrowingAxeBlackmetalPrefab;

		public static GameObject JavelinFlintPrefab;

		public static GameObject JavelinBronzePrefab;

		public static GameObject ClubPufferfishPrefab;

		public static GameObject BowFireExplosionPrefab;

		public static GameObject AxeFireExplosionPrefab;

		public static GameObject VFXAtgeirFireHitPrefab;

		public static GameObject VFXSpearFireTeleportInPrefab;

		public static GameObject VFXSpearFireTeleportOutPrefab;

		public static AudioClip SFXAtgeirFireHitPrefab;

		public static GameObject SwordFireProjPrefab;

		public static void Init()
		{
			TerraheimAssetBundle = GetAssetBundleFromResources("bundle_terraheim");
			FolcbrandPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/folcbrand/SwordFolcbrand.prefab");
			GreatswordIronPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/greatswordiron/GreatswordIron.prefab");
			GreatswordBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/greatswordblackmetal/GreatswordBlackmetal.prefab");
			GreatswordChitinPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/greatswordChitin/GreatswordChitinTH.prefab");
			AtgeirSilverPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/kresja/AtgeirSilver.prefab");
			AxeForstascaPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/forstasca/AxeForstasca.prefab");
			AxeSerpentPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/serpentaxe/AxeSerpentTH.prefab");
			BattleaxeBronzePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/BattleaxeBronze/BattleaxeBronzeTerraheim.prefab");
			BattleaxeFlintPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/greatclub/GreataxeFlintTH.prefab");
			KnifeIronPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/ironKnife/KnifeIron.prefab");
			KnifeSilverPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/KnifeObsidian/KnifeSilverTH.prefab");
			BowBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/blackmetalbow/BowBlackmetalTH.prefab");
			PickaxeBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/blackironPickaxe/PickaxeBlackmetal.prefab");
			SpearBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/blackmetalspear/SpearBlackmetal.prefab");
			BattleaxeBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/blackmetalAxehammer/BattleaxeBlackmetal.prefab");
			BattleaxeSilverPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/BattleaxeSilver/BattleaxeSilver.prefab");
			GreateaxeBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/BattleaxeBlackmetal/GreataxeBlackmetal.prefab");
			MaceFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/mace/MaceFireTH.prefab");
			GreatswordFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/greatsword/GreatswordFireTH.prefab");
			GreatswordFirePrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_secondaryAttack.m_attackProjectile.GetComponent<Projectile>().m_spawnOnHit.GetComponent<Aoe>().m_damage.m_fire = (float)balance["GreatswordFire"][(object)"effectVal"];
			AtgeirFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/atgeir/AtgeirFireTH.prefab");
			BowFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/bow/BowFireTH.prefab");
			BattleaxeFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/greataxe/BattleaxeFireTH.prefab");
			BattleaxeFirePrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_secondaryAttack.m_attackProjectile.GetComponent<Projectile>().m_damage.m_fire = (float)balance["BattleaxeFire"][(object)"effectVal"];
			SledgeFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/sledge/SledgeFireTH.prefab");
			SledgeFirePrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_secondaryAttack.m_attackProjectile.GetComponent<Projectile>().m_spawnOnHit.GetComponent<Aoe>().m_damage.m_fire = (float)balance["SledgeFire"][(object)"effectVal"];
			AxeFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/axe/AxeFireTH.prefab");
			KnifeFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/knife/KnifeFireTH.prefab");
			SpearFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/spear/SpearFireTH.prefab");
			ThrowingAxeFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/throwingaxe/ThrowingAxeFire.prefab");
			ArrowGreatFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/arrow/ArrowGreatFireTH.prefab");
			SwordFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/swordProj/SwordFireTH.prefab");
			SwordFirePrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_secondaryAttack.m_attackProjectile.GetComponent<Projectile>().m_damage.m_fire = (float)balance["SwordFire"][(object)"effectVal"];
			ShieldFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/shield/ShieldFireTH.prefab");
			ShieldFireTowerPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/gshield/ShieldFireTowerTH.prefab");
			ShieldFireTowerPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)ScriptableObject.CreateInstance<SE_ShieldFireListener>();
			ShieldFirePrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)ScriptableObject.CreateInstance<SE_ShieldFireParryListener>();
			TorchOlympiaPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Olympia/TorchOlympia.prefab");
			ParryingDaggerPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/parryingdagger/ShieldSilverDagger.prefab");
			BombFirePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/firebomb/BombFire.prefab");
			BombFrostPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/frostbomb/BombFrost.prefab");
			BombLightningPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/lightningbomb/BombLightning.prefab");
			ThrowingAxeFlintPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/ThrowingAxes/Flint/ThrowingAxeFlint.prefab");
			ThrowingAxeBronzePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/ThrowingAxes/Bronze/ThrowingAxeBronze.prefab");
			ThrowingAxeIronPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/ThrowingAxes/Iron/ThrowingAxeIron.prefab");
			ThrowingAxeSilverPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/ThrowingAxes/Silver/ThrowingAxeSilver.prefab");
			ThrowingAxeBlackmetalPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/ThrowingAxes/Blackmetal/ThrowingAxeBlackmetal.prefab");
			JavelinFlintPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Javelins/Flint/JavelinFlint.prefab");
			JavelinBronzePrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Javelins/Bronze/JavelinBronze.prefab");
			SwordFireProjPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/swordProj/swordironfire_projectile.prefab");
			BowFireExplosionPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/bow/bowFire_explosion.prefab");
			AxeFireExplosionPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/axe/axeFire_explosion.prefab");
			AxeFireExplosionPrefab.GetComponent<Aoe>().m_statusEffect = "ChainExplosionListener";
			VFXAtgeirFireHitPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/Effects/vfx_flametal_atgeir_hit.prefab");
			VFXSpearFireTeleportInPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/spear/spearFire_teleportIn.prefab");
			VFXSpearFireTeleportOutPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/CustomItems/flametal/spear/spearFire_teleportOut.prefab");
			SFXAtgeirFireHitPrefab = TerraheimAssetBundle.LoadAsset<AudioClip>("Assets/CustomItems/flametal/atgeir/Flame_SpitFire3.wav");
			TerraheimAssetBundle = GetAssetBundleFromResources("bundle_terraheimnewitems");
			Log.LogMessage("New Bundle Loaded");
			ClubPufferfishPrefab = TerraheimAssetBundle.LoadAsset<GameObject>("Assets/customAssets/ClubPufferfishTH.prefab");
		}

		public static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}
	}
	internal class TranslationUtils
	{
		private static readonly string m_translationsPath = TerraheimItems.ModPath;

		private static readonly string m_defaultLanguage = "English";

		private static string m_language = Localization.instance.GetSelectedLanguage();

		private static string m_translationPath;

		public static void LoadTranslations()
		{
			GetTranslationFilePath();
			ReadTranslationFile();
		}

		private static void GetTranslationFilePath()
		{
			string text = Path.Combine(m_translationsPath, m_language.ToLowerInvariant() + ".lang");
			if (!File.Exists(text))
			{
				Log.LogWarning("No translation file found for " + m_language + "; defaulting to " + m_defaultLanguage);
				m_language = m_defaultLanguage;
				text = Path.Combine(m_translationsPath, m_defaultLanguage.ToLowerInvariant() + ".lang");
				if (!File.Exists(text))
				{
					Log.LogError("No default translation file found for " + m_language);
					return;
				}
			}
			m_translationPath = text;
		}

		private static void ReadTranslationFile()
		{
			if (m_translationPath == null)
			{
				Log.LogError("No translation found; skipping translation");
				return;
			}
			int num = 0;
			try
			{
				using StreamReader streamReader = new StreamReader(m_translationPath, Encoding.BigEndianUnicode);
				int num2 = 0;
				string text;
				while ((text = streamReader.ReadLine()) != null)
				{
					string[] array = text.Split(new char[1] { '=' });
					if (array.Length != 2 && !text.StartsWith("#"))
					{
						num++;
						Log.LogWarning($"Skipping incorrect translation found at line {num2} in {m_language.ToLowerInvariant()}.lang");
					}
					else if (!text.StartsWith("#"))
					{
						Localization.instance.AddWord(array[0], array[1]);
					}
					num2++;
				}
			}
			catch (Exception)
			{
				Log.LogError("Could not read file " + m_translationPath);
			}
			string text2 = "Loaded localization for " + m_language;
			if (num > 0)
			{
				Log.LogWarning($"{text2} with {num} errors.");
			}
			else
			{
				Log.LogInfo(text2);
			}
		}
	}
	internal class UtilityFunctions
	{
		public static JObject GetJsonFromFile(string filename)
		{
			string path = Path.Combine(TerraheimItems.ModPath, filename);
			string text = File.ReadAllText(path);
			return JObject.Parse(text);
		}

		public static void ModifyWeaponDamage(ref CustomItem item, JToken damages, string type = "", string description = "")
		{
			foreach (JToken item2 in (IEnumerable<JToken>)damages[(object)"damages"])
			{
				switch ((string)item2[(object)"type"])
				{
				case "blunt":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_blunt = (float)item2[(object)"value"];
					break;
				case "slash":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_slash = (float)item2[(object)"value"];
					break;
				case "pierce":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_pierce = (float)item2[(object)"value"];
					break;
				case "chop":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_chop = (float)item2[(object)"value"];
					break;
				case "pickaxe":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_blunt = (float)item2[(object)"value"];
					break;
				case "fire":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_fire = (float)item2[(object)"value"];
					break;
				case "frost":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_frost = (float)item2[(object)"value"];
					break;
				case "lightning":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_lightning = (float)item2[(object)"value"];
					break;
				case "poison":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_poison = (float)item2[(object)"value"];
					break;
				case "spirit":
					item.ItemDrop.m_itemData.m_shared.m_damages.m_spirit = (float)item2[(object)"value"];
					break;
				default:
					Log.LogWarning("Terraheim: Warning damage type not found! " + (string)item2[(object)"type"]);
					break;
				}
			}
			if (type != "")
			{
				item.ItemDrop.m_itemData.m_shared.m_description = type + item.ItemDrop.m_itemData.m_shared.m_description;
			}
			if (description != "")
			{
				SharedData shared = item.ItemDrop.m_itemData.m_shared;
				shared.m_description += description;
			}
		}

		public static void GetRecipe(ref Recipe recipe, JToken json, bool useName = true)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			List<Requirement> list = new List<Requirement>();
			int num = 0;
			foreach (JToken item2 in (IEnumerable<JToken>)json[(object)"recipe"])
			{
				if ((string)item2[(object)"item"] == "SalamanderFur")
				{
					Requirement item = new Requirement
					{
						m_resItem = SharedResources.SalamanderItem.ItemDrop,
						m_amount = (int)item2[(object)"amount"]
					};
					list.Add(item);
				}
				else
				{
					list.Add(MockRequirement.Create((string)item2[(object)"item"], (int)item2[(object)"amount"], true));
					list[num].m_amountPerLevel = (int)item2[(object)"perLevel"];
				}
				num++;
			}
			if (useName)
			{
				((Object)recipe).name = "Recipe_" + json.Path;
			}
			recipe.m_resources = list.ToArray();
			recipe.m_craftingStation = Mock<CraftingStation>.Create((string)json[(object)"station"]);
			recipe.m_amount = (int)json[(object)"amountCrafted"];
		}

		public static bool HasProjectileAttack(string name)
		{
			if (name.Contains("_greatsword_fire"))
			{
				return true;
			}
			if (name.Contains("_battleaxe_fire"))
			{
				return true;
			}
			if (name.Contains("_sword_fire"))
			{
				return true;
			}
			if (name.Contains("_sledge_fire"))
			{
				return true;
			}
			if (name.Contains("_axe_serpent"))
			{
				return true;
			}
			return false;
		}

		public static StatusEffect GetStatusEffectFromName(string name, SEMan seman)
		{
			foreach (StatusEffect statusEffect in seman.GetStatusEffects())
			{
				if (((Object)statusEffect).name == name)
				{
					return statusEffect;
				}
			}
			return null;
		}
	}
}
namespace TerraheimItems.StatusEffects
{
	internal class SE_ChainExplosionListener : StatusEffect
	{
		public float TTL
		{
			get
			{
				return base.m_ttl;
			}
			set
			{
				base.m_ttl = value;
			}
		}

		public void Awake()
		{
			base.m_name = "ChainExplosionListener";
			((Object)this).name = "ChainExplosionListener";
			base.m_tooltip = "";
			base.m_icon = null;
		}

		public override void Setup(Character character)
		{
			TTL = 0.25f;
			Log.LogMessage("Hit " + character.m_name + " w/ axe fire explosion.");
			((StatusEffect)this).Setup(character);
		}
	}
	internal class SE_HealthPercentDamage : StatusEffect
	{
		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		public bool hasTriggered = false;

		public float TTL
		{
			get
			{
				return base.m_ttl;
			}
			set
			{
				base.m_ttl = value;
			}
		}

		public void Awake()
		{
			base.m_name = "HealthPercentDamage";
			((Object)this).name = "HealthPercentDamage";
			base.m_tooltip = "";
			base.m_icon = null;
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00ae: 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)
			if (base.m_time >= TTL - 0.1f && !hasTriggered)
			{
				float num = base.m_character.GetHealth() * (float)balance["AtgeirFire"][(object)"effectVal"];
				Log.LogMessage($"Inflicting {num} damage on expiration");
				base.m_character.SetHealth(base.m_character.GetHealth() - num);
				HitData val = new HitData();
				val.m_damage.m_slash = num;
				base.m_character.Damage(val);
				GameObject val2 = Object.Instantiate<GameObject>(AssetHelper.VFXAtgeirFireHitPrefab, base.m_character.GetCenterPoint(), Quaternion.identity);
				ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>();
				ParticleSystem[] array = componentsInChildren;
				foreach (ParticleSystem val3 in array)
				{
					val3.Play();
				}
				AudioSource val4 = ((Component)base.m_character).GetComponent<AudioSource>();
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = ((Component)base.m_character).gameObject.AddComponent<AudioSource>();
					val4.playOnAwake = false;
				}
				val4.PlayOneShot(AssetHelper.SFXAtgeirFireHitPrefab);
				hasTriggered = true;
			}
			((StatusEffect)this).UpdateStatusEffect(dt);
		}

		public override void Setup(Character character)
		{
			TTL = 1.5f;
			Log.LogMessage("Hit " + character.m_name + " w/ atgeir secondary. Effect triggered!");
			((StatusEffect)this).Setup(character);
		}
	}
}
namespace TerraheimItems.Patches
{
	[HarmonyPatch]
	internal class ApplyDamagePatch
	{
		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		private static Dictionary<int, float> explosionList = new Dictionary<int, float>();

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SEMan), "OnDamaged")]
		public static void DamagePrefix(SEMan __instance, HitData hit)
		{
			if (__instance.m_character.IsPlayer() && hit.m_statusEffectHash == StringExtensionMethods.GetStableHashCode("ChainExplosionListener"))
			{
				hit.m_damage.m_damage = 0f;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Ragdoll), "SaveLootList")]
		public static void SaveLootListPrefix(Ragdoll __instance, CharacterDrop characterDrop)
		{
			if (characterDrop.m_character.GetSEMan().HaveStatusEffect("ChainExplosionListener"))
			{
				explosionList.Add(((Object)__instance).GetInstanceID(), characterDrop.m_character.GetMaxHealth() * (float)balance["AxeFire"][(object)"effectVal"]);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Ragdoll), "SpawnLoot")]
		public static void SpawnLootPostfix(Ragdoll __instance, Vector3 center)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (explosionList.ContainsKey(((Object)__instance).GetInstanceID()))
			{
				AssetHelper.AxeFireExplosionPrefab.GetComponent<Aoe>().m_hitFriendly = false;
				AssetHelper.AxeFireExplosionPrefab.GetComponent<Aoe>().m_hitOwner = false;
				AssetHelper.AxeFireExplosionPrefab.GetComponent<Aoe>().m_damage.m_damage = explosionList[((Object)__instance).GetInstanceID()];
				Object.Instantiate<GameObject>(AssetHelper.AxeFireExplosionPrefab, center, Quaternion.identity);
				explosionList.Remove(((Object)__instance).GetInstanceID());
			}
		}
	}
	[HarmonyPatch]
	internal class AttackDrawUpdatePatch
	{
		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		[HarmonyPostfix]
		[HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")]
		private static void UpdateEquipmentVisualsPatch(VisEquipment __instance)
		{
			//IL_02d8: 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_007c: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			GameObject leftItemInstance = __instance.m_leftItemInstance;
			if (!((Object)(object)leftItemInstance != (Object)null) || !(__instance.m_leftItem == "BowFireTH") || !__instance.m_isPlayer)
			{
				return;
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetAttackDrawPercentage() > 0f)
			{
				foreach (Transform item in leftItemInstance.transform)
				{
					Transform val = item;
					if (((Object)val).name == "FullModel" && ((Renderer)((Component)val).gameObject.GetComponent<MeshRenderer>()).enabled)
					{
						((Renderer)((Component)val).gameObject.GetComponent<MeshRenderer>()).enabled = false;
					}
					else if (((Object)val).name == "HiddenModel")
					{
						if (!((Renderer)((Component)val).gameObject.GetComponent<MeshRenderer>()).enabled)
						{
							((Renderer)((Component)val).gameObject.GetComponent<MeshRenderer>()).enabled = true;
						}
						((Component)val).gameObject.GetComponent<Renderer>().material.color = new Color(1f, 1f, 1f, Mathf.Clamp(1f - ((Humanoid)Player.m_localPlayer).GetAttackDrawPercentage(), 0.05f, 1f));
					}
					else if (((Object)val).name == "effects" && ((Component)val).gameObject.activeSelf)
					{
						((Component)val).gameObject.SetActive(false);
					}
					else if (((Object)val).name == "effectsCharging" && !((Component)val).gameObject.activeSelf)
					{
						((Component)val).gameObject.SetActive(true);
					}
				}
				return;
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null && !((Renderer)((Component)leftItemInstance.transform.Find("FullModel")).gameObject.GetComponent<MeshRenderer>()).enabled)
			{
				((Renderer)((Component)leftItemInstance.transform.Find("FullModel")).gameObject.GetComponent<MeshRenderer>()).enabled = true;
				((Component)leftItemInstance.transform.Find("effects")).gameObject.SetActive(true);
				((Component)leftItemInstance.transform.Find("effectsCharging")).gameObject.SetActive(false);
				((Renderer)((Component)leftItemInstance.transform.Find("HiddenModel")).gameObject.GetComponent<MeshRenderer>()).enabled = false;
				((Component)leftItemInstance.transform.Find("HiddenModel")).gameObject.GetComponent<Renderer>().material.color = new Color(1f, 1f, 1f);
			}
		}
	}
	[HarmonyPatch]
	internal class MeleeProjectilePatch
	{
		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Attack), "OnAttackTrigger")]
		private static void OnAttackTriggerPatch(Attack __instance)
		{
			if (!(bool)balance["FlametalWeaponsSpecialEffectsEnabled"] || !((Character)__instance.m_character).IsPlayer())
			{
				return;
			}
			if (UtilityFunctions.HasProjectileAttack(__instance.GetWeapon().m_shared.m_name) && __instance.m_attackAnimation == __instance.GetWeapon().m_shared.m_secondaryAttack.m_attackAnimation)
			{
				__instance.ProjectileAttackTriggered();
				ItemData weapon = __instance.GetWeapon();
				weapon.m_durability -= (float)(int)balance["FlametalWeaponSpecialDurabilityDrain"];
			}
			else if (__instance.GetWeapon().m_shared.m_name.Contains("_atgeir_fire"))
			{
				if (__instance.m_attackAnimation == __instance.GetWeapon().m_shared.m_secondaryAttack.m_attackAnimation)
				{
					__instance.m_weapon.m_shared.m_attackStatusEffect = (StatusEffect)(object)ScriptableObject.CreateInstance<SE_HealthPercentDamage>();
					ItemData weapon2 = __instance.GetWeapon();
					weapon2.m_durability -= (float)(int)balance["FlametalWeaponSpecialDurabilityDrain"];
				}
				else if ((Object)(object)__instance.m_weapon.m_shared.m_attackStatusEffect != (Object)null)
				{
					__instance.m_weapon.m_shared.m_attackStatusEffect = null;
				}
			}
			else if (__instance.GetWeapon().m_shared.m_name.Contains("_mace_fire"))
			{
				if (__instance.m_attackAnimation == __instance.GetWeapon().m_shared.m_secondaryAttack.m_attackAnimation)
				{
					SE_Pinned val = ScriptableObject.CreateInstance<SE_Pinned>();
					val.SetPinTTL((float)balance["MaceFire"][(object)"effectVal"]);
					val.SetPinCooldownTTL((float)balance["MaceFire"][(object)"cooldownVal"]);
					__instance.m_weapon.m_shared.m_attackStatusEffect = (StatusEffect)(object)val;
					ItemData weapon3 = __instance.GetWeapon();
					weapon3.m_durability -= (float)(int)balance["FlametalWeaponSpecialDurabilityDrain"];
				}
				else if ((Object)(object)__instance.m_weapon.m_shared.m_attackStatusEffect != (Object)null)
				{
					__instance.m_weapon.m_shared.m_attackStatusEffect = null;
				}
			}
			else if (__instance.GetWeapon().m_shared.m_name.Contains("_knife_fire"))
			{
				if (__instance.m_attackAnimation == __instance.GetWeapon().m_shared.m_secondaryAttack.m_attackAnimation)
				{
					SE_MarkedForDeath val2 = ScriptableObject.CreateInstance<SE_MarkedForDeath>();
					val2.SetActivationCount((int)balance["KnifeFire"][(object)"effectThreshold"]);
					val2.SetHitDuration((int)balance["KnifeFire"][(object)"effectDur"]);
					val2.SetDamageBonus((float)balance["KnifeFire"][(object)"effectVal"]);
					__instance.m_weapon.m_shared.m_attackStatusEffect = (StatusEffect)(object)val2;
					ItemData weapon4 = __instance.GetWeapon();
					weapon4.m_durability -= (float)(int)balance["FlametalWeaponSpecialDurabilityDrain"];
				}
				else if ((Object)(object)__instance.m_weapon.m_shared.m_attackStatusEffect != (Object)null)
				{
					__instance.m_weapon.m_shared.m_attackStatusEffect = null;
				}
			}
		}
	}
	[HarmonyPatch]
	internal class ProjectileSpawnOnHitPatch
	{
		public static int stackHolder = -1;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Projectile), "SpawnOnHit")]
		private static void ProjectileSetupPatch(ref ItemData ___m_spawnItem)
		{
			if (___m_spawnItem != null && ___m_spawnItem.m_stack > 1)
			{
				stackHolder = ___m_spawnItem.m_stack;
				___m_spawnItem.m_stack = 1;
			}
			else
			{
				stackHolder = -1;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Projectile), "SpawnOnHit")]
		private static void ProjectileSetupPostfix(ref ItemData ___m_spawnItem)
		{
			if (___m_spawnItem != null && stackHolder > -1)
			{
				___m_spawnItem.m_stack = stackHolder;
			}
		}
	}
	[HarmonyPatch]
	internal class SpawnOnHitPatch
	{
		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		[HarmonyPatch(typeof(Projectile), "SpawnOnHit")]
		public static void Postfix(Projectile __instance, GameObject go, Collider collider)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			if (!(bool)balance["FlametalWeaponsSpecialEffectsEnabled"] || __instance.m_spawnItem == null || !__instance.m_spawnItem.m_shared.m_name.Contains("spear_fire"))
			{
				return;
			}
			Vector3 val = ((Component)__instance).transform.position + ((Component)__instance).transform.TransformDirection(__instance.m_spawnOffset);
			Quaternion rotation = ((Component)__instance).transform.rotation;
			Character owner = __instance.m_owner;
			if ((Object)(object)((owner is Player) ? owner : null) == (Object)(object)Player.m_localPlayer)
			{
				GameObject val2 = Object.Instantiate<GameObject>(AssetHelper.VFXSpearFireTeleportInPrefab, __instance.m_owner.GetCenterPoint(), Quaternion.identity);
				ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>();
				ParticleSystem[] array = componentsInChildren;
				foreach (ParticleSystem val3 in array)
				{
					val3.Play();
				}
				((Component)Player.m_localPlayer).transform.position = val;
				((Component)Player.m_localPlayer).transform.rotation = rotation;
				GameObject val4 = Object.Instantiate<GameObject>(AssetHelper.VFXSpearFireTeleportOutPrefab, val, rotation);
				ParticleSystem[] componentsInChildren2 = val4.GetComponentsInChildren<ParticleSystem>();
				ParticleSystem[] array2 = componentsInChildren2;
				foreach (ParticleSystem val5 in array2)
				{
					val5.Play();
				}
			}
		}
	}
	[HarmonyPatch]
	internal class AnimationSpeedPatches
	{
		public static Dictionary<string, float> baseAnimationSpeeds = new Dictionary<string, float>();

		private static JObject balance = UtilityFunctions.GetJsonFromFile("weaponBalance.json");

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterAnimEvent), "CustomFixedUpdate")]
		private static void CharacterAnimFixedUpdatePrefix(ref Animator ___m_animator, Character ___m_character)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || !___m_character.IsPlayer() || (___m_character.IsPlayer() && ((Player)((___m_character is Player) ? ___m_character : null)).GetPlayerID() != Player.m_localPlayer.GetPlayerID()))
			{
				return;
			}
			Animator obj = ___m_animator;
			if (obj == null || obj.GetCurrentAnimatorClipInfo(0)?.Any() != true || (Object)(object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip == (Object)null || ((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Idle") || ((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Jog") || ((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Run") || ((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Walk") || ((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("Standing") || ((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.Contains("jump") || (baseAnimationSpeeds.ContainsKey(((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name) && baseAnimationSpeeds[((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name] != ___m_animator.speed))
			{
				return;
			}
			float num = 0f;
			if (___m_character.GetSEMan().HaveStatusEffect("Attack Speed"))
			{
				float num2 = num;
				StatusEffect statusEffectFromName = UtilityFunctions.GetStatusEffectFromName("Attack Speed", ___m_character.GetSEMan());
				num = num2 + ((SE_AttackSpeed)((statusEffectFromName is SE_AttackSpeed) ? statusEffectFromName : null)).GetSpeed();
			}
			if (___m_character.GetSEMan().HaveStatusEffect("Adrenaline"))
			{
				float num3 = num;
				StatusEffect statusEffectFromName2 = UtilityFunctions.GetStatusEffectFromName("Adrenaline", ___m_character.GetSEMan());
				num = num3 + ((SE_Adrenaline)((statusEffectFromName2 is SE_Adrenaline) ? statusEffectFromName2 : null)).GetAttackSpeed();
			}
			float num4 = 0f;
			if (((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.StartsWith("Bomb"))
			{
				if ((((Humanoid)((___m_character is Humanoid) ? ___m_character : null)).GetCurrentWeapon()?.m_shared?.m_name.Contains("throwingaxe")).Value)
				{
					num4 = (float)balance["ThrowingAxeAnimationSpeedAdjust"];
				}
			}
			else if (((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.StartsWith("BattleAxe1"))
			{
				if ((((Humanoid)((___m_character is Humanoid) ? ___m_character : null)).GetCurrentWeapon()?.m_shared?.m_name.Contains("greatsword")).Value)
				{
					num4 = (float)balance["GreatswordStartAnimationSpeedAdjust"];
				}
			}
			else if (((Object)((AnimatorClipInfo)(ref ___m_animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name.StartsWith("BattleAxe") && (((Humanoid)((___m_character is Humanoid) ? ___m_character : null)).GetCurrentWeapon()?.m_shared?.m_name.Contains("greatsword")).Value)
			{
				num4 = (float)balance["GreatswordAnimationSpeedAdjust"];
			}
			if (num4 + num != 0f)
			{
				___m_animator.speed = ChangeSpeed(___m_character, ___m_animator, num4, num);
			}
		}

		public static float ChangeSpeed(Character character, Animator animator, float speed, float speedMod)
		{
			string name = ((Object)((AnimatorClipInfo)(ref animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name;
			if (!baseAnimationSpeeds.ContainsKey(name))
			{
				baseAnimationSpeeds.Add(name, animator.speed);
			}
			if (speedMod < 1f)
			{
				speedMod += 1f;
			}
			if (speed < 1f)
			{
				speed += 1f;
			}
			if ((double)(baseAnimationSpeeds[name] * speed * speedMod) > 7.59375)
			{
				return 7.7f;
			}
			return baseAnimationSpeeds[name] * speed * speedMod;
		}
	}
}

plugins/TGServer.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Taeguk")]
[assembly: AssemblyProduct("TGServer")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTitle("TGServer")]
[assembly: AssemblyDescription("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<0e5f4be2-c77e-4d30-ba38-a68ae0816918>Embedded]
	internal sealed class <0e5f4be2-c77e-4d30-ba38-a68ae0816918>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<0e5f4be2-c77e-4d30-ba38-a68ae0816918>Embedded]
	internal sealed class <bcfea496-feac-4d51-b436-e2e03bcd6883>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <bcfea496-feac-4d51-b436-e2e03bcd6883>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <bcfea496-feac-4d51-b436-e2e03bcd6883>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<0e5f4be2-c77e-4d30-ba38-a68ae0816918>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <0ca92395-0097-4de6-a26d-1926aceecc19>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <0ca92395-0097-4de6-a26d-1926aceecc19>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace TGServer
{
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[BepInPlugin("Taeguk.TGServer", "TGServer", "1.0.2")]
	public class TGServerPlugin : BaseUnityPlugin
	{
		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
			public string Category;

			[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
		private class AcceptableShortcuts : AcceptableValueBase
		{
			public AcceptableShortcuts()
				: base(typeof(KeyboardShortcut))
			{
			}

			public override object Clamp(object value)
			{
				return value;
			}

			public override bool IsValid(object value)
			{
				return true;
			}

			public override string ToDescriptionString()
			{
				return "# Acceptable values: " + string.Join(", ", KeyboardShortcut.AllKeyCodes);
			}
		}

		internal const string ModName = "TGServer";

		internal const string ModVersion = "1.0.2";

		internal const string Author = "Taeguk";

		private const string ModGUID = "Taeguk.TGServer";

		private static string ConfigFileName = "Taeguk.TGServer.cfg";

		private static string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("Taeguk.TGServer");

		public static readonly ManualLogSource TGServerLogger;

		private static readonly ConfigSync ConfigSync;

		public Texture2D tex;

		private Sprite mySprite;

		private SpriteRenderer sr;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public void Awake()
		{
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			Item item = new Item("lostscrolls", "TGCapeFlight");
			item.Name.English("Flight Cape");
			item.Description.English("A legendary cape that gives better flight abilties.");
			item.Crafting.Add(CraftingTable.MageTable, 1);
			item.RequiredItems.Add("CapeFeather", 1);
			item.RequiredItems.Add("TGWilScrollStart", 1);
			item.RequiredItems.Add("TGWilScroll1", 1);
			item.RequiredItems.Add("TGWilScroll2", 1);
			item.RequiredItems.Add("TGWilScroll3", 1);
			item.RequiredItems.Add("TGWilScroll4", 1);
			item.RequiredItems.Add("TGWilScroll5", 1);
			item.RequiredItems.Add("TGWilScroll6", 1);
			item.RequiredItems.Add("TGWilScroll7", 1);
			item.RequiredUpgradeItems.Add("TGRebelSpirit", 1);
			Item item2 = new Item("lostscrolls", "TGCapeFlash");
			item2.Name.English("Flash Cape");
			item2.Description.English("A legendary cape that gives superb moving speed.");
			item2.Crafting.Add(CraftingTable.MageTable, 1);
			item2.RequiredItems.Add("CapeLinen", 1);
			item2.RequiredItems.Add("TGWilScrollStart", 1);
			item2.RequiredItems.Add("TGWilScroll1", 1);
			item2.RequiredItems.Add("TGWilScroll2", 1);
			item2.RequiredItems.Add("TGWilScroll3", 1);
			item2.RequiredItems.Add("TGWilScroll4", 1);
			item2.RequiredItems.Add("TGWilScroll5", 1);
			item2.RequiredItems.Add("TGWilScroll6", 1);
			item2.RequiredItems.Add("TGWilScroll7", 1);
			item2.RequiredUpgradeItems.Add("TGRebelSpirit", 1);
			Item item3 = new Item("lostscrolls", "TGCapeShadow");
			item3.Name.English("Shadow Cape");
			item3.Description.English("A legendary cape that gives better hiding and sneaking abilities.");
			item3.Crafting.Add(CraftingTable.MageTable, 1);
			item3.RequiredItems.Add("CapeLox", 1);
			item3.RequiredItems.Add("TGWilScrollStart", 1);
			item3.RequiredItems.Add("TGWilScroll1", 1);
			item3.RequiredItems.Add("TGWilScroll2", 1);
			item3.RequiredItems.Add("TGWilScroll3", 1);
			item3.RequiredItems.Add("TGWilScroll4", 1);
			item3.RequiredItems.Add("TGWilScroll5", 1);
			item3.RequiredItems.Add("TGWilScroll6", 1);
			item3.RequiredItems.Add("TGWilScroll7", 1);
			item3.RequiredUpgradeItems.Add("TGRebelSpirit", 1);
			Item item4 = new Item("lostscrolls", "TGHSPotion");
			item4.Name.English("Spirit Potion");
			item4.Description.English("A complete formula of all fruits of the Holy Spirit. Grants user immunity to all damage for a period of time. Use it wisely.\r\n\r\nBring this in the Ashlands to spawn and face Damon.");
			item4.Crafting.Add(CraftingTable.MageTable, 2);
			item4.RequiredItems.Add("TGSpiritLove", 1);
			item4.RequiredItems.Add("TGSpiritJoy", 1);
			item4.RequiredItems.Add("TGSpiritPeace", 1);
			item4.RequiredItems.Add("TGSpiritForbearance", 1);
			item4.RequiredItems.Add("TGSpiritKindness", 1);
			item4.RequiredItems.Add("TGSpiritGoodness", 1);
			item4.RequiredItems.Add("TGSpiritGentle", 1);
			item4.RequiredItems.Add("TGSpiritControl", 1);
			item4.RequiredItems.Add("TGSpiritFaith", 1);
			Item item5 = new Item("lostscrolls", "TGSpiritLove");
			item5.Name.English("Spirit of Love");
			item5.Description.English("But God demonstrates his own love for us in this: While we were still sinners, Christ died for us.\r\n\r\nRomans 5:8, NIV\r\n\r\n<color=yellow>1 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item6 = new Item("lostscrolls", "TGSpiritJoy");
			item6.Name.English("Spirit of Joy");
			item6.Description.English("The joy of the LORD is your strength.\r\n\r\nNehemiah 8:10, NIV\r\n\r\n<color=yellow>2 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item7 = new Item("lostscrolls", "TGSpiritPeace");
			item7.Name.English("Spirit of Peace");
			item7.Description.English("Do not be anxious about anything, but in every situation, by prayer and petition, with thanksgiving, present your requests to God. And the peace of God, which transcends all understanding, will guard your hearts and your minds in Christ Jesus.\r\n\r\nPhilippians 4:6-7, NIV\r\n\r\n<color=yellow>3 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item8 = new Item("lostscrolls", "TGSpiritForbearance");
			item8.Name.English("Spirit of Forbearance");
			item8.Description.English("Be completely humble and gentle; be patient, bearing with one another in love.\r\n\r\nEphesians 4:2, NIV\r\n\r\n<color=yellow>4 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item9 = new Item("lostscrolls", "TGSpiritKindness");
			item9.Name.English("Spirit of Kindness");
			item9.Description.English("Be kind and compassionate to one another, forgiving each other, just as in Christ God forgave you.\r\n\r\nEphesians 4:32, NIV\r\n\r\n<color=yellow>5 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item10 = new Item("lostscrolls", "TGSpiritGoodness");
			item10.Name.English("Spirit of Goodness");
			item10.Description.English("Therefore, as we have opportunity, let us do good to all people, especially to those who belong to the family of believers.\r\n\r\nGalatians 6:10, NIV\r\n\r\n<color=yellow>6 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item11 = new Item("lostscrolls", "TGSpiritFaith");
			item11.Name.English("Spirit of Faithfullness");
			item11.Description.English("Blessed is the one who perseveres under trial because, having stood the test, that person will receive the crown of life that the Lord has promised to those who love him.\r\n\r\nJames 1:12, NIV\r\n\r\n<color=yellow>7 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item12 = new Item("lostscrolls", "TGSpiritGentle");
			item12.Name.English("Spirit of Gentleness");
			item12.Description.English("A gentle answer turns away wrath, but a harsh word stirs up anger.\r\n\r\nProverbs 15:1, NIV\r\n\r\n<color=yellow>8 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item13 = new Item("lostscrolls", "TGSpiritControl");
			item13.Name.English("Spirit of Self-Control");
			item13.Description.English("For the grace of God has appeared that offers salvation to all people. It teaches us to say “No” to ungodliness and worldly passions, and to live self-controlled, upright and godly lives in this present age.\r\n\r\nTitus 2:11-12, NIV\r\n\r\n<color=yellow>9 of 9 gifts of the Holy Spirit. Damon is after these spirits.</color>");
			Item item14 = new Item("lostscrolls", "TGRebelSpirit");
			item14.Name.English("Spirit of Rebellion");
			item14.Description.English("This is Damon's rebellious spirit againts God's authority. Rebellion started from the beginning of Creation. It was the deception of the serpent that caused Eve to rebel against God’s command. It is the very root of original sin and separates us from God and His Presence.\r\n\r\n<color=yellow>Purify this with any of the heavenly capes.</color>");
			Item item15 = new Item("lostscrolls", "TGWilScrollStart");
			item15.Name.English("Ancient Scroll");
			item15.Description.English("Damon has returned and is creating chaos once again in the heavenly realm.\r\n\r\nThe messages of the holy scrolls have been stolen and were sealed within the corrupted Vikings. Free them from the slavery of sin by defeating them to restore the messages of the scrolls.\r\n\r\n<color=yellow>Everytime you defeated a corrupted Viking, carry each scroll at the Ancient Stone Circle and WAIT for the messenger who carries the next restored page.\r\nThe first corrupted Viking is lurking around the Swamps.</color> ");
			item15.DropsFrom.Add("SeekerQueen", 1f);
			Item item16 = new Item("lostscrolls", "TGWilScroll1");
			item16.Name.English("Lost Scrolls page 1");
			item16.Description.English("We all have a STORY of brokenness, shame, guilt, and fear.\r\nOur struggle is real. We search for our purpose. We worry about the future. We get anxious. We get insecure. We try to make sense of our pain. We struggle with our identity. We are lost.\r\n\r\n“All of us, like sheep, have strayed away.\r\nWe have left God’s paths to follow our own…” (Isaiah 43:6 NLT)\r\n\r\n“For everyone has sinned; we all fall short of God’s glorious standard.” (Romans 3:23 NLT)\r\n\r\nWe’ve lost our connection with God. We’ve lost our relationship with the Father.\r\n\r\nBut OUR STORY doesn’t end here.\r\n\r\n<color=yellow>The corrupted assassin has been seen lurking in the Mountains.</color>");
			Item item17 = new Item("lostscrolls", "TGWilScroll2");
			item17.Name.English("Lost Scrolls page 2");
			item17.Description.English("Here’s the good news!\r\n\r\n“For God so loved the world that He gave His one and only Son, that whoever believes in Him shall not perish but have eternal life.” (John 3:16 NIV)\r\n\r\n<color=yellow>A corrupted mage has been found around the Plains.</color>");
			Item item18 = new Item("lostscrolls", "TGWilScroll3");
			item18.Name.English("Lost Scrolls page 3");
			item18.Description.English("HIS STORY\r\n\r\nBefore anything else existed, there was Christ, with God.\r\nHe has always been alive and is Himself God.\r\nHe created everything there is –\r\nNothing exists that He didn’t make.\r\nEternal life is in Him, and this gives light to all mankind.\r\nHis life is the light that shines through the darkness –\r\nAnd the darkness can never extinguish it.\r\n\r\nAnd Christ became a human being and lived here on earth\r\nAmong us and was full of loving forgiveness and truth\r\nAnd some of us have seen His glory – the glory of the only Son of the Heavenly Father!” (John 1:1-5, 14 TLB)\r\n\r\n<color=yellow>Search and defeat Gaurav in the Mistlands.</color>");
			Item item19 = new Item("lostscrolls", "TGWilScroll4");
			item19.Name.English("Lost Scrolls page 4");
			item19.Description.English("He came.\r\nHe became just like us.\r\nHe lived among us.\r\nHe died for us.\r\nHe rose from the dead.\r\nHe conquered sin and death.\r\n\r\nThis is LOVE\r\nJesus Christ laid down his life for us. (1 John 3:16)\r\n\r\n<color=yellow>Search and defeat Basar in the Ashlands.</color>");
			Item item20 = new Item("lostscrolls", "TGWilScroll5");
			item20.Name.English("Lost Scrolls page 5");
			item20.Description.English("Christ proved God’s passionate love for us by dying in our place while we were still lost and ungodly. (Romans 5:8 TPT)\r\n\r\nThis is the STORY of redemption.\r\n\r\nYet through His powerful declaration of acquittal,\r\nGod freely gives away His righteousness.\r\nHis gift of love and favor now cascades over us,\r\nAll because Jesus, The Anointed One,\r\nHas liberated us from the guilt, punishment, and power of sin!” (Romans 3:24 TPT)\r\n\r\n<color=yellow>Search and defeat Kreas in the Deepnorth.</color>");
			Item item21 = new Item("lostscrolls", "TGWilScroll6");
			item21.Name.English("Lost Scrolls page 6");
			item21.Description.English("The Turning Point\r\n\r\nAdmit that you are a sinner.\r\nAcknowledge your need of a Savior.\r\nAccept Jesus to be your Lord and Savior.\r\n\r\nFor it is by GRACE you have been SAVED, through FAITH – and this is not from yourselves, it is the GIFT of GOD.” (Ephesians 2:8 NIV)\r\n\r\nThis means that anyone who belongs to Christ has become a new person. The old life is gone; a new life has begun! (2 Corinthians 5:17 NLT)\r\n\r\n<color=yellow>Search and defeat Avid in the Ashlands.</color>");
			Item item22 = new Item("lostscrolls", "TGWilScroll7");
			item22.Name.English("Lost Scrolls page 7");
			item22.Description.English("To all who believed Him and accepted Him, He gave the right to become children of God.” (John 1:12 NLT)\r\n\r\nIn Christ,\r\nYou are forgiven,\r\nYou are accepted,\r\nYou are loved.\r\n\r\nThis is the greatest LOVE STORY ever told.\r\n\r\n<color=yellow>This is the last page of the lost scrolls. Combine all 8 with a cape to receive the grace of the scrolls.</color>");
			Item item23 = new Item("tgserver", "TGcoin");
			item23.Name.English("TG Coin");
			item23.Description.English("A gift for server supporters. Use to trade with items from the donator trader.");
			Item item24 = new Item("tgserver", "TGcoupon");
			item24.Name.English("Server Coupon");
			item24.Description.English("Use this to trade cool items at the Rewards Traders at the Mystical Tower.");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

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

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

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

		private ConfigEntry<T> config<[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		static TGServerPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			TGServerLogger = Logger.CreateLogSource("TGServer");
			ConfigSync = new ConfigSync("Taeguk.TGServer")
			{
				DisplayName = "TGServer",
				CurrentVersion = "1.0.2",
				MinimumRequiredVersion = "1.0.2"
			};
			_serverConfigLocked = null;
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			TGServerPlugin.TGServerLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("TGServer_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_TGServer_Version);
			TGServerPlugin.TGServerLogger.LogDebug((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("1.0.2");
			peer.m_rpc.Invoke("TGServer_VersionCheck", new object[1] { val });
		}
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			TGServerPlugin.TGServerLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + TGServerPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				TGServerPlugin.TGServerLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_TGServer_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			TGServerPlugin.TGServerLogger.LogInfo((object)("Version check, local: 1.0.2,  remote: " + text));
			if (text != "1.0.2")
			{
				TGServerPlugin.ConnectionError = "TGServer Installed: 1.0.2\n Needed: " + text;
				if (ZNet.instance.IsServer())
				{
					TGServerPlugin.TGServerLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting"));
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				TGServerPlugin.TGServerLogger.LogInfo((object)"Received same version from server!");
			}
			else
			{
				TGServerPlugin.TGServerLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
				ValidatedPeers.Add(rpc);
			}
		}
	}
}
namespace StatusEffectManager
{
	[PublicAPI]
	[Description("The ItemDrop effect to apply the status effect")]
	public enum EffectType
	{
		Equip,
		Attack,
		Consume,
		Set
	}
	public struct SE_Item
	{
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(1)]
		public StatusEffect Effect;

		public EffectType Type;
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[PublicAPI]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	public class CustomSE
	{
		private static readonly List<CustomSE> RegisteredEffects = new List<CustomSE>();

		private static readonly Dictionary<StatusEffect, CustomSE> CustomEffectMap = new Dictionary<StatusEffect, CustomSE>();

		internal static readonly List<StatusEffect> CustomSEs = new List<StatusEffect>();

		internal static readonly Dictionary<SE_Item, string> AddToPrefabs = new Dictionary<SE_Item, string>();

		[Description("Instance of the StatusEffect.")]
		public readonly StatusEffect Effect;

		public EffectType Type;

		private string _folderName = "icons";

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private AssetBundle _assetBundle;

		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		public Sprite IconSprite = null;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private string IconName = null;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private LocalizeKey _name;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static Localization _english;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object _configSync;

		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		public string Icon
		{
			[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
			get
			{
				return IconName;
			}
			[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
			set
			{
				IconName = value;
				IconSprite = ((IconName == null) ? null : loadSprite(IconName));
				Effect.m_icon = IconSprite;
			}
		}

		[Description("Sets the in-game name for the StatusEffect")]
		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				StatusEffect effect = Effect;
				if (effect.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(effect.m_name);
				}
				else
				{
					string text = "$statuseffect_" + ((Object)Effect).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(effect.m_name);
					effect.m_name = text;
				}
				return _name;
			}
		}

		private static Localization english
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				if (_english == null)
				{
					_english = new Localization();
					_english.SetupLanguage("English");
				}
				return _english;
			}
		}

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

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object configSync
		{
			[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		public CustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
			: this(EffectManager.RegisterAssetBundle(assetBundleFileName, folderName), customEffectName)
		{
		}

		public CustomSE(AssetBundle bundle, string customEffectName)
		{
			Effect = EffectManager.RegisterCustomSE(bundle, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[Effect] = this;
		}

		public CustomSE(string customEffectName)
		{
			Effect = ScriptableObject.CreateInstance<StatusEffect>();
			EffectManager.RegisterCustomSE(Effect, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[Effect] = this;
		}

		[return: <bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((_folderName == "") ? "" : ".") + _folderName + "." + name);
			if (manifestResourceStream == null)
			{
				return null;
			}
			manifestResourceStream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		[return: <bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private Texture2D loadTexture(string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			byte[] array = ReadEmbeddedFileBytes(name);
			if (array != null)
			{
				Texture2D val = new Texture2D(0, 0);
				ImageConversion.LoadImage(val, array);
				return val;
			}
			return null;
		}

		private Sprite loadSprite(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = loadTexture(name);
			if (val != null)
			{
				return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), Vector2.zero);
			}
			AssetBundle assetBundle = _assetBundle;
			Sprite val2 = ((assetBundle != null) ? assetBundle.LoadAsset<Sprite>(name) : null);
			if (val2 != null)
			{
				return val2;
			}
			throw new FileNotFoundException("Could not find a file named " + name + " for the effect icon");
		}

		public void AddSEToPrefab(CustomSE customSE, string prefabName)
		{
			SE_Item sE_Item = default(SE_Item);
			sE_Item.Effect = customSE.Effect;
			sE_Item.Type = customSE.Type;
			SE_Item key = sE_Item;
			AddToPrefabs.Add(key, prefabName);
		}

		private static ConfigEntry<T> config<[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] T>(string group, string name, T value, ConfigDescription description)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T))
				.Invoke(configSync, new object[1] { val });
			return val;
		}

		private static ConfigEntry<T> config<[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] T>(string group, string name, T value, string description)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	public class LocalizeKey
	{
		public readonly string Key;

		public LocalizeKey(string key)
		{
			Key = key.Replace("$", "");
		}

		public LocalizeKey English(string key)
		{
			return addForLang("English", key);
		}

		public LocalizeKey Swedish(string key)
		{
			return addForLang("Swedish", key);
		}

		public LocalizeKey French(string key)
		{
			return addForLang("French", key);
		}

		public LocalizeKey Italian(string key)
		{
			return addForLang("Italian", key);
		}

		public LocalizeKey German(string key)
		{
			return addForLang("German", key);
		}

		public LocalizeKey Spanish(string key)
		{
			return addForLang("Spanish", key);
		}

		public LocalizeKey Russian(string key)
		{
			return addForLang("Russian", key);
		}

		public LocalizeKey Romanian(string key)
		{
			return addForLang("Romanian", key);
		}

		public LocalizeKey Bulgarian(string key)
		{
			return addForLang("Bulgarian", key);
		}

		public LocalizeKey Macedonian(string key)
		{
			return addForLang("Macedonian", key);
		}

		public LocalizeKey Finnish(string key)
		{
			return addForLang("Finnish", key);
		}

		public LocalizeKey Danish(string key)
		{
			return addForLang("Danish", key);
		}

		public LocalizeKey Norwegian(string key)
		{
			return addForLang("Norwegian", key);
		}

		public LocalizeKey Icelandic(string key)
		{
			return addForLang("Icelandic", key);
		}

		public LocalizeKey Turkish(string key)
		{
			return addForLang("Turkish", key);
		}

		public LocalizeKey Lithuanian(string key)
		{
			return addForLang("Lithuanian", key);
		}

		public LocalizeKey Czech(string key)
		{
			return addForLang("Czech", key);
		}

		public LocalizeKey Hungarian(string key)
		{
			return addForLang("Hungarian", key);
		}

		public LocalizeKey Slovak(string key)
		{
			return addForLang("Slovak", key);
		}

		public LocalizeKey Polish(string key)
		{
			return addForLang("Polish", key);
		}

		public LocalizeKey Dutch(string key)
		{
			return addForLang("Dutch", key);
		}

		public LocalizeKey Portuguese_European(string key)
		{
			return addForLang("Portuguese_European", key);
		}

		public LocalizeKey Portuguese_Brazilian(string key)
		{
			return addForLang("Portuguese_Brazilian", key);
		}

		public LocalizeKey Chinese(string key)
		{
			return addForLang("Chinese", key);
		}

		public LocalizeKey Japanese(string key)
		{
			return addForLang("Japanese", key);
		}

		public LocalizeKey Korean(string key)
		{
			return addForLang("Korean", key);
		}

		public LocalizeKey Hindi(string key)
		{
			return addForLang("Hindi", key);
		}

		public LocalizeKey Thai(string key)
		{
			return addForLang("Thai", key);
		}

		public LocalizeKey Abenaki(string key)
		{
			return addForLang("Abenaki", key);
		}

		public LocalizeKey Croatian(string key)
		{
			return addForLang("Croatian", key);
		}

		public LocalizeKey Georgian(string key)
		{
			return addForLang("Georgian", key);
		}

		public LocalizeKey Greek(string key)
		{
			return addForLang("Greek", key);
		}

		public LocalizeKey Serbian(string key)
		{
			return addForLang("Serbian", key);
		}

		public LocalizeKey Ukrainian(string key)
		{
			return addForLang("Ukrainian", key);
		}

		private LocalizeKey addForLang(string lang, string value)
		{
			if (Localization.instance.GetSelectedLanguage() == lang)
			{
				Localization.instance.AddWord(Key, value);
			}
			else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key))
			{
				Localization.instance.AddWord(Key, value);
			}
			return this;
		}
	}
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	public static class EffectManager
	{
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
		private struct BundleId
		{
			[UsedImplicitly]
			public string assetBundleFileName;

			[UsedImplicitly]
			public string folderName;
		}

		private static readonly Dictionary<BundleId, AssetBundle> bundleCache;

		static EffectManager()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			bundleCache = new Dictionary<BundleId, AssetBundle>();
			Harmony val = new Harmony("org.bepinex.helpers.StatusEffectManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets")
		{
			BundleId bundleId = default(BundleId);
			bundleId.assetBundleFileName = assetBundleFileName;
			bundleId.folderName = folderName;
			BundleId key = bundleId;
			if (!bundleCache.TryGetValue(key, out var value))
			{
				Dictionary<BundleId, AssetBundle> dictionary = bundleCache;
				AssetBundle? obj = ((IEnumerable<AssetBundle>)Resources.FindObjectsOfTypeAll<AssetBundle>()).FirstOrDefault((Func<AssetBundle, bool>)([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((folderName == "") ? "" : ".") + folderName + "." + assetBundleFileName));
				AssetBundle result = obj;
				dictionary[key] = obj;
				return result;
			}
			return value;
		}

		public static StatusEffect RegisterCustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
		{
			return RegisterCustomSE(RegisterAssetBundle(assetBundleFileName, folderName), customEffectName);
		}

		public static StatusEffect RegisterCustomSE(AssetBundle assets, string customEffectName)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			StatusEffect val = (StatusEffect)assets.LoadAsset<ScriptableObject>(customEffectName);
			CustomSE.CustomSEs.Add(val);
			return val;
		}

		public static StatusEffect RegisterCustomSE(StatusEffect customSE, string customEffectName)
		{
			((Object)customSE).name = customEffectName;
			CustomSE.CustomSEs.Add(customSE);
			return customSE;
		}

		[HarmonyPriority(700)]
		private static void Patch_ObjectDBInit(ObjectDB __instance)
		{
			foreach (StatusEffect customSE in CustomSE.CustomSEs)
			{
				if (!__instance.m_StatusEffects.Contains(customSE))
				{
					__instance.m_StatusEffects.Add(customSE);
				}
			}
			__instance.UpdateItemHashes();
		}

		[HarmonyPriority(700)]
		private static void Patch_ZNetSceneAwake(ZNetScene __instance)
		{
			foreach (KeyValuePair<SE_Item, string> addToPrefab in CustomSE.AddToPrefabs)
			{
				try
				{
					GameObject prefab = __instance.GetPrefab(addToPrefab.Value);
					ItemDrop val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<ItemDrop>() : prefab.GetComponentInChildren<ItemDrop>());
					Aoe val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Aoe>() : prefab.GetComponentInChildren<Aoe>());
					EffectArea val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<EffectArea>() : prefab.GetComponentInChildren<EffectArea>());
					if (Object.op_Implicit((Object)(object)val))
					{
						switch (addToPrefab.Key.Type)
						{
						case EffectType.Equip:
							val.m_itemData.m_shared.m_equipStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Attack:
							val.m_itemData.m_shared.m_attackStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Consume:
							val.m_itemData.m_shared.m_consumeStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Set:
							val.m_itemData.m_shared.m_setSize = 1;
							val.m_itemData.m_shared.m_setName = ((Object)addToPrefab.Key.Effect).name;
							val.m_itemData.m_shared.m_setStatusEffect = addToPrefab.Key.Effect;
							break;
						default:
							throw new ArgumentOutOfRangeException();
						}
					}
					else if (Object.op_Implicit((Object)(object)val2))
					{
						val2.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else if (Object.op_Implicit((Object)(object)val3))
					{
						val3.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else
					{
						Debug.LogWarning((object)("The prefab '" + ((Object)prefab).name + "' does not have an ItemDrop, AOE, or EffectArea component. Cannot add the StatusEffect to the prefab."));
					}
				}
				catch (Exception)
				{
					Debug.LogWarning((object)"BROKE");
				}
			}
		}
	}
}
namespace SkillManager
{
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	public class Skill
	{
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
		public static class LocalizationCache
		{
			private static readonly Dictionary<string, Localization> localizations = new Dictionary<string, Localization>();

			internal static void LocalizationPostfix(Localization __instance, string language)
			{
				string key = localizations.FirstOrDefault([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (KeyValuePair<string, Localization> l) => l.Value == __instance).Key;
				if (key != null)
				{
					localizations.Remove(key);
				}
				if (!localizations.ContainsKey(language))
				{
					localizations.Add(language, __instance);
				}
			}

			public static Localization ForLanguage([<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] string language = null)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out var value))
				{
					return value;
				}
				value = new Localization();
				if (language != null)
				{
					value.SetupLanguage(language);
				}
				return value;
			}
		}

		[PublicAPI]
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
		public class LocalizeKey
		{
			private static readonly List<LocalizeKey> keys = new List<LocalizeKey>();

			public readonly string Key;

			public readonly Dictionary<string, string> Localizations = new Dictionary<string, string>();

			public LocalizeKey(string key)
			{
				Key = key.Replace("$", "");
			}

			public void Alias(string alias)
			{
				Localizations.Clear();
				if (!alias.Contains("$"))
				{
					alias = "$" + alias;
				}
				Localizations["alias"] = alias;
				Localization.instance.AddWord(Key, Localization.instance.Localize(alias));
			}

			public LocalizeKey English(string key)
			{
				return addForLang("English", key);
			}

			public LocalizeKey Swedish(string key)
			{
				return addForLang("Swedish", key);
			}

			public LocalizeKey French(string key)
			{
				return addForLang("French", key);
			}

			public LocalizeKey Italian(string key)
			{
				return addForLang("Italian", key);
			}

			public LocalizeKey German(string key)
			{
				return addForLang("German", key);
			}

			public LocalizeKey Spanish(string key)
			{
				return addForLang("Spanish", key);
			}

			public LocalizeKey Russian(string key)
			{
				return addForLang("Russian", key);
			}

			public LocalizeKey Romanian(string key)
			{
				return addForLang("Romanian", key);
			}

			public LocalizeKey Bulgarian(string key)
			{
				return addForLang("Bulgarian", key);
			}

			public LocalizeKey Macedonian(string key)
			{
				return addForLang("Macedonian", key);
			}

			public LocalizeKey Finnish(string key)
			{
				return addForLang("Finnish", key);
			}

			public LocalizeKey Danish(string key)
			{
				return addForLang("Danish", key);
			}

			public LocalizeKey Norwegian(string key)
			{
				return addForLang("Norwegian", key);
			}

			public LocalizeKey Icelandic(string key)
			{
				return addForLang("Icelandic", key);
			}

			public LocalizeKey Turkish(string key)
			{
				return addForLang("Turkish", key);
			}

			public LocalizeKey Lithuanian(string key)
			{
				return addForLang("Lithuanian", key);
			}

			public LocalizeKey Czech(string key)
			{
				return addForLang("Czech", key);
			}

			public LocalizeKey Hungarian(string key)
			{
				return addForLang("Hungarian", key);
			}

			public LocalizeKey Slovak(string key)
			{
				return addForLang("Slovak", key);
			}

			public LocalizeKey Polish(string key)
			{
				return addForLang("Polish", key);
			}

			public LocalizeKey Dutch(string key)
			{
				return addForLang("Dutch", key);
			}

			public LocalizeKey Portuguese_European(string key)
			{
				return addForLang("Portuguese_European", key);
			}

			public LocalizeKey Portuguese_Brazilian(string key)
			{
				return addForLang("Portuguese_Brazilian", key);
			}

			public LocalizeKey Chinese(string key)
			{
				return addForLang("Chinese", key);
			}

			public LocalizeKey Japanese(string key)
			{
				return addForLang("Japanese", key);
			}

			public LocalizeKey Korean(string key)
			{
				return addForLang("Korean", key);
			}

			public LocalizeKey Hindi(string key)
			{
				return addForLang("Hindi", key);
			}

			public LocalizeKey Thai(string key)
			{
				return addForLang("Thai", key);
			}

			public LocalizeKey Abenaki(string key)
			{
				return addForLang("Abenaki", key);
			}

			public LocalizeKey Croatian(string key)
			{
				return addForLang("Croatian", key);
			}

			public LocalizeKey Georgian(string key)
			{
				return addForLang("Georgian", key);
			}

			public LocalizeKey Greek(string key)
			{
				return addForLang("Greek", key);
			}

			public LocalizeKey Serbian(string key)
			{
				return addForLang("Serbian", key);
			}

			public LocalizeKey Ukrainian(string key)
			{
				return addForLang("Ukrainian", key);
			}

			private LocalizeKey addForLang(string lang, string value)
			{
				Localizations[lang] = value;
				if (Localization.instance.GetSelectedLanguage() == lang)
				{
					Localization.instance.AddWord(Key, value);
				}
				else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key))
				{
					Localization.instance.AddWord(Key, value);
				}
				return this;
			}

			[HarmonyPriority(300)]
			internal static void AddLocalizedKeys(Localization __instance, string language)
			{
				foreach (LocalizeKey key in keys)
				{
					string value2;
					if (key.Localizations.TryGetValue(language, out var value) || key.Localizations.TryGetValue("English", out value))
					{
						__instance.AddWord(key.Key, value);
					}
					else if (key.Localizations.TryGetValue("alias", out value2))
					{
						Localization.instance.AddWord(key.Key, Localization.instance.Localize(value2));
					}
				}
			}
		}

		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
			[UsedImplicitly]
			public string Category;
		}

		[HarmonyPatch(typeof(Skills), "IsSkillValid")]
		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)]
		private static class Patch_Skills_IsSkillValid
		{
			private static void Postfix(SkillType type, ref bool __result)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				if (!__result && skills.ContainsKey(type))
				{
					__result = true;
				}
			}
		}

		private static readonly Dictionary<SkillType, Skill> skills;

		internal static readonly Dictionary<string, Skill> skillByName;

		private readonly string skillName;

		private readonly string internalSkillName;

		private readonly SkillDef skillDef;

		public readonly LocalizeKey Name;

		public readonly LocalizeKey Description;

		private float skillEffectFactor = 1f;

		public bool Configurable = false;

		private static bool InitializedTerminal;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static Localization _english;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object _configSync;

		public float SkillGainFactor
		{
			get
			{
				return skillDef.m_increseStep;
			}
			set
			{
				skillDef.m_increseStep = value;
				this.SkillGainFactorChanged?.Invoke(value);
			}
		}

		public float SkillEffectFactor
		{
			get
			{
				return skillEffectFactor;
			}
			set
			{
				skillEffectFactor = value;
				this.SkillEffectFactorChanged?.Invoke(value);
			}
		}

		private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English"));

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Expected O, but got Unknown
				object obj = _plugin;
				if (obj == null)
				{
					BaseUnityPlugin val = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)Assembly.GetExecutingAssembly().DefinedTypes.First([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
					_plugin = val;
					obj = (object)val;
				}
				return (BaseUnityPlugin)obj;
			}
		}

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object configSync
		{
			[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " SkillManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		[method: <0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
		[field: <bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		public event Action<float> SkillGainFactorChanged;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		[method: <0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
		[field: <bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		public event Action<float> SkillEffectFactorChanged;

		public Skill(string englishName, string icon)
			: this(englishName, loadSprite(icon, 64, 64))
		{
		}

		public Skill(string englishName, Sprite icon)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			SkillType val = fromName(englishName);
			string text = new Regex("[^a-zA-Z]").Replace(englishName, "_");
			skills[val] = this;
			skillByName[englishName] = this;
			skillDef = new SkillDef
			{
				m_description = "$skilldesc_" + text,
				m_icon = icon,
				m_increseStep = 1f,
				m_skill = val
			};
			internalSkillName = text;
			skillName = englishName;
			Name = new LocalizeKey("skill_" + ((object)(SkillType)(ref val)).ToString()).English(englishName);
			Description = new LocalizeKey("skilldesc_" + text);
		}

		public static SkillType fromName(string englishName)
		{
			return (SkillType)Math.Abs(StringExtensionMethods.GetStableHashCode(englishName));
		}

		static Skill()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01ad: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			skills = new Dictionary<SkillType, Skill>();
			skillByName = new Dictionary<string, Skill>();
			InitializedTerminal = false;
			hasConfigSync = true;
			Harmony val = new Harmony("org.bepinex.helpers.skillmanager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "GetSkillDef", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_GetSkillDef", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "CheatRaiseSkill", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_CheatRaiseskill", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "CheatResetSkill", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_CheatResetSkill", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Terminal), "InitTerminal", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Terminal_InitTerminal_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Terminal_InitTerminal", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void Patch_FejdStartup()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			foreach (Skill skill in skills.Values)
			{
				if (skill.Configurable)
				{
					string key = skill.Name.Key;
					string group = new Regex("['[\"\\]]").Replace(english.Localize(key), "").Trim();
					string category = Localization.instance.Localize(key).Trim();
					ConfigEntry<float> skillGain = config(group, "Skill gain factor", skill.SkillGainFactor, new ConfigDescription("The rate at which you gain experience for the skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), new object[1]
					{
						new ConfigurationManagerAttributes
						{
							Category = category
						}
					}));
					skill.SkillGainFactor = skillGain.Value;
					skillGain.SettingChanged += [<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (object _, EventArgs _) =>
					{
						skill.SkillGainFactor = skillGain.Value;
					};
					ConfigEntry<float> skillEffect = config(group, "Skill effect factor", skill.SkillEffectFactor, new ConfigDescription("The power of the skill, based on the default power.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), new object[1]
					{
						new ConfigurationManagerAttributes
						{
							Category = category
						}
					}));
					skill.SkillEffectFactor = skillEffect.Value;
					skillEffect.SettingChanged += [<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (object _, EventArgs _) =>
					{
						skill.SkillEffectFactor = skillEffect.Value;
					};
				}
			}
		}

		private static void Patch_Skills_GetSkillDef([<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] ref SkillDef __result, List<SkillDef> ___m_skills, SkillType type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (__result == null)
			{
				SkillDef val = GetSkillDef(type);
				if (val != null)
				{
					___m_skills.Add(val);
					__result = val;
				}
			}
		}

		private static bool Patch_Skills_CheatRaiseskill(Skills __instance, string name, float value, Player ___m_player)
		{
			//IL_0019: 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_0025: 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)
			foreach (SkillType key in skills.Keys)
			{
				SkillType current = key;
				Skill skill = skills[current];
				if (string.Equals(skill.internalSkillName, name, StringComparison.CurrentCultureIgnoreCase))
				{
					Skill skill2 = __instance.GetSkill(current);
					skill2.m_level += value;
					skill2.m_level = Mathf.Clamp(skill2.m_level, 0f, 100f);
					((Character)___m_player).Message((MessageType)1, "Skill increased " + Localization.instance.Localize("$skill_" + ((object)(SkillType)(ref current)).ToString()) + ": " + (int)skill2.m_level, 0, skill2.m_info.m_icon);
					Console.instance.Print("Skill " + skill.internalSkillName + " = " + skill2.m_level);
					return false;
				}
			}
			return true;
		}

		private static bool Patch_Skills_CheatResetSkill(Skills __instance, string name)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			foreach (SkillType key in skills.Keys)
			{
				Skill skill = skills[key];
				if (string.Equals(skill.internalSkillName, name, StringComparison.CurrentCultureIgnoreCase))
				{
					__instance.ResetSkill(key);
					Console.instance.Print("Skill " + skill.internalSkillName + " reset");
					return false;
				}
			}
			return true;
		}

		private static void Patch_Terminal_InitTerminal_Prefix()
		{
			InitializedTerminal = Terminal.m_terminalInitialized;
		}

		private static void Patch_Terminal_InitTerminal()
		{
			if (!InitializedTerminal)
			{
				AddSkill(Terminal.commands["raiseskill"]);
				AddSkill(Terminal.commands["resetskill"]);
			}
			static void AddSkill(ConsoleCommand command)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				ConsoleOptionsFetcher fetcher = command.m_tabOptionsFetcher;
				command.m_tabOptionsFetcher = (ConsoleOptionsFetcher)([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] () =>
				{
					List<string> list = fetcher.Invoke();
					list.AddRange(skills.Values.Select([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Skill skill) => skill.internalSkillName));
					return list;
				});
			}
		}

		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
		private static SkillDef GetSkillDef(SkillType skillType)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!skills.ContainsKey(skillType))
			{
				return null;
			}
			Skill skill = skills[skillType];
			return skill.skillDef;
		}

		private static byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static Texture2D loadTexture(string name)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			Texture2D val = new Texture2D(0, 0);
			ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("icons." + name));
			return val;
		}

		private static Sprite loadSprite(string name, int width, int height)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(loadTexture(name), new Rect(0f, 0f, (float)width, (float)height), Vector2.zero);
		}

		private static ConfigEntry<T> config<[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] T>(string group, string name, T value, ConfigDescription description)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T))
				.Invoke(configSync, new object[1] { val });
			return val;
		}

		private static ConfigEntry<T> config<[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)] T>(string group, string name, T value, string description)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[PublicAPI]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	public static class SkillExtensions
	{
		public static float GetSkillFactor(this Character character, string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return character.GetSkillFactor(Skill.fromName(name)) * Skill.skillByName[name].SkillEffectFactor;
		}

		public static float GetSkillFactor(this Skills skills, string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return skills.GetSkillFactor(Skill.fromName(name)) * Skill.skillByName[name].SkillEffectFactor;
		}

		public static void RaiseSkill(this Character character, string name, float value = 1f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			character.RaiseSkill(Skill.fromName(name), value);
		}

		public static void RaiseSkill(this Skills skill, string name, float value = 1f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			skill.RaiseSkill(Skill.fromName(name), value);
		}
	}
}
namespace PieceManager
{
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	public static class MaterialReplacer
	{
		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)]
		public enum ShaderType
		{
			PieceShader,
			VegetationShader,
			RockShader,
			RugShader,
			GrassShader,
			CustomCreature,
			UseUnityShader
		}

		private static readonly Dictionary<GameObject, bool> ObjectToSwap;

		internal static readonly Dictionary<string, Material> OriginalMaterials;

		private static readonly Dictionary<GameObject, ShaderType> ObjectsForShaderReplace;

		private static bool hasRun;

		static MaterialReplacer()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			OriginalMaterials = new Dictionary<string, Material>();
			ObjectToSwap = new Dictionary<GameObject, bool>();
			ObjectsForShaderReplace = new Dictionary<GameObject, ShaderType>();
			Harmony val = new Harmony("org.bepinex.helpers.PieceManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZoneSystem), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void RegisterGameObjectForShaderSwap(GameObject go, ShaderType type)
		{
			if (!ObjectsForShaderReplace.ContainsKey(go))
			{
				ObjectsForShaderReplace.Add(go, type);
			}
		}

		public static void RegisterGameObjectForMatSwap(GameObject go, bool isJotunnMock = false)
		{
			if (!ObjectToSwap.ContainsKey(go))
			{
				ObjectToSwap.Add(go, isJotunnMock);
			}
		}

		private static void GetAllMaterials()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				OriginalMaterials[((Object)val).name] = val;
			}
		}

		[HarmonyPriority(700)]
		private static void ReplaceAllMaterialsWithOriginal()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType == 4 || hasRun)
			{
				return;
			}
			if (OriginalMaterials.Count <= 0)
			{
				GetAllMaterials();
			}
			foreach (Renderer item in ObjectToSwap.Keys.SelectMany([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (GameObject gameObject) => gameObject.GetComponentsInChildren<Renderer>(true)))
			{
				ObjectToSwap.TryGetValue(((Component)item).gameObject, out var value);
				Material[] array = (Material[])(object)new Material[item.sharedMaterials.Length];
				int num = 0;
				Material[] sharedMaterials = item.sharedMaterials;
				foreach (Material val in sharedMaterials)
				{
					string text = (value ? "JVLmock_" : "_REPLACE_");
					if (((Object)val).name.StartsWith(text, StringComparison.Ordinal))
					{
						string text2 = ((Object)val).name.Replace(" (Instance)", string.Empty).Replace(text, "");
						if (OriginalMaterials.ContainsKey(text2))
						{
							array[num] = OriginalMaterials[text2];
						}
						else
						{
							Debug.LogWarning((object)("No suitable material found to replace: " + text2));
							OriginalMaterials[text2] = array[num];
						}
						num++;
					}
				}
				item.materials = array;
				item.sharedMaterials = array;
			}
			foreach (Renderer item2 in ObjectsForShaderReplace.Keys.SelectMany([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (GameObject gameObject) => gameObject.GetComponentsInChildren<Renderer>(true)))
			{
				ObjectsForShaderReplace.TryGetValue(((Component)((Component)item2).gameObject.transform.root).gameObject, out var value2);
				if ((Object)(object)item2 == (Object)null)
				{
					continue;
				}
				Material[] sharedMaterials2 = item2.sharedMaterials;
				foreach (Material val2 in sharedMaterials2)
				{
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					string name = ((Object)val2.shader).name;
					switch (value2)
					{
					case ShaderType.PieceShader:
						val2.shader = Shader.Find("Custom/Piece");
						break;
					case ShaderType.VegetationShader:
						val2.shader = Shader.Find("Custom/Vegetation");
						break;
					case ShaderType.RockShader:
						val2.shader = Shader.Find("Custom/StaticRock");
						break;
					case ShaderType.RugShader:
						val2.shader = Shader.Find("Custom/Rug");
						break;
					case ShaderType.GrassShader:
						val2.shader = Shader.Find("Custom/Grass");
						break;
					case ShaderType.CustomCreature:
						val2.shader = Shader.Find("Custom/Creature");
						break;
					case ShaderType.UseUnityShader:
						if ((Object)(object)Shader.Find(name) != (Object)null)
						{
							val2.shader = Shader.Find(name);
						}
						break;
					default:
						val2.shader = Shader.Find("ToonDeferredShading2017");
						break;
					}
				}
			}
			hasRun = true;
		}
	}
	[PublicAPI]
	public enum CraftingTable
	{
		None,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	public class ExtensionList
	{
		public readonly List<ExtensionConfig> ExtensionStations = new List<ExtensionConfig>();

		public void Set(CraftingTable table, int maxStationDistance = 5)
		{
			ExtensionStations.Add(new ExtensionConfig
			{
				Table = table,
				maxStationDistance = maxStationDistance
			});
		}

		public void Set(string customTable, int maxStationDistance = 5)
		{
			ExtensionStations.Add(new ExtensionConfig
			{
				Table = CraftingTable.Custom,
				custom = customTable,
				maxStationDistance = maxStationDistance
			});
		}
	}
	public struct ExtensionConfig
	{
		public CraftingTable Table;

		public float maxStationDistance;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		public string custom;
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	public class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

		public void Set(CraftingTable table)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = table
			});
		}

		public void Set(string customTable)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				custom = customTable
			});
		}
	}
	public struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		public string custom;
	}
	[PublicAPI]
	public enum BuildPieceCategory
	{
		Misc = 0,
		Crafting = 1,
		Building = 2,
		Furniture = 3,
		All = 100,
		Custom = 99
	}
	[PublicAPI]
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	public class RequiredResourcesList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public void Add(string item, int amount, bool recover)
		{
			Requirements.Add(new Requirement
			{
				itemName = item,
				amount = amount,
				recover = recover
			});
		}
	}
	public struct Requirement
	{
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(1)]
		public string itemName;

		public int amount;

		public bool recover;
	}
	public struct SpecialProperties
	{
		[Description("Admins should be the only ones that can build this piece.")]
		public bool AdminOnly;

		[Description("Turns off generating a config for this build piece.")]
		public bool NoConfig;
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	public class BuildingPieceCategory
	{
		public BuildPieceCategory Category;

		public string custom = "";

		public void Set(BuildPieceCategory category)
		{
			Category = category;
		}

		public void Set(string customCategory)
		{
			Category = BuildPieceCategory.Custom;
			custom = customCategory;
		}
	}
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	public class PieceTool
	{
		public readonly HashSet<string> Tools = new HashSet<string>();

		public void Add(string tool)
		{
			Tools.Add(tool);
		}
	}
	[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(1)]
	[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
	[PublicAPI]
	public class BuildPiece
	{
		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
		internal class PieceConfig
		{
			public ConfigEntry<string> craft = null;

			public ConfigEntry<BuildPieceCategory> category = null;

			public ConfigEntry<string> customCategory = null;

			public ConfigEntry<string> tools = null;

			public ConfigEntry<CraftingTable> extensionTable = null;

			public ConfigEntry<string> customExtentionTable = null;

			public ConfigEntry<float> maxStationDistance = null;

			public ConfigEntry<CraftingTable> table = null;

			public ConfigEntry<string> customTable = null;
		}

		[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
			public string Category;

			[UsedImplicitly]
			[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(0)]
		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

			public SerializedRequirements(List<Requirement> reqs)
			{
				Reqs = reqs;
			}

			public SerializedRequirements(string reqs)
			{
				Reqs = reqs.Split(new char[1] { ',' }).Select([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					Requirement result = default(Requirement);
					result.itemName = array[0];
					result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2);
					bool result3 = default(bool);
					result.recover = array.Length <= 2 || !bool.TryParse(array[2], out result3) || result3;
					return result;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}:{r.recover}"));
			}

			public static Requirement[] toPieceReqs(SerializedRequirements craft)
			{
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Requirement r) =>
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references)
					ItemDrop val2 = ResItem(r);
					return (val2 == null) ? ((Requirement)null) : new Requirement
					{
						m_amount = r.amount,
						m_resItem = val2,
						m_recover = r.recover
					};
				}));
				return dictionary.Values.Where([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Requirement v) => v != null).ToArray();
				[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
				static ItemDrop ResItem(Requirement r)
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(r.itemName);
					ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val == (Object)null)
					{
						Debug.LogWarning((object)("The required item '" + r.itemName + "' does not exist."));
					}
					return val;
				}
			}
		}

		internal static readonly List<BuildPiece> registeredPieces = new List<BuildPiece>();

		internal static Dictionary<BuildPiece, PieceConfig> pieceConfigs = new Dictionary<BuildPiece, PieceConfig>();

		[Description("Disables generation of the configs for your pieces. This is global, this turns it off for all pieces in your mod.")]
		public static bool ConfigurationEnabled = true;

		public readonly GameObject Prefab;

		[Description("Specifies the resources needed to craft the piece.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the building piece should need.")]
		public readonly RequiredResourcesList RequiredItems = new RequiredResourcesList();

		[Description("Sets the category for the building piece.")]
		public readonly BuildingPieceCategory Category = new BuildingPieceCategory();

		[Description("Specifies the tool needed to build your piece.\nUse .Add to add a tool.")]
		public readonly PieceTool Tool = new PieceTool();

		[Description("Specifies the crafting station needed to build your piece.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.")]
		public CraftingStationList Crafting = new CraftingStationList();

		[Description("Makes this piece a station extension")]
		public ExtensionList Extension = new ExtensionList();

		[Description("Change the extended/special properties of your build piece.")]
		public SpecialProperties SpecialProperties;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private LocalizeKey _name;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private LocalizeKey _description;

		internal string[] activeTools = null;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object configManager;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static Localization _english;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		internal static BaseUnityPlugin _plugin = null;

		private static bool hasConfigSync = true;

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object _configSync;

		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				Piece component = Prefab.GetComponent<Piece>();
				if (component.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(component.m_name);
				}
				else
				{
					string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(component.m_name);
					component.m_name = text;
				}
				return _name;
			}
		}

		public LocalizeKey Description
		{
			get
			{
				LocalizeKey description = _description;
				if (description != null)
				{
					return description;
				}
				Piece component = Prefab.GetComponent<Piece>();
				if (component.m_description.StartsWith("$"))
				{
					_description = new LocalizeKey(component.m_description);
				}
				else
				{
					string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_") + "_description";
					_description = new LocalizeKey(text).English(component.m_description);
					component.m_description = text;
				}
				return _description;
			}
		}

		private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English"));

		internal static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				if (_plugin != null)
				{
					return _plugin;
				}
				IEnumerable<TypeInfo> source;
				try
				{
					source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
				}
				catch (ReflectionTypeLoadException ex)
				{
					source = from t in ex.Types
						where t != null
						select t.GetTypeInfo();
				}
				_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				return _plugin;
			}
		}

		[<bcfea496-feac-4d51-b436-e2e03bcd6883>Nullable(2)]
		private static object configSync
		{
			[<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(2)]
			get
			{
				if (_configSync != null || !hasConfigSync)
				{
					return _configSync;
				}
				Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
				if ((object)type != null)
				{
					_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " PieceManager");
					type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
					type.GetProperty("IsLocked").SetValue(_configSync, true);
				}
				else
				{
					hasConfigSync = false;
				}
				return _configSync;
			}
		}

		public BuildPiece(string assetBundleFileName, string prefabName, string folderName = "assets")
			: this(PiecePrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName)
		{
		}

		public BuildPiece(AssetBundle bundle, string prefabName)
		{
			Prefab = PiecePrefabManager.RegisterPrefab(bundle, prefabName);
			registeredPieces.Add(this);
		}

		internal static void Patch_FejdStartup(FejdStartup __instance)
		{
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Expected O, but got Unknown
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Expected O, but got Unknown
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Expected O, but got Unknown
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Expected O, but got Unknown
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Expected O, but got Unknown
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cc: Expected O, but got Unknown
			//IL_0900: Unknown result type (might be due to invalid IL or missing references)
			//IL_090a: Expected O, but got Unknown
			Type configManagerType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			configManager = ((configManagerType == null) ? null : Chainloader.ManagerObject.GetComponent(configManagerType));
			foreach (BuildPiece registeredPiece in registeredPieces)
			{
				registeredPiece.activeTools = registeredPiece.Tool.Tools.DefaultIfEmpty("Hammer").ToArray();
			}
			if (!ConfigurationEnabled)
			{
				return;
			}
			bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
			plugin.Config.SaveOnConfigSet = false;
			foreach (BuildPiece registeredPiece2 in registeredPieces)
			{
				BuildPiece piece = registeredPiece2;
				if (piece.SpecialProperties.NoConfig)
				{
					continue;
				}
				PieceConfig pieceConfig2 = (pieceConfigs[piece] = new PieceConfig());
				PieceConfig cfg = pieceConfig2;
				Piece piecePrefab = piece.Prefab.GetComponent<Piece>();
				string pieceName = piecePrefab.m_name;
				string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(pieceName), "").Trim();
				string localizedName = Localization.instance.Localize(pieceName).Trim();
				int order = 0;
				cfg.category = config(englishName, "Build Table Category", piece.Category.Category, new ConfigDescription("Build Category where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = (order -= 1),
						Category = localizedName
					}
				}));
				ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
				{
					Order = (order -= 1),
					Browsable = (cfg.category.Value == BuildPieceCategory.Custom),
					Category = localizedName
				};
				cfg.customCategory = config(englishName, "Custom Build Category", piece.Category.custom, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
				cfg.category.SettingChanged += BuildTableConfigChanged;
				cfg.customCategory.SettingChanged += BuildTableConfigChanged;
				if (cfg.category.Value == BuildPieceCategory.Custom)
				{
					piecePrefab.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value);
				}
				else
				{
					piecePrefab.m_category = (PieceCategory)cfg.category.Value;
				}
				cfg.tools = config(englishName, "Tools", string.Join(", ", piece.activeTools), new ConfigDescription("Comma separated list of tools where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
				piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' })
					select s.Trim()).ToArray();
				cfg.tools.SettingChanged += [<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (object _, EventArgs _) =>
				{
					Inventory[] source = (from c in Player.s_players.Select([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType<Container>()
							select c.GetInventory())
						where c != null
						select c).ToArray();
					Dictionary<string, List<PieceTable>> dictionary = (from kv in (from i in (from p in ObjectDB.instance.m_items
								select p.GetComponent<ItemDrop>() into c
								where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent<ZNetView>())
								select c).Concat(ItemDrop.s_instances)
							select new KeyValuePair<string, ItemData>(Utils.GetPrefabName(((Component)i).gameObject), i.m_itemData)).Concat(from i in source.SelectMany([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (Inventory i) => i.GetAllItems())
							select new KeyValuePair<string, ItemData>(((Object)i.m_dropPrefab).name, i))
						where Object.op_Implicit((Object)(object)kv.Value.m_shared.m_buildPieces)
						group kv by kv.Key).ToDictionary([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (IGrouping<string, KeyValuePair<string, ItemData>> g) => g.Key, [<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (IGrouping<string, KeyValuePair<string, ItemData>> g) => g.Select([<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (KeyValuePair<string, ItemData> kv) => kv.Value.m_shared.m_buildPieces).Distinct().ToList());
					string[] array5 = piece.activeTools;
					foreach (string key in array5)
					{
						if (dictionary.TryGetValue(key, out var value3))
						{
							foreach (PieceTable item3 in value3)
							{
								item3.m_pieces.Remove(piece.Prefab);
							}
						}
					}
					piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' })
						select s.Trim()).ToArray();
					if (Object.op_Implicit((Object)(object)ObjectDB.instance))
					{
						string[] array6 = piece.activeTools;
						foreach (string key2 in array6)
						{
							if (dictionary.TryGetValue(key2, out var value4))
							{
								foreach (PieceTable item4 in value4)
								{
									if (!item4.m_pieces.Contains(piece.Prefab))
									{
										item4.m_pieces.Add(piece.Prefab);
									}
								}
							}
						}
						if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces))
						{
							((Humanoid)Player.m_localPlayer).SetPlaceMode(Player.m_localPlayer.m_buildPieces);
						}
					}
				};
				StationExtension pieceExtensionComp;
				List<ConfigurationManagerAttributes> hideWhenNoneAttributes2;
				if (piece.Extension.ExtensionStations.Count > 0)
				{
					pieceExtensionComp = piece.Prefab.GetOrAddComponent<StationExtension>();
					PieceConfig pieceConfig3 = cfg;
					string group = englishName;
					CraftingTable table = piece.Extension.ExtensionStations.First().Table;
					string text = "Crafting station that " + localizedName + " extends.";
					object[] array = new object[1];
					ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes();
					int num = order - 1;
					order = num;
					configurationManagerAttributes.Order = num;
					array[0] = configurationManagerAttributes;
					pieceConfig3.extensionTable = config(group, "Extends Station", table, new ConfigDescription(text, (AcceptableValueBase)null, array));
					cfg.customExtentionTable = config(englishName, "Custom Extend Station", piece.Extension.ExtensionStations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
					PieceConfig pieceConfig4 = cfg;
					string group2 = englishName;
					float maxStationDistance = piece.Extension.ExtensionStations.First().maxStationDistance;
					string text2 = "Distance from the station that " + localizedName + " can be placed.";
					object[] array2 = new object[1];
					ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes();
					num = order - 1;
					order = num;
					configurationManagerAttributes2.Order = num;
					array2[0] = configurationManagerAttributes2;
					pieceConfig4.maxStationDistance = config(group2, "Max Station Distance", maxStationDistance, new ConfigDescription(text2, (AcceptableValueBase)null, array2));
					hideWhenNoneAttributes2 = new List<ConfigurationManagerAttributes>();
					cfg.extensionTable.SettingChanged += ExtensionTableConfigChanged;
					cfg.customExtentionTable.SettingChanged += ExtensionTableConfigChanged;
					cfg.maxStationDistance.SettingChanged += ExtensionTableConfigChanged;
					ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes();
					num = order - 1;
					order = num;
					configurationManagerAttributes3.Order = num;
					configurationManagerAttributes3.Browsable = cfg.extensionTable.Value != CraftingTable.None;
					ConfigurationManagerAttributes item = configurationManagerAttributes3;
					hideWhenNoneAttributes2.Add(item);
				}
				List<ConfigurationManagerAttributes> hideWhenNoneAttributes;
				if (piece.Crafting.Stations.Count > 0)
				{
					hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
					PieceConfig pieceConfig5 = cfg;
					string group3 = englishName;
					CraftingTable table2 = piece.Crafting.Stations.First().Table;
					string text3 = "Crafting station where " + localizedName + " is available.";
					object[] array3 = new object[1];
					ConfigurationManagerAttributes configurationManagerAttributes4 = new ConfigurationManagerAttributes();
					int num = order - 1;
					order = num;
					configurationManagerAttributes4.Order = num;
					array3[0] = configurationManagerAttributes4;
					pieceConfig5.table = config(group3, "Crafting Station", table2, new ConfigDescription(text3, (AcceptableValueBase)null, array3));
					cfg.customTable = config(englishName, "Custom Crafting Station", piece.Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
					cfg.table.SettingChanged += TableConfigChanged;
					cfg.customTable.SettingChanged += TableConfigChanged;
					ConfigurationManagerAttributes configurationManagerAttributes5 = new ConfigurationManagerAttributes();
					num = order - 1;
					order = num;
					configurationManagerAttributes5.Order = num;
					configurationManagerAttributes5.Browsable = cfg.table.Value != CraftingTable.None;
					ConfigurationManagerAttributes item2 = configurationManagerAttributes5;
					hideWhenNoneAttributes.Add(item2);
				}
				cfg.craft = itemConfig("Crafting Costs", new SerializedRequirements(piece.RequiredItems.Requirements).ToString(), "Item costs to craft " + localizedName);
				cfg.craft.SettingChanged += [<0ca92395-0097-4de6-a26d-1926aceecc19>NullableContext(0)] (object _, EventArgs _) =>
				{
					if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("Wood") != (Object)null)
					{
						Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value));
						piecePrefab.m_resources = resources;
						Piece[] array4 = Object.FindObjectsOfType<Piece>();
						foreach (Piece val in array4)
						{
							if (val.m_name == pieceName)
							{
								val.m_resources = resources;
							}
						}
					}
				};
				void BuildTableConfigChanged(object o, EventArgs e)
				{
					//IL_0066: 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)
					if (registeredPieces.Count > 0)
					{
						if (cfg.category.Value == BuildPieceCategory.Custom)
						{
							piecePrefab.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value);
						}
						else
						{
							piecePrefab.m_category = (PieceCategory)cfg.category.Value;
						}
						if (Object.op_Implicit((Object)(object)Hud.instance))
						{
							PiecePrefabManager.CreateCategoryTabs();
						}
					}
					customTableAttributes.Browsable = cfg.category.Value == BuildPieceCategory.Custom;
					ReloadConfigDisplay();
				}
				void ExtensionTableConfigChanged(object o, EventArgs e)
				{
					if (piece.RequiredItems.Requirements.Count > 0)
					{
						CraftingTable value2 = cfg.extensionTable.Value;
						CraftingTable craftingTable = value2;
						if (craftingTable == CraftingTable.Custom)
						{
							StationExtension obj2 = pieceExtensionComp;
							GameObject prefab2 = ZNetScene.instance.GetPrefab(cfg.customExtentionTable.Value);
							obj2.m_craftingStation = ((prefab2 != null) ? prefab2.GetComponent<CraftingStation>() : null);
						}
						else
						{
							pieceExtensionComp.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.extensionTable.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent<CraftingStation>();
						}
						pieceExtensionComp.m_maxStationDistance = cfg.maxStationDistance.Value;
					}
					customTableAttributes.Browsable = cfg.extensionTable.Value == CraftingTable.Custom;
					foreach (ConfigurationManagerAttributes item5 in hideWhenNoneAttributes2)
					{
						item5.Browsable = cfg.extensionTable.Value != CraftingTable.None;
					}
					ReloadConfigDisplay();
					plugin.Config.Save();
				}
				void TableConfigChanged(object o, EventArgs e)
				{
					if (piece.RequiredItems.Requirements.Count > 0)
					{
						switch (cfg.table.Value)
						{
						case CraftingTable.None:
							piecePrefab.m_craftingStation = null;
							break;
						case CraftingTable.Custom:
						{
							Piece obj = piecePrefab;
							GameObject prefab = ZNetScene.instance.GetPrefab(cfg.customTable.Value);
							obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null);
							break;
						}
						default:
							piecePrefab.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.table.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent<CraftingStation>();
							break;
						}
					}
					customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
					foreach (ConfigurationManagerAttributes item6 in hideWhenNoneAttributes)
					{
						item6.Browsable = cfg.table.Value != CraftingTable.None;
					}
					ReloadConfigDisplay();
					plugin.Config.Save();
				}
				ConfigEntry<string> itemConfig(string name, string value, string desc)
				{
					//IL_0057: Unknown result type (might be due to invalid IL or missing references)
					//IL_0061: Expected O, but got Unknown
					ConfigurationManagerAttributes configurationManagerAttributes6 = new ConfigurationManagerAttributes
					{
						CustomDrawer = DrawConfigTable,
						Order = (order -= 1),
						Category = localizedName
					};
					return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes6 }));
				}
			}
			if (saveOnConfigSet)
			{
				plugin.Config.SaveOnConfigSet = true;
				plugin.Config.Save();
			}
			void ReloadConfigDisplay()
			{
				configManagerType?.GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
			}
		}

		[HarmonyPriority(700)]
		internal static void Patch_ObjectDBInit(ObjectDB __instance)
		{
			if ((Object)(object)__instance.GetItemPrefab("Wood") == (Object)null)
			{
				return;
			}
			foreach (BuildPiece registeredPiece in registeredPieces)
			{
				pieceConfigs.TryGetValue(registeredPiece, out var value);
				registeredPiece.Prefab.GetComponent<Piece>().m_resources = SerializedRequirements.toPieceReqs((value == null) ? new SerializedRequirements(registeredPiece.RequiredItems.Requirements) : new SerializedRequirements(value.craft.Value));
				foreach (ExtensionConfig extensionStation in registeredPiece.Extension.ExtensionStations)
				{
					switch ((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.Table : value.extensionTable.Value)
					{
					case CraftingTable.None:
						registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = null;
						break;
					case CraftingTable.Custom:
					{
						GameObject prefab = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value);
						if (prefab != null)
						{
							registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = prefab.GetComponent<CraftingStation>();
						}
						else
						{
							Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value) + "' does not exist"));
						}
						break;
					}
					default:
						if (value != null && value.table.Value == CraftingTable.None)
						{
							registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = null;
						}
						else
						{
							registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.Table : v