Decompiled source of DSPMultiplyStackSize v1.0.13

DSPMultiplyStackSize.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TranslationCommon.SimpleJSON;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyTitle("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace TranslationCommon.SimpleJSON
{
	public enum JSONNodeType
	{
		Array = 1,
		Object = 2,
		String = 3,
		Number = 4,
		NullValue = 5,
		Boolean = 6,
		None = 7,
		Custom = 255
	}
	public enum JSONTextMode
	{
		Compact,
		Indent
	}
	public abstract class JSONNode
	{
		public struct Enumerator
		{
			private enum Type
			{
				None,
				Array,
				Object
			}

			private readonly Type type;

			private Dictionary<string, JSONNode>.Enumerator m_Object;

			private List<JSONNode>.Enumerator m_Array;

			public bool IsValid => type != Type.None;

			public KeyValuePair<string, JSONNode> Current
			{
				get
				{
					if (type == Type.Array)
					{
						return new KeyValuePair<string, JSONNode>(string.Empty, m_Array.Current);
					}
					if (type == Type.Object)
					{
						return m_Object.Current;
					}
					return new KeyValuePair<string, JSONNode>(string.Empty, null);
				}
			}

			public Enumerator(List<JSONNode>.Enumerator aArrayEnum)
			{
				type = Type.Array;
				m_Object = default(Dictionary<string, JSONNode>.Enumerator);
				m_Array = aArrayEnum;
			}

			public Enumerator(Dictionary<string, JSONNode>.Enumerator aDictEnum)
			{
				type = Type.Object;
				m_Object = aDictEnum;
				m_Array = default(List<JSONNode>.Enumerator);
			}

			public bool MoveNext()
			{
				if (type == Type.Array)
				{
					return m_Array.MoveNext();
				}
				if (type == Type.Object)
				{
					return m_Object.MoveNext();
				}
				return false;
			}
		}

		public struct ValueEnumerator
		{
			private Enumerator m_Enumerator;

			public JSONNode Current => m_Enumerator.Current.Value;

			public ValueEnumerator(List<JSONNode>.Enumerator aArrayEnum)
				: this(new Enumerator(aArrayEnum))
			{
			}

			public ValueEnumerator(Dictionary<string, JSONNode>.Enumerator aDictEnum)
				: this(new Enumerator(aDictEnum))
			{
			}

			public ValueEnumerator(Enumerator aEnumerator)
			{
				m_Enumerator = aEnumerator;
			}

			public bool MoveNext()
			{
				return m_Enumerator.MoveNext();
			}

			public ValueEnumerator GetEnumerator()
			{
				return this;
			}
		}

		public struct KeyEnumerator
		{
			private Enumerator m_Enumerator;

			public string Current => m_Enumerator.Current.Key;

			public KeyEnumerator(List<JSONNode>.Enumerator aArrayEnum)
				: this(new Enumerator(aArrayEnum))
			{
			}

			public KeyEnumerator(Dictionary<string, JSONNode>.Enumerator aDictEnum)
				: this(new Enumerator(aDictEnum))
			{
			}

			public KeyEnumerator(Enumerator aEnumerator)
			{
				m_Enumerator = aEnumerator;
			}

			public bool MoveNext()
			{
				return m_Enumerator.MoveNext();
			}

			public KeyEnumerator GetEnumerator()
			{
				return this;
			}
		}

		public class LinqEnumerator : IEnumerator<KeyValuePair<string, JSONNode>>, IDisposable, IEnumerator, IEnumerable<KeyValuePair<string, JSONNode>>, IEnumerable
		{
			private Enumerator m_Enumerator;

			private JSONNode m_Node;

			public KeyValuePair<string, JSONNode> Current => m_Enumerator.Current;

			object IEnumerator.Current => m_Enumerator.Current;

			internal LinqEnumerator(JSONNode aNode)
			{
				m_Node = aNode;
				if (m_Node != null)
				{
					m_Enumerator = m_Node.GetEnumerator();
				}
			}

			public IEnumerator<KeyValuePair<string, JSONNode>> GetEnumerator()
			{
				return new LinqEnumerator(m_Node);
			}

			IEnumerator IEnumerable.GetEnumerator()
			{
				return new LinqEnumerator(m_Node);
			}

			public bool MoveNext()
			{
				return m_Enumerator.MoveNext();
			}

			public void Dispose()
			{
				m_Node = null;
				m_Enumerator = default(Enumerator);
			}

			public void Reset()
			{
				if (m_Node != null)
				{
					m_Enumerator = m_Node.GetEnumerator();
				}
			}
		}

		[ThreadStatic]
		private static StringBuilder m_EscapeBuilder;

		public static bool forceASCII = false;

		public static bool longAsString = false;

		public static bool allowLineComments = true;

		public static byte Color32DefaultAlpha = byte.MaxValue;

		public static float ColorDefaultAlpha = 1f;

		public static JSONContainerType VectorContainerType = JSONContainerType.Array;

		public static JSONContainerType QuaternionContainerType = JSONContainerType.Array;

		public static JSONContainerType RectContainerType = JSONContainerType.Array;

		public static JSONContainerType ColorContainerType = JSONContainerType.Array;

		internal static StringBuilder EscapeBuilder
		{
			get
			{
				if (m_EscapeBuilder == null)
				{
					m_EscapeBuilder = new StringBuilder();
				}
				return m_EscapeBuilder;
			}
		}

		public abstract JSONNodeType Tag { get; }

		public virtual JSONNode this[int aIndex]
		{
			get
			{
				return null;
			}
			set
			{
			}
		}

		public virtual JSONNode this[string aKey]
		{
			get
			{
				return null;
			}
			set
			{
			}
		}

		public virtual string Value
		{
			get
			{
				return "";
			}
			set
			{
			}
		}

		public virtual int Count => 0;

		public virtual bool IsNumber => false;

		public virtual bool IsString => false;

		public virtual bool IsBoolean => false;

		public virtual bool IsNull => false;

		public virtual bool IsArray => false;

		public virtual bool IsObject => false;

		public virtual bool Inline
		{
			get
			{
				return false;
			}
			set
			{
			}
		}

		public virtual IEnumerable<JSONNode> Children
		{
			get
			{
				yield break;
			}
		}

		public IEnumerable<JSONNode> DeepChildren
		{
			get
			{
				foreach (JSONNode C in Children)
				{
					foreach (JSONNode deepChild in C.DeepChildren)
					{
						yield return deepChild;
					}
				}
			}
		}

		public IEnumerable<KeyValuePair<string, JSONNode>> Linq => new LinqEnumerator(this);

		public KeyEnumerator Keys => new KeyEnumerator(GetEnumerator());

		public ValueEnumerator Values => new ValueEnumerator(GetEnumerator());

		public virtual double AsDouble
		{
			get
			{
				double result = 0.0;
				if (double.TryParse(Value, NumberStyles.Float, CultureInfo.InvariantCulture, out result))
				{
					return result;
				}
				return 0.0;
			}
			set
			{
				Value = value.ToString(CultureInfo.InvariantCulture);
			}
		}

		public virtual int AsInt
		{
			get
			{
				return (int)AsDouble;
			}
			set
			{
				AsDouble = value;
			}
		}

		public virtual float AsFloat
		{
			get
			{
				return (float)AsDouble;
			}
			set
			{
				AsDouble = value;
			}
		}

		public virtual bool AsBool
		{
			get
			{
				bool result = false;
				if (bool.TryParse(Value, out result))
				{
					return result;
				}
				return !string.IsNullOrEmpty(Value);
			}
			set
			{
				Value = (value ? "true" : "false");
			}
		}

		public virtual long AsLong
		{
			get
			{
				long result = 0L;
				if (long.TryParse(Value, out result))
				{
					return result;
				}
				return 0L;
			}
			set
			{
				Value = value.ToString();
			}
		}

		public virtual ulong AsULong
		{
			get
			{
				ulong result = 0uL;
				if (ulong.TryParse(Value, out result))
				{
					return result;
				}
				return 0uL;
			}
			set
			{
				Value = value.ToString();
			}
		}

		public virtual JSONArray AsArray => this as JSONArray;

		public virtual JSONObject AsObject => this as JSONObject;

		public virtual decimal AsDecimal
		{
			get
			{
				if (!decimal.TryParse(Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var result))
				{
					result = default(decimal);
				}
				return result;
			}
			set
			{
				Value = value.ToString();
			}
		}

		public virtual char AsChar
		{
			get
			{
				if (IsString && Value.Length > 0)
				{
					return Value[0];
				}
				if (IsNumber)
				{
					return (char)AsInt;
				}
				return '\0';
			}
			set
			{
				if (IsString)
				{
					Value = value.ToString();
				}
				else if (IsNumber)
				{
					AsInt = value;
				}
			}
		}

		public virtual uint AsUInt
		{
			get
			{
				return (uint)AsDouble;
			}
			set
			{
				AsDouble = value;
			}
		}

		public virtual byte AsByte
		{
			get
			{
				return (byte)AsInt;
			}
			set
			{
				AsInt = value;
			}
		}

		public virtual sbyte AsSByte
		{
			get
			{
				return (sbyte)AsInt;
			}
			set
			{
				AsInt = value;
			}
		}

		public virtual short AsShort
		{
			get
			{
				return (short)AsInt;
			}
			set
			{
				AsInt = value;
			}
		}

		public virtual ushort AsUShort
		{
			get
			{
				return (ushort)AsInt;
			}
			set
			{
				AsInt = value;
			}
		}

		public virtual DateTime AsDateTime
		{
			get
			{
				if (!DateTime.TryParse(Value, CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
				{
					result = new DateTime(0L);
				}
				return result;
			}
			set
			{
				Value = value.ToString(CultureInfo.InvariantCulture);
			}
		}

		public virtual TimeSpan AsTimeSpan
		{
			get
			{
				if (!TimeSpan.TryParse(Value, out var result))
				{
					result = new TimeSpan(0L);
				}
				return result;
			}
			set
			{
				Value = value.ToString();
			}
		}

		public virtual byte[] AsByteArray
		{
			get
			{
				if (IsNull || !IsArray)
				{
					return null;
				}
				int count = Count;
				byte[] array = new byte[count];
				for (int i = 0; i < count; i++)
				{
					array[i] = this[i].AsByte;
				}
				return array;
			}
			set
			{
				if (IsArray && value != null)
				{
					Clear();
					for (int i = 0; i < value.Length; i++)
					{
						Add(value[i]);
					}
				}
			}
		}

		public virtual List<byte> AsByteList
		{
			get
			{
				if (IsNull || !IsArray)
				{
					return null;
				}
				int count = Count;
				List<byte> list = new List<byte>(count);
				for (int i = 0; i < count; i++)
				{
					list.Add(this[i].AsByte);
				}
				return list;
			}
			set
			{
				if (IsArray && value != null)
				{
					Clear();
					for (int i = 0; i < value.Count; i++)
					{
						Add(value[i]);
					}
				}
			}
		}

		public virtual string[] AsStringArray
		{
			get
			{
				if (IsNull || !IsArray)
				{
					return null;
				}
				int count = Count;
				string[] array = new string[count];
				for (int i = 0; i < count; i++)
				{
					array[i] = this[i].Value;
				}
				return array;
			}
			set
			{
				if (IsArray && value != null)
				{
					Clear();
					for (int i = 0; i < value.Length; i++)
					{
						Add(value[i]);
					}
				}
			}
		}

		public virtual List<string> AsStringList
		{
			get
			{
				if (IsNull || !IsArray)
				{
					return null;
				}
				int count = Count;
				List<string> list = new List<string>(count);
				for (int i = 0; i < count; i++)
				{
					list.Add(this[i].Value);
				}
				return list;
			}
			set
			{
				if (IsArray && value != null)
				{
					Clear();
					for (int i = 0; i < value.Count; i++)
					{
						Add(value[i]);
					}
				}
			}
		}

		internal static string Escape(string aText)
		{
			StringBuilder escapeBuilder = EscapeBuilder;
			escapeBuilder.Length = 0;
			if (escapeBuilder.Capacity < aText.Length + aText.Length / 10)
			{
				escapeBuilder.Capacity = aText.Length + aText.Length / 10;
			}
			foreach (char c in aText)
			{
				switch (c)
				{
				case '\\':
					escapeBuilder.Append("\\\\");
					continue;
				case '"':
					escapeBuilder.Append("\\\"");
					continue;
				case '\n':
					escapeBuilder.Append("\\n");
					continue;
				case '\r':
					escapeBuilder.Append("\\r");
					continue;
				case '\t':
					escapeBuilder.Append("\\t");
					continue;
				case '\b':
					escapeBuilder.Append("\\b");
					continue;
				case '\f':
					escapeBuilder.Append("\\f");
					continue;
				}
				if (c < ' ' || (forceASCII && c > '\u007f'))
				{
					ushort num = c;
					escapeBuilder.Append("\\u").Append(num.ToString("X4"));
				}
				else
				{
					escapeBuilder.Append(c);
				}
			}
			string result = escapeBuilder.ToString();
			escapeBuilder.Length = 0;
			return result;
		}

		private static JSONNode ParseElement(string token, bool quoted)
		{
			if (quoted)
			{
				return token;
			}
			if (token.Length <= 5)
			{
				string text = token.ToLower();
				if (text == "false" || text == "true")
				{
					return text == "true";
				}
				if (text == "null")
				{
					return JSONNull.CreateOrGet();
				}
			}
			if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return token;
		}

		public static JSONNode Parse(string aJSON)
		{
			Stack<JSONNode> stack = new Stack<JSONNode>();
			JSONNode jSONNode = null;
			int i = 0;
			StringBuilder stringBuilder = new StringBuilder();
			string aKey = "";
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			for (; i < aJSON.Length; i++)
			{
				switch (aJSON[i])
				{
				case '{':
					if (flag)
					{
						stringBuilder.Append(aJSON[i]);
						break;
					}
					stack.Push(new JSONObject());
					if (jSONNode != null)
					{
						jSONNode.Add(aKey, stack.Peek());
					}
					aKey = "";
					stringBuilder.Length = 0;
					jSONNode = stack.Peek();
					flag3 = false;
					break;
				case '[':
					if (flag)
					{
						stringBuilder.Append(aJSON[i]);
						break;
					}
					stack.Push(new JSONArray());
					if (jSONNode != null)
					{
						jSONNode.Add(aKey, stack.Peek());
					}
					aKey = "";
					stringBuilder.Length = 0;
					jSONNode = stack.Peek();
					flag3 = false;
					break;
				case ']':
				case '}':
					if (flag)
					{
						stringBuilder.Append(aJSON[i]);
						break;
					}
					if (stack.Count == 0)
					{
						throw new Exception("JSON Parse: Too many closing brackets");
					}
					stack.Pop();
					if (stringBuilder.Length > 0 || flag2)
					{
						jSONNode.Add(aKey, ParseElement(stringBuilder.ToString(), flag2));
					}
					if (jSONNode != null)
					{
						jSONNode.Inline = !flag3;
					}
					flag2 = false;
					aKey = "";
					stringBuilder.Length = 0;
					if (stack.Count > 0)
					{
						jSONNode = stack.Peek();
					}
					break;
				case ':':
					if (flag)
					{
						stringBuilder.Append(aJSON[i]);
						break;
					}
					aKey = stringBuilder.ToString();
					stringBuilder.Length = 0;
					flag2 = false;
					break;
				case '"':
					flag = !flag;
					flag2 = flag2 || flag;
					break;
				case ',':
					if (flag)
					{
						stringBuilder.Append(aJSON[i]);
						break;
					}
					if (stringBuilder.Length > 0 || flag2)
					{
						jSONNode.Add(aKey, ParseElement(stringBuilder.ToString(), flag2));
					}
					flag2 = false;
					aKey = "";
					stringBuilder.Length = 0;
					flag2 = false;
					break;
				case '\n':
				case '\r':
					flag3 = true;
					break;
				case '\t':
				case ' ':
					if (flag)
					{
						stringBuilder.Append(aJSON[i]);
					}
					break;
				case '\\':
					i++;
					if (flag)
					{
						char c = aJSON[i];
						switch (c)
						{
						case 't':
							stringBuilder.Append('\t');
							break;
						case 'r':
							stringBuilder.Append('\r');
							break;
						case 'n':
							stringBuilder.Append('\n');
							break;
						case 'b':
							stringBuilder.Append('\b');
							break;
						case 'f':
							stringBuilder.Append('\f');
							break;
						case 'u':
						{
							string s = aJSON.Substring(i + 1, 4);
							stringBuilder.Append((char)int.Parse(s, NumberStyles.AllowHexSpecifier));
							i += 4;
							break;
						}
						default:
							stringBuilder.Append(c);
							break;
						}
					}
					break;
				case '/':
					if (allowLineComments && !flag && i + 1 < aJSON.Length && aJSON[i + 1] == '/')
					{
						while (++i < aJSON.Length && aJSON[i] != '\n' && aJSON[i] != '\r')
						{
						}
					}
					else
					{
						stringBuilder.Append(aJSON[i]);
					}
					break;
				default:
					stringBuilder.Append(aJSON[i]);
					break;
				case '\ufeff':
					break;
				}
			}
			if (flag)
			{
				throw new Exception("JSON Parse: Quotation marks seems to be messed up.");
			}
			if (jSONNode == null)
			{
				return ParseElement(stringBuilder.ToString(), flag2);
			}
			return jSONNode;
		}

		public virtual void Add(string aKey, JSONNode aItem)
		{
		}

		public virtual void Add(JSONNode aItem)
		{
			Add("", aItem);
		}

		public virtual JSONNode Remove(string aKey)
		{
			return null;
		}

		public virtual JSONNode Remove(int aIndex)
		{
			return null;
		}

		public virtual JSONNode Remove(JSONNode aNode)
		{
			return aNode;
		}

		public virtual void Clear()
		{
		}

		public virtual JSONNode Clone()
		{
			return null;
		}

		public virtual bool HasKey(string aKey)
		{
			return false;
		}

		public virtual JSONNode GetValueOrDefault(string aKey, JSONNode aDefault)
		{
			return aDefault;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			WriteToStringBuilder(stringBuilder, 0, 0, JSONTextMode.Compact);
			return stringBuilder.ToString();
		}

		public virtual string ToString(int aIndent)
		{
			StringBuilder stringBuilder = new StringBuilder();
			WriteToStringBuilder(stringBuilder, 0, aIndent, JSONTextMode.Indent);
			return stringBuilder.ToString();
		}

		internal abstract void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode);

		public abstract Enumerator GetEnumerator();

		public static implicit operator JSONNode(string s)
		{
			return (s == null) ? ((JSONNode)JSONNull.CreateOrGet()) : ((JSONNode)new JSONString(s));
		}

		public static implicit operator string(JSONNode d)
		{
			return (d == null) ? null : d.Value;
		}

		public static implicit operator JSONNode(double n)
		{
			return new JSONNumber(n);
		}

		public static implicit operator double(JSONNode d)
		{
			return (d == null) ? 0.0 : d.AsDouble;
		}

		public static implicit operator JSONNode(float n)
		{
			return new JSONNumber(n);
		}

		public static implicit operator float(JSONNode d)
		{
			return (d == null) ? 0f : d.AsFloat;
		}

		public static implicit operator JSONNode(int n)
		{
			return new JSONNumber(n);
		}

		public static implicit operator int(JSONNode d)
		{
			return (!(d == null)) ? d.AsInt : 0;
		}

		public static implicit operator JSONNode(long n)
		{
			if (longAsString)
			{
				return new JSONString(n.ToString());
			}
			return new JSONNumber(n);
		}

		public static implicit operator long(JSONNode d)
		{
			return (d == null) ? 0 : d.AsLong;
		}

		public static implicit operator JSONNode(ulong n)
		{
			if (longAsString)
			{
				return new JSONString(n.ToString());
			}
			return new JSONNumber(n);
		}

		public static implicit operator ulong(JSONNode d)
		{
			return (d == null) ? 0 : d.AsULong;
		}

		public static implicit operator JSONNode(bool b)
		{
			return new JSONBool(b);
		}

		public static implicit operator bool(JSONNode d)
		{
			return !(d == null) && d.AsBool;
		}

		public static implicit operator JSONNode(KeyValuePair<string, JSONNode> aKeyValue)
		{
			return aKeyValue.Value;
		}

		public static bool operator ==(JSONNode a, object b)
		{
			if ((object)a == b)
			{
				return true;
			}
			bool flag = a is JSONNull || (object)a == null || a is JSONLazyCreator;
			bool flag2 = b is JSONNull || b == null || b is JSONLazyCreator;
			if (flag && flag2)
			{
				return true;
			}
			return !flag && a.Equals(b);
		}

		public static bool operator !=(JSONNode a, object b)
		{
			return !(a == b);
		}

		public override bool Equals(object obj)
		{
			return (object)this == obj;
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		public abstract void SerializeBinary(BinaryWriter aWriter);

		public void SaveToBinaryStream(Stream aData)
		{
			BinaryWriter aWriter = new BinaryWriter(aData);
			SerializeBinary(aWriter);
		}

		public void SaveToCompressedStream(Stream aData)
		{
			throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
		}

		public void SaveToCompressedFile(string aFileName)
		{
			throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
		}

		public string SaveToCompressedBase64()
		{
			throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
		}

		public void SaveToBinaryFile(string aFileName)
		{
			Directory.CreateDirectory(new FileInfo(aFileName).Directory.FullName);
			using FileStream aData = File.OpenWrite(aFileName);
			SaveToBinaryStream(aData);
		}

		public string SaveToBinaryBase64()
		{
			using MemoryStream memoryStream = new MemoryStream();
			SaveToBinaryStream(memoryStream);
			memoryStream.Position = 0L;
			return Convert.ToBase64String(memoryStream.ToArray());
		}

		public static JSONNode DeserializeBinary(BinaryReader aReader)
		{
			JSONNodeType jSONNodeType = (JSONNodeType)aReader.ReadByte();
			switch (jSONNodeType)
			{
			case JSONNodeType.Array:
			{
				int num2 = aReader.ReadInt32();
				JSONArray jSONArray = new JSONArray();
				for (int j = 0; j < num2; j++)
				{
					jSONArray.Add(DeserializeBinary(aReader));
				}
				return jSONArray;
			}
			case JSONNodeType.Object:
			{
				int num = aReader.ReadInt32();
				JSONObject jSONObject = new JSONObject();
				for (int i = 0; i < num; i++)
				{
					string aKey = aReader.ReadString();
					JSONNode aItem = DeserializeBinary(aReader);
					jSONObject.Add(aKey, aItem);
				}
				return jSONObject;
			}
			case JSONNodeType.String:
				return new JSONString(aReader.ReadString());
			case JSONNodeType.Number:
				return new JSONNumber(aReader.ReadDouble());
			case JSONNodeType.Boolean:
				return new JSONBool(aReader.ReadBoolean());
			case JSONNodeType.NullValue:
				return JSONNull.CreateOrGet();
			default:
				throw new Exception("Error deserializing JSON. Unknown tag: " + jSONNodeType);
			}
		}

		public static JSONNode LoadFromCompressedFile(string aFileName)
		{
			throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
		}

		public static JSONNode LoadFromCompressedStream(Stream aData)
		{
			throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
		}

		public static JSONNode LoadFromCompressedBase64(string aBase64)
		{
			throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
		}

		public static JSONNode LoadFromBinaryStream(Stream aData)
		{
			using BinaryReader aReader = new BinaryReader(aData);
			return DeserializeBinary(aReader);
		}

		public static JSONNode LoadFromBinaryFile(string aFileName)
		{
			using FileStream aData = File.OpenRead(aFileName);
			return LoadFromBinaryStream(aData);
		}

		public static JSONNode LoadFromBinaryBase64(string aBase64)
		{
			byte[] buffer = Convert.FromBase64String(aBase64);
			MemoryStream memoryStream = new MemoryStream(buffer);
			memoryStream.Position = 0L;
			return LoadFromBinaryStream(memoryStream);
		}

		public static implicit operator JSONNode(decimal aDecimal)
		{
			return new JSONString(aDecimal.ToString());
		}

		public static implicit operator decimal(JSONNode aNode)
		{
			return aNode.AsDecimal;
		}

		public static implicit operator JSONNode(char aChar)
		{
			return new JSONString(aChar.ToString());
		}

		public static implicit operator char(JSONNode aNode)
		{
			return aNode.AsChar;
		}

		public static implicit operator JSONNode(uint aUInt)
		{
			return new JSONNumber(aUInt);
		}

		public static implicit operator uint(JSONNode aNode)
		{
			return aNode.AsUInt;
		}

		public static implicit operator JSONNode(byte aByte)
		{
			return new JSONNumber((int)aByte);
		}

		public static implicit operator byte(JSONNode aNode)
		{
			return aNode.AsByte;
		}

		public static implicit operator JSONNode(sbyte aSByte)
		{
			return new JSONNumber(aSByte);
		}

		public static implicit operator sbyte(JSONNode aNode)
		{
			return aNode.AsSByte;
		}

		public static implicit operator JSONNode(short aShort)
		{
			return new JSONNumber(aShort);
		}

		public static implicit operator short(JSONNode aNode)
		{
			return aNode.AsShort;
		}

		public static implicit operator JSONNode(ushort aUShort)
		{
			return new JSONNumber((int)aUShort);
		}

		public static implicit operator ushort(JSONNode aNode)
		{
			return aNode.AsUShort;
		}

		public static implicit operator JSONNode(DateTime aDateTime)
		{
			return new JSONString(aDateTime.ToString(CultureInfo.InvariantCulture));
		}

		public static implicit operator DateTime(JSONNode aNode)
		{
			return aNode.AsDateTime;
		}

		public static implicit operator JSONNode(TimeSpan aTimeSpan)
		{
			return new JSONString(aTimeSpan.ToString());
		}

		public static implicit operator TimeSpan(JSONNode aNode)
		{
			return aNode.AsTimeSpan;
		}

		public static implicit operator JSONNode(byte[] aByteArray)
		{
			return new JSONArray
			{
				AsByteArray = aByteArray
			};
		}

		public static implicit operator byte[](JSONNode aNode)
		{
			return aNode.AsByteArray;
		}

		public static implicit operator JSONNode(List<byte> aByteList)
		{
			return new JSONArray
			{
				AsByteList = aByteList
			};
		}

		public static implicit operator List<byte>(JSONNode aNode)
		{
			return aNode.AsByteList;
		}

		public static implicit operator JSONNode(string[] aStringArray)
		{
			return new JSONArray
			{
				AsStringArray = aStringArray
			};
		}

		public static implicit operator string[](JSONNode aNode)
		{
			return aNode.AsStringArray;
		}

		public static implicit operator JSONNode(List<string> aStringList)
		{
			return new JSONArray
			{
				AsStringList = aStringList
			};
		}

		public static implicit operator List<string>(JSONNode aNode)
		{
			return aNode.AsStringList;
		}

		public static implicit operator JSONNode(int? aValue)
		{
			if (!aValue.HasValue)
			{
				return JSONNull.CreateOrGet();
			}
			return new JSONNumber(aValue.Value);
		}

		public static implicit operator int?(JSONNode aNode)
		{
			if (aNode == null || aNode.IsNull)
			{
				return null;
			}
			return aNode.AsInt;
		}

		public static implicit operator JSONNode(float? aValue)
		{
			if (!aValue.HasValue)
			{
				return JSONNull.CreateOrGet();
			}
			return new JSONNumber(aValue.Value);
		}

		public static implicit operator float?(JSONNode aNode)
		{
			if (aNode == null || aNode.IsNull)
			{
				return null;
			}
			return aNode.AsFloat;
		}

		public static implicit operator JSONNode(double? aValue)
		{
			if (!aValue.HasValue)
			{
				return JSONNull.CreateOrGet();
			}
			return new JSONNumber(aValue.Value);
		}

		public static implicit operator double?(JSONNode aNode)
		{
			if (aNode == null || aNode.IsNull)
			{
				return null;
			}
			return aNode.AsDouble;
		}

		public static implicit operator JSONNode(bool? aValue)
		{
			if (!aValue.HasValue)
			{
				return JSONNull.CreateOrGet();
			}
			return new JSONBool(aValue.Value);
		}

		public static implicit operator bool?(JSONNode aNode)
		{
			if (aNode == null || aNode.IsNull)
			{
				return null;
			}
			return aNode.AsBool;
		}

		public static implicit operator JSONNode(long? aValue)
		{
			if (!aValue.HasValue)
			{
				return JSONNull.CreateOrGet();
			}
			return new JSONNumber(aValue.Value);
		}

		public static implicit operator long?(JSONNode aNode)
		{
			if (aNode == null || aNode.IsNull)
			{
				return null;
			}
			return aNode.AsLong;
		}

		public static implicit operator JSONNode(short? aValue)
		{
			if (!aValue.HasValue)
			{
				return JSONNull.CreateOrGet();
			}
			return new JSONNumber(aValue.Value);
		}

		public static implicit operator short?(JSONNode aNode)
		{
			if (aNode == null || aNode.IsNull)
			{
				return null;
			}
			return aNode.AsShort;
		}

		private static JSONNode GetContainer(JSONContainerType aType)
		{
			if (aType == JSONContainerType.Array)
			{
				return new JSONArray();
			}
			return new JSONObject();
		}

		public static implicit operator JSONNode(Vector2 aVec)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(VectorContainerType);
			container.WriteVector2(aVec);
			return container;
		}

		public static implicit operator JSONNode(Vector3 aVec)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(VectorContainerType);
			container.WriteVector3(aVec);
			return container;
		}

		public static implicit operator JSONNode(Vector4 aVec)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(VectorContainerType);
			container.WriteVector4(aVec);
			return container;
		}

		public static implicit operator JSONNode(Color aCol)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(ColorContainerType);
			container.WriteColor(aCol);
			return container;
		}

		public static implicit operator JSONNode(Color32 aCol)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(ColorContainerType);
			container.WriteColor32(aCol);
			return container;
		}

		public static implicit operator JSONNode(Quaternion aRot)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(QuaternionContainerType);
			container.WriteQuaternion(aRot);
			return container;
		}

		public static implicit operator JSONNode(Rect aRect)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(RectContainerType);
			container.WriteRect(aRect);
			return container;
		}

		public static implicit operator JSONNode(RectOffset aRect)
		{
			JSONNode container = GetContainer(RectContainerType);
			container.WriteRectOffset(aRect);
			return container;
		}

		public static implicit operator JSONNode(Matrix4x4 aMatrix)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			JSONNode container = GetContainer(RectContainerType);
			container.WriteMatrix(aMatrix);
			return container;
		}

		public static implicit operator Vector2(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadVector2();
		}

		public static implicit operator Vector3(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadVector3();
		}

		public static implicit operator Vector4(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadVector4();
		}

		public static implicit operator Color(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadColor();
		}

		public static implicit operator Color32(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadColor32();
		}

		public static implicit operator Quaternion(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadQuaternion();
		}

		public static implicit operator Rect(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadRect();
		}

		public static implicit operator RectOffset(JSONNode aNode)
		{
			return aNode.ReadRectOffset();
		}

		public static implicit operator Matrix4x4(JSONNode aNode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return aNode.ReadMatrix();
		}

		public Vector2 ReadVector2(Vector2 aDefault)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Vector2(this["x"].AsFloat, this["y"].AsFloat);
			}
			if (IsArray)
			{
				return new Vector2(this[0].AsFloat, this[1].AsFloat);
			}
			return aDefault;
		}

		public Vector2 ReadVector2(string aXName, string aYName)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Vector2(this[aXName].AsFloat, this[aYName].AsFloat);
			}
			return Vector2.zero;
		}

		public Vector2 ReadVector2()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ReadVector2(Vector2.zero);
		}

		public JSONNode WriteVector2(Vector2 aVec, string aXName = "x", string aYName = "y")
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				Inline = true;
				this[aXName].AsFloat = aVec.x;
				this[aYName].AsFloat = aVec.y;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsFloat = aVec.x;
				this[1].AsFloat = aVec.y;
			}
			return this;
		}

		public Vector3 ReadVector3(Vector3 aDefault)
		{
			//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_0079: 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_0071: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Vector3(this["x"].AsFloat, this["y"].AsFloat, this["z"].AsFloat);
			}
			if (IsArray)
			{
				return new Vector3(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat);
			}
			return aDefault;
		}

		public Vector3 ReadVector3(string aXName, string aYName, string aZName)
		{
			//IL_0037: 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_002f: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Vector3(this[aXName].AsFloat, this[aYName].AsFloat, this[aZName].AsFloat);
			}
			return Vector3.zero;
		}

		public Vector3 ReadVector3()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ReadVector3(Vector3.zero);
		}

		public JSONNode WriteVector3(Vector3 aVec, string aXName = "x", string aYName = "y", string aZName = "z")
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				Inline = true;
				this[aXName].AsFloat = aVec.x;
				this[aYName].AsFloat = aVec.y;
				this[aZName].AsFloat = aVec.z;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsFloat = aVec.x;
				this[1].AsFloat = aVec.y;
				this[2].AsFloat = aVec.z;
			}
			return this;
		}

		public Vector4 ReadVector4(Vector4 aDefault)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Vector4(this["x"].AsFloat, this["y"].AsFloat, this["z"].AsFloat, this["w"].AsFloat);
			}
			if (IsArray)
			{
				return new Vector4(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, this[3].AsFloat);
			}
			return aDefault;
		}

		public Vector4 ReadVector4()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ReadVector4(Vector4.zero);
		}

		public JSONNode WriteVector4(Vector4 aVec)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				Inline = true;
				this["x"].AsFloat = aVec.x;
				this["y"].AsFloat = aVec.y;
				this["z"].AsFloat = aVec.z;
				this["w"].AsFloat = aVec.w;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsFloat = aVec.x;
				this[1].AsFloat = aVec.y;
				this[2].AsFloat = aVec.z;
				this[3].AsFloat = aVec.w;
			}
			return this;
		}

		public Color ReadColor(Color aDefault)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Color(this["r"].AsFloat, this["g"].AsFloat, this["b"].AsFloat, HasKey("a") ? this["a"].AsFloat : ColorDefaultAlpha);
			}
			if (IsArray)
			{
				return new Color(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, (Count > 3) ? this[3].AsFloat : ColorDefaultAlpha);
			}
			return aDefault;
		}

		public Color ReadColor()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ReadColor(Color.clear);
		}

		public JSONNode WriteColor(Color aCol)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				Inline = true;
				this["r"].AsFloat = aCol.r;
				this["g"].AsFloat = aCol.g;
				this["b"].AsFloat = aCol.b;
				this["a"].AsFloat = aCol.a;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsFloat = aCol.r;
				this[1].AsFloat = aCol.g;
				this[2].AsFloat = aCol.b;
				this[3].AsFloat = aCol.a;
			}
			return this;
		}

		public Color32 ReadColor32(Color32 aDefault)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Color32((byte)this["r"].AsInt, (byte)this["g"].AsInt, (byte)this["b"].AsInt, (byte)(HasKey("a") ? this["a"].AsInt : Color32DefaultAlpha));
			}
			if (IsArray)
			{
				return new Color32((byte)this[0].AsInt, (byte)this[1].AsInt, (byte)this[2].AsInt, (byte)((Count > 3) ? this[3].AsInt : Color32DefaultAlpha));
			}
			return aDefault;
		}

		public Color32 ReadColor32()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return ReadColor32(default(Color32));
		}

		public JSONNode WriteColor32(Color32 aCol)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				Inline = true;
				this["r"].AsInt = aCol.r;
				this["g"].AsInt = aCol.g;
				this["b"].AsInt = aCol.b;
				this["a"].AsInt = aCol.a;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsInt = aCol.r;
				this[1].AsInt = aCol.g;
				this[2].AsInt = aCol.b;
				this[3].AsInt = aCol.a;
			}
			return this;
		}

		public Quaternion ReadQuaternion(Quaternion aDefault)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Quaternion(this["x"].AsFloat, this["y"].AsFloat, this["z"].AsFloat, this["w"].AsFloat);
			}
			if (IsArray)
			{
				return new Quaternion(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, this[3].AsFloat);
			}
			return aDefault;
		}

		public Quaternion ReadQuaternion()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ReadQuaternion(Quaternion.identity);
		}

		public JSONNode WriteQuaternion(Quaternion aRot)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				Inline = true;
				this["x"].AsFloat = aRot.x;
				this["y"].AsFloat = aRot.y;
				this["z"].AsFloat = aRot.z;
				this["w"].AsFloat = aRot.w;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsFloat = aRot.x;
				this[1].AsFloat = aRot.y;
				this[2].AsFloat = aRot.z;
				this[3].AsFloat = aRot.w;
			}
			return this;
		}

		public Rect ReadRect(Rect aDefault)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (IsObject)
			{
				return new Rect(this["x"].AsFloat, this["y"].AsFloat, this["width"].AsFloat, this["height"].AsFloat);
			}
			if (IsArray)
			{
				return new Rect(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, this[3].AsFloat);
			}
			return aDefault;
		}

		public Rect ReadRect()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return ReadRect(default(Rect));
		}

		public JSONNode WriteRect(Rect aRect)
		{
			if (IsObject)
			{
				Inline = true;
				this["x"].AsFloat = ((Rect)(ref aRect)).x;
				this["y"].AsFloat = ((Rect)(ref aRect)).y;
				this["width"].AsFloat = ((Rect)(ref aRect)).width;
				this["height"].AsFloat = ((Rect)(ref aRect)).height;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsFloat = ((Rect)(ref aRect)).x;
				this[1].AsFloat = ((Rect)(ref aRect)).y;
				this[2].AsFloat = ((Rect)(ref aRect)).width;
				this[3].AsFloat = ((Rect)(ref aRect)).height;
			}
			return this;
		}

		public RectOffset ReadRectOffset(RectOffset aDefault)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			if (this is JSONObject)
			{
				return new RectOffset(this["left"].AsInt, this["right"].AsInt, this["top"].AsInt, this["bottom"].AsInt);
			}
			if (this is JSONArray)
			{
				return new RectOffset(this[0].AsInt, this[1].AsInt, this[2].AsInt, this[3].AsInt);
			}
			return aDefault;
		}

		public RectOffset ReadRectOffset()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			return ReadRectOffset(new RectOffset());
		}

		public JSONNode WriteRectOffset(RectOffset aRect)
		{
			if (IsObject)
			{
				Inline = true;
				this["left"].AsInt = aRect.left;
				this["right"].AsInt = aRect.right;
				this["top"].AsInt = aRect.top;
				this["bottom"].AsInt = aRect.bottom;
			}
			else if (IsArray)
			{
				Inline = true;
				this[0].AsInt = aRect.left;
				this[1].AsInt = aRect.right;
				this[2].AsInt = aRect.top;
				this[3].AsInt = aRect.bottom;
			}
			return this;
		}

		public Matrix4x4 ReadMatrix()
		{
			//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_003b: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 identity = Matrix4x4.identity;
			if (IsArray)
			{
				for (int i = 0; i < 16; i++)
				{
					((Matrix4x4)(ref identity))[i] = this[i].AsFloat;
				}
			}
			return identity;
		}

		public JSONNode WriteMatrix(Matrix4x4 aMatrix)
		{
			if (IsArray)
			{
				Inline = true;
				for (int i = 0; i < 16; i++)
				{
					this[i].AsFloat = ((Matrix4x4)(ref aMatrix))[i];
				}
			}
			return this;
		}
	}
	public class JSONArray : JSONNode
	{
		private readonly List<JSONNode> m_List = new List<JSONNode>();

		private bool inline;

		public override bool Inline
		{
			get
			{
				return inline;
			}
			set
			{
				inline = value;
			}
		}

		public override JSONNodeType Tag => JSONNodeType.Array;

		public override bool IsArray => true;

		public override JSONNode this[int aIndex]
		{
			get
			{
				if (aIndex < 0 || aIndex >= m_List.Count)
				{
					return new JSONLazyCreator(this);
				}
				return m_List[aIndex];
			}
			set
			{
				if (value == null)
				{
					value = JSONNull.CreateOrGet();
				}
				if (aIndex < 0 || aIndex >= m_List.Count)
				{
					m_List.Add(value);
				}
				else
				{
					m_List[aIndex] = value;
				}
			}
		}

		public override JSONNode this[string aKey]
		{
			get
			{
				return new JSONLazyCreator(this);
			}
			set
			{
				if (value == null)
				{
					value = JSONNull.CreateOrGet();
				}
				m_List.Add(value);
			}
		}

		public override int Count => m_List.Count;

		public override IEnumerable<JSONNode> Children
		{
			get
			{
				foreach (JSONNode item in m_List)
				{
					yield return item;
				}
			}
		}

		public override Enumerator GetEnumerator()
		{
			return new Enumerator(m_List.GetEnumerator());
		}

		public override void Add(string aKey, JSONNode aItem)
		{
			if (aItem == null)
			{
				aItem = JSONNull.CreateOrGet();
			}
			m_List.Add(aItem);
		}

		public override JSONNode Remove(int aIndex)
		{
			if (aIndex < 0 || aIndex >= m_List.Count)
			{
				return null;
			}
			JSONNode result = m_List[aIndex];
			m_List.RemoveAt(aIndex);
			return result;
		}

		public override JSONNode Remove(JSONNode aNode)
		{
			m_List.Remove(aNode);
			return aNode;
		}

		public override void Clear()
		{
			m_List.Clear();
		}

		public override JSONNode Clone()
		{
			JSONArray jSONArray = new JSONArray();
			jSONArray.m_List.Capacity = m_List.Capacity;
			foreach (JSONNode item in m_List)
			{
				if (item != null)
				{
					jSONArray.Add(item.Clone());
				}
				else
				{
					jSONArray.Add(null);
				}
			}
			return jSONArray;
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append('[');
			int count = m_List.Count;
			if (inline)
			{
				aMode = JSONTextMode.Compact;
			}
			for (int i = 0; i < count; i++)
			{
				if (i > 0)
				{
					aSB.Append(',');
				}
				if (aMode == JSONTextMode.Indent)
				{
					aSB.AppendLine();
				}
				if (aMode == JSONTextMode.Indent)
				{
					aSB.Append(' ', aIndent + aIndentInc);
				}
				m_List[i].WriteToStringBuilder(aSB, aIndent + aIndentInc, aIndentInc, aMode);
			}
			if (aMode == JSONTextMode.Indent)
			{
				aSB.AppendLine().Append(' ', aIndent);
			}
			aSB.Append(']');
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
			aWriter.Write((byte)1);
			aWriter.Write(m_List.Count);
			for (int i = 0; i < m_List.Count; i++)
			{
				m_List[i].SerializeBinary(aWriter);
			}
		}
	}
	public class JSONObject : JSONNode
	{
		private readonly Dictionary<string, JSONNode> m_Dict = new Dictionary<string, JSONNode>();

		private bool inline;

		public override bool Inline
		{
			get
			{
				return inline;
			}
			set
			{
				inline = value;
			}
		}

		public override JSONNodeType Tag => JSONNodeType.Object;

		public override bool IsObject => true;

		public override JSONNode this[string aKey]
		{
			get
			{
				if (m_Dict.ContainsKey(aKey))
				{
					return m_Dict[aKey];
				}
				return new JSONLazyCreator(this, aKey);
			}
			set
			{
				if (value == null)
				{
					value = JSONNull.CreateOrGet();
				}
				if (m_Dict.ContainsKey(aKey))
				{
					m_Dict[aKey] = value;
				}
				else
				{
					m_Dict.Add(aKey, value);
				}
			}
		}

		public override JSONNode this[int aIndex]
		{
			get
			{
				if (aIndex < 0 || aIndex >= m_Dict.Count)
				{
					return null;
				}
				return m_Dict.ElementAt(aIndex).Value;
			}
			set
			{
				if (value == null)
				{
					value = JSONNull.CreateOrGet();
				}
				if (aIndex >= 0 && aIndex < m_Dict.Count)
				{
					string key = m_Dict.ElementAt(aIndex).Key;
					m_Dict[key] = value;
				}
			}
		}

		public override int Count => m_Dict.Count;

		public override IEnumerable<JSONNode> Children
		{
			get
			{
				foreach (KeyValuePair<string, JSONNode> item in m_Dict)
				{
					yield return item.Value;
				}
			}
		}

		public override Enumerator GetEnumerator()
		{
			return new Enumerator(m_Dict.GetEnumerator());
		}

		public override void Add(string aKey, JSONNode aItem)
		{
			if (aItem == null)
			{
				aItem = JSONNull.CreateOrGet();
			}
			if (aKey != null)
			{
				if (m_Dict.ContainsKey(aKey))
				{
					m_Dict[aKey] = aItem;
				}
				else
				{
					m_Dict.Add(aKey, aItem);
				}
			}
			else
			{
				m_Dict.Add(Guid.NewGuid().ToString(), aItem);
			}
		}

		public override JSONNode Remove(string aKey)
		{
			if (!m_Dict.ContainsKey(aKey))
			{
				return null;
			}
			JSONNode result = m_Dict[aKey];
			m_Dict.Remove(aKey);
			return result;
		}

		public override JSONNode Remove(int aIndex)
		{
			if (aIndex < 0 || aIndex >= m_Dict.Count)
			{
				return null;
			}
			KeyValuePair<string, JSONNode> keyValuePair = m_Dict.ElementAt(aIndex);
			m_Dict.Remove(keyValuePair.Key);
			return keyValuePair.Value;
		}

		public override JSONNode Remove(JSONNode aNode)
		{
			try
			{
				KeyValuePair<string, JSONNode> keyValuePair = m_Dict.Where((KeyValuePair<string, JSONNode> k) => k.Value == aNode).First();
				m_Dict.Remove(keyValuePair.Key);
				return aNode;
			}
			catch
			{
				return null;
			}
		}

		public override void Clear()
		{
			m_Dict.Clear();
		}

		public override JSONNode Clone()
		{
			JSONObject jSONObject = new JSONObject();
			foreach (KeyValuePair<string, JSONNode> item in m_Dict)
			{
				jSONObject.Add(item.Key, item.Value.Clone());
			}
			return jSONObject;
		}

		public override bool HasKey(string aKey)
		{
			return m_Dict.ContainsKey(aKey);
		}

		public override JSONNode GetValueOrDefault(string aKey, JSONNode aDefault)
		{
			if (m_Dict.TryGetValue(aKey, out var value))
			{
				return value;
			}
			return aDefault;
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append('{');
			if (Children.Count() != 0)
			{
				bool flag = true;
				if (inline)
				{
					aMode = JSONTextMode.Compact;
				}
				foreach (KeyValuePair<string, JSONNode> item in m_Dict)
				{
					if (!flag)
					{
						aSB.Append(',');
					}
					flag = false;
					if (aMode == JSONTextMode.Indent)
					{
						aSB.AppendLine();
					}
					if (aMode == JSONTextMode.Indent)
					{
						aSB.Append(' ', aIndent + aIndentInc);
					}
					aSB.Append('"').Append(JSONNode.Escape(item.Key)).Append('"');
					if (aMode == JSONTextMode.Compact)
					{
						aSB.Append(':');
					}
					else
					{
						aSB.Append(": ");
					}
					item.Value.WriteToStringBuilder(aSB, aIndent + aIndentInc, aIndentInc, aMode);
				}
				if (aMode == JSONTextMode.Indent)
				{
					aSB.AppendLine().Append(' ', aIndent);
				}
			}
			aSB.Append('}');
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
			aWriter.Write((byte)2);
			aWriter.Write(m_Dict.Count);
			foreach (string key in m_Dict.Keys)
			{
				aWriter.Write(key);
				m_Dict[key].SerializeBinary(aWriter);
			}
		}
	}
	public class JSONString : JSONNode
	{
		private string m_Data;

		public override JSONNodeType Tag => JSONNodeType.String;

		public override bool IsString => true;

		public override string Value
		{
			get
			{
				return m_Data;
			}
			set
			{
				m_Data = value;
			}
		}

		public JSONString(string aData)
		{
			m_Data = aData;
		}

		public override Enumerator GetEnumerator()
		{
			return default(Enumerator);
		}

		public override JSONNode Clone()
		{
			return new JSONString(m_Data);
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append('"').Append(JSONNode.Escape(m_Data)).Append('"');
		}

		public override bool Equals(object obj)
		{
			if (base.Equals(obj))
			{
				return true;
			}
			if (obj is string text)
			{
				return m_Data == text;
			}
			JSONString jSONString = obj as JSONString;
			if (jSONString != null)
			{
				return m_Data == jSONString.m_Data;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return m_Data.GetHashCode();
		}

		public override void Clear()
		{
			m_Data = "";
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
			aWriter.Write((byte)3);
			aWriter.Write(m_Data);
		}
	}
	public class JSONNumber : JSONNode
	{
		private double m_Data;

		public override JSONNodeType Tag => JSONNodeType.Number;

		public override bool IsNumber => true;

		public override string Value
		{
			get
			{
				return m_Data.ToString(CultureInfo.InvariantCulture);
			}
			set
			{
				if (double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					m_Data = result;
				}
			}
		}

		public override double AsDouble
		{
			get
			{
				return m_Data;
			}
			set
			{
				m_Data = value;
			}
		}

		public override long AsLong
		{
			get
			{
				return (long)m_Data;
			}
			set
			{
				m_Data = value;
			}
		}

		public override ulong AsULong
		{
			get
			{
				return (ulong)m_Data;
			}
			set
			{
				m_Data = value;
			}
		}

		public JSONNumber(double aData)
		{
			m_Data = aData;
		}

		public JSONNumber(string value)
		{
			Value = value;
		}

		public override Enumerator GetEnumerator()
		{
			return default(Enumerator);
		}

		public override JSONNode Clone()
		{
			return new JSONNumber(m_Data);
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append(m_Data.ToString("R", CultureInfo.InvariantCulture));
		}

		public static bool IsNumeric(object value)
		{
			return value is int || value is uint || value is float || value is double || value is decimal || value is long || value is ulong || value is short || value is ushort || value is sbyte || value is byte;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (base.Equals(obj))
			{
				return true;
			}
			JSONNumber jSONNumber = obj as JSONNumber;
			if (jSONNumber != null)
			{
				return m_Data == jSONNumber.m_Data;
			}
			if (IsNumeric(obj))
			{
				return Convert.ToDouble(obj) == m_Data;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return m_Data.GetHashCode();
		}

		public override void Clear()
		{
			m_Data = 0.0;
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
			aWriter.Write((byte)4);
			aWriter.Write(m_Data);
		}
	}
	public class JSONBool : JSONNode
	{
		private bool m_Data;

		public override JSONNodeType Tag => JSONNodeType.Boolean;

		public override bool IsBoolean => true;

		public override string Value
		{
			get
			{
				return m_Data.ToString();
			}
			set
			{
				if (bool.TryParse(value, out var result))
				{
					m_Data = result;
				}
			}
		}

		public override bool AsBool
		{
			get
			{
				return m_Data;
			}
			set
			{
				m_Data = value;
			}
		}

		public JSONBool(bool aData)
		{
			m_Data = aData;
		}

		public JSONBool(string aData)
		{
			Value = aData;
		}

		public override Enumerator GetEnumerator()
		{
			return default(Enumerator);
		}

		public override JSONNode Clone()
		{
			return new JSONBool(m_Data);
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append(m_Data ? "true" : "false");
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (obj is bool)
			{
				return m_Data == (bool)obj;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return m_Data.GetHashCode();
		}

		public override void Clear()
		{
			m_Data = false;
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
			aWriter.Write((byte)6);
			aWriter.Write(m_Data);
		}
	}
	public class JSONNull : JSONNode
	{
		private static readonly JSONNull m_StaticInstance = new JSONNull();

		public static bool reuseSameInstance = true;

		public override JSONNodeType Tag => JSONNodeType.NullValue;

		public override bool IsNull => true;

		public override string Value
		{
			get
			{
				return "null";
			}
			set
			{
			}
		}

		public override bool AsBool
		{
			get
			{
				return false;
			}
			set
			{
			}
		}

		private JSONNull()
		{
		}

		public static JSONNull CreateOrGet()
		{
			if (reuseSameInstance)
			{
				return m_StaticInstance;
			}
			return new JSONNull();
		}

		public override Enumerator GetEnumerator()
		{
			return default(Enumerator);
		}

		public override JSONNode Clone()
		{
			return CreateOrGet();
		}

		public override bool Equals(object obj)
		{
			if ((object)this == obj)
			{
				return true;
			}
			return obj is JSONNull;
		}

		public override int GetHashCode()
		{
			return 0;
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append("null");
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
			aWriter.Write((byte)5);
		}
	}
	internal class JSONLazyCreator : JSONNode
	{
		private readonly string m_Key;

		private JSONNode m_Node;

		public override JSONNodeType Tag => JSONNodeType.None;

		public override JSONNode this[int aIndex]
		{
			get
			{
				return new JSONLazyCreator(this);
			}
			set
			{
				Set(new JSONArray()).Add(value);
			}
		}

		public override JSONNode this[string aKey]
		{
			get
			{
				return new JSONLazyCreator(this, aKey);
			}
			set
			{
				Set(new JSONObject()).Add(aKey, value);
			}
		}

		public override int AsInt
		{
			get
			{
				Set(new JSONNumber(0.0));
				return 0;
			}
			set
			{
				Set(new JSONNumber(value));
			}
		}

		public override float AsFloat
		{
			get
			{
				Set(new JSONNumber(0.0));
				return 0f;
			}
			set
			{
				Set(new JSONNumber(value));
			}
		}

		public override double AsDouble
		{
			get
			{
				Set(new JSONNumber(0.0));
				return 0.0;
			}
			set
			{
				Set(new JSONNumber(value));
			}
		}

		public override long AsLong
		{
			get
			{
				if (JSONNode.longAsString)
				{
					Set(new JSONString("0"));
				}
				else
				{
					Set(new JSONNumber(0.0));
				}
				return 0L;
			}
			set
			{
				if (JSONNode.longAsString)
				{
					Set(new JSONString(value.ToString()));
				}
				else
				{
					Set(new JSONNumber(value));
				}
			}
		}

		public override ulong AsULong
		{
			get
			{
				if (JSONNode.longAsString)
				{
					Set(new JSONString("0"));
				}
				else
				{
					Set(new JSONNumber(0.0));
				}
				return 0uL;
			}
			set
			{
				if (JSONNode.longAsString)
				{
					Set(new JSONString(value.ToString()));
				}
				else
				{
					Set(new JSONNumber(value));
				}
			}
		}

		public override bool AsBool
		{
			get
			{
				Set(new JSONBool(aData: false));
				return false;
			}
			set
			{
				Set(new JSONBool(value));
			}
		}

		public override JSONArray AsArray => Set(new JSONArray());

		public override JSONObject AsObject => Set(new JSONObject());

		public JSONLazyCreator(JSONNode aNode)
		{
			m_Node = aNode;
			m_Key = null;
		}

		public JSONLazyCreator(JSONNode aNode, string aKey)
		{
			m_Node = aNode;
			m_Key = aKey;
		}

		public override Enumerator GetEnumerator()
		{
			return default(Enumerator);
		}

		private T Set<T>(T aVal) where T : JSONNode
		{
			if (m_Key == null)
			{
				m_Node.Add(aVal);
			}
			else
			{
				m_Node.Add(m_Key, aVal);
			}
			m_Node = null;
			return aVal;
		}

		public override void Add(JSONNode aItem)
		{
			Set(new JSONArray()).Add(aItem);
		}

		public override void Add(string aKey, JSONNode aItem)
		{
			Set(new JSONObject()).Add(aKey, aItem);
		}

		public static bool operator ==(JSONLazyCreator a, object b)
		{
			if (b == null)
			{
				return true;
			}
			return (object)a == b;
		}

		public static bool operator !=(JSONLazyCreator a, object b)
		{
			return !(a == b);
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return true;
			}
			return (object)this == obj;
		}

		public override int GetHashCode()
		{
			return 0;
		}

		internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode)
		{
			aSB.Append("null");
		}

		public override void SerializeBinary(BinaryWriter aWriter)
		{
		}
	}
	public static class JSON
	{
		public static JSONNode Parse(string aJSON)
		{
			return JSONNode.Parse(aJSON);
		}

		public static string ToJson(object data, bool isIndented = true)
		{
			return new SimpleJSONBuilder().Serialize(data, isIndented);
		}

		public static T FromJson<T>(string data) where T : new()
		{
			return new SimpleJSONBuilder().Deserialize<T>(data);
		}
	}
	public class SimpleJSONBuilder
	{
		public T Deserialize<T>(string serializationStream) where T : new()
		{
			JSONNode value = JSON.Parse(serializationStream);
			return (T)SimpleJSONStaticParser.FromJsonNode(value, typeof(T), default(SimpleJSONParserSettings));
		}

		public string Serialize(object graph, bool isIndented)
		{
			SimpleJSONParserSettings simpleJSONParserSettings = default(SimpleJSONParserSettings);
			simpleJSONParserSettings.IsIndented = isIndented;
			SimpleJSONParserSettings settings = simpleJSONParserSettings;
			JSONNode jSONNode = SimpleJSONStaticParser.ToJsonNode(graph, settings);
			StringBuilder stringBuilder = new StringBuilder();
			jSONNode.WriteToStringBuilder(stringBuilder, 0, settings.IsIndented ? 2 : 0, settings.IsIndented ? JSONTextMode.Indent : JSONTextMode.Compact);
			return stringBuilder.ToString();
		}
	}
	public struct SimpleJSONParserSettings
	{
		public bool IsIndented;

		public static SimpleJSONParserSettings Default()
		{
			SimpleJSONParserSettings result = default(SimpleJSONParserSettings);
			result.IsIndented = true;
			return result;
		}
	}
	public static class SimpleJSONStaticParser
	{
		public static object FromJsonNodeImplicitSlow(JSONNode node, Type type)
		{
			Type typeFromHandle = typeof(JSONNode);
			MethodInfo methodInfo = typeFromHandle.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo info) => info.Name == "op_Implicit" && info.ReturnType == type);
			if (methodInfo != null)
			{
				object[] parameters = new JSONNode[1] { node };
				return methodInfo.Invoke(null, parameters);
			}
			return node;
		}

		public static object FromJsonNode(JSONNode value, Type type, SimpleJSONParserSettings settings)
		{
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			if (value == null)
			{
				return null;
			}
			if (type == typeof(string))
			{
				return (string)value;
			}
			if (type == typeof(char))
			{
				return (char)value;
			}
			if (type == typeof(bool))
			{
				return (bool)value;
			}
			if (typeof(IList).IsAssignableFrom(type))
			{
				Type typeFromHandle = typeof(List<>);
				Type[] genericArguments = type.GetGenericArguments();
				Type type2 = typeFromHandle.MakeGenericType(genericArguments);
				IList list = (IList)Activator.CreateInstance(type2);
				foreach (JSONNode child in value.AsArray.Children)
				{
					list.Add(FromJsonNode(child, genericArguments[0], settings));
				}
				return list;
			}
			if (typeof(IDictionary).IsAssignableFrom(type))
			{
				Type typeFromHandle2 = typeof(Dictionary<, >);
				Type[] genericArguments2 = type.GetGenericArguments();
				Type type3 = typeFromHandle2.MakeGenericType(genericArguments2);
				IDictionary dictionary = (IDictionary)Activator.CreateInstance(type3);
				JSONNode.Enumerator enumerator2 = value.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					KeyValuePair<string, JSONNode> current2 = enumerator2.Current;
					dictionary.Add(FromJsonNode(current2.Key, genericArguments2[0], settings), FromJsonNode(current2.Value, genericArguments2[1], settings));
				}
				return dictionary;
			}
			if (type == typeof(Vector2))
			{
				return (Vector2)value;
			}
			if (type == typeof(Vector3))
			{
				return (Vector3)value;
			}
			if (type == typeof(Vector4))
			{
				return (Vector4)value;
			}
			if (type == typeof(Quaternion))
			{
				return (Quaternion)value;
			}
			if (type == typeof(Rect))
			{
				return (Rect)value;
			}
			if (type == typeof(RectOffset))
			{
				return (RectOffset)value;
			}
			if (type == typeof(Matrix4x4))
			{
				return (Matrix4x4)value;
			}
			if (type == typeof(Color))
			{
				return (Color)value;
			}
			if (type == typeof(Color32))
			{
				return (Color32)value;
			}
			if (type == typeof(byte))
			{
				return (byte)value;
			}
			if (type == typeof(sbyte))
			{
				return (sbyte)value;
			}
			if (type == typeof(int))
			{
				return (int)value;
			}
			if (type == typeof(uint))
			{
				return (uint)value;
			}
			if (type == typeof(short))
			{
				return (short)value;
			}
			if (type == typeof(ushort))
			{
				return (ushort)value;
			}
			if (type == typeof(char))
			{
				return (char)value;
			}
			if (type == typeof(float))
			{
				return (float)value;
			}
			if (type == typeof(double))
			{
				return (double)value;
			}
			if (type == typeof(decimal))
			{
				return (decimal)value;
			}
			if (type == typeof(long))
			{
				return (long)value;
			}
			if (type == typeof(ulong))
			{
				return (ulong)value;
			}
			object obj = Activator.CreateInstance(type);
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(obj, FromJsonNode(value[fieldInfo.Name], fieldInfo.FieldType, settings));
			}
			return obj;
		}

		public static JSONNode ToJsonNode(object value, SimpleJSONParserSettings settings)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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)
			if (value != null)
			{
				if (!(value is JSONNode result))
				{
					if (!(value is string aData))
					{
						if (!(value is char c))
						{
							if (!(value is bool aData2))
							{
								if (!(value is IList list))
								{
									if (!(value is IDictionary dict))
									{
										if (!(value is Vector2 val))
										{
											if (!(value is Vector3 val2))
											{
												if (!(value is Vector4 val3))
												{
													if (!(value is Quaternion val4))
													{
														if (!(value is Rect val5))
														{
															RectOffset val6 = (RectOffset)((value is RectOffset) ? value : null);
															if (val6 == null)
															{
																if (!(value is Matrix4x4 val7))
																{
																	if (!(value is Color val8))
																	{
																		if (!(value is Color32 val9))
																		{
																			if (value is float num)
																			{
																				return new JSONNumber(num.ToString("R", CultureInfo.InvariantCulture));
																			}
																			if (JSONNumber.IsNumeric(value))
																			{
																				return new JSONNumber(Convert.ToDouble(value));
																			}
																			JSONObject jSONObject = new JSONObject();
																			FieldInfo[] fields = value.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
																			FieldInfo[] array = fields;
																			foreach (FieldInfo fieldInfo in array)
																			{
																				object value2 = fieldInfo.GetValue(value);
																				JSONNode aItem = ToJsonNode(value2, settings);
																				jSONObject.Add(fieldInfo.Name, aItem);
																			}
																			return jSONObject;
																		}
																		return val9;
																	}
																	return val8;
																}
																return val7;
															}
															return val6;
														}
														return val5;
													}
													return val4;
												}
												return val3;
											}
											return val2;
										}
										return val;
									}
									return ToJsonNode(dict, settings);
								}
								return ToJsonNode(list, settings);
							}
							return new JSONBool(aData2);
						}
						return new JSONString(new string(c, 1));
					}
					return new JSONString(aData);
				}
				return result;
			}
			return JSONNull.CreateOrGet();
		}

		private static JSONArray ToJsonNode(IList list, SimpleJSONParserSettings settings)
		{
			JSONArray jSONArray = new JSONArray();
			for (int i = 0; i < list.Count; i++)
			{
				jSONArray.Add(ToJsonNode(list[i], settings));
			}
			return jSONArray;
		}

		private static JSONObject ToJsonNode(IDictionary dict, SimpleJSONParserSettings settings)
		{
			JSONObject jSONObject = new JSONObject();
			foreach (object key in dict.Keys)
			{
				jSONObject.Add(key.ToString(), ToJsonNode(dict[key], settings));
			}
			return jSONObject;
		}
	}
	public enum JSONContainerType
	{
		Array,
		Object
	}
}
namespace DSPMultiplyStackSize
{
	[BepInPlugin("Appun.DSP.plugin.MultiplyStackSize", "DSPMultiplyStackSize", "1.0.13")]
	public class Main : BaseUnityPlugin
	{
		public static bool StackSizeUpdated = false;

		public static Sprite stackIcon;

		public static ConfigEntry<int> configMultiplyStackSize;

		public static ConfigEntry<bool> editWarperSlotStackSize;

		public static bool stackSizeChangerMode = false;

		public static int maxIndex;

		public static Dictionary<int, int> stackSizeDictionaryOrigin = new Dictionary<int, int>();

		public static Dictionary<int, int> stackSizeDictionary = new Dictionary<int, int>();

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

		public static string jsonFilePath;

		public void Start()
		{
			configMultiplyStackSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StackSizeMultiplier", 5, "Multiplies the stack size of all items.");
			editWarperSlotStackSize = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "changeWarperSlotStackSize", true, "change Mecha Warper Slot Stack Size ");
			LogManager.Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			jsonFilePath = Path.Combine(Paths.ConfigPath, "stackSizeDictionary.json");
			if (!File.Exists(jsonFilePath))
			{
				File.WriteAllText(jsonFilePath, JSON.ToJson("{}"));
			}
			else
			{
				stackSizeDictionary = JSON.FromJson<Dictionary<int, int>>(File.ReadAllText(jsonFilePath));
			}
			LoadIcon();
			maxIndex = 112;
			UI.Create();
		}

		public static void LoadIcon()
		{
			try
			{
				AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("DSPMultiplyStackSize.multiplystacksize"));
				if ((Object)(object)val == (Object)null)
				{
					LogManager.Logger.LogInfo((object)"Icon loaded.");
					return;
				}
				stackIcon = val.LoadAsset<Sprite>("StackSize");
				val.Unload(false);
			}
			catch (Exception ex)
			{
				LogManager.Logger.LogInfo((object)("e.Message " + ex.Message));
				LogManager.Logger.LogInfo((object)("e.StackTrace " + ex.StackTrace));
			}
		}
	}
	public class LogManager
	{
		public static ManualLogSource Logger;
	}
	[HarmonyPatch]
	internal class Patch
	{
		[HarmonyPatch(typeof(UIMechaWindow), "_OnOpen")]
		public static class UIMechaWindow_OnOpen
		{
			[HarmonyPostfix]
			public static void Postfix(UIMechaWindow __instance)
			{
				__instance.warpGrid.storage.grids[0].filter = 1210;
				__instance.warpGrid.storage.grids[0].itemId = 1210;
				__instance.warpGrid.storage.grids[0].stackSize = StorageComponent.itemStackCount[1210];
			}
		}

		public static ItemProto selectedProto;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIItemPicker), "OnBoxMouseDown")]
		public static bool UIItemPicker_OnBoxMouseDowne_PrePatch(UIItemPicker __instance)
		{
			if (Main.stackSizeChangerMode)
			{
				if (__instance.hoveredIndex >= 0)
				{
					selectedProto = __instance.protoArray[__instance.hoveredIndex];
					if (selectedProto != null)
					{
						UI.selectedItemName.GetComponent<Text>().text = ((Proto)selectedProto).name;
						((Component)UI.selectedItemIcon.transform.Find("icon 1")).gameObject.SetActive(true);
						((Component)UI.selectedItemIcon.transform.Find("icon 1")).GetComponent<Image>().sprite = selectedProto.iconSprite;
						UI.selectedItemStackSizeInput.GetComponent<InputField>().text = selectedProto.StackSize.ToString();
						return false;
					}
				}
				else
				{
					UI.selectedItemName.GetComponent<Text>().text = "";
					((Component)UI.selectedItemIcon.transform.Find("icon 1")).gameObject.SetActive(false);
					UI.selectedItemStackSizeInput.GetComponent<InputField>().text = "";
				}
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIItemPicker), "OnTypeButtonClick")]
		public static void UIItemPicker_OnTypeButtonClick_PostPatch(UIItemPicker __instance)
		{
			if (Main.stackSizeChangerMode)
			{
				UI.selectedItemName.GetComponent<Text>().text = "";
				((Component)UI.selectedItemIcon.transform.Find("icon 1")).gameObject.SetActive(false);
				UI.selectedItemStackSizeInput.GetComponent<InputField>().text = "";
				UI.refreshNumTexts();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIItemPicker), "_OnOpen")]
		public static void UIItemPicker_OnUpdate_Patch(UIItemPicker __instance)
		{
			if (Main.stackSizeChangerMode)
			{
				UI.numTextsBase.SetActive(true);
				UI.resetButton.SetActive(true);
				UI.selectedItem.SetActive(true);
				UI.selectedItemName.GetComponent<Text>().text = "";
				((Component)UI.selectedItemIcon.transform.Find("icon 1")).gameObject.SetActive(false);
				UI.selectedItemStackSizeInput.GetComponent<InputField>().text = "";
				UI.refreshNumTexts();
			}
			else
			{
				UI.selectedItem.SetActive(false);
				UI.numTextsBase.SetActive(false);
				UI.resetButton.SetActive(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIItemPicker), "_OnClose")]
		public static void UIItemPicker_Close_Patch(UIItemPicker __instance)
		{
			Main.stackSizeChangerMode = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
		[HarmonyPriority(1)]
		public static void VFPreload_PreloadThread_Patch()
		{
			if (Main.StackSizeUpdated)
			{
				return;
			}
			LogManager.Logger.LogInfo((object)"Apply Multiply Stack Size.");
			ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
			foreach (ItemProto val in dataArray)
			{
				if (val != null)
				{
					int num = val.StackSize * Main.configMultiplyStackSize.Value;
					Main.stackSizeDictionaryOrigin.Add(((Proto)val).ID, num);
					if (Main.stackSizeDictionary.ContainsKey(((Proto)val).ID))
					{
						num = Main.stackSizeDictionary[((Proto)val).ID];
					}
					val.StackSize = num;
					StorageComponent.itemStackCount[((Proto)val).ID] = num;
				}
			}
			Main.StackSizeUpdated = true;
		}

		public static void Mecha_Init_Patch(Mecha __instance)
		{
			LogManager.Logger.LogInfo((object)"WarperSlot1.");
			__instance.warpStorage.grids[0].filter = 1210;
			__instance.warpStorage.grids[0].itemId = 1210;
			__instance.warpStorage.grids[0].stackSize = StorageComponent.itemStackCount[1210];
			LogManager.Logger.LogInfo((object)("WarperSlot1 stacksize : " + __instance.warpStorage.grids[0].stackSize));
		}

		public static void Mecha_SetForNewGame_Patch(Mecha __instance)
		{
			LogManager.Logger.LogInfo((object)"WarperSlot2.");
			__instance.warpStorage.grids[0].filter = 1210;
			__instance.warpStorage.grids[0].itemId = 1210;
			__instance.warpStorage.grids[0].stackSize = StorageComponent.itemStackCount[1210];
			LogManager.Logger.LogInfo((object)("WarperSlot2 stacksize : " + __instance.warpStorage.grids[0].stackSize));
		}
	}
	public class UI : MonoBehaviour
	{
		public static UIMessageBox messageBox;

		public static GameObject selectedItem;

		public static GameObject stackSizeButton;

		public static GameObject ItemPicker;

		public static GameObject selectedItemStackSizeInput;

		public static GameObject selectedItemName;

		public static GameObject stackSizeLabel;

		public static GameObject applyButton;

		public static GameObject resetButton;

		public static GameObject numTextsBase;

		public static Text prefabNumText;

		public static Text[] numTexts = (Text[])(object)new Text[Main.maxIndex];

		public static GameObject selectedItemIcon;

		public static Color normalColor = new Color(0.4f, 0.8f, 1f, 0.8f);

		public static Color editedColor = new Color(1f, 0.6f, 0f, 0.9f);

		public static void Create()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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_020f: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_06de: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0750: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_084e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0853: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0905: Expected O, but got Unknown
			//IL_091c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0926: Expected O, but got Unknown
			//IL_093d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0947: Expected O, but got Unknown
			ItemPicker = ((Component)UIRoot.instance.uiGame.itemPicker).gameObject;
			prefabNumText = Object.Instantiate<Text>(UIRoot.instance.uiGame.inventoryWindow.inventory.prefabNumText, ((Component)ItemPicker.transform.Find("content")).gameObject.transform);
			prefabNumText.fontSize = 14;
			((Shadow)((Component)prefabNumText).gameObject.GetComponent<Outline>()).effectDistance = new Vector2(2f, 2f);
			((Behaviour)((Component)prefabNumText).gameObject.GetComponent<Outline>()).enabled = true;
			((Component)prefabNumText).gameObject.GetComponent<Shadow>().effectDistance = new Vector2(2f, 2f);
			((Behaviour)((Component)prefabNumText).gameObject.GetComponent<Shadow>()).enabled = true;
			((Component)prefabNumText).gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(46f, 24f);
			numTextsBase = new GameObject();
			numTextsBase.transform.SetParent(((Component)ItemPicker.transform.Find("content")).gameObject.transform, false);
			((Object)numTextsBase).name = "numTextsBase";
			numTextsBase.transform.localPosition = new Vector3(-273f, 5f, 0f);
			numTextsBase.SetActive(false);
			for (int i = 0; i < Main.maxIndex; i++)
			{
				numTexts[i] = Object.Instantiate<Text>(prefabNumText, numTextsBase.gameObject.transform);
				((Object)numTexts[i]).name = "numTexts" + i;
				int num = i % 14;
				int num2 = i / 14;
				((Graphic)numTexts[i]).rectTransform.anchoredPosition = new Vector2((float)(num * 46 - 5 - 46), (float)(num2 * -46 - 29));
			}
			selectedItem = new GameObject();
			selectedItem.transform.SetParent(ItemPicker.transform, false);
			((Object)selectedItem).name = "selectedItem";
			selectedItem.transform.localPosition = new Vector3(-55f, -5f, 0f);
			selectedItem.SetActive(false);
			selectedItemStackSizeInput = Object.Instantiate<GameObject>(((Component)UIRoot.instance.uiGame.blueprintBrowser.inspector.shortTextInput).gameObject, selectedItem.transform);
			((Object)selectedItemStackSizeInput).name = "inputText";
			selectedItemStackSizeInput.GetComponent<InputField>().contentType = (ContentType)2;
			selectedItemStackSizeInput.GetComponent<InputField>().characterLimit = 6;
			selectedItemStackSizeInput.transform.localPosition = new Vector3(440f, -75f, 0f);
			selectedItemStackSizeInput.GetComponent<RectTransform>().sizeDelta = new Vector2(60f, 24f);
			selectedItemStackSizeInput.SetActive(true);
			Object.Destroy((Object)(object)selectedItemStackSizeInput.GetComponent<UIButton>());
			selectedItemIcon = Object.Instantiate<GameObject>(((Component)((Component)UIRoot.instance.uiGame.replicator.treeMainIcon0).gameObject.transform.parent).gameObject);
			selectedItemIcon.transform.SetParent(selectedItem.transform, false);
			selectedItemIcon.transform.localPosition = new Vector3(300f, -75f, 0f);
			((Component)selectedItemIcon.transform.Find("place-text")).GetComponentInChildren<Text>().text = Localization.Translate("Selected Item");
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("vline-m")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("hline-0")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("hline-1")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("icon 2")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("text 1")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("text 2")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("time-text")).gameObject);
			Object.Destroy((Object)(object)((Component)selectedItemIcon.transform.Find("time-text")).gameObject);
			selectedItemIcon.SetActive(true);
			selectedItemName = Object.Instantiate<GameObject>(((Component)selectedItemIcon.transform.Find("place-text")).gameObject, selectedItem.transform);
			selectedItemName.transform.localPosition = new Vector3(445f, -60f, 0f);
			selectedItemName.GetComponent<Text>().fontSize = 16;
			selectedItemName.GetComponent<Text>().text = "";
			selectedItemName.GetComponent<Text>().alignment = (TextAnchor)3;
			selectedItemName.SetActive(true);
			stackSizeLabel = Object.Instantiate<GameObject>(((Component)selectedItemIcon.transform.Find("place-text")).gameObject, selectedItem.transform);
			stackSizeLabel.transform.localPosition = new Vector3(385f, -87f, 0f);
			stackSizeLabel.GetComponent<Text>().text = Localization.Translate("Stack Size");
			stackSizeLabel.SetActive(true);
			applyButton = Object.Instantiate<GameObject>(((Component)UIRoot.instance.uiGame.stationWindow.storageUIPrefab.localSdButton).gameObject, selectedItem.transform);
			applyButton.transform.localPosition = new Vector3(565f, -87f, 0f);
			((Object)applyButton).name = "applyButton";
			applyButton.GetComponentInChildren<Text>().text = Localization.Translate("Apply");
			applyButton.GetComponent<RectTransform>().sizeDelta = new Vector2(60f, 26f);
			((Graphic)applyButton.GetComponent<Image>()).color = new Color(0.24f, 0.55f, 0.65f, 0.7f);
			applyButton.SetActive(true);
			resetButton = Object.Instantiate<GameObject>(applyButton, ItemPicker.transform);
			resetButton.transform.localPosition = new Vector3(580f, -105f, 0f);
			((Object)resetButton).name = "resetButton";
			resetButton.GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 20f);
			resetButton.GetComponentInChildren<Text>().text = Localization.Translate("Reset");
			((Graphic)resetButton.GetComponent<Image>()).color = new Color(1f, 0.68f, 0.45f, 0.7f);
			resetButton.SetActive(true);
			GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Player Inventory/panel-bg/title-text");
			stackSizeButton = Object.Instantiate<GameObject>(GameObject.Find("UI Root/Overlay Canvas/In Game/Game Menu/detail-func-group/dfunc-1"), val.transform);
			((Object)stackSizeButton).name = "stackSizeButton";
			stackSizeButton.transform.localPosition = new Vector3(114f, -3f, 0f);
			stackSizeButton.transform.localScale = new Vector3(0.6f, 0.6f, 1f);
			stackSizeButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Stack size editor");
			stackSizeButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to enter Stack Size edit mode.");
			stackSizeButton.GetComponent<UIButton>().tips.corner = 4;
			stackSizeButton.GetComponent<UIButton>().tips.offset = new Vector2(0f, 20f);
			stackSizeButton.GetComponent<RectTransform>().sizeDelta = new Vector2(27f, 27f);
			((Component)stackSizeButton.transform.Find("icon")).GetComponent<RectTransform>().sizeDelta = new Vector2(15f, 15f);
			((Component)stackSizeButton.transform.Find("icon")).GetComponent<Image>().sprite = Main.stackIcon;
			stackSizeButton.GetComponent<UIButton>().highlighted = true;
			stackSizeButton.SetActive(true);
			((UnityEvent)stackSizeButton.GetComponent<Button>().onClick).AddListener(new UnityAction(OnClickStackSizeButton));
			((UnityEvent)applyButton.GetComponent<Button>().onClick).AddListener(new UnityAction(OnClickApplyButton));
			((UnityEvent)resetButton.GetComponent<Button>().onClick).AddListener(new UnityAction(OnClickResetButton));
		}

		public static void OnClickStackSizeButton()
		{
			if (UIItemPicker.isOpened)
			{
				Main.stackSizeChangerMode = false;
				UIItemPicker.Close();
			}
			else
			{
				Main.stackSizeChangerMode = true;
				((ManualBehaviour)UIRoot.instance.uiGame.itemPicker)._Open();
			}
		}

		public static void OnClickApplyButton()
		{
			if (Patch.selectedProto == null)
			{
				return;
			}
			ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(((Proto)Patch.selectedProto).ID);
			int num = int.Parse(selectedItemStackSizeInput.GetComponent<InputField>().text);
			if (val.StackSize != num)
			{
				val.StackSize = num;
				StorageComponent.itemStackCount[((Proto)val).ID] = num;
				if (Main.stackSizeDictionary.ContainsKey(((Proto)Patch.selectedProto).ID))
				{
					Main.stackSizeDictionary[((Proto)Patch.selectedProto).ID] = num;
				}
				else
				{
					Main.stackSizeDictionary.Add(((Proto)Patch.selectedProto).ID, num);
				}
				File.WriteAllText(Main.jsonFilePath, JSON.ToJson(Main.stackSizeDictionary));
				selectedItemName.GetComponent<Text>().text = "";
				((Component)selectedItemIcon.transform.Find("icon 1")).gameObject.SetActive(false);
				selectedItemStackSizeInput.GetComponent<InputField>().text = "";
				refreshNumTexts();
			}
		}

		public static void OnClickResetButton()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			messageBox = UIMessageBox.Show(Localization.Translate("DSPMultiplyStackSize"), Localization.Translate("Reset all stack sizes?"), Localization.Translate("Cancel"), Localization.Translate("Reset"), 0, (Response)null, new Response(Reset));
		}

		public static void OnClickCloseButton()
		{
			selectedItem.SetActive(false);
			resetButton.SetActive(false);
			numTextsBase.SetActive(false);
			Main.stackSizeChangerMode = false;
			UIItemPicker.Close();
		}

		public static void refreshNumTexts()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Main.maxIndex; i++)
			{
				if (UIRoot.instance.uiGame.itemPicker.protoArray[i] != null)
				{
					numTexts[i].text = UIRoot.instance.uiGame.itemPicker.protoArray[i].StackSize.ToString();
					((Component)numTexts[i]).gameObject.SetActive(true);
					if (Main.stackSizeDictionary.ContainsKey(((Proto)UIRoot.instance.uiGame.itemPicker.protoArray[i]).ID))
					{
						((Graphic)numTexts[i]).color = editedColor;
					}
					else
					{
						((Graphic)numTexts[i]).color = normalColor;
					}
				}
				else
				{
					((Component)numTexts[i]).gameObject.SetActive(false);
				}
			}
		}

		public static void Reset()
		{
			Main.stackSizeDictionary.Clear();
			File.WriteAllText(Main.jsonFilePath, JSON.ToJson(Main.stackSizeDictionary));
			ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
			foreach (ItemProto val in dataArray)
			{
				int num = (val.StackSize = Main.stackSizeDictionaryOrigin[((Proto)val).ID]);
				StorageComponent.itemStackCount[((Proto)val).ID] = num;
			}
			refreshNumTexts();
		}
	}
}