Decompiled source of WackysDatabase v2.4.46

WackysDatabase.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using B83.Image.BMP;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dummiesman;
using Dummiesman.Extensions;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using PieceManager;
using RainbowTrollArmor;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;
using wackydatabase;
using wackydatabase.Armor;
using wackydatabase.Datas;
using wackydatabase.GetData;
using wackydatabase.OBJimporter;
using wackydatabase.OtherApi;
using wackydatabase.Read;
using wackydatabase.SetData;
using wackydatabase.SetData.SetOldData;
using wackydatabase.Startup;
using wackydatabase.Util;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WackysDatabase")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("WackysDatabase")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("2.4.46")]
[assembly: AssemblyCompany("WackyMole")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.4.46.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<3badc016-54c3-4b33-abb1-8d87ba46e93e>Embedded]
	internal sealed class <3badc016-54c3-4b33-abb1-8d87ba46e93e>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<3badc016-54c3-4b33-abb1-8d87ba46e93e>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<3badc016-54c3-4b33-abb1-8d87ba46e93e>Embedded]
	[CompilerGenerated]
	internal sealed class <3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
public class MTLLoader
{
	public List<string> SearchPaths = new List<string>
	{
		"%FileName%_Textures",
		string.Empty
	};

	private FileInfo _objFileInfo;

	public virtual Texture2D TextureLoadFunction(string path, bool isNormalMap)
	{
		foreach (string searchPath in SearchPaths)
		{
			string text = Path.Combine((_objFileInfo != null) ? searchPath.Replace("%FileName%", Path.GetFileNameWithoutExtension(_objFileInfo.Name)) : searchPath, path);
			if (File.Exists(text))
			{
				Texture2D val = ImageLoader.LoadTexture(text);
				if (isNormalMap)
				{
					val = ImageUtils.ConvertToNormalMap(val);
				}
				return val;
			}
		}
		return null;
	}

	private Texture2D TryLoadTexture(string texturePath, bool normalMap = false)
	{
		texturePath = texturePath.Replace('\\', Path.DirectorySeparatorChar);
		texturePath = texturePath.Replace('/', Path.DirectorySeparatorChar);
		return TextureLoadFunction(texturePath, normalMap);
	}

	private int GetArgValueCount(string arg)
	{
		switch (arg)
		{
		case "-bm":
		case "-blendu":
		case "-blendv":
		case "-texres":
		case "-clamp":
		case "-imfchan":
			return 1;
		case "-mm":
			return 2;
		case "-o":
		case "-s":
		case "-t":
			return 3;
		default:
			return -1;
		}
	}

	private int GetTexNameIndex(string[] components)
	{
		int num;
		for (num = 1; num < components.Length; num++)
		{
			int argValueCount = GetArgValueCount(components[num]);
			if (argValueCount < 0)
			{
				return num;
			}
			num += argValueCount;
		}
		return -1;
	}

	private float GetArgValue(string[] components, string arg, float fallback = 1f)
	{
		string text = arg.ToLower();
		for (int i = 1; i < components.Length - 1; i++)
		{
			string text2 = components[i].ToLower();
			if (text == text2)
			{
				return OBJLoaderHelper.FastFloatParse(components[i + 1]);
			}
		}
		return fallback;
	}

	private string GetTexPathFromMapStatement(string processedLine, string[] splitLine)
	{
		int texNameIndex = GetTexNameIndex(splitLine);
		if (texNameIndex < 0)
		{
			Debug.LogError((object)("texNameCmpIdx < 0 on line " + processedLine + ". Texture not loaded."));
			return null;
		}
		int startIndex = processedLine.IndexOf(splitLine[texNameIndex]);
		return processedLine.Substring(startIndex);
	}

	public Dictionary<string, Material> Load(Stream input)
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Invalid comparison between Unknown and I4
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Invalid comparison between Unknown and I4
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0392: Unknown result type (might be due to invalid IL or missing references)
		StringReader stringReader = new StringReader(new StreamReader(input).ReadToEnd());
		Dictionary<string, Material> dictionary = new Dictionary<string, Material>();
		Material val = null;
		for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
		{
			if (!string.IsNullOrWhiteSpace(text))
			{
				string text2 = text.Clean();
				string[] array = text2.Split(new char[1] { ' ' });
				if (array.Length >= 2 && text2[0] != '#')
				{
					if (array[0] == "newmtl")
					{
						string text3 = text2.Substring(7);
						Material val3 = (dictionary[text3] = new Material(Shader.Find("Standard (Specular setup)"))
						{
							name = text3
						});
						val = val3;
					}
					else if (!((Object)(object)val == (Object)null))
					{
						if (array[0] == "Kd" || array[0] == "kd")
						{
							Color color = val.GetColor("_Color");
							Color val4 = OBJLoaderHelper.ColorFromStrArray(array);
							val.SetColor("_Color", new Color(val4.r, val4.g, val4.b, color.a));
						}
						else if (array[0] == "map_Kd" || array[0] == "map_kd")
						{
							string texPathFromMapStatement = GetTexPathFromMapStatement(text2, array);
							if (texPathFromMapStatement != null)
							{
								Texture2D val5 = TryLoadTexture(texPathFromMapStatement);
								val.SetTexture("_MainTex", (Texture)(object)val5);
								if ((Object)(object)val5 != (Object)null && ((int)val5.format == 12 || (int)val5.format == 5))
								{
									OBJLoaderHelper.EnableMaterialTransparency(val);
								}
								if (Path.GetExtension(texPathFromMapStatement).ToLower() == ".dds")
								{
									val.mainTextureScale = new Vector2(1f, -1f);
								}
							}
						}
						else if (array[0] == "map_Bump" || array[0] == "map_bump")
						{
							string texPathFromMapStatement2 = GetTexPathFromMapStatement(text2, array);
							if (texPathFromMapStatement2 != null)
							{
								Texture2D val6 = TryLoadTexture(texPathFromMapStatement2, normalMap: true);
								float argValue = GetArgValue(array, "-bm");
								if ((Object)(object)val6 != (Object)null)
								{
									val.SetTexture("_BumpMap", (Texture)(object)val6);
									val.SetFloat("_BumpScale", argValue);
									val.EnableKeyword("_NORMALMAP");
								}
							}
						}
						else if (array[0] == "Ks" || array[0] == "ks")
						{
							val.SetColor("_SpecColor", OBJLoaderHelper.ColorFromStrArray(array));
						}
						else if (array[0] == "Ka" || array[0] == "ka")
						{
							val.SetColor("_EmissionColor", OBJLoaderHelper.ColorFromStrArray(array, 0.05f));
							val.EnableKeyword("_EMISSION");
						}
						else if (array[0] == "map_Ka" || array[0] == "map_ka")
						{
							string texPathFromMapStatement3 = GetTexPathFromMapStatement(text2, array);
							if (texPathFromMapStatement3 != null)
							{
								val.SetTexture("_EmissionMap", (Texture)(object)TryLoadTexture(texPathFromMapStatement3));
							}
						}
						else if (array[0] == "d" || array[0] == "Tr")
						{
							float num = OBJLoaderHelper.FastFloatParse(array[1]);
							if (array[0] == "Tr")
							{
								num = 1f - num;
							}
							if (num < 1f - Mathf.Epsilon)
							{
								Color color2 = val.GetColor("_Color");
								color2.a = num;
								val.SetColor("_Color", color2);
								OBJLoaderHelper.EnableMaterialTransparency(val);
							}
						}
						else if (array[0] == "Ns" || array[0] == "ns")
						{
							float num2 = OBJLoaderHelper.FastFloatParse(array[1]);
							num2 /= 1000f;
							val.SetFloat("_Glossiness", num2);
						}
					}
				}
			}
		}
		return dictionary;
	}

	public Dictionary<string, Material> Load(string path)
	{
		_objFileInfo = new FileInfo(path);
		SearchPaths.Add(_objFileInfo.Directory.FullName);
		using FileStream input = new FileStream(path, FileMode.Open);
		return Load(input);
	}
}
public class RequirementQuality
{
	public int quality;
}
[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
public class ColorUtil
{
	public static Color GetColorFromHex(string hex)
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		hex = hex.TrimStart(new char[1] { '#' });
		Color result = default(Color);
		((Color)(ref result))..ctor(255f, 0f, 0f);
		if (hex.Length >= 6)
		{
			result.r = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
			result.g = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber);
			result.b = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
			if (hex.Length == 8)
			{
				result.a = int.Parse(hex.Substring(6, 2), NumberStyles.HexNumber);
			}
		}
		return result;
	}

	public static string GetHexFromColor(Color color)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		return $"#{(int)(color.r * 255f):X2}" + $"{(int)(color.g * 255f):X2}" + $"{(int)(color.b * 255f):X2}" + $"{(int)(color.a * 255f):X2}";
	}
}
[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
internal sealed class ConfigurationManagerAttributes
{
	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
public class TextureEventArgs : EventArgs
{
	public Texture2D Texture { get; private set; }

	public TextureEventArgs(Texture2D t)
	{
		Texture = t;
	}
}
namespace RainbowTrollArmor
{
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public class SpriteTools
	{
		private Sprite outcome;

		private Texture2D texture;

		private Texture2D rawTexture;

		private Texture2D secondaryLayer;

		private Sprite source;

		private Color tint;

		public float ratio = 0.5f;

		public void setTint(Color tint)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			this.tint = tint;
		}

		public void setSecondaryLayer(Texture2D secondaryLayer)
		{
			this.secondaryLayer = secondaryLayer;
		}

		public void setRatio(int ratio)
		{
			this.ratio = (float)ratio / 100f;
		}

		public void setRatio(float ratio)
		{
			this.ratio = ratio;
		}

		public Texture2D CreateTexture2D(Texture2D rawTexture, bool useTint)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			this.rawTexture = rawTexture;
			makeTexture(((Texture)rawTexture).width, ((Texture)rawTexture).height);
			getTexturePixels();
			if (useTint)
			{
				_ = tint;
				BlendTexture();
			}
			return texture;
		}

		public Texture2D CreateTexture2D(Sprite source, bool useTint)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			this.source = source;
			Rect rect = source.rect;
			int width = (int)((Rect)(ref rect)).width;
			rect = source.rect;
			makeTexture(width, (int)((Rect)(ref rect)).height);
			getSpritePixels();
			if (useTint)
			{
				_ = tint;
				BlendTexture();
			}
			return texture;
		}

		private void MakeGrayscale()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			for (int i = 0; i < ((Texture)texture).width; i++)
			{
				for (int j = 0; j < ((Texture)texture).height; j++)
				{
					Color pixel = texture.GetPixel(i, j);
					if (pixel.a > 0f)
					{
						float grayscale = ((Color)(ref pixel)).grayscale;
						((Color)(ref val))..ctor(grayscale, grayscale, grayscale, pixel.a);
						texture.SetPixel(i, j, val);
					}
				}
			}
			texture.Apply();
		}

		public Sprite CreateSprite(Sprite source, bool useTint, bool grayscale = false)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			this.source = source;
			Rect rect = source.rect;
			int width = (int)((Rect)(ref rect)).width;
			rect = source.rect;
			makeTexture(width, (int)((Rect)(ref rect)).height);
			getSpritePixels();
			if (grayscale)
			{
				MakeGrayscale();
			}
			if (useTint)
			{
				_ = tint;
				BlendTexture();
			}
			MakeSprite();
			return outcome;
		}

		public Sprite CreateSprite(Texture2D rawTexture, bool useTint, bool grayscale = false)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			this.rawTexture = rawTexture;
			makeTexture(((Texture)rawTexture).width, ((Texture)rawTexture).height);
			getTexturePixels();
			if (grayscale)
			{
				MakeGrayscale();
			}
			if (useTint)
			{
				_ = tint;
				BlendTexture();
			}
			MakeSprite();
			return outcome;
		}

		public void makeTexture(int width, int height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			texture = new Texture2D(width, height);
		}

		private void getTexturePixels()
		{
			Color[] pixels = rawTexture.GetPixels();
			texture.SetPixels(pixels);
			texture.Apply();
		}

		private void getSpritePixels()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Texture2D obj = source.texture;
			Rect textureRect = source.textureRect;
			int num = (int)((Rect)(ref textureRect)).x;
			textureRect = source.textureRect;
			int num2 = (int)((Rect)(ref textureRect)).y;
			textureRect = source.textureRect;
			int num3 = (int)((Rect)(ref textureRect)).width;
			textureRect = source.textureRect;
			Color[] pixels = obj.GetPixels(num, num2, num3, (int)((Rect)(ref textureRect)).height);
			texture.SetPixels(pixels);
			texture.Apply();
		}

		private void BlendTexture()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < ((Texture)texture).width; i++)
			{
				for (int j = 0; j < ((Texture)texture).height; j++)
				{
					Color pixel = texture.GetPixel(i, j);
					if (!(pixel.a > 0f))
					{
						continue;
					}
					texture.SetPixel(i, j, Color.Lerp(pixel, tint, ratio));
					if ((Object)(object)secondaryLayer != (Object)null)
					{
						Color pixel2 = secondaryLayer.GetPixel(i, j);
						if (pixel2.a > 0f)
						{
							texture.SetPixel(i, j, pixel2);
						}
					}
				}
			}
			texture.Apply();
		}

		public Sprite convertTextureToSprite(Texture2D tex)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), Vector2.zero);
		}

		private void MakeSprite()
		{
			//IL_0029: 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)
			outcome = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.zero);
		}

		public Texture2D GetTexture2D()
		{
			return texture;
		}

		public Sprite getSprite()
		{
			return outcome;
		}

		public static Sprite LoadNewSprite(string FilePath, float PixelsPerUnit = 100f, SpriteMeshType spriteType = 1)
		{
			//IL_0020: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = LoadTexture(FilePath);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), PixelsPerUnit, 0u, spriteType);
		}

		public static Sprite ConvertTextureToSprite(Texture2D texture, float PixelsPerUnit = 100f, SpriteMeshType spriteType = 1)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0f, 0f), PixelsPerUnit, 0u, spriteType);
		}

		public static Texture2D LoadTexture(string FilePath)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (File.Exists(FilePath))
			{
				byte[] array = File.ReadAllBytes(FilePath);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					return val;
				}
			}
			return null;
		}

		public static string Base64Encode(string plainText)
		{
			return Convert.ToBase64String(Encoding.UTF8.GetBytes(plainText));
		}

		public static string Base64Decode(string base64EncodedData)
		{
			byte[] bytes = Convert.FromBase64String(base64EncodedData);
			return Encoding.UTF8.GetString(bytes);
		}
	}
}
namespace B83.Image.BMP
{
	public enum BMPComressionMode
	{
		BI_RGB = 0,
		BI_RLE8 = 1,
		BI_RLE4 = 2,
		BI_BITFIELDS = 3,
		BI_JPEG = 4,
		BI_PNG = 5,
		BI_ALPHABITFIELDS = 6,
		BI_CMYK = 11,
		BI_CMYKRLE8 = 12,
		BI_CMYKRLE4 = 13
	}
	public struct BMPFileHeader
	{
		public ushort magic;

		public uint filesize;

		public uint reserved;

		public uint offset;
	}
	public struct BitmapInfoHeader
	{
		public uint size;

		public int width;

		public int height;

		public ushort nColorPlanes;

		public ushort nBitsPerPixel;

		public BMPComressionMode compressionMethod;

		public uint rawImageSize;

		public int xPPM;

		public int yPPM;

		public uint nPaletteColors;

		public uint nImportantColors;

		public int absWidth => Mathf.Abs(width);

		public int absHeight => Mathf.Abs(height);
	}
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public class BMPImage
	{
		public BMPFileHeader header;

		public BitmapInfoHeader info;

		public uint rMask = 16711680u;

		public uint gMask = 65280u;

		public uint bMask = 255u;

		public uint aMask;

		public List<Color32> palette;

		public Color32[] imageData;

		public Texture2D ToTexture2D()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Texture2D val = new Texture2D(info.absWidth, info.absHeight);
			val.SetPixels32(imageData);
			val.Apply();
			return val;
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public class BMPLoader
	{
		private const ushort MAGIC = 19778;

		public bool ReadPaletteAlpha;

		public bool ForceAlphaReadWhenPossible;

		public BMPImage LoadBMP(string aFileName)
		{
			using FileStream aData = File.OpenRead(aFileName);
			return LoadBMP(aData);
		}

		public BMPImage LoadBMP(byte[] aData)
		{
			using MemoryStream aData2 = new MemoryStream(aData);
			return LoadBMP(aData2);
		}

		public BMPImage LoadBMP(Stream aData)
		{
			using BinaryReader aReader = new BinaryReader(aData);
			return LoadBMP(aReader);
		}

		public BMPImage LoadBMP(BinaryReader aReader)
		{
			BMPImage bMPImage = new BMPImage();
			if (!ReadFileHeader(aReader, ref bMPImage.header))
			{
				Debug.LogError((object)"Not a BMP file");
				return null;
			}
			if (!ReadInfoHeader(aReader, ref bMPImage.info))
			{
				Debug.LogError((object)"Unsupported header format");
				return null;
			}
			if (bMPImage.info.compressionMethod != 0 && bMPImage.info.compressionMethod != BMPComressionMode.BI_BITFIELDS && bMPImage.info.compressionMethod != BMPComressionMode.BI_ALPHABITFIELDS && bMPImage.info.compressionMethod != BMPComressionMode.BI_RLE4 && bMPImage.info.compressionMethod != BMPComressionMode.BI_RLE8)
			{
				Debug.LogError((object)("Unsupported image format: " + bMPImage.info.compressionMethod));
				return null;
			}
			long offset = 14 + bMPImage.info.size;
			aReader.BaseStream.Seek(offset, SeekOrigin.Begin);
			if (bMPImage.info.nBitsPerPixel < 24)
			{
				bMPImage.rMask = 31744u;
				bMPImage.gMask = 992u;
				bMPImage.bMask = 31u;
			}
			if (bMPImage.info.compressionMethod == BMPComressionMode.BI_BITFIELDS || bMPImage.info.compressionMethod == BMPComressionMode.BI_ALPHABITFIELDS)
			{
				bMPImage.rMask = aReader.ReadUInt32();
				bMPImage.gMask = aReader.ReadUInt32();
				bMPImage.bMask = aReader.ReadUInt32();
			}
			if (ForceAlphaReadWhenPossible)
			{
				bMPImage.aMask = GetMask(bMPImage.info.nBitsPerPixel) ^ (bMPImage.rMask | bMPImage.gMask | bMPImage.bMask);
			}
			if (bMPImage.info.compressionMethod == BMPComressionMode.BI_ALPHABITFIELDS)
			{
				bMPImage.aMask = aReader.ReadUInt32();
			}
			if (bMPImage.info.nPaletteColors != 0 || bMPImage.info.nBitsPerPixel <= 8)
			{
				bMPImage.palette = ReadPalette(aReader, bMPImage, ReadPaletteAlpha || ForceAlphaReadWhenPossible);
			}
			aReader.BaseStream.Seek(bMPImage.header.offset, SeekOrigin.Begin);
			bool flag = bMPImage.info.compressionMethod == BMPComressionMode.BI_RGB || bMPImage.info.compressionMethod == BMPComressionMode.BI_BITFIELDS || bMPImage.info.compressionMethod == BMPComressionMode.BI_ALPHABITFIELDS;
			if (bMPImage.info.nBitsPerPixel == 32 && flag)
			{
				Read32BitImage(aReader, bMPImage);
			}
			else if (bMPImage.info.nBitsPerPixel == 24 && flag)
			{
				Read24BitImage(aReader, bMPImage);
			}
			else if (bMPImage.info.nBitsPerPixel == 16 && flag)
			{
				Read16BitImage(aReader, bMPImage);
			}
			else if (bMPImage.info.compressionMethod == BMPComressionMode.BI_RLE4 && bMPImage.info.nBitsPerPixel == 4 && bMPImage.palette != null)
			{
				ReadIndexedImageRLE4(aReader, bMPImage);
			}
			else if (bMPImage.info.compressionMethod == BMPComressionMode.BI_RLE8 && bMPImage.info.nBitsPerPixel == 8 && bMPImage.palette != null)
			{
				ReadIndexedImageRLE8(aReader, bMPImage);
			}
			else
			{
				if (!flag || bMPImage.info.nBitsPerPixel > 8 || bMPImage.palette == null)
				{
					Debug.LogError((object)("Unsupported file format: " + bMPImage.info.compressionMethod.ToString() + " BPP: " + bMPImage.info.nBitsPerPixel));
					return null;
				}
				ReadIndexedImage(aReader, bMPImage);
			}
			return bMPImage;
		}

		private static void Read32BitImage(BinaryReader aReader, BMPImage bmp)
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(bmp.info.width);
			int num2 = Mathf.Abs(bmp.info.height);
			Color32[] array = (bmp.imageData = (Color32[])(object)new Color32[num * num2]);
			if (aReader.BaseStream.Position + num * num2 * 4 > aReader.BaseStream.Length)
			{
				Debug.LogError((object)"Unexpected end of file.");
				return;
			}
			int shiftCount = GetShiftCount(bmp.rMask);
			int shiftCount2 = GetShiftCount(bmp.gMask);
			int shiftCount3 = GetShiftCount(bmp.bMask);
			int shiftCount4 = GetShiftCount(bmp.aMask);
			byte b = byte.MaxValue;
			for (int i = 0; i < array.Length; i++)
			{
				uint num3 = aReader.ReadUInt32();
				byte b2 = (byte)((num3 & bmp.rMask) >> shiftCount);
				byte b3 = (byte)((num3 & bmp.gMask) >> shiftCount2);
				byte b4 = (byte)((num3 & bmp.bMask) >> shiftCount3);
				if (bmp.bMask != 0)
				{
					b = (byte)((num3 & bmp.aMask) >> shiftCount4);
				}
				array[i] = new Color32(b2, b3, b4, b);
			}
		}

		private static void Read24BitImage(BinaryReader aReader, BMPImage bmp)
		{
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(bmp.info.width);
			int num2 = Mathf.Abs(bmp.info.height);
			int num3 = (24 * num + 31) / 32 * 4;
			int num4 = num3 * num2;
			int num5 = num3 - num * 3;
			Color32[] array = (bmp.imageData = (Color32[])(object)new Color32[num * num2]);
			if (aReader.BaseStream.Position + num4 > aReader.BaseStream.Length)
			{
				Debug.LogError((object)("Unexpected end of file. (Have " + (aReader.BaseStream.Position + num4) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"));
				return;
			}
			int shiftCount = GetShiftCount(bmp.rMask);
			int shiftCount2 = GetShiftCount(bmp.gMask);
			int shiftCount3 = GetShiftCount(bmp.bMask);
			for (int i = 0; i < num2; i++)
			{
				for (int j = 0; j < num; j++)
				{
					int num6 = aReader.ReadByte() | (aReader.ReadByte() << 8) | (aReader.ReadByte() << 16);
					byte b = (byte)(((uint)num6 & bmp.rMask) >> shiftCount);
					byte b2 = (byte)(((uint)num6 & bmp.gMask) >> shiftCount2);
					byte b3 = (byte)(((uint)num6 & bmp.bMask) >> shiftCount3);
					array[j + i * num] = new Color32(b, b2, b3, byte.MaxValue);
				}
				for (int k = 0; k < num5; k++)
				{
					aReader.ReadByte();
				}
			}
		}

		private static void Read16BitImage(BinaryReader aReader, BMPImage bmp)
		{
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(bmp.info.width);
			int num2 = Mathf.Abs(bmp.info.height);
			int num3 = (16 * num + 31) / 32 * 4;
			int num4 = num3 * num2;
			int num5 = num3 - num * 2;
			Color32[] array = (bmp.imageData = (Color32[])(object)new Color32[num * num2]);
			if (aReader.BaseStream.Position + num4 > aReader.BaseStream.Length)
			{
				Debug.LogError((object)("Unexpected end of file. (Have " + (aReader.BaseStream.Position + num4) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"));
				return;
			}
			int shiftCount = GetShiftCount(bmp.rMask);
			int shiftCount2 = GetShiftCount(bmp.gMask);
			int shiftCount3 = GetShiftCount(bmp.bMask);
			int shiftCount4 = GetShiftCount(bmp.aMask);
			byte b = byte.MaxValue;
			for (int i = 0; i < num2; i++)
			{
				for (int j = 0; j < num; j++)
				{
					uint num6 = (uint)(aReader.ReadByte() | (aReader.ReadByte() << 8));
					byte b2 = (byte)((num6 & bmp.rMask) >> shiftCount);
					byte b3 = (byte)((num6 & bmp.gMask) >> shiftCount2);
					byte b4 = (byte)((num6 & bmp.bMask) >> shiftCount3);
					if (bmp.aMask != 0)
					{
						b = (byte)((num6 & bmp.aMask) >> shiftCount4);
					}
					array[j + i * num] = new Color32(b2, b3, b4, b);
				}
				for (int k = 0; k < num5; k++)
				{
					aReader.ReadByte();
				}
			}
		}

		private static void ReadIndexedImage(BinaryReader aReader, BMPImage bmp)
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(bmp.info.width);
			int num2 = Mathf.Abs(bmp.info.height);
			int nBitsPerPixel = bmp.info.nBitsPerPixel;
			int num3 = (nBitsPerPixel * num + 31) / 32 * 4;
			int num4 = num3 * num2;
			int num5 = num3 - (num * nBitsPerPixel + 7) / 8;
			Color32[] array = (bmp.imageData = (Color32[])(object)new Color32[num * num2]);
			if (aReader.BaseStream.Position + num4 > aReader.BaseStream.Length)
			{
				Debug.LogError((object)("Unexpected end of file. (Have " + (aReader.BaseStream.Position + num4) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"));
				return;
			}
			BitStreamReader bitStreamReader = new BitStreamReader(aReader);
			for (int i = 0; i < num2; i++)
			{
				for (int j = 0; j < num; j++)
				{
					int num6 = (int)bitStreamReader.ReadBits(nBitsPerPixel);
					if (num6 >= bmp.palette.Count)
					{
						Debug.LogError((object)"Indexed bitmap has indices greater than it's color palette");
						return;
					}
					array[j + i * num] = bmp.palette[num6];
				}
				bitStreamReader.Flush();
				for (int k = 0; k < num5; k++)
				{
					aReader.ReadByte();
				}
			}
		}

		private static void ReadIndexedImageRLE4(BinaryReader aReader, BMPImage bmp)
		{
			//IL_0079: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(bmp.info.width);
			int num2 = Mathf.Abs(bmp.info.height);
			Color32[] array = (bmp.imageData = (Color32[])(object)new Color32[num * num2]);
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			while (aReader.BaseStream.Position < aReader.BaseStream.Length - 1)
			{
				int num6 = aReader.ReadByte();
				byte b = aReader.ReadByte();
				if (num6 > 0)
				{
					for (int num7 = num6 / 2; num7 > 0; num7--)
					{
						array[num3++ + num5] = bmp.palette[(b >> 4) & 0xF];
						array[num3++ + num5] = bmp.palette[b & 0xF];
					}
					if ((num6 & 1) > 0)
					{
						array[num3++ + num5] = bmp.palette[(b >> 4) & 0xF];
					}
					continue;
				}
				switch (b)
				{
				case 0:
					num3 = 0;
					num4++;
					num5 = num4 * num;
					continue;
				case 2:
					num3 += aReader.ReadByte();
					num4 += aReader.ReadByte();
					num5 = num4 * num;
					continue;
				case 1:
					return;
				}
				for (int num8 = b / 2; num8 > 0; num8--)
				{
					byte b2 = aReader.ReadByte();
					array[num3++ + num5] = bmp.palette[(b2 >> 4) & 0xF];
					array[num3++ + num5] = bmp.palette[b2 & 0xF];
				}
				if ((b & 1) > 0)
				{
					array[num3++ + num5] = bmp.palette[(aReader.ReadByte() >> 4) & 0xF];
				}
				if ((((b - 1) / 2) & 1) == 0)
				{
					aReader.ReadByte();
				}
			}
		}

		private static void ReadIndexedImageRLE8(BinaryReader aReader, BMPImage bmp)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(bmp.info.width);
			int num2 = Mathf.Abs(bmp.info.height);
			Color32[] array = (bmp.imageData = (Color32[])(object)new Color32[num * num2]);
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			while (aReader.BaseStream.Position < aReader.BaseStream.Length - 1)
			{
				int num6 = aReader.ReadByte();
				byte b = aReader.ReadByte();
				if (num6 > 0)
				{
					for (int num7 = num6; num7 > 0; num7--)
					{
						array[num3++ + num5] = bmp.palette[b];
					}
					continue;
				}
				switch (b)
				{
				case 0:
					num3 = 0;
					num4++;
					num5 = num4 * num;
					continue;
				case 2:
					num3 += aReader.ReadByte();
					num4 += aReader.ReadByte();
					num5 = num4 * num;
					continue;
				case 1:
					return;
				}
				for (int num8 = b; num8 > 0; num8--)
				{
					array[num3++ + num5] = bmp.palette[aReader.ReadByte()];
				}
				if ((b & 1) > 0)
				{
					aReader.ReadByte();
				}
			}
		}

		private static int GetShiftCount(uint mask)
		{
			for (int i = 0; i < 32; i++)
			{
				if ((mask & (true ? 1u : 0u)) != 0)
				{
					return i;
				}
				mask >>= 1;
			}
			return -1;
		}

		private static uint GetMask(int bitCount)
		{
			uint num = 0u;
			for (int i = 0; i < bitCount; i++)
			{
				num <<= 1;
				num |= 1u;
			}
			return num;
		}

		private static bool ReadFileHeader(BinaryReader aReader, ref BMPFileHeader aFileHeader)
		{
			aFileHeader.magic = aReader.ReadUInt16();
			if (aFileHeader.magic != 19778)
			{
				return false;
			}
			aFileHeader.filesize = aReader.ReadUInt32();
			aFileHeader.reserved = aReader.ReadUInt32();
			aFileHeader.offset = aReader.ReadUInt32();
			return true;
		}

		private static bool ReadInfoHeader(BinaryReader aReader, ref BitmapInfoHeader aHeader)
		{
			aHeader.size = aReader.ReadUInt32();
			if (aHeader.size < 40)
			{
				return false;
			}
			aHeader.width = aReader.ReadInt32();
			aHeader.height = aReader.ReadInt32();
			aHeader.nColorPlanes = aReader.ReadUInt16();
			aHeader.nBitsPerPixel = aReader.ReadUInt16();
			aHeader.compressionMethod = (BMPComressionMode)aReader.ReadInt32();
			aHeader.rawImageSize = aReader.ReadUInt32();
			aHeader.xPPM = aReader.ReadInt32();
			aHeader.yPPM = aReader.ReadInt32();
			aHeader.nPaletteColors = aReader.ReadUInt32();
			aHeader.nImportantColors = aReader.ReadUInt32();
			int num = (int)(aHeader.size - 40);
			if (num > 0)
			{
				aReader.ReadBytes(num);
			}
			return true;
		}

		public static List<Color32> ReadPalette(BinaryReader aReader, BMPImage aBmp, bool aReadAlpha)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			uint num = aBmp.info.nPaletteColors;
			if (num == 0)
			{
				num = (uint)(1 << (int)aBmp.info.nBitsPerPixel);
			}
			List<Color32> list = new List<Color32>((int)num);
			for (int i = 0; i < num; i++)
			{
				byte b = aReader.ReadByte();
				byte b2 = aReader.ReadByte();
				byte b3 = aReader.ReadByte();
				byte b4 = aReader.ReadByte();
				if (!aReadAlpha)
				{
					b4 = byte.MaxValue;
				}
				list.Add(new Color32(b3, b2, b, b4));
			}
			return list;
		}
	}
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public class BitStreamReader
	{
		private BinaryReader m_Reader;

		private byte m_Data;

		private int m_Bits;

		public BitStreamReader(BinaryReader aReader)
		{
			m_Reader = aReader;
		}

		public BitStreamReader(Stream aStream)
			: this(new BinaryReader(aStream))
		{
		}

		public byte ReadBit()
		{
			if (m_Bits <= 0)
			{
				m_Data = m_Reader.ReadByte();
				m_Bits = 8;
			}
			return (byte)((uint)(m_Data >> --m_Bits) & 1u);
		}

		public ulong ReadBits(int aCount)
		{
			ulong num = 0uL;
			if (aCount <= 0 || aCount > 32)
			{
				throw new ArgumentOutOfRangeException("aCount", "aCount must be between 1 and 32 inclusive");
			}
			for (int num2 = aCount - 1; num2 >= 0; num2--)
			{
				num |= (ulong)ReadBit() << num2;
			}
			return num;
		}

		public void Flush()
		{
			m_Data = 0;
			m_Bits = 0;
		}
	}
}
namespace Dummiesman
{
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public static class BinaryExtensions
	{
		public static Color32 ReadColor32RGBR(this BinaryReader r)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = r.ReadBytes(4);
			return new Color32(array[0], array[1], array[2], byte.MaxValue);
		}

		public static Color32 ReadColor32RGBA(this BinaryReader r)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = r.ReadBytes(4);
			return new Color32(array[0], array[1], array[2], array[3]);
		}

		public static Color32 ReadColor32RGB(this BinaryReader r)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = r.ReadBytes(3);
			return new Color32(array[0], array[1], array[2], byte.MaxValue);
		}

		public static Color32 ReadColor32BGR(this BinaryReader r)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = r.ReadBytes(3);
			return new Color32(array[2], array[1], array[0], byte.MaxValue);
		}
	}
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public class CharWordReader
	{
		public char[] word;

		public int wordSize;

		public bool endReached;

		private StreamReader reader;

		private int bufferSize;

		private char[] buffer;

		public char currentChar;

		private int currentPosition;

		private int maxPosition;

		public CharWordReader(StreamReader reader, int bufferSize)
		{
			this.reader = reader;
			this.bufferSize = bufferSize;
			buffer = new char[this.bufferSize];
			word = new char[this.bufferSize];
			MoveNext();
		}

		public void SkipWhitespaces()
		{
			while (char.IsWhiteSpace(currentChar))
			{
				MoveNext();
			}
		}

		public void SkipWhitespaces(out bool newLinePassed)
		{
			newLinePassed = false;
			while (char.IsWhiteSpace(currentChar))
			{
				if (currentChar == '\r' || currentChar == '\n')
				{
					newLinePassed = true;
				}
				MoveNext();
			}
		}

		public void SkipUntilNewLine()
		{
			while (currentChar != 0 && currentChar != '\n' && currentChar != '\r')
			{
				MoveNext();
			}
			SkipNewLineSymbols();
		}

		public void ReadUntilWhiteSpace()
		{
			wordSize = 0;
			while (currentChar != 0 && !char.IsWhiteSpace(currentChar))
			{
				word[wordSize] = currentChar;
				wordSize++;
				MoveNext();
			}
		}

		public void ReadUntilNewLine()
		{
			wordSize = 0;
			while (currentChar != 0 && currentChar != '\n' && currentChar != '\r')
			{
				word[wordSize] = currentChar;
				wordSize++;
				MoveNext();
			}
			SkipNewLineSymbols();
		}

		public bool Is(string other)
		{
			if (other.Length != wordSize)
			{
				return false;
			}
			for (int i = 0; i < wordSize; i++)
			{
				if (word[i] != other[i])
				{
					return false;
				}
			}
			return true;
		}

		public string GetString(int startIndex = 0)
		{
			if (startIndex >= wordSize - 1)
			{
				return string.Empty;
			}
			return new string(word, startIndex, wordSize - startIndex);
		}

		public Vector3 ReadVector()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			SkipWhitespaces();
			float num = ReadFloat();
			SkipWhitespaces();
			float num2 = ReadFloat();
			SkipWhitespaces(out var newLinePassed);
			float num3 = 0f;
			if (!newLinePassed)
			{
				num3 = ReadFloat();
			}
			return new Vector3(num, num2, num3);
		}

		public int ReadInt()
		{
			int num = 0;
			bool flag = currentChar == '-';
			if (flag)
			{
				MoveNext();
			}
			while (currentChar >= '0' && currentChar <= '9')
			{
				int num2 = currentChar - 48;
				num = num * 10 + num2;
				MoveNext();
			}
			if (!flag)
			{
				return num;
			}
			return -num;
		}

		public float ReadFloat()
		{
			bool num = currentChar == '-';
			if (num)
			{
				MoveNext();
			}
			float num2 = ReadInt();
			if (currentChar == '.' || currentChar == ',')
			{
				MoveNext();
				num2 += ReadFloatEnd();
				if (currentChar == 'e' || currentChar == 'E')
				{
					MoveNext();
					int num3 = ReadInt();
					num2 *= Mathf.Pow(10f, (float)num3);
				}
			}
			if (num)
			{
				num2 = 0f - num2;
			}
			return num2;
		}

		private float ReadFloatEnd()
		{
			float num = 0f;
			float num2 = 0.1f;
			while (currentChar >= '0' && currentChar <= '9')
			{
				int num3 = currentChar - 48;
				num += (float)num3 * num2;
				num2 *= 0.1f;
				MoveNext();
			}
			return num;
		}

		private void SkipNewLineSymbols()
		{
			while (currentChar == '\n' || currentChar == '\r')
			{
				MoveNext();
			}
		}

		public void MoveNext()
		{
			currentPosition++;
			if (currentPosition >= maxPosition)
			{
				if (reader.EndOfStream)
				{
					currentChar = '\0';
					endReached = true;
					return;
				}
				currentPosition = 0;
				maxPosition = reader.Read(buffer, 0, bufferSize);
			}
			currentChar = buffer[currentPosition];
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public static class DDSLoader
	{
		public static Texture2D Load(Stream ddsStream)
		{
			byte[] array = new byte[ddsStream.Length];
			ddsStream.Read(array, 0, (int)ddsStream.Length);
			return Load(array);
		}

		public static Texture2D Load(string ddsPath)
		{
			return Load(File.ReadAllBytes(ddsPath));
		}

		public static Texture2D Load(byte[] ddsBytes)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			try
			{
				if (ddsBytes[4] != 124)
				{
					throw new Exception("Invalid DDS header. Structure length is incrrrect.");
				}
				byte b = ddsBytes[87];
				if (b != 49 && b != 53)
				{
					throw new Exception("Cannot load DDS due to an unsupported pixel format. Needs to be DXT1 or DXT5.");
				}
				int num = ddsBytes[13] * 256 + ddsBytes[12];
				int num2 = ddsBytes[17] * 256 + ddsBytes[16];
				bool flag = ddsBytes[28] > 0;
				TextureFormat val = (TextureFormat)((b == 49) ? 10 : 12);
				int num3 = 128;
				byte[] array = new byte[ddsBytes.Length - num3];
				Buffer.BlockCopy(ddsBytes, num3, array, 0, ddsBytes.Length - num3);
				Texture2D val2 = new Texture2D(num2, num, val, flag);
				val2.LoadRawTextureData(array);
				val2.Apply();
				return val2;
			}
			catch (Exception ex)
			{
				throw new Exception("An error occured while loading DirectDraw Surface: " + ex.Message);
			}
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public class ImageLoader
	{
		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		public enum TextureFormat
		{
			DDS,
			TGA,
			BMP,
			PNG,
			JPG,
			CRN
		}

		public static void SetNormalMap(ref Texture2D tex)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Color[] pixels = tex.GetPixels();
			for (int i = 0; i < pixels.Length; i++)
			{
				Color val = pixels[i];
				val.r = pixels[i].g;
				val.a = pixels[i].r;
				pixels[i] = val;
			}
			tex.SetPixels(pixels);
			tex.Apply(true);
		}

		public static Texture2D LoadTexture(Stream stream, TextureFormat format)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0054: Expected O, but got Unknown
			switch (format)
			{
			case TextureFormat.BMP:
				return new BMPLoader().LoadBMP(stream).ToTexture2D();
			case TextureFormat.DDS:
				return DDSLoader.Load(stream);
			case TextureFormat.PNG:
			case TextureFormat.JPG:
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, (int)stream.Length);
				Texture2D val = new Texture2D(1, 1);
				ImageConversion.LoadImage(val, array);
				return val;
			}
			case TextureFormat.TGA:
				return TGALoader.Load(stream);
			default:
				return null;
			}
		}

		public static Texture2D LoadTexture(string fn)
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			if (!File.Exists(fn))
			{
				return null;
			}
			byte[] array = File.ReadAllBytes(fn);
			string text = Path.GetExtension(fn).ToLower();
			string fileName = Path.GetFileName(fn);
			Texture2D val = null;
			if (text != null)
			{
				int length = text.Length;
				if (length != 4)
				{
					if (length == 5 && text == ".jpeg")
					{
						goto IL_0103;
					}
				}
				else
				{
					switch (text[1])
					{
					case 'p':
						break;
					case 'j':
						goto IL_0099;
					case 'd':
						goto IL_00ab;
					case 't':
						goto IL_00bd;
					case 'b':
						goto IL_00cf;
					case 'c':
						goto IL_00e1;
					default:
						goto IL_020a;
					}
					if (text == ".png")
					{
						goto IL_0103;
					}
				}
			}
			goto IL_020a;
			IL_0220:
			if ((Object)(object)val != (Object)null)
			{
				val = ImageLoaderHelper.VerifyFormat(val);
				((Object)val).name = Path.GetFileNameWithoutExtension(fn);
			}
			return val;
			IL_00e1:
			if (!(text == ".crn"))
			{
				goto IL_020a;
			}
			byte[] array2 = array;
			ushort num = BitConverter.ToUInt16(new byte[2]
			{
				array2[13],
				array2[12]
			}, 0);
			ushort num2 = BitConverter.ToUInt16(new byte[2]
			{
				array2[15],
				array2[14]
			}, 0);
			byte b = array2[18];
			TextureFormat val2 = (TextureFormat)3;
			if (b == 0)
			{
				val2 = (TextureFormat)28;
			}
			else if (b == 2)
			{
				val2 = (TextureFormat)29;
			}
			else
			{
				if (b != 12)
				{
					Debug.LogError((object)("Could not load crunched texture " + fileName + " because its format is not supported (" + b + "): " + fn));
					goto IL_0220;
				}
				val2 = (TextureFormat)65;
			}
			val = new Texture2D((int)num, (int)num2, val2, true);
			val.LoadRawTextureData(array2);
			val.Apply(true);
			goto IL_0220;
			IL_020a:
			Debug.LogError((object)("Could not load texture " + fileName + " because its format is not supported : " + fn));
			goto IL_0220;
			IL_00bd:
			if (!(text == ".tga"))
			{
				goto IL_020a;
			}
			val = TGALoader.Load(array);
			goto IL_0220;
			IL_0103:
			val = new Texture2D(1, 1);
			ImageConversion.LoadImage(val, array);
			goto IL_0220;
			IL_00cf:
			if (!(text == ".bmp"))
			{
				goto IL_020a;
			}
			val = new BMPLoader().LoadBMP(array).ToTexture2D();
			goto IL_0220;
			IL_0099:
			if (text == ".jpg")
			{
				goto IL_0103;
			}
			goto IL_020a;
			IL_00ab:
			if (!(text == ".dds"))
			{
				goto IL_020a;
			}
			val = DDSLoader.Load(array);
			goto IL_0220;
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public class ImageLoaderHelper
	{
		public static Texture2D VerifyFormat(Texture2D tex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			if ((int)tex.format != 5 && (int)tex.format != 4 && (int)tex.format != 12)
			{
				return tex;
			}
			Color32[] pixels = tex.GetPixels32();
			bool flag = false;
			Color32[] array = pixels;
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].a < byte.MaxValue)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				Texture2D val = new Texture2D(((Texture)tex).width, ((Texture)tex).height, (TextureFormat)3, ((Texture)tex).mipmapCount > 0);
				val.SetPixels32(pixels);
				val.Apply(true);
				return val;
			}
			return tex;
		}

		public static void FillPixelArray(Color32[] fillArray, byte[] pixelData, int bytesPerPixel, bool bgra = false)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (bgra)
			{
				if (bytesPerPixel == 4)
				{
					for (int i = 0; i < fillArray.Length; i++)
					{
						int num = i * bytesPerPixel;
						fillArray[i] = new Color32(pixelData[num + 2], pixelData[num + 1], pixelData[num], pixelData[num + 3]);
					}
					return;
				}
				for (int j = 0; j < fillArray.Length; j++)
				{
					fillArray[j].r = pixelData[j * 3 + 2];
					fillArray[j].g = pixelData[j * 3 + 1];
					fillArray[j].b = pixelData[j * 3];
				}
			}
			else if (bytesPerPixel == 4)
			{
				for (int k = 0; k < fillArray.Length; k++)
				{
					fillArray[k].r = pixelData[k * 4];
					fillArray[k].g = pixelData[k * 4 + 1];
					fillArray[k].b = pixelData[k * 4 + 2];
					fillArray[k].a = pixelData[k * 4 + 3];
				}
			}
			else
			{
				int num2 = 0;
				for (int l = 0; l < fillArray.Length; l++)
				{
					fillArray[l].r = pixelData[num2++];
					fillArray[l].g = pixelData[num2++];
					fillArray[l].b = pixelData[num2++];
					fillArray[l].a = byte.MaxValue;
				}
			}
		}
	}
	public static class ImageUtils
	{
		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
		public static Texture2D ConvertToNormalMap(Texture2D tex)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = tex;
			if ((int)tex.format != 4 && (int)tex.format != 5)
			{
				val = new Texture2D(((Texture)tex).width, ((Texture)tex).height, (TextureFormat)4, true);
			}
			Color[] pixels = tex.GetPixels();
			for (int i = 0; i < pixels.Length; i++)
			{
				Color val2 = pixels[i];
				val2.a = pixels[i].r;
				val2.r = 0f;
				val2.g = pixels[i].g;
				val2.b = 0f;
				pixels[i] = val2;
			}
			val.SetPixels(pixels);
			val.Apply(true);
			return val;
		}
	}
	public enum SplitMode
	{
		None,
		Object,
		Material
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public class OBJLoader
	{
		public SplitMode SplitMode = SplitMode.Object;

		internal List<Vector3> Vertices = new List<Vector3>();

		internal List<Vector3> Normals = new List<Vector3>();

		internal List<Vector2> UVs = new List<Vector2>();

		internal Dictionary<string, Material> Materials;

		private FileInfo _objInfo;

		private void LoadMaterialLibrary(string mtlLibPath)
		{
			if (_objInfo != null && File.Exists(Path.Combine(_objInfo.Directory.FullName, mtlLibPath)))
			{
				Materials = new MTLLoader().Load(Path.Combine(_objInfo.Directory.FullName, mtlLibPath));
			}
			else if (File.Exists(mtlLibPath))
			{
				Materials = new MTLLoader().Load(mtlLibPath);
			}
		}

		public GameObject Load(Stream input)
		{
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			StreamReader reader = new StreamReader(input);
			Dictionary<string, OBJObjectBuilder> builderDict = new Dictionary<string, OBJObjectBuilder>();
			OBJObjectBuilder currentBuilder = null;
			string material = "default";
			List<int> list = new List<int>();
			List<int> list2 = new List<int>();
			List<int> list3 = new List<int>();
			Action<string> action = delegate(string objectName)
			{
				if (!builderDict.TryGetValue(objectName, out currentBuilder))
				{
					currentBuilder = new OBJObjectBuilder(objectName, this);
					builderDict[objectName] = currentBuilder;
				}
			};
			action("default");
			CharWordReader charWordReader = new CharWordReader(reader, 4096);
			while (true)
			{
				charWordReader.SkipWhitespaces();
				if (charWordReader.endReached)
				{
					break;
				}
				charWordReader.ReadUntilWhiteSpace();
				if (charWordReader.Is("#"))
				{
					charWordReader.SkipUntilNewLine();
				}
				else if (Materials == null && charWordReader.Is("mtllib"))
				{
					charWordReader.SkipWhitespaces();
					charWordReader.ReadUntilNewLine();
					string @string = charWordReader.GetString();
					LoadMaterialLibrary(@string);
				}
				else if (charWordReader.Is("v"))
				{
					Vertices.Add(charWordReader.ReadVector());
				}
				else if (charWordReader.Is("vn"))
				{
					Normals.Add(charWordReader.ReadVector());
				}
				else if (charWordReader.Is("vt"))
				{
					UVs.Add(Vector2.op_Implicit(charWordReader.ReadVector()));
				}
				else if (charWordReader.Is("usemtl"))
				{
					charWordReader.SkipWhitespaces();
					charWordReader.ReadUntilNewLine();
					string string2 = charWordReader.GetString();
					material = string2;
					if (SplitMode == SplitMode.Material)
					{
						action(string2);
					}
				}
				else if ((charWordReader.Is("o") || charWordReader.Is("g")) && SplitMode == SplitMode.Object)
				{
					charWordReader.ReadUntilNewLine();
					string string3 = charWordReader.GetString(1);
					action(string3);
				}
				else if (charWordReader.Is("f"))
				{
					while (true)
					{
						charWordReader.SkipWhitespaces(out var newLinePassed);
						if (newLinePassed)
						{
							break;
						}
						int num = int.MinValue;
						int num2 = int.MinValue;
						int num3 = int.MinValue;
						num = charWordReader.ReadInt();
						if (charWordReader.currentChar == '/')
						{
							charWordReader.MoveNext();
							if (charWordReader.currentChar != '/')
							{
								num3 = charWordReader.ReadInt();
							}
							if (charWordReader.currentChar == '/')
							{
								charWordReader.MoveNext();
								num2 = charWordReader.ReadInt();
							}
						}
						if (num > int.MinValue)
						{
							if (num < 0)
							{
								num = Vertices.Count - num;
							}
							num--;
						}
						if (num2 > int.MinValue)
						{
							if (num2 < 0)
							{
								num2 = Normals.Count - num2;
							}
							num2--;
						}
						if (num3 > int.MinValue)
						{
							if (num3 < 0)
							{
								num3 = UVs.Count - num3;
							}
							num3--;
						}
						list.Add(num);
						list2.Add(num2);
						list3.Add(num3);
					}
					currentBuilder.PushFace(material, list, list2, list3);
					list.Clear();
					list2.Clear();
					list3.Clear();
				}
				else
				{
					charWordReader.SkipUntilNewLine();
				}
			}
			GameObject val = new GameObject((_objInfo != null) ? Path.GetFileNameWithoutExtension(_objInfo.Name) : "WavefrontObject");
			val.transform.localScale = new Vector3(1f, 1f, 1f);
			foreach (KeyValuePair<string, OBJObjectBuilder> item in builderDict)
			{
				if (item.Value.PushedFaceCount != 0)
				{
					item.Value.Build().transform.SetParent(val.transform, false);
				}
			}
			return val;
		}

		public GameObject Load(Stream input, Stream mtlInput)
		{
			MTLLoader mTLLoader = new MTLLoader();
			Materials = mTLLoader.Load(mtlInput);
			return Load(input);
		}

		public GameObject Load(string path, string mtlPath)
		{
			_objInfo = new FileInfo(path);
			if (!string.IsNullOrEmpty(mtlPath) && File.Exists(mtlPath))
			{
				MTLLoader mTLLoader = new MTLLoader();
				Materials = mTLLoader.Load(mtlPath);
				using FileStream input = new FileStream(path, FileMode.Open);
				return Load(input);
			}
			using FileStream input2 = new FileStream(path, FileMode.Open);
			return Load(input2);
		}

		public GameObject Load(string path)
		{
			return Load(path, null);
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public static class OBJLoaderHelper
	{
		public static void EnableMaterialTransparency(Material mtl)
		{
			mtl.SetFloat("_Mode", 3f);
			mtl.SetInt("_SrcBlend", 5);
			mtl.SetInt("_DstBlend", 10);
			mtl.SetInt("_ZWrite", 0);
			mtl.DisableKeyword("_ALPHATEST_ON");
			mtl.EnableKeyword("_ALPHABLEND_ON");
			mtl.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			mtl.renderQueue = 3000;
		}

		public static float FastFloatParse(string input)
		{
			if (input.Contains("e") || input.Contains("E"))
			{
				return float.Parse(input, CultureInfo.InvariantCulture);
			}
			float num = 0f;
			int num2 = 0;
			int length = input.Length;
			if (length == 0)
			{
				return float.NaN;
			}
			char c = input[0];
			float num3 = 1f;
			if (c == '-')
			{
				num3 = -1f;
				num2++;
				if (num2 >= length)
				{
					return float.NaN;
				}
			}
			while (true)
			{
				if (num2 >= length)
				{
					return num3 * num;
				}
				c = input[num2++];
				if (c < '0' || c > '9')
				{
					break;
				}
				num = num * 10f + (float)(c - 48);
			}
			if (c != '.' && c != ',')
			{
				return float.NaN;
			}
			float num4 = 0.1f;
			while (num2 < length)
			{
				c = input[num2++];
				if (c < '0' || c > '9')
				{
					return float.NaN;
				}
				num += (float)(c - 48) * num4;
				num4 *= 0.1f;
			}
			return num3 * num;
		}

		public static int FastIntParse(string input)
		{
			int num = 0;
			bool flag = input[0] == '-';
			for (int i = (flag ? 1 : 0); i < input.Length; i++)
			{
				num = num * 10 + (input[i] - 48);
			}
			if (!flag)
			{
				return num;
			}
			return -num;
		}

		public static Material CreateNullMaterial()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new Material(Shader.Find("Standard (Specular setup)"));
		}

		public static Vector3 VectorFromStrArray(string[] cmps)
		{
			//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)
			float num = FastFloatParse(cmps[1]);
			float num2 = FastFloatParse(cmps[2]);
			if (cmps.Length == 4)
			{
				float num3 = FastFloatParse(cmps[3]);
				return new Vector3(num, num2, num3);
			}
			return Vector2.op_Implicit(new Vector2(num, num2));
		}

		public static Color ColorFromStrArray(string[] cmps, float scalar = 1f)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			float num = FastFloatParse(cmps[1]) * scalar;
			float num2 = FastFloatParse(cmps[2]) * scalar;
			float num3 = FastFloatParse(cmps[3]) * scalar;
			return new Color(num, num2, num3);
		}
	}
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public class OBJObjectBuilder
	{
		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		private class ObjLoopHash
		{
			public int vertexIndex;

			public int normalIndex;

			public int uvIndex;

			[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
			public override bool Equals(object obj)
			{
				if (!(obj is ObjLoopHash))
				{
					return false;
				}
				ObjLoopHash objLoopHash = obj as ObjLoopHash;
				if (objLoopHash.vertexIndex == vertexIndex && objLoopHash.uvIndex == uvIndex)
				{
					return objLoopHash.normalIndex == normalIndex;
				}
				return false;
			}

			public override int GetHashCode()
			{
				return ((3 * 314159 + vertexIndex) * 314159 + normalIndex) * 314159 + uvIndex;
			}
		}

		private OBJLoader _loader;

		private string _name;

		private Dictionary<ObjLoopHash, int> _globalIndexRemap = new Dictionary<ObjLoopHash, int>();

		private Dictionary<string, List<int>> _materialIndices = new Dictionary<string, List<int>>();

		private List<int> _currentIndexList;

		private string _lastMaterial;

		private List<Vector3> _vertices = new List<Vector3>();

		private List<Vector3> _normals = new List<Vector3>();

		private List<Vector2> _uvs = new List<Vector2>();

		private bool recalculateNormals;

		public int PushedFaceCount { get; private set; }

		public GameObject Build()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			GameObject val = new GameObject(_name);
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			int num = 0;
			Material[] array = (Material[])(object)new Material[_materialIndices.Count];
			foreach (KeyValuePair<string, List<int>> materialIndex in _materialIndices)
			{
				_ = materialIndex;
				array[num] = WMRecipeCust.originalMaterials["wood"];
				num++;
			}
			((Renderer)val2).sharedMaterials = array;
			MeshFilter val3 = val.AddComponent<MeshFilter>();
			num = 0;
			Mesh val4 = new Mesh
			{
				name = _name,
				indexFormat = (IndexFormat)(_vertices.Count > 65535),
				subMeshCount = _materialIndices.Count
			};
			val4.SetVertices(_vertices);
			val4.SetNormals(_normals);
			val4.SetUVs(0, _uvs);
			foreach (KeyValuePair<string, List<int>> materialIndex2 in _materialIndices)
			{
				val4.SetTriangles(materialIndex2.Value, num);
				num++;
			}
			if (recalculateNormals)
			{
				val4.RecalculateNormals();
			}
			val4.RecalculateTangents();
			val4.RecalculateBounds();
			val3.sharedMesh = val4;
			return val;
		}

		public void SetMaterial(string name)
		{
			if (!_materialIndices.TryGetValue(name, out _currentIndexList))
			{
				_currentIndexList = new List<int>();
				_materialIndices[name] = _currentIndexList;
			}
		}

		public void PushFace(string material, List<int> vertexIndices, List<int> normalIndices, List<int> uvIndices)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (vertexIndices.Count < 3)
			{
				return;
			}
			if (material != _lastMaterial)
			{
				SetMaterial(material);
				_lastMaterial = material;
			}
			int[] array = new int[vertexIndices.Count];
			for (int i = 0; i < vertexIndices.Count; i++)
			{
				int num = vertexIndices[i];
				int num2 = normalIndices[i];
				int num3 = uvIndices[i];
				ObjLoopHash key = new ObjLoopHash
				{
					vertexIndex = num,
					normalIndex = num2,
					uvIndex = num3
				};
				int value = -1;
				if (!_globalIndexRemap.TryGetValue(key, out value))
				{
					_globalIndexRemap.Add(key, _vertices.Count);
					value = _vertices.Count;
					_vertices.Add((num >= 0 && num < _loader.Vertices.Count) ? _loader.Vertices[num] : Vector3.zero);
					_normals.Add((num2 >= 0 && num2 < _loader.Normals.Count) ? _loader.Normals[num2] : Vector3.zero);
					_uvs.Add((num3 >= 0 && num3 < _loader.UVs.Count) ? _loader.UVs[num3] : Vector2.zero);
					if (num2 < 0)
					{
						recalculateNormals = true;
					}
				}
				array[i] = value;
			}
			if (array.Length == 3)
			{
				_currentIndexList.AddRange(new int[3]
				{
					array[0],
					array[1],
					array[2]
				});
			}
			else if (array.Length == 4)
			{
				_currentIndexList.AddRange(new int[3]
				{
					array[0],
					array[1],
					array[2]
				});
				_currentIndexList.AddRange(new int[3]
				{
					array[2],
					array[3],
					array[0]
				});
			}
			else if (array.Length > 4)
			{
				for (int num4 = array.Length - 1; num4 >= 2; num4--)
				{
					_currentIndexList.AddRange(new int[3]
					{
						array[0],
						array[num4 - 1],
						array[num4]
					});
				}
			}
			PushedFaceCount++;
		}

		public OBJObjectBuilder(string name, OBJLoader loader)
		{
			_name = name;
			_loader = loader;
		}
	}
	public static class StringExtensions
	{
		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
		public static string Clean(this string str)
		{
			string text = str.Replace('\t', ' ');
			while (text.Contains("  "))
			{
				text = text.Replace("  ", " ");
			}
			return text.Trim();
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public class TGALoader
	{
		private static int GetBits(byte b, int offset, int count)
		{
			return (b >> offset) & ((1 << count) - 1);
		}

		private static Color32[] LoadRawTGAData(BinaryReader r, int bitDepth, int width, int height)
		{
			Color32[] array = new Color32[width * height];
			byte[] pixelData = r.ReadBytes(width * height * (bitDepth / 8));
			ImageLoaderHelper.FillPixelArray((Color32[])(object)array, pixelData, bitDepth / 8, bgra: true);
			return (Color32[])(object)array;
		}

		private static Color32[] LoadRLETGAData(BinaryReader r, int bitDepth, int width, int height)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			Color32[] array = (Color32[])(object)new Color32[width * height];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				byte b = r.ReadByte();
				int bits = GetBits(b, 7, 1);
				num = GetBits(b, 0, 7) + 1;
				if (bits == 0)
				{
					for (int j = 0; j < num; j++)
					{
						Color32 val = ((bitDepth == 32) ? r.ReadColor32RGBA().FlipRB() : r.ReadColor32RGB().FlipRB());
						array[j + i] = val;
					}
				}
				else
				{
					Color32 val2 = ((bitDepth == 32) ? r.ReadColor32RGBA().FlipRB() : r.ReadColor32RGB().FlipRB());
					for (int k = 0; k < num; k++)
					{
						array[k + i] = val2;
					}
				}
			}
			return array;
		}

		public static Texture2D Load(string fileName)
		{
			using FileStream tGAStream = File.OpenRead(fileName);
			return Load(tGAStream);
		}

		public static Texture2D Load(byte[] bytes)
		{
			using MemoryStream tGAStream = new MemoryStream(bytes);
			return Load(tGAStream);
		}

		public static Texture2D Load(Stream TGAStream)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			using BinaryReader binaryReader = new BinaryReader(TGAStream);
			binaryReader.BaseStream.Seek(2L, SeekOrigin.Begin);
			byte b = binaryReader.ReadByte();
			if (b != 10 && b != 2)
			{
				Debug.LogError((object)$"Unsupported targa image type. ({b})");
				return null;
			}
			binaryReader.BaseStream.Seek(12L, SeekOrigin.Begin);
			short num = binaryReader.ReadInt16();
			short num2 = binaryReader.ReadInt16();
			int num3 = binaryReader.ReadByte();
			if (num3 < 24)
			{
				throw new Exception("Tried to load TGA with unsupported bit depth");
			}
			binaryReader.BaseStream.Seek(1L, SeekOrigin.Current);
			Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)((num3 == 24) ? 3 : 5), true);
			if (b == 2)
			{
				val.SetPixels32(LoadRawTGAData(binaryReader, num3, num, num2));
			}
			else
			{
				val.SetPixels32(LoadRLETGAData(binaryReader, num3, num, num2));
			}
			val.Apply();
			return val;
		}
	}
}
namespace Dummiesman.Extensions
{
	public static class ColorExtensions
	{
		public static Color FlipRB(this Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Color(color.b, color.g, color.r, color.a);
		}

		public static Color32 FlipRB(this Color32 color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Color32(color.b, color.g, color.r, color.a);
		}
	}
}
namespace ServerSync
{
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[PublicAPI]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public abstract class OwnConfigEntryBase
	{
		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		public object LocalBaseValue;

		public bool SynchronizedConfig = true;

		public abstract ConfigEntryBase BaseConfig { get; }
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[PublicAPI]
	public class SyncedConfigEntry<[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)] T> : OwnConfigEntryBase
	{
		public readonly ConfigEntry<T> SourceConfig;

		public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig;

		public T Value
		{
			get
			{
				return SourceConfig.Value;
			}
			set
			{
				SourceConfig.Value = value;
			}
		}

		public SyncedConfigEntry(ConfigEntry<T> sourceConfig)
		{
			SourceConfig = sourceConfig;
		}

		public void AssignLocalValue(T value)
		{
			if (LocalBaseValue == null)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(2)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	public abstract class CustomSyncedValueBase
	{
		public object LocalBaseValue;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(1)]
		public readonly string Identifier;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(1)]
		public readonly Type Type;

		private object boxedValue;

		protected bool localIsOwner;

		public readonly int Priority;

		public object BoxedValue
		{
			get
			{
				return boxedValue;
			}
			set
			{
				boxedValue = value;
				this.ValueChanged?.Invoke();
			}
		}

		public event Action ValueChanged;

		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
		protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority)
		{
			Priority = priority;
			Identifier = identifier;
			Type = type;
			configSync.AddCustomValue(this);
			localIsOwner = configSync.IsSourceOfTruth;
			configSync.SourceOfTruthChanged += delegate(bool truth)
			{
				localIsOwner = truth;
			};
		}
	}
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[PublicAPI]
	public sealed class CustomSyncedValue<[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)] T> : CustomSyncedValueBase
	{
		public T Value
		{
			get
			{
				return (T)base.BoxedValue;
			}
			set
			{
				base.BoxedValue = value;
			}
		}

		public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0)
			: base(configSync, identifier, typeof(T), priority)
		{
			Value = value;
		}

		public void AssignLocalValue(T value)
		{
			if (localIsOwner)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ReadOnly = false;
	}
	[PublicAPI]
	[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
	[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
	public class ConfigSync
	{
		[HarmonyPatch(typeof(ZRpc), "HandlePackage")]
		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		private static class SnatchCurrentlyHandlingRPC
		{
			[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
			public static ZRpc currentRpc;

			[HarmonyPrefix]
			[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
			private static void Prefix(ZRpc __instance)
			{
				currentRpc = __instance;
			}
		}

		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		[HarmonyPatch(typeof(ZNet), "Awake")]
		internal static class RegisterRPCPatch
		{
			[HarmonyPostfix]
			[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
			private static void Postfix(ZNet __instance)
			{
				isServer = __instance.IsServer();
				foreach (ConfigSync configSync2 in configSyncs)
				{
					ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync);
					if (isServer)
					{
						configSync2.InitialSyncDone = true;
						Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections"));
					}
				}
				if (isServer)
				{
					((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges());
				}
				[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
				static void SendAdmin(List<ZNetPeer> peers, bool isAdmin)
				{
					ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1]
					{
						new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = isAdmin
						}
					});
					ConfigSync configSync = configSyncs.First();
					if (configSync != null)
					{
						((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package));
					}
				}
				[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
				static IEnumerator WatchAdminListChanges()
				{
					MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
					SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
					List<string> CurrentList = new List<string>(adminList.GetList());
					while (true)
					{
						yield return (object)new WaitForSeconds(30f);
						if (!adminList.GetList().SequenceEqual(CurrentList))
						{
							CurrentList = new List<string>(adminList.GetList());
							List<ZNetPeer> list = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p)
							{
								string hostName = p.m_rpc.GetSocket().GetHostName();
								return ((object)listContainsId != null) ? ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName })) : adminList.Contains(hostName);
							}).ToList();
							SendAdmin(ZNet.instance.GetPeers().Except(list).ToList(), isAdmin: false);
							SendAdmin(list, isAdmin: true);
						}
					}
				}
			}
		}

		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
		private static class RegisterClientRPCPatch
		{
			[HarmonyPostfix]
			[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
			private static void Postfix(ZNet __instance, ZNetPeer peer)
			{
				if (__instance.IsServer())
				{
					return;
				}
				foreach (ConfigSync configSync in configSyncs)
				{
					peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync);
				}
			}
		}

		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		private class ParsedConfigs
		{
			[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(new byte[] { 1, 1, 2 })]
			public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>();

			[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(new byte[] { 1, 1, 2 })]
			public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>();
		}

		[HarmonyPatch(typeof(ZNet), "Shutdown")]
		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		private class ResetConfigsOnShutdown
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				ProcessingServerUpdate = true;
				foreach (ConfigSync configSync in configSyncs)
				{
					configSync.resetConfigsFromServer();
					configSync.IsSourceOfTruth = true;
					configSync.InitialSyncDone = false;
				}
				ProcessingServerUpdate = false;
			}
		}

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
		[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
		private class SendConfigsAfterLogin
		{
			[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
			private class BufferingSocket : ISocket
			{
				public volatile bool finished;

				public volatile int versionMatchQueued = -1;

				public readonly List<ZPackage> Package = new List<ZPackage>();

				public readonly ISocket Original;

				public BufferingSocket(ISocket original)
				{
					Original = original;
				}

				public bool IsConnected()
				{
					return Original.IsConnected();
				}

				public ZPackage Recv()
				{
					return Original.Recv();
				}

				public int GetSendQueueSize()
				{
					return Original.GetSendQueueSize();
				}

				public int GetCurrentSendRate()
				{
					return Original.GetCurrentSendRate();
				}

				public bool IsHost()
				{
					return Original.IsHost();
				}

				public void Dispose()
				{
					Original.Dispose();
				}

				public bool GotNewData()
				{
					return Original.GotNewData();
				}

				public void Close()
				{
					Original.Close();
				}

				public string GetEndPointString()
				{
					return Original.GetEndPointString();
				}

				public void GetAndResetStats(out int totalSent, out int totalRecv)
				{
					Original.GetAndResetStats(ref totalSent, ref totalRecv);
				}

				public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec)
				{
					Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec);
				}

				public ISocket Accept()
				{
					return Original.Accept();
				}

				public int GetHostPort()
				{
					return Original.GetHostPort();
				}

				public bool Flush()
				{
					return Original.Flush();
				}

				public string GetHostName()
				{
					return Original.GetHostName();
				}

				public void VersionMatch()
				{
					if (finished)
					{
						Original.VersionMatch();
					}
					else
					{
						versionMatchQueued = Package.Count;
					}
				}

				public void Send(ZPackage pkg)
				{
					//IL_004c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0052: Expected O, but got Unknown
					int pos = pkg.GetPos();
					pkg.SetPos(0);
					int num = pkg.ReadInt();
					if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished)
					{
						ZPackage val = new ZPackage(pkg.GetArray());
						val.SetPos(pos);
						Package.Add(val);
					}
					else
					{
						pkg.SetPos(pos);
						Original.Send(pkg);
					}
				}
			}

			[HarmonyPriority(800)]
			[HarmonyPrefix]
			private static void Prefix([<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc)
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.IsServer())
				{
					BufferingSocket value = new BufferingSocket(rpc.GetSocket());
					AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value);
					object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
					ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null);
					if (val != null && (int)ZNet.m_onlineBackend != 0)
					{
						AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value);
					}
					if (__state == null)
					{
						__state = new Dictionary<Assembly, BufferingSocket>();
					}
					__state[Assembly.GetExecutingAssembly()] = value;
				}
			}

			[HarmonyPostfix]
			private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc)
			{
				ZNetPeer peer;
				if (__instance.IsServer())
				{
					object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
					peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null);
					if (peer == null)
					{
						SendBufferedData();
					}
					else
					{
						((MonoBehaviour)__instance).StartCoroutine(sendAsync());
					}
				}
				void SendBufferedData()
				{
					if (rpc.GetSocket() is BufferingSocket bufferingSocket)
					{
						AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket.Original);
						object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
						ZNetPeer val2 = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null);
						if (val2 != null)
						{
							AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val2, bufferingSocket.Original);
						}
					}
					BufferingSocket bufferingSocket2 = __state[Assembly.GetExecutingAssembly()];
					bufferingSocket2.finished = true;
					for (int i = 0; i < bufferingSocket2.Package.Count; i++)
					{
						if (i == bufferingSocket2.versionMatchQueued)
						{
							bufferingSocket2.Original.VersionMatch();
						}
						bufferingSocket2.Original.Send(bufferingSocket2.Package[i]);
					}
					if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued)
					{
						bufferingSocket2.Original.VersionMatch();
					}
				}
				IEnumerator sendAsync()
				{
					foreach (ConfigSync configSync in configSyncs)
					{
						List<PackageEntry> list = new List<PackageEntry>();
						if (configSync.CurrentVersion != null)
						{
							list.Add(new PackageEntry
							{
								section = "Internal",
								key = "serverversion",
								type = typeof(string),
								value = configSync.CurrentVersion
							});
						}
						MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
						SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
						list.Add(new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = (((object)methodInfo == null) ? ((object)val.Contains(rpc.GetSocket().GetHostName())) : methodInfo.Invoke(ZNet.instance, new object[2]
							{
								val,
								rpc.GetSocket().GetHostName()
							}))
						});
						ZPackage package = ConfigsToPackage(configSync.allConfigs.Select([<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, list, partial: false);
						yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package));
					}
					SendBufferedData();
				}
			}
		}

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
		private class PackageEntry
		{
			public string section;

			public string key;

			public Type type;

			[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
			public object value;
		}

		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		[HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")]
		private static class PreventSavingServerInfo
		{
			[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
			[HarmonyPrefix]
			private static bool Prefix(ConfigEntryBase __instance, ref string __result)
			{
				OwnConfigEntryBase ownConfigEntryBase = configData(__instance);
				if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase))
				{
					return true;
				}
				__result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType);
				return false;
			}
		}

		[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)]
		[HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")]
		private static class PreventConfigRereadChangingValues
		{
			[<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(1)]
			[HarmonyPrefix]
			private static bool Prefix(ConfigEntryBase __instance, string value)
			{
				OwnConfigEntryBase ownConfigEntryBase = configData(__instance);
				if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null)
				{
					return true;
				}
				try
				{
					ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType);
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}");
				}
				return false;
			}
		}

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)]
		private class InvalidDeserializationTypeException : Exception
		{
			public string expected;

			public string received;

			public string field = "";
		}

		public static bool ProcessingServerUpdate;

		public readonly string Name;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		public string DisplayName;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		public string CurrentVersion;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		public string MinimumRequiredVersion;

		public bool ModRequired;

		private bool? forceConfigLocking;

		private bool isSourceOfTruth = true;

		private static readonly HashSet<ConfigSync> configSyncs;

		private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>();

		private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>();

		private static bool isServer;

		private static bool lockExempt;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		private OwnConfigEntryBase lockedConfig;

		private const byte PARTIAL_CONFIGS = 1;

		private const byte FRAGMENTED_CONFIG = 2;

		private const byte COMPRESSED_CONFIG = 4;

		private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>();

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(new byte[] { 1, 0, 1 })]
		private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>();

		private static long packageCounter;

		public bool IsLocked
		{
			get
			{
				bool? flag = forceConfigLocking;
				bool num;
				if (!flag.HasValue)
				{
					if (lockedConfig == null)
					{
						goto IL_0051;
					}
					num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0;
				}
				else
				{
					num = flag.GetValueOrDefault();
				}
				if (num)
				{
					return !lockExempt;
				}
				goto IL_0051;
				IL_0051:
				return false;
			}
			set
			{
				forceConfigLocking = value;
			}
		}

		public bool IsAdmin
		{
			get
			{
				if (!lockExempt)
				{
					return isSourceOfTruth;
				}
				return true;
			}
		}

		public bool IsSourceOfTruth
		{
			get
			{
				return isSourceOfTruth;
			}
			private set
			{
				if (value != isSourceOfTruth)
				{
					isSourceOfTruth = value;
					this.SourceOfTruthChanged?.Invoke(value);
				}
			}
		}

		public bool InitialSyncDone { get; private set; }

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		[method: <3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(2)]
		[field: <c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		public event Action<bool> SourceOfTruthChanged;

		[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		[method: <3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(2)]
		[field: <c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)]
		private event Action lockedConfigChanged;

		static ConfigSync()
		{
			ProcessingServerUpdate = false;
			configSyncs = new HashSet<ConfigSync>();
			lockExempt = false;
			packageCounter = 0L;
			RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle);
		}

		public ConfigSync(string name)
		{
			Name = name;
			configSyncs.Add(this);
			new VersionCheck(this);
		}

		public SyncedConfigEntry<T> AddConfigEntry<[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(2)] T>(ConfigEntry<T> configEntry)
		{
			OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry);
			SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>;
			if (syncedEntry == null)
			{
				syncedEntry = new SyncedConfigEntry<T>(configEntry);
				AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry).Description, new object[1]
				{
					new ConfigurationManagerAttributes()
				}.Concat(((ConfigEntryBase)configEntry).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray());
				configEntry.SettingChanged += [<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)] (object _, EventArgs _) =>
				{
					if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig)
					{
						Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry);
					}
				};
				allConfigs.Add(syncedEntry);
			}
			return syncedEntry;
		}

		public SyncedConfigEntry<T> AddLockingConfigEntry<[<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(0)] T>(ConfigEntry<T> lockingConfig) where T : IConvertible
		{
			if (lockedConfig != null)
			{
				throw new Exception("Cannot initialize locking ConfigEntry twice");
			}
			lockedConfig = AddConfigEntry<T>(lockingConfig);
			lockingConfig.SettingChanged += [<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)] (object _, EventArgs _) =>
			{
				this.lockedConfigChanged?.Invoke();
			};
			return (SyncedConfigEntry<T>)lockedConfig;
		}

		internal void AddCustomValue(CustomSyncedValueBase customValue)
		{
			if (allCustomValues.Select([<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)] (CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue.Identifier))
			{
				throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)");
			}
			allCustomValues.Add(customValue);
			allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending([<3cde7647-e7bd-4bc4-930d-6a36f5cfb8ad>NullableContext(0)] (CustomSyncedValueBase v) => v.Priority));
			customValue.ValueChanged += delegate
			{
				if (!ProcessingServerUpdate)
				{
					Broadcast(ZRoutedRpc.Everybody, customValue);
				}
			};
		}

		private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package)
		{
			lockedConfigChanged += serverLockedSettingChanged;
			IsSourceOfTruth = false;
			if (HandleConfigSyncRPC(0L, package, clientUpdate: false))
			{
				InitialSyncDone = true;
			}
		}

		private void RPC_FromOtherClientConfigSync(long sender, ZPackage package)
		{
			HandleConfigSyncRPC(sender, package, clientUpdate: true);
		}

		private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate)
		{
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			try
			{
				if (isServer && IsLocked)
				{
					ZRpc currentRpc = SnatchCurrentlyHandlingRPC.currentRpc;
					object obj;
					if (currentRpc == null)
					{
						obj = null;
					}
					else
					{
						ISocket socket = currentRpc.GetSocket();
						obj = ((socket != null) ? socket.GetHostName() : null);
					}
					string text = (string)obj;
					if (text != null)
					{
						MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
						SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
						if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text }))))
						{
							return false;
						}
					}
				}
				cacheExpirations.RemoveAll(([<c21a6985-9cb5-4d0b-87f2-41c8caaadbcf>Nullable(new byte[] { 0, 1 })] KeyValuePair<long, string> kv) =>
				{
					if (kv.Key < DateTimeOffset.Now.Ticks)
					{
						configValueCache.Remove(kv.Value);
						return true;
					}
					return false;
				});
				byte b = package.ReadByte();
				if ((b & 2u) != 0)
				{