Decompiled source of Custom Products v1.9.0

function/CustomProducts.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using B83.Image.BMP;
using BepInEx;
using BepInEx.Configuration;
using Dummiesman;
using Dummiesman.Extensions;
using HarmonyLib;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CustomProducts")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomProducts")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e712be4-4758-4b3c-a44c-30f9a489ab0f")]
[assembly: AssemblyFileVersion("1.1.9.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.9.0")]
public class MTLLoader
{
	public List<string> SearchPaths = new List<string>
	{
		"%FileName%_Textures",
		string.Empty
	};

	private FileInfo _objFileInfo = null;

	public virtual Texture2D TextureLoadFunction(string path, bool isNormalMap)
	{
		foreach (string searchPath in SearchPaths)
		{
			string path2 = ((_objFileInfo != null) ? searchPath.Replace("%FileName%", Path.GetFileNameWithoutExtension(_objFileInfo.Name)) : searchPath);
			string text = Path.Combine(path2, 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 "-clamp":
		case "-blendu":
		case "-blendv":
		case "-imfchan":
		case "-texres":
			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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_0106: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Invalid comparison between Unknown and I4
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Invalid comparison between Unknown and I4
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		StreamReader streamReader = new StreamReader(input);
		StringReader stringReader = new StringReader(streamReader.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);
	}
}
[Serializable]
public class NewProduct
{
	[JsonIgnore]
	public string Json_Path { get; set; }

	public int Tier_ID { get; set; }

	public string Tier_Name { get; set; }

	public int Tier_Requirement { get; set; }

	public string Blackboard_CategoryName { get; set; }

	public string Blackboard_Color { get; set; }

	public int Product_ID { get; set; }

	public string Product_Name { get; set; }

	public string Product_Brand { get; set; }

	public int Product_ContainerClass { get; set; }

	public int Product_maxItemsPerBox { get; set; }

	public bool Product_isStackable { get; set; }

	public float Product_basePricePerUnit { get; set; }

	public string Prefab_Name { get; set; } = "";


	public string Mesh_Name { get; set; }

	public string Texture_Name { get; set; }

	public string Sprite_Name { get; set; }

	public string Sprite_Tier_Name { get; set; } = "";


	public float Hitbox_Width { get; set; }

	public float Hitbox_Height { get; set; }

	public float Hitbox_Depth { get; set; }

	public bool Mesh_AutoSmooth { get; set; } = false;


	public NewProduct(string json_Path, int tier_ID, string tier_Name, int tier_Requirement, string blackboard_CategoryName, string blackboard_Color, int product_ID, string product_name, string product_brand, int product_containerClass, int product_maxItemsPerBox, bool product_isStackable, float product_basePricePerUnit, string prefab_name, string mesh_name, string texture_name, string sprite_name, string sprite_Tier_name, float hitbox_Width, float hitbox_Height, float hitbox_Depth, bool mesh_AutoSmooth)
	{
		Json_Path = json_Path;
		Tier_ID = tier_ID;
		Tier_Name = tier_Name;
		Tier_Requirement = tier_Requirement;
		Blackboard_CategoryName = blackboard_CategoryName;
		Blackboard_Color = blackboard_Color;
		Product_ID = product_ID;
		Product_Name = product_name;
		Product_Brand = product_brand;
		Product_ContainerClass = product_containerClass;
		Product_maxItemsPerBox = product_maxItemsPerBox;
		Product_isStackable = product_isStackable;
		Product_basePricePerUnit = product_basePricePerUnit;
		Prefab_Name = prefab_name;
		Mesh_Name = mesh_name;
		Texture_Name = texture_name;
		Sprite_Name = sprite_name;
		Sprite_Tier_Name = sprite_Tier_name;
		Hitbox_Width = hitbox_Width;
		Hitbox_Height = hitbox_Height;
		Hitbox_Depth = hitbox_Depth;
		Mesh_AutoSmooth = mesh_AutoSmooth;
	}

	public Color GetProductTierColor()
	{
		//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_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		Color result = default(Color);
		if (ColorUtility.TryParseHtmlString(Blackboard_Color, ref result))
		{
			return result;
		}
		return Color.white;
	}
}
public static class OBJExporter
{
	public static void ExportMeshToOBJ(Mesh mesh, string filePath)
	{
		//IL_005c: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mesh == (Object)null || mesh.vertexCount == 0 || mesh.triangles.Length == 0)
		{
			Debug.LogError((object)"Mesh is empty or null. Export aborted.");
			return;
		}
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("# Exported OBJ file");
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3[] vertices = mesh.vertices;
		foreach (Vector3 val in vertices)
		{
			stringBuilder.AppendLine(string.Format(invariantCulture, "v {0} {1} {2}", val.x, val.y, val.z));
		}
		Vector3[] normals = mesh.normals;
		foreach (Vector3 val2 in normals)
		{
			stringBuilder.AppendLine(string.Format(invariantCulture, "vn {0} {1} {2}", val2.x, val2.y, val2.z));
		}
		if (mesh.uv.Length != 0)
		{
			Vector2[] uv = mesh.uv;
			foreach (Vector2 val3 in uv)
			{
				stringBuilder.AppendLine(string.Format(invariantCulture, "vt {0} {1}", val3.x, val3.y));
			}
		}
		for (int l = 0; l < mesh.subMeshCount; l++)
		{
			stringBuilder.AppendLine($"o SubMesh_{l}");
			int[] triangles = mesh.GetTriangles(l);
			for (int m = 0; m < triangles.Length; m += 3)
			{
				int num = triangles[m] + 1;
				int num2 = triangles[m + 1] + 1;
				int num3 = triangles[m + 2] + 1;
				stringBuilder.AppendLine(string.Format(invariantCulture, "f {0}//{0} {1}//{1} {2}//{2}", num, num2, num3));
			}
		}
		File.WriteAllText(filePath, stringBuilder.ToString());
		Debug.Log((object)$"Mesh exported successfully to {filePath} with {mesh.subMeshCount} submeshes.");
	}
}
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);
	}
	public class BMPImage
	{
		public BMPFileHeader header;

		public BitmapInfoHeader info;

		public uint rMask = 16711680u;

		public uint gMask = 65280u;

		public uint bMask = 255u;

		public uint aMask = 0u;

		public List<Color32> palette;

		public Color32[] imageData;

		public Texture2D ToTexture2D()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			Texture2D val = new Texture2D(info.absWidth, info.absHeight);
			val.SetPixels32(imageData);
			val.Apply();
			return val;
		}
	}
	public class BMPLoader
	{
		private const ushort MAGIC = 19778;

		public bool ReadPaletteAlpha = false;

		public bool ForceAlphaReadWhenPossible = false;

		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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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++)
				{
					uint num6 = (uint)(aReader.ReadByte() | (aReader.ReadByte() << 8) | (aReader.ReadByte() << 16));
					byte b = (byte)((num6 & bmp.rMask) >> shiftCount);
					byte b2 = (byte)((num6 & bmp.gMask) >> shiftCount2);
					byte b3 = (byte)((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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			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 1:
					return;
				case 2:
					num3 += aReader.ReadByte();
					num4 += aReader.ReadByte();
					num5 = num4 * num;
					continue;
				}
				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_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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			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 1:
					return;
				case 2:
					num3 += aReader.ReadByte();
					num4 += aReader.ReadByte();
					num5 = num4 * num;
					continue;
				}
				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_006c: 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;
		}
	}
	public class BitStreamReader
	{
		private BinaryReader m_Reader;

		private byte m_Data = 0;

		private int m_Bits = 0;

		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
{
	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 = 0;

		private int maxPosition = 0;

		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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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();
			}
			return flag ? (-num) : num;
		}

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

		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];
		}
	}
	public enum SplitMode
	{
		None,
		Object,
		Material
	}
	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))) && !File.Exists(mtlLibPath))
			{
			}
		}

		public GameObject Load(Stream input)
		{
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Expected O, but got Unknown
			//IL_0402: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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)
				{
					GameObject val2 = item.Value.Build();
					val2.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);
		}
	}
	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);
			}
			return flag ? (-num) : num;
		}

		public static Material CreateNullMaterial()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			return new Material(Shader.Find("Universal Render Pipeline/Lit"));
		}

		public static Vector3 VectorFromStrArray(string[] cmps)
		{
			//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_003f: 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_002f: 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)
			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_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_002d: 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);
		}
	}
	public class OBJObjectBuilder
	{
		private class ObjLoopHash
		{
			public int vertexIndex;

			public int normalIndex;

			public int uvIndex;

			public override bool Equals(object obj)
			{
				if (!(obj is ObjLoopHash))
				{
					return false;
				}
				ObjLoopHash objLoopHash = obj as ObjLoopHash;
				return objLoopHash.vertexIndex == vertexIndex && objLoopHash.uvIndex == uvIndex && objLoopHash.normalIndex == normalIndex;
			}

			public override int GetHashCode()
			{
				int num = 3;
				num = num * 314159 + vertexIndex;
				num = num * 314159 + normalIndex;
				return num * 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 = null;

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

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

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

		private bool recalculateNormals = false;

		public int PushedFaceCount { get; private set; } = 0;


		public GameObject Build()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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)
			{
				Material value = null;
				if (_loader.Materials == null)
				{
					value = OBJLoaderHelper.CreateNullMaterial();
					((Object)value).name = materialIndex.Key;
				}
				else if (!_loader.Materials.TryGetValue(materialIndex.Key, out value))
				{
					value = OBJLoaderHelper.CreateNullMaterial();
					((Object)value).name = materialIndex.Key;
					_loader.Materials[materialIndex.Key] = value;
				}
				array[num] = value;
				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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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
	{
		public static string Clean(this string str)
		{
			string text = str.Replace('\t', ' ');
			while (text.Contains("  "))
			{
				text = text.Replace("  ", " ");
			}
			return text.Trim();
		}
	}
	public static class BinaryExtensions
	{
		public static Color32 ReadColor32RGBR(this BinaryReader r)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			byte[] array = r.ReadBytes(4);
			return new Color32(array[0], array[1], array[2], array[3]);
		}

		public static Color32 ReadColor32RGB(this BinaryReader r)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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);
		}
	}
	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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			try
			{
				byte b = ddsBytes[4];
				if (b != 124)
				{
					throw new Exception("Invalid DDS header. Structure length is incrrrect.");
				}
				byte b2 = ddsBytes[87];
				if (b2 != 49 && b2 != 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)((b2 == 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);
			}
		}
	}
	public class ImageLoader
	{
		public enum TextureFormat
		{
			DDS,
			TGA,
			BMP,
			PNG,
			JPG,
			CRN
		}

		public static void SetNormalMap(ref Texture2D tex)
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			switch (format)
			{
			case TextureFormat.BMP:
				return new BMPLoader().LoadBMP(stream).ToTexture2D();
			case TextureFormat.DDS:
				return DDSLoader.Load(stream);
			default:
				if (format != TextureFormat.PNG)
				{
					if (format == TextureFormat.TGA)
					{
						return TGALoader.Load(stream);
					}
					return null;
				}
				goto case TextureFormat.JPG;
			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;
			}
			}
		}

		public static Texture2D LoadTexture(string fn)
		{
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_01f8: 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;
			switch (text)
			{
			case ".png":
			case ".jpg":
			case ".jpeg":
				val = new Texture2D(1, 1);
				ImageConversion.LoadImage(val, array);
				break;
			case ".dds":
				val = DDSLoader.Load(array);
				break;
			case ".tga":
				val = TGALoader.Load(array);
				break;
			case ".bmp":
				val = new BMPLoader().LoadBMP(array).ToTexture2D();
				break;
			case ".crn":
			{
				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));
						break;
					}
					val2 = (TextureFormat)65;
				}
				val = new Texture2D((int)num, (int)num2, val2, true);
				val.LoadRawTextureData(array2);
				val.Apply(true);
				break;
			}
			default:
				Debug.LogError((object)("Could not load texture " + fileName + " because its format is not supported : " + fn));
				break;
			}
			if ((Object)(object)val != (Object)null)
			{
				val = ImageLoaderHelper.VerifyFormat(val);
				((Object)val).name = Path.GetFileNameWithoutExtension(fn);
			}
			return val;
		}
	}
	public class ImageLoaderHelper
	{
		public static Texture2D VerifyFormat(Texture2D tex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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;
			foreach (Color32 val in array)
			{
				if (val.a < byte.MaxValue)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				Texture2D val2 = new Texture2D(((Texture)tex).width, ((Texture)tex).height, (TextureFormat)3, ((Texture)tex).mipmapCount > 0);
				val2.SetPixels32(pixels);
				val2.Apply(true);
				return val2;
			}
			return tex;
		}

		public static void FillPixelArray(Color32[] fillArray, byte[] pixelData, int bytesPerPixel, bool bgra = false)
		{
			//IL_0030: 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)
			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
	{
		public static Texture2D ConvertToNormalMap(Texture2D tex)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			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 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 = (Color32[])(object)new Color32[width * height];
			byte[] pixelData = r.ReadBytes(width * height * (bitDepth / 8));
			ImageLoaderHelper.FillPixelArray(array, pixelData, bitDepth / 8, bgra: true);
			return array;
		}

		private static Color32[] LoadRLETGAData(BinaryReader r, int bitDepth, int width, int height)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Color32(color.b, color.g, color.r, color.a);
		}
	}
}
namespace CustomProducts
{
	[BepInPlugin("shaklin.CustomProducts", "CustomProducts", "1.1.9")]
	public class BepInExPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ProductListing), "updateProductList")]
		public static class Patch_ProductListing
		{
			[HarmonyPrefix]
			private static bool Prefix(ProductListing __instance)
			{
				__instance.availableProducts.Clear();
				for (int i = 0; i < __instance.unlockedProductTiers.Length; i++)
				{
					if (i <= Instance.vanilla_tiers && __instance.unlockedProductTiers[i])
					{
						string[] array = __instance.tiers[i].Split(new char[1] { char.Parse("-") });
						int num = int.Parse(array[0]);
						int num2 = int.Parse(array[1]);
						for (int j = num; j < num2 + 1; j++)
						{
							__instance.availableProducts.Add(j);
						}
					}
				}
				if (modEnabled.Value && !cleanSavegame.Value)
				{
					foreach (KeyValuePair<int, int> item in Instance.customproduct_added)
					{
						if (!__instance.availableProducts.Contains(item.Key) && HasRequiredTier(item.Key))
						{
							__instance.availableProducts.Add(item.Key);
						}
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(SaveBehaviour), "LoadProductValues")]
		public static class Patch_SaveBehaviour
		{
			[HarmonyPrefix]
			private static bool Prefix(SaveBehaviour __instance, ref float[] pPlayerPricingArray, ref float[] tInflationArray, ref bool[] uProductTiersArray)
			{
				ProductListing component = __instance.gameDataOBJ.GetComponent<ProductListing>();
				if (modEnabled.Value && !cleanSavegame.Value)
				{
					if (component.productPlayerPricing.Length < pPlayerPricingArray.Length)
					{
						Array.Resize(ref component.productPlayerPricing, pPlayerPricingArray.Length);
					}
					for (int i = 0; i < pPlayerPricingArray.Length; i++)
					{
						component.productPlayerPricing[i] = pPlayerPricingArray[i];
					}
					if (component.tierInflation.Length < tInflationArray.Length)
					{
						Array.Resize(ref component.tierInflation, tInflationArray.Length);
					}
					for (int j = 0; j < tInflationArray.Length; j++)
					{
						component.tierInflation[j] = tInflationArray[j];
					}
					if (component.unlockedProductTiers.Length < uProductTiersArray.Length)
					{
						Array.Resize(ref component.unlockedProductTiers, uProductTiersArray.Length);
					}
					for (int k = 0; k < uProductTiersArray.Length; k++)
					{
						component.unlockedProductTiers[k] = uProductTiersArray[k];
					}
				}
				else
				{
					if (pPlayerPricingArray.Length > component.productPlayerPricing.Length)
					{
						Array.Resize(ref pPlayerPricingArray, component.productPlayerPricing.Length);
						Instance.limit_productPlayerPricing = component.productPlayerPricing.Length;
					}
					for (int l = 0; l < pPlayerPricingArray.Length; l++)
					{
						component.productPlayerPricing[l] = pPlayerPricingArray[l];
					}
					if (tInflationArray.Length > component.tierInflation.Length)
					{
						Array.Resize(ref tInflationArray, component.tierInflation.Length);
						Instance.limit_tierInflation = component.tierInflation.Length;
					}
					for (int m = 0; m < tInflationArray.Length; m++)
					{
						component.tierInflation[m] = tInflationArray[m];
					}
					if (uProductTiersArray.Length > component.unlockedProductTiers.Length)
					{
						Array.Resize(ref uProductTiersArray, component.unlockedProductTiers.Length);
						Instance.limit_unlockedProductTiers = component.unlockedProductTiers.Length;
					}
					for (int n = 0; n < uProductTiersArray.Length; n++)
					{
						component.unlockedProductTiers[n] = uProductTiersArray[n];
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Data_Container), "BoxSpawner")]
		public static class Patch_Data_Container
		{
			[HarmonyPrefix]
			public static bool Prefix_BoxSpawner(Data_Container __instance)
			{
				if (modEnabled.Value)
				{
					GameObject gameObject = ((Component)((Component)__instance).transform.Find("BoxContainer")).gameObject;
					for (int i = 0; i < gameObject.transform.childCount; i++)
					{
						int num = __instance.productInfoArray[i * 2];
						if ((cleanSavegame.Value && num > 1000) || (num > 1000 && !Instance.customproduct_added.ContainsKey(num)))
						{
							Transform child = gameObject.transform.GetChild(i);
							if (child.childCount > 0)
							{
								Object.Destroy((Object)(object)((Component)child.GetChild(0)).gameObject);
							}
							__instance.productInfoArray[i * 2] = -1;
							__instance.productInfoArray[i * 2 + 1] = 0;
						}
					}
					if (cleanSavegame.Value)
					{
						if (Object.op_Implicit((Object)(object)NPC_Manager.Instance))
						{
							NPC_Manager.Instance.EndDaySaveEmployeesValues();
						}
						((MonoBehaviour)Instance).StartCoroutine(SaveCleanGame());
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Data_Container), "ItemSpawner")]
		public static class Patch_Data_Container2
		{
			[HarmonyPrefix]
			public static bool Prefix_ItemSpawner(Data_Container __instance)
			{
				if (modEnabled.Value)
				{
					GameObject gameObject = ((Component)((Component)__instance).transform.Find("ProductContainer")).gameObject;
					for (int i = 0; i < gameObject.transform.childCount; i++)
					{
						Transform child = gameObject.transform.GetChild(i);
						int num = __instance.productInfoArray[i * 2];
						if ((cleanSavegame.Value && num > 1000) || (num > 1000 && !Instance.customproduct_added.ContainsKey(num)))
						{
							for (int num2 = child.childCount - 1; num2 >= 0; num2--)
							{
								Object.Destroy((Object)(object)((Component)child.GetChild(num2)).gameObject);
							}
							__instance.productInfoArray[i * 2] = -1;
							__instance.productInfoArray[i * 2 + 1] = 0;
						}
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ManagerBlackboard), "UpdateUnlockedFranchises")]
		public static class Patch_ManagerBlackboard
		{
			[HarmonyPrefix]
			private static bool Prefix_updateSkillState(ManagerBlackboard __instance)
			{
				//IL_023d: Unknown result type (might be due to invalid IL or missing references)
				bool[] value = Traverse.Create((object)__instance).Field("unlockedFranchises").GetValue<bool[]>();
				string[] value2 = Traverse.Create((object)__instance).Field("tiers").GetValue<string[]>();
				List<int> value3 = Traverse.Create((object)__instance).Field("groupsList").GetValue<List<int>>();
				PlayMakerFSM val = Traverse.Create((object)__instance).Field("fsm").GetValue<PlayMakerFSM>();
				value = ((Component)__instance).GetComponent<ProductListing>().unlockedProductTiers;
				value2 = ((Component)__instance).GetComponent<ProductListing>().tiers;
				if (__instance.shortcutsParent.transform.childCount > 0)
				{
					int childCount = __instance.shortcutsParent.transform.childCount;
					for (int i = 0; i < childCount; i++)
					{
						Object.Destroy((Object)(object)((Component)__instance.shortcutsParent.transform.GetChild(__instance.shortcutsParent.transform.childCount - 1 - i)).gameObject);
					}
				}
				List<string> list = new List<string>();
				value3.Clear();
				for (int j = 0; j < value.Length; j++)
				{
					if (!value[j])
					{
						continue;
					}
					int num = ProductListing.Instance.productGroups[j];
					if (num > 1000)
					{
						string item = Get_Blackboard_CategoryName(num);
						if (list.Contains(item))
						{
							continue;
						}
						list.Add(item);
					}
					bool flag = false;
					foreach (int item2 in value3)
					{
						if (item2 == num)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						GameObject val2 = Object.Instantiate<GameObject>(__instance.UIShortcutPrefab, __instance.shortcutsParent.transform);
						val = val2.GetComponent<PlayMakerFSM>();
						val.FsmVariables.GetFsmInt("GroupIndex").Value = num;
						string text = "productGroup" + num;
						string localizationString = LocalizationManager.instance.GetLocalizationString(text);
						((TMP_Text)((Component)val2.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = localizationString;
						((Graphic)((Component)val2.transform.GetChild(1)).GetComponent<Image>()).color = ProductListing.Instance.groupsColors[num];
						value3.Add(num);
					}
				}
				Traverse.Create((object)__instance).Field("unlockedFranchises").SetValue((object)value);
				Traverse.Create((object)__instance).Field("tiers").SetValue((object)value2);
				Traverse.Create((object)__instance).Field("groupsList").SetValue((object)value3);
				Traverse.Create((object)__instance).Field("fsm").SetValue((object)val);
				return false;
			}
		}

		[HarmonyPatch(typeof(ManagerBlackboard), "UpdateVisibleProducts")]
		public static class Patch_ManagerBlackboard2
		{
			[HarmonyPrefix]
			private static bool Prefix(ManagerBlackboard __instance, ref int groupTier)
			{
				if (modEnabled.Value && !cleanSavegame.Value)
				{
					MethodInfo methodInfo = AccessTools.Method(((object)__instance).GetType(), "SetShortcutHighlight", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						methodInfo.Invoke(__instance, new object[1] { groupTier });
					}
					MethodInfo methodInfo2 = AccessTools.Method(((object)__instance).GetType(), "ClearItems", (Type[])null, (Type[])null);
					if (methodInfo2 != null)
					{
						methodInfo2.Invoke(__instance, new object[0]);
					}
					int value = Traverse.Create((object)__instance).Field("oldGroupTier").GetValue<int>();
					value = groupTier;
					Traverse.Create((object)__instance).Field("oldGroupTier").SetValue((object)value);
					ProductListing component = ((Component)__instance).GetComponent<ProductListing>();
					bool[] value2 = Traverse.Create((object)__instance).Field("unlockedFranchises").GetValue<bool[]>();
					string[] value3 = Traverse.Create((object)__instance).Field("tiers").GetValue<string[]>();
					if (groupTier < 1000)
					{
						try
						{
							for (int i = 0; i < value2.Length; i++)
							{
								if (!value2[i] || ProductListing.Instance.productGroups[i] != groupTier)
								{
									continue;
								}
								string[] array = value3[i].Split(new char[1] { char.Parse("-") });
								float num = component.tierInflation[i];
								string localizationString = LocalizationManager.instance.GetLocalizationString("productRelated0");
								int num2 = int.Parse(array[0]);
								int num3 = int.Parse(array[1]);
								for (int j = num2; j < num3 + 1; j++)
								{
									MethodInfo methodInfo3 = AccessTools.Method(((object)__instance).GetType(), "CreateUIShopItem", (Type[])null, (Type[])null);
									if (methodInfo3 != null)
									{
										methodInfo3.Invoke(__instance, new object[4] { j, component, num, localizationString });
									}
								}
							}
						}
						catch
						{
						}
					}
					else
					{
						foreach (KeyValuePair<string, (List<NewProduct>, Dictionary<string, Mesh>, Dictionary<string, Texture2D>, Dictionary<string, AssetBundle>)> customProducts_datum in Instance.customProducts_data)
						{
							foreach (NewProduct item in customProducts_datum.Value.Item1)
							{
								if ((groupTier == item.Tier_ID && HasRequiredTier(item.Product_ID)) || (Get_Blackboard_CategoryName(groupTier) == item.Blackboard_CategoryName && HasRequiredTier(item.Product_ID)))
								{
									int product_ID = item.Product_ID;
									float num4 = component.tierInflation[component.productPrefabs[product_ID].GetComponent<Data_Product>().productTier];
									string localizationString2 = LocalizationManager.instance.GetLocalizationString("productRelated0");
									MethodInfo methodInfo4 = AccessTools.Method(((object)__instance).GetType(), "CreateUIShopItem", (Type[])null, (Type[])null);
									if (methodInfo4 != null)
									{
										methodInfo4.Invoke(__instance, new object[4] { product_ID, component, num4, localizationString2 });
									}
								}
							}
						}
					}
					Traverse.Create((object)__instance).Field("unlockedFranchises").SetValue((object)value2);
					Traverse.Create((object)__instance).Field("tiers").SetValue((object)value3);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ProductListing), "SetBoxColor")]
		public static class Patch_ProductListing2
		{
			[HarmonyPrefix]
			private static bool Prefix(ProductListing __instance, ref GameObject boxOBJ, ref int productID)
			{
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				if (modEnabled.Value && !cleanSavegame.Value && productID > 1000)
				{
					foreach (KeyValuePair<string, (List<NewProduct>, Dictionary<string, Mesh>, Dictionary<string, Texture2D>, Dictionary<string, AssetBundle>)> customProducts_datum in Instance.customProducts_data)
					{
						foreach (NewProduct item in customProducts_datum.Value.Item1)
						{
							if (productID == item.Product_ID)
							{
								((Renderer)((Component)boxOBJ.transform.Find("BoxMesh")).GetComponent<SkinnedMeshRenderer>()).material.color = item.GetProductTierColor();
							}
						}
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ProductListing), "updateSkillState")]
		public static class Patch_ProductListing3
		{
			[HarmonyPrefix]
			private static bool Prefix_updateSkillState(ProductListing __instance)
			{
				if (!doprepare)
				{
					doprepare = true;
					doprepare_go = true;
					if (Instance.vanilla_tiers == -999)
					{
						int num = -1;
						foreach (KeyValuePair<string, string> item in LocalizationManager.instance.LocalizationDictionary)
						{
							if (item.Key.Contains("productCategory"))
							{
								num++;
							}
						}
						Instance.vanilla_tiers = num;
					}
					Instance.PrepareVanillaLists(__instance);
					if (useFranchisePoints.Value)
					{
						Instance.AddCustomTierOnWall(__instance);
					}
				}
				for (int i = 0; i < __instance.unlockedProductTiers.Length; i++)
				{
					if (i > Instance.vanilla_tiers)
					{
						if (!modEnabled.Value || cleanSavegame.Value || !Instance.customtier_added.ContainsKey(i))
						{
							continue;
						}
						if (__instance.unlockedProductTiers[i] || !useFranchisePoints.Value)
						{
							if (!useFranchisePoints.Value && CanShowTier(i))
							{
								__instance.unlockedProductTiers[i] = true;
							}
							GameObject val = Instance.custom_tier_objs["custom_tier_" + i];
							if ((Object)(object)val != (Object)null)
							{
								val.GetComponent<CanvasGroup>().alpha = 1f;
								val.tag = "Untagged";
								((Component)val.transform.Find("Highlight2")).gameObject.SetActive(true);
							}
						}
						else if (CanHighlightTier(i))
						{
							GameObject val2 = Instance.custom_tier_objs["custom_tier_" + i];
							if ((Object)(object)val2 != (Object)null)
							{
								((Component)val2.transform.Find("Highlight2")).gameObject.SetActive(true);
							}
						}
						continue;
					}
					GameObject gameObject = ((Component)__instance.skillTreeOBJ.transform.GetChild(i)).gameObject;
					if (__instance.unlockedProductTiers[i])
					{
						gameObject.GetComponent<CanvasGroup>().alpha = 1f;
						gameObject.tag = "Untagged";
						((Component)gameObject.transform.Find("Highlight2")).gameObject.SetActive(true);
						continue;
					}
					int[] previousSkillRequirements = gameObject.GetComponent<InteractableData>().previousSkillRequirements;
					bool flag = true;
					if (previousSkillRequirements.Length == 0)
					{
						continue;
					}
					int[] array = previousSkillRequirements;
					int[] array2 = array;
					foreach (int num2 in array2)
					{
						if (!__instance.unlockedProductTiers[num2])
						{
							flag = false;
						}
					}
					if (flag)
					{
						((Component)gameObject.transform.Find("Highlight2")).gameObject.SetActive(true);
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(PlayerNetwork), "Update")]
		public static class Patch_PlayerNetwork
		{
			[HarmonyPostfix]
			private static void Postfix_Update(PlayerNetwork __instance)
			{
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0226: Unknown result type (might be due to invalid IL or missing references)
				//IL_0235: Unknown result type (might be due to invalid IL or missing references)
				//IL_023a: Unknown result type (might be due to invalid IL or missing references)
				//IL_025d: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				if (modEnabled.Value && !cleanSavegame.Value && (showIDOnHud.Value || showIDOnHudVanilla.Value))
				{
					GameObject value = Traverse.Create((object)__instance).Field("gameCanvasProductOBJ").GetValue<GameObject>();
					RaycastHit val = default(RaycastHit);
					if ((Object)(object)value == (Object)null || !value.activeSelf || !Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val, 4f, LayerMask.op_Implicit(__instance.interactableMask)))
					{
						return;
					}
					InteractableContainer component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<InteractableContainer>();
					if ((Object)(object)component == (Object)null)
					{
						return;
					}
					int siblingIndex = ((RaycastHit)(ref val)).transform.GetSiblingIndex();
					Data_Container component2 = ((Component)((Component)((RaycastHit)(ref val)).transform.parent).transform.parent).GetComponent<Data_Container>();
					if ((Object)(object)component2 == (Object)null)
					{
						return;
					}
					int num = component2.productInfoArray[siblingIndex * 2];
					if (num < 0)
					{
						return;
					}
					GameObject val2 = ProductListing.Instance.productPrefabs[num];
					if ((Object)(object)val2 == (Object)null)
					{
						return;
					}
					Data_Product component3 = val2.GetComponent<Data_Product>();
					if ((Object)(object)component3 == (Object)null)
					{
						return;
					}
					int productID = component3.productID;
					int productTier = component3.productTier;
					string text = $"\nTier ID: {productTier}\nProduct ID: {productID}";
					Transform obj = value.transform.Find("Container/ProductName");
					productNameTMP = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
					if (!((Object)(object)productNameTMP == (Object)null))
					{
						if ((Object)(object)customTextMesh == (Object)null)
						{
							GameObject val3 = Object.Instantiate<GameObject>(((Component)productNameTMP).gameObject, ((TMP_Text)productNameTMP).transform.parent);
							customTextMesh = val3.GetComponent<TextMeshProUGUI>();
							RectTransform rectTransform = ((TMP_Text)customTextMesh).rectTransform;
							rectTransform.sizeDelta += new Vector2(0f, 20f);
							((Object)val3).name = "CustomProductText";
							RectTransform rectTransform2 = ((TMP_Text)customTextMesh).rectTransform;
							rectTransform2.anchoredPosition += new Vector2(0f, -70f);
						}
						if ((!showIDOnHudVanilla.Value && component3.productID < 1001) || (!showIDOnHud.Value && component3.productID > 1000))
						{
							((TMP_Text)customTextMesh).text = "";
						}
						else
						{
							((TMP_Text)customTextMesh).text = text;
						}
					}
				}
				else if ((Object)(object)customTextMesh != (Object)null)
				{
					((TMP_Text)customTextMesh).text = "";
				}
			}
		}

		[HarmonyPatch(typeof(PricingMachine), "Generation")]
		private static class PricingMachine_Generation_Patch
		{
			[CompilerGenerated]
			private sealed class <Postfix_Generation>d__0 : IEnumerator<object>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private object <>2__current;

				public IEnumerator original;

				public PricingMachine __instance;

				private ProductListing <pListing>5__1;

				private bool <generating>5__2;

				private List<int> <availableProducts>5__3;

				private int <counter>5__4;

				private List<int>.Enumerator <>s__5;

				private int <item>5__6;

				private GameObject <obj>5__7;

				private float <num>5__8;

				private float <marketPrice>5__9;

				private float <playerPrice>5__10;

				private int <productTier>5__11;

				private int <groupNum>5__12;

				private float <roundedMarketPrice>5__13;

				private float <roundedPlayerPrice>5__14;

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

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

				[DebuggerHidden]
				public <Postfix_Generation>d__0(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					int num = <>1__state;
					if (num == -3 || num == 1)
					{
						try
						{
						}
						finally
						{
							<>m__Finally1();
						}
					}
					<pListing>5__1 = null;
					<availableProducts>5__3 = null;
					<>s__5 = default(List<int>.Enumerator);
					<obj>5__7 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
					try
					{
						switch (<>1__state)
						{
						default:
							return false;
						case 0:
							<>1__state = -1;
							<pListing>5__1 = Traverse.Create((object)__instance).Field("pListing").GetValue<ProductListing>();
							<generating>5__2 = Traverse.Create((object)__instance).Field("generating").GetValue<bool>();
							<availableProducts>5__3 = <pListing>5__1.availableProducts;
							<counter>5__4 = 0;
							<>s__5 = <availableProducts>5__3.GetEnumerator();
							<>1__state = -3;
							goto IL_0382;
						case 1:
							<>1__state = -3;
							goto IL_037a;
						case 2:
							{
								<>1__state = -1;
								<generating>5__2 = false;
								Traverse.Create((object)__instance).Field("generating").SetValue((object)<generating>5__2);
								return false;
							}
							IL_0382:
							if (<>s__5.MoveNext())
							{
								<item>5__6 = <>s__5.Current;
								<obj>5__7 = Object.Instantiate<GameObject>(__instance.UIPricingPrefabOBJ, __instance.UIproductsContainer.transform);
								((TMP_Text)((Component)<obj>5__7.transform.Find("ProductName")).GetComponent<TextMeshProUGUI>()).text = LocalizationManager.instance.GetLocalizationString("product" + <item>5__6);
								((TMP_Text)((Component)<obj>5__7.transform.Find("BrandName")).GetComponent<TextMeshProUGUI>()).text = <pListing>5__1.productPrefabs[<item>5__6].GetComponent<Data_Product>().productBrand;
								((Component)<obj>5__7.transform.Find("ProductBCK/ProductImage")).GetComponent<Image>().sprite = <pListing>5__1.productSprites[<item>5__6];
								<num>5__8 = <pListing>5__1.tierInflation[<pListing>5__1.productPrefabs[<item>5__6].GetComponent<Data_Product>().productTier];
								<marketPrice>5__9 = <pListing>5__1.productPrefabs[<item>5__6].GetComponent<Data_Product>().basePricePerUnit * <num>5__8;
								((TMP_Text)((Component)<obj>5__7.transform.Find("MarketPriceBCK/MarketPrice")).GetComponent<TextMeshProUGUI>()).text = <pListing>5__1.ConvertFloatToTextPrice(<marketPrice>5__9);
								<playerPrice>5__10 = <pListing>5__1.productPlayerPricing[<item>5__6];
								((TMP_Text)((Component)<obj>5__7.transform.Find("YourPriceBCK/YourPrice")).GetComponent<TextMeshProUGUI>()).text = <pListing>5__1.ConvertFloatToTextPrice(<playerPrice>5__10);
								((Component)<obj>5__7.transform.Find("SelectionButton")).GetComponent<PlayMakerFSM>().FsmVariables.GetFsmInt("ProductID").Value = <item>5__6;
								<productTier>5__11 = <pListing>5__1.productPrefabs[<item>5__6].GetComponent<Data_Product>().productTier;
								<groupNum>5__12 = <pListing>5__1.productGroups[<productTier>5__11];
								((Graphic)<obj>5__7.GetComponent<Image>()).color = <pListing>5__1.groupsColors[<groupNum>5__12];
								<roundedMarketPrice>5__13 = Mathf.Round(<marketPrice>5__9 * 100f) / 100f;
								<roundedPlayerPrice>5__14 = Mathf.Round(<playerPrice>5__10 * 100f) / 100f;
								<counter>5__4++;
								if (<counter>5__4 >= 20)
								{
									<counter>5__4 = 0;
									<>2__current = null;
									<>1__state = 1;
									return true;
								}
								goto IL_037a;
							}
							<>m__Finally1();
							<>s__5 = default(List<int>.Enumerator);
							<>2__current = null;
							<>1__state = 2;
							return true;
							IL_037a:
							<obj>5__7 = null;
							goto IL_0382;
						}
					}
					catch
					{
						//try-fault
						((IDisposable)this).Dispose();
						throw;
					}
				}

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

				private void <>m__Finally1()
				{
					<>1__state = -1;
					((IDisposable)<>s__5).Dispose();
				}

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

			[IteratorStateMachine(typeof(<Postfix_Generation>d__0))]
			[HarmonyPostfix]
			private static IEnumerator Postfix_Generation(IEnumerator original, PricingMachine __instance)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Postfix_Generation>d__0(0)
				{
					original = original,
					__instance = __instance
				};
			}
		}

		[HarmonyPatch(typeof(OrderPackaging), "Update")]
		public class Patch_OrderPackagingHandler_Update
		{
			private static void Postfix(OrderPackaging __instance)
			{
				PlayMakerFSM value = Traverse.Create((object)__instance).Field("overlappingFSM").GetValue<PlayMakerFSM>();
				if ((Object)(object)value != (Object)null)
				{
					bool value2 = value.FsmVariables.GetFsmBool("Overlapping").Value;
					value.FsmVariables.GetFsmBool("Overlapping").Value = false;
					value.FsmVariables.GetFsmBool("NotOverlapping").Value = true;
				}
			}
		}

		[HarmonyPatch(typeof(OrderingTray), "AddItemToTray")]
		public class AddItemToTrayPatch
		{
			private static bool Prefix(OrderingTray __instance, int productID, ref bool __result)
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: 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)
				if (productID < 1000)
				{
					return true;
				}
				GameObject val = ProductListing.Instance.productPrefabs[productID];
				Data_Product component = val.GetComponent<Data_Product>();
				BoxCollider component2 = val.GetComponent<BoxCollider>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					Vector3 size = component2.size;
					if (size.x > 0.5f || size.y > 0.5f || size.z > 0.5f)
					{
						component.hasTrueCollider = true;
						component.trueCollider = new Vector3((size.x > 0.5f) ? 0.2f : size.x, (size.y > 0.5f) ? 0.2f : size.y, (size.z > 0.5f) ? 0.2f : size.z);
					}
					else
					{
						component.hasTrueCollider = false;
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(GameData), "ServerCalculateNewInflation")]
		private static class GameData_Patch
		{
			[HarmonyPrefix]
			private static bool Prefix_ServerCalculateNewInflation(GameData __instance)
			{
				if (!cleanSavegame.Value)
				{
					if (__instance.gameDay % 7 != 4)
					{
						return false;
					}
					HashSet<int> hashSet = new HashSet<int>(((Component)ProductListing.Instance).GetComponent<ProductListing>().availableProducts);
					float[] tierInflation = ((Component)ProductListing.Instance).GetComponent<ProductListing>().tierInflation;
					for (int i = 0; i < tierInflation.Length; i++)
					{
						if ((i >= 1000 || i <= __instance.gameDay / 2) && (i <= 999 || hashSet.Contains(i)))
						{
							float num = Random.Range(0.05f, 0.15f) + Random.Range(0.04f, 0.08f) * ((float)__instance.gameDay / 40f);
							float num2 = tierInflation[i] + num;
							num2 = Mathf.Round(num2 * 100f) / 100f;
							((Component)ProductListing.Instance).GetComponent<ProductListing>().tierInflation[i] = num2;
							MethodInfo methodInfo = AccessTools.Method(((object)__instance).GetType(), "RpcUpdateInflationOnClient", (Type[])null, (Type[])null);
							if (methodInfo != null)
							{
								methodInfo.Invoke(__instance, new object[2] { i, num2 });
							}
						}
					}
					return false;
				}
				return true;
			}
		}

		[CompilerGenerated]
		private sealed class <SaveCleanGame>d__50 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private int <runId>5__1;

			private ProductListing <component>5__2;

			private PlayMakerFSM <fsm>5__3;

			private NetworkSpawner <nSpawnerComponent>5__4;

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

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

			[DebuggerHidden]
			public <SaveCleanGame>d__50(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 5u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<component>5__2 = null;
				<fsm>5__3 = null;
				<nSpawnerComponent>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Expected O, but got Unknown
				//IL_0237: Unknown result type (might be due to invalid IL or missing references)
				//IL_0241: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (_isRunning)
						{
							return false;
						}
						_isRunning = true;
						<runId>5__1 = ++_runIdSeq;
						<>1__state = -3;
						<component>5__2 = null;
						goto IL_00d7;
					case 1:
						<>1__state = -3;
						goto IL_00d7;
					case 2:
						<>1__state = -3;
						goto IL_0108;
					case 3:
						<>1__state = -3;
						<fsm>5__3 = GameData.Instance.SaveOBJ.GetComponent<PlayMakerFSM>();
						<fsm>5__3.FsmVariables.GetFsmBool("IsSaving").Value = true;
						<fsm>5__3.SendEvent("Send_Data");
						goto IL_01f4;
					case 4:
						<>1__state = -3;
						goto IL_01f4;
					case 5:
						<>1__state = -3;
						break;
					case 6:
						{
							<>1__state = -3;
							break;
						}
						IL_01f4:
						if (<fsm>5__3.FsmVariables.GetFsmBool("IsSaving").Value)
						{
							<>2__current = null;
							<>1__state = 4;
							return true;
						}
						<nSpawnerComponent>5__4 = ((Component)GameData.Instance).GetComponent<NetworkSpawner>();
						<nSpawnerComponent>5__4.SaveProps(false);
						<>2__current = (object)new WaitForSeconds(0.25f);
						<>1__state = 5;
						return true;
						IL_00d7:
						while ((Object)(object)<component>5__2 == (Object)null)
						{
							<component>5__2 = ((Component)GameData.Instance).GetComponent<ProductListing>();
							if ((Object)(object)<component>5__2 == (Object)null)
							{
								<>2__current = null;
								<>1__state = 1;
								return true;
							}
						}
						goto IL_0108;
						IL_0108:
						if (<component>5__2.tierInflation == null)
						{
							<>2__current = null;
							<>1__state = 2;
							return true;
						}
						Array.Resize(ref <component>5__2.productPlayerPricing, Instance.limit_productPlayerPricing);
						Array.Resize(ref <component>5__2.tierInflation, Instance.limit_tierInflation);
						Array.Resize(ref <component>5__2.unlockedProductTiers, Instance.limit_unlockedProductTiers);
						<>2__current = (object)new WaitForSeconds(5f);
						<>1__state = 3;
						return true;
					}
					if (<nSpawnerComponent>5__4.isSaving)
					{
						<>2__current = null;
						<>1__state = 6;
						return true;
					}
					if ((Object)(object)Instance != (Object)null)
					{
						Instance._showText = true;
					}
					<component>5__2 = null;
					<fsm>5__3 = null;
					<nSpawnerComponent>5__4 = null;
					<>m__Finally1();
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				_isRunning = false;
			}

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

		private static BepInExPlugin Instance;

		private static ConfigEntry<bool> modEnabled;

		private static ConfigEntry<bool> useFranchisePoints;

		private static ConfigEntry<string> tiersOrder_style;

		private static ConfigEntry<bool> useSmoothing;

		private static ConfigEntry<bool> showIDOnHud;

		private static ConfigEntry<bool> showIDOnHudVanilla;

		private static ConfigEntry<bool> cleanSavegame;

		private static ConfigEntry<int> hb_productID;

		private static ConfigEntry<float> hb_Width;

		private static ConfigEntry<float> hb_Height;

		private static ConfigEntry<float> hb_Depth;

		private static string path_products = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Product