Decompiled source of ULTRASKINS GC v7.0.0

Iconic.Zlib.Netstandard.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using Ionic.Crc;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v1.3", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("https://github.com/HelloKitty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A .NETStandard port of Iconic.Zlib from DotNetZip project.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Iconic.Zlib.Netstandard")]
[assembly: AssemblyTitle("Iconic.Zlib.Netstandard")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Ionic.Zlib
{
	internal enum BlockState
	{
		NeedMore,
		BlockDone,
		FinishStarted,
		FinishDone
	}
	internal enum DeflateFlavor
	{
		Store,
		Fast,
		Slow
	}
	internal sealed class DeflateManager
	{
		internal delegate BlockState CompressFunc(FlushType flush);

		internal class Config
		{
			internal int GoodLength;

			internal int MaxLazy;

			internal int NiceLength;

			internal int MaxChainLength;

			internal DeflateFlavor Flavor;

			private static readonly Config[] Table;

			private Config(int goodLength, int maxLazy, int niceLength, int maxChainLength, DeflateFlavor flavor)
			{
				GoodLength = goodLength;
				MaxLazy = maxLazy;
				NiceLength = niceLength;
				MaxChainLength = maxChainLength;
				Flavor = flavor;
			}

			public static Config Lookup(CompressionLevel level)
			{
				return Table[(int)level];
			}

			static Config()
			{
				Table = new Config[10]
				{
					new Config(0, 0, 0, 0, DeflateFlavor.Store),
					new Config(4, 4, 8, 4, DeflateFlavor.Fast),
					new Config(4, 5, 16, 8, DeflateFlavor.Fast),
					new Config(4, 6, 32, 32, DeflateFlavor.Fast),
					new Config(4, 4, 16, 16, DeflateFlavor.Slow),
					new Config(8, 16, 32, 32, DeflateFlavor.Slow),
					new Config(8, 16, 128, 128, DeflateFlavor.Slow),
					new Config(8, 32, 128, 256, DeflateFlavor.Slow),
					new Config(32, 128, 258, 1024, DeflateFlavor.Slow),
					new Config(32, 258, 258, 4096, DeflateFlavor.Slow)
				};
			}
		}

		private static readonly int MEM_LEVEL_MAX = 9;

		private static readonly int MEM_LEVEL_DEFAULT = 8;

		private CompressFunc DeflateFunction;

		private static readonly string[] _ErrorMessage = new string[10] { "need dictionary", "stream end", "", "file error", "stream error", "data error", "insufficient memory", "buffer error", "incompatible version", "" };

		private static readonly int PRESET_DICT = 32;

		private static readonly int INIT_STATE = 42;

		private static readonly int BUSY_STATE = 113;

		private static readonly int FINISH_STATE = 666;

		private static readonly int Z_DEFLATED = 8;

		private static readonly int STORED_BLOCK = 0;

		private static readonly int STATIC_TREES = 1;

		private static readonly int DYN_TREES = 2;

		private static readonly int Z_BINARY = 0;

		private static readonly int Z_ASCII = 1;

		private static readonly int Z_UNKNOWN = 2;

		private static readonly int Buf_size = 16;

		private static readonly int MIN_MATCH = 3;

		private static readonly int MAX_MATCH = 258;

		private static readonly int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;

		private static readonly int HEAP_SIZE = 2 * InternalConstants.L_CODES + 1;

		private static readonly int END_BLOCK = 256;

		internal ZlibCodec _codec;

		internal int status;

		internal byte[] pending;

		internal int nextPending;

		internal int pendingCount;

		internal sbyte data_type;

		internal int last_flush;

		internal int w_size;

		internal int w_bits;

		internal int w_mask;

		internal byte[] window;

		internal int window_size;

		internal short[] prev;

		internal short[] head;

		internal int ins_h;

		internal int hash_size;

		internal int hash_bits;

		internal int hash_mask;

		internal int hash_shift;

		internal int block_start;

		private Config config;

		internal int match_length;

		internal int prev_match;

		internal int match_available;

		internal int strstart;

		internal int match_start;

		internal int lookahead;

		internal int prev_length;

		internal CompressionLevel compressionLevel;

		internal CompressionStrategy compressionStrategy;

		internal short[] dyn_ltree;

		internal short[] dyn_dtree;

		internal short[] bl_tree;

		internal Tree treeLiterals = new Tree();

		internal Tree treeDistances = new Tree();

		internal Tree treeBitLengths = new Tree();

		internal short[] bl_count = new short[InternalConstants.MAX_BITS + 1];

		internal int[] heap = new int[2 * InternalConstants.L_CODES + 1];

		internal int heap_len;

		internal int heap_max;

		internal sbyte[] depth = new sbyte[2 * InternalConstants.L_CODES + 1];

		internal int _lengthOffset;

		internal int lit_bufsize;

		internal int last_lit;

		internal int _distanceOffset;

		internal int opt_len;

		internal int static_len;

		internal int matches;

		internal int last_eob_len;

		internal short bi_buf;

		internal int bi_valid;

		private bool Rfc1950BytesEmitted;

		internal bool WantRfc1950HeaderBytes { get; set; } = true;


		internal DeflateManager()
		{
			dyn_ltree = new short[HEAP_SIZE * 2];
			dyn_dtree = new short[(2 * InternalConstants.D_CODES + 1) * 2];
			bl_tree = new short[(2 * InternalConstants.BL_CODES + 1) * 2];
		}

		private void _InitializeLazyMatch()
		{
			window_size = 2 * w_size;
			Array.Clear(head, 0, hash_size);
			config = Config.Lookup(compressionLevel);
			SetDeflater();
			strstart = 0;
			block_start = 0;
			lookahead = 0;
			match_length = (prev_length = MIN_MATCH - 1);
			match_available = 0;
			ins_h = 0;
		}

		private void _InitializeTreeData()
		{
			treeLiterals.dyn_tree = dyn_ltree;
			treeLiterals.staticTree = StaticTree.Literals;
			treeDistances.dyn_tree = dyn_dtree;
			treeDistances.staticTree = StaticTree.Distances;
			treeBitLengths.dyn_tree = bl_tree;
			treeBitLengths.staticTree = StaticTree.BitLengths;
			bi_buf = 0;
			bi_valid = 0;
			last_eob_len = 8;
			_InitializeBlocks();
		}

		internal void _InitializeBlocks()
		{
			for (int i = 0; i < InternalConstants.L_CODES; i++)
			{
				dyn_ltree[i * 2] = 0;
			}
			for (int j = 0; j < InternalConstants.D_CODES; j++)
			{
				dyn_dtree[j * 2] = 0;
			}
			for (int k = 0; k < InternalConstants.BL_CODES; k++)
			{
				bl_tree[k * 2] = 0;
			}
			dyn_ltree[END_BLOCK * 2] = 1;
			opt_len = (static_len = 0);
			last_lit = (matches = 0);
		}

		internal void pqdownheap(short[] tree, int k)
		{
			int num = heap[k];
			for (int num2 = k << 1; num2 <= heap_len; num2 <<= 1)
			{
				if (num2 < heap_len && _IsSmaller(tree, heap[num2 + 1], heap[num2], depth))
				{
					num2++;
				}
				if (_IsSmaller(tree, num, heap[num2], depth))
				{
					break;
				}
				heap[k] = heap[num2];
				k = num2;
			}
			heap[k] = num;
		}

		internal static bool _IsSmaller(short[] tree, int n, int m, sbyte[] depth)
		{
			short num = tree[n * 2];
			short num2 = tree[m * 2];
			if (num >= num2)
			{
				if (num == num2)
				{
					return depth[n] <= depth[m];
				}
				return false;
			}
			return true;
		}

		internal void scan_tree(short[] tree, int max_code)
		{
			int num = -1;
			int num2 = tree[1];
			int num3 = 0;
			int num4 = 7;
			int num5 = 4;
			if (num2 == 0)
			{
				num4 = 138;
				num5 = 3;
			}
			tree[(max_code + 1) * 2 + 1] = short.MaxValue;
			for (int i = 0; i <= max_code; i++)
			{
				int num6 = num2;
				num2 = tree[(i + 1) * 2 + 1];
				if (++num3 < num4 && num6 == num2)
				{
					continue;
				}
				if (num3 < num5)
				{
					bl_tree[num6 * 2] = (short)(bl_tree[num6 * 2] + num3);
				}
				else if (num6 != 0)
				{
					if (num6 != num)
					{
						bl_tree[num6 * 2]++;
					}
					bl_tree[InternalConstants.REP_3_6 * 2]++;
				}
				else if (num3 <= 10)
				{
					bl_tree[InternalConstants.REPZ_3_10 * 2]++;
				}
				else
				{
					bl_tree[InternalConstants.REPZ_11_138 * 2]++;
				}
				num3 = 0;
				num = num6;
				if (num2 == 0)
				{
					num4 = 138;
					num5 = 3;
				}
				else if (num6 == num2)
				{
					num4 = 6;
					num5 = 3;
				}
				else
				{
					num4 = 7;
					num5 = 4;
				}
			}
		}

		internal int build_bl_tree()
		{
			scan_tree(dyn_ltree, treeLiterals.max_code);
			scan_tree(dyn_dtree, treeDistances.max_code);
			treeBitLengths.build_tree(this);
			int num = InternalConstants.BL_CODES - 1;
			while (num >= 3 && bl_tree[Tree.bl_order[num] * 2 + 1] == 0)
			{
				num--;
			}
			opt_len += 3 * (num + 1) + 5 + 5 + 4;
			return num;
		}

		internal void send_all_trees(int lcodes, int dcodes, int blcodes)
		{
			send_bits(lcodes - 257, 5);
			send_bits(dcodes - 1, 5);
			send_bits(blcodes - 4, 4);
			for (int i = 0; i < blcodes; i++)
			{
				send_bits(bl_tree[Tree.bl_order[i] * 2 + 1], 3);
			}
			send_tree(dyn_ltree, lcodes - 1);
			send_tree(dyn_dtree, dcodes - 1);
		}

		internal void send_tree(short[] tree, int max_code)
		{
			int num = -1;
			int num2 = tree[1];
			int num3 = 0;
			int num4 = 7;
			int num5 = 4;
			if (num2 == 0)
			{
				num4 = 138;
				num5 = 3;
			}
			for (int i = 0; i <= max_code; i++)
			{
				int num6 = num2;
				num2 = tree[(i + 1) * 2 + 1];
				if (++num3 < num4 && num6 == num2)
				{
					continue;
				}
				if (num3 < num5)
				{
					do
					{
						send_code(num6, bl_tree);
					}
					while (--num3 != 0);
				}
				else if (num6 != 0)
				{
					if (num6 != num)
					{
						send_code(num6, bl_tree);
						num3--;
					}
					send_code(InternalConstants.REP_3_6, bl_tree);
					send_bits(num3 - 3, 2);
				}
				else if (num3 <= 10)
				{
					send_code(InternalConstants.REPZ_3_10, bl_tree);
					send_bits(num3 - 3, 3);
				}
				else
				{
					send_code(InternalConstants.REPZ_11_138, bl_tree);
					send_bits(num3 - 11, 7);
				}
				num3 = 0;
				num = num6;
				if (num2 == 0)
				{
					num4 = 138;
					num5 = 3;
				}
				else if (num6 == num2)
				{
					num4 = 6;
					num5 = 3;
				}
				else
				{
					num4 = 7;
					num5 = 4;
				}
			}
		}

		private void put_bytes(byte[] p, int start, int len)
		{
			Array.Copy(p, start, pending, pendingCount, len);
			pendingCount += len;
		}

		internal void send_code(int c, short[] tree)
		{
			int num = c * 2;
			send_bits(tree[num] & 0xFFFF, tree[num + 1] & 0xFFFF);
		}

		internal void send_bits(int value, int length)
		{
			if (bi_valid > Buf_size - length)
			{
				bi_buf |= (short)((value << bi_valid) & 0xFFFF);
				pending[pendingCount++] = (byte)bi_buf;
				pending[pendingCount++] = (byte)(bi_buf >> 8);
				bi_buf = (short)(value >>> Buf_size - bi_valid);
				bi_valid += length - Buf_size;
			}
			else
			{
				bi_buf |= (short)((value << bi_valid) & 0xFFFF);
				bi_valid += length;
			}
		}

		internal void _tr_align()
		{
			send_bits(STATIC_TREES << 1, 3);
			send_code(END_BLOCK, StaticTree.lengthAndLiteralsTreeCodes);
			bi_flush();
			if (1 + last_eob_len + 10 - bi_valid < 9)
			{
				send_bits(STATIC_TREES << 1, 3);
				send_code(END_BLOCK, StaticTree.lengthAndLiteralsTreeCodes);
				bi_flush();
			}
			last_eob_len = 7;
		}

		internal bool _tr_tally(int dist, int lc)
		{
			pending[_distanceOffset + last_lit * 2] = (byte)((uint)dist >> 8);
			pending[_distanceOffset + last_lit * 2 + 1] = (byte)dist;
			pending[_lengthOffset + last_lit] = (byte)lc;
			last_lit++;
			if (dist == 0)
			{
				dyn_ltree[lc * 2]++;
			}
			else
			{
				matches++;
				dist--;
				dyn_ltree[(Tree.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2]++;
				dyn_dtree[Tree.DistanceCode(dist) * 2]++;
			}
			if ((last_lit & 0x1FFF) == 0 && compressionLevel > CompressionLevel.Level2)
			{
				int num = last_lit << 3;
				int num2 = strstart - block_start;
				for (int i = 0; i < InternalConstants.D_CODES; i++)
				{
					num = (int)(num + dyn_dtree[i * 2] * (5L + (long)Tree.ExtraDistanceBits[i]));
				}
				num >>= 3;
				if (matches < last_lit / 2 && num < num2 / 2)
				{
					return true;
				}
			}
			if (last_lit != lit_bufsize - 1)
			{
				return last_lit == lit_bufsize;
			}
			return true;
		}

		internal void send_compressed_block(short[] ltree, short[] dtree)
		{
			int num = 0;
			if (last_lit != 0)
			{
				do
				{
					int num2 = _distanceOffset + num * 2;
					int num3 = ((pending[num2] << 8) & 0xFF00) | (pending[num2 + 1] & 0xFF);
					int num4 = pending[_lengthOffset + num] & 0xFF;
					num++;
					if (num3 == 0)
					{
						send_code(num4, ltree);
						continue;
					}
					int num5 = Tree.LengthCode[num4];
					send_code(num5 + InternalConstants.LITERALS + 1, ltree);
					int num6 = Tree.ExtraLengthBits[num5];
					if (num6 != 0)
					{
						num4 -= Tree.LengthBase[num5];
						send_bits(num4, num6);
					}
					num3--;
					num5 = Tree.DistanceCode(num3);
					send_code(num5, dtree);
					num6 = Tree.ExtraDistanceBits[num5];
					if (num6 != 0)
					{
						num3 -= Tree.DistanceBase[num5];
						send_bits(num3, num6);
					}
				}
				while (num < last_lit);
			}
			send_code(END_BLOCK, ltree);
			last_eob_len = ltree[END_BLOCK * 2 + 1];
		}

		internal void set_data_type()
		{
			int i = 0;
			int num = 0;
			int num2 = 0;
			for (; i < 7; i++)
			{
				num2 += dyn_ltree[i * 2];
			}
			for (; i < 128; i++)
			{
				num += dyn_ltree[i * 2];
			}
			for (; i < InternalConstants.LITERALS; i++)
			{
				num2 += dyn_ltree[i * 2];
			}
			data_type = (sbyte)((num2 > num >> 2) ? Z_BINARY : Z_ASCII);
		}

		internal void bi_flush()
		{
			if (bi_valid == 16)
			{
				pending[pendingCount++] = (byte)bi_buf;
				pending[pendingCount++] = (byte)(bi_buf >> 8);
				bi_buf = 0;
				bi_valid = 0;
			}
			else if (bi_valid >= 8)
			{
				pending[pendingCount++] = (byte)bi_buf;
				bi_buf >>= 8;
				bi_valid -= 8;
			}
		}

		internal void bi_windup()
		{
			if (bi_valid > 8)
			{
				pending[pendingCount++] = (byte)bi_buf;
				pending[pendingCount++] = (byte)(bi_buf >> 8);
			}
			else if (bi_valid > 0)
			{
				pending[pendingCount++] = (byte)bi_buf;
			}
			bi_buf = 0;
			bi_valid = 0;
		}

		internal void copy_block(int buf, int len, bool header)
		{
			bi_windup();
			last_eob_len = 8;
			if (header)
			{
				pending[pendingCount++] = (byte)len;
				pending[pendingCount++] = (byte)(len >> 8);
				pending[pendingCount++] = (byte)(~len);
				pending[pendingCount++] = (byte)(~len >> 8);
			}
			put_bytes(window, buf, len);
		}

		internal void flush_block_only(bool eof)
		{
			_tr_flush_block((block_start >= 0) ? block_start : (-1), strstart - block_start, eof);
			block_start = strstart;
			_codec.flush_pending();
		}

		internal BlockState DeflateNone(FlushType flush)
		{
			int num = 65535;
			if (num > pending.Length - 5)
			{
				num = pending.Length - 5;
			}
			while (true)
			{
				if (lookahead <= 1)
				{
					_fillWindow();
					if (lookahead == 0 && flush == FlushType.None)
					{
						return BlockState.NeedMore;
					}
					if (lookahead == 0)
					{
						break;
					}
				}
				strstart += lookahead;
				lookahead = 0;
				int num2 = block_start + num;
				if (strstart == 0 || strstart >= num2)
				{
					lookahead = strstart - num2;
					strstart = num2;
					flush_block_only(eof: false);
					if (_codec.AvailableBytesOut == 0)
					{
						return BlockState.NeedMore;
					}
				}
				if (strstart - block_start >= w_size - MIN_LOOKAHEAD)
				{
					flush_block_only(eof: false);
					if (_codec.AvailableBytesOut == 0)
					{
						return BlockState.NeedMore;
					}
				}
			}
			flush_block_only(flush == FlushType.Finish);
			if (_codec.AvailableBytesOut == 0)
			{
				if (flush != FlushType.Finish)
				{
					return BlockState.NeedMore;
				}
				return BlockState.FinishStarted;
			}
			if (flush != FlushType.Finish)
			{
				return BlockState.BlockDone;
			}
			return BlockState.FinishDone;
		}

		internal void _tr_stored_block(int buf, int stored_len, bool eof)
		{
			send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3);
			copy_block(buf, stored_len, header: true);
		}

		internal void _tr_flush_block(int buf, int stored_len, bool eof)
		{
			int num = 0;
			int num2;
			int num3;
			if (compressionLevel > CompressionLevel.None)
			{
				if (data_type == Z_UNKNOWN)
				{
					set_data_type();
				}
				treeLiterals.build_tree(this);
				treeDistances.build_tree(this);
				num = build_bl_tree();
				num2 = opt_len + 3 + 7 >> 3;
				num3 = static_len + 3 + 7 >> 3;
				if (num3 <= num2)
				{
					num2 = num3;
				}
			}
			else
			{
				num2 = (num3 = stored_len + 5);
			}
			if (stored_len + 4 <= num2 && buf != -1)
			{
				_tr_stored_block(buf, stored_len, eof);
			}
			else if (num3 == num2)
			{
				send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3);
				send_compressed_block(StaticTree.lengthAndLiteralsTreeCodes, StaticTree.distTreeCodes);
			}
			else
			{
				send_bits((DYN_TREES << 1) + (eof ? 1 : 0), 3);
				send_all_trees(treeLiterals.max_code + 1, treeDistances.max_code + 1, num + 1);
				send_compressed_block(dyn_ltree, dyn_dtree);
			}
			_InitializeBlocks();
			if (eof)
			{
				bi_windup();
			}
		}

		private void _fillWindow()
		{
			do
			{
				int num = window_size - lookahead - strstart;
				int num2;
				if (num == 0 && strstart == 0 && lookahead == 0)
				{
					num = w_size;
				}
				else if (num == -1)
				{
					num--;
				}
				else if (strstart >= w_size + w_size - MIN_LOOKAHEAD)
				{
					Array.Copy(window, w_size, window, 0, w_size);
					match_start -= w_size;
					strstart -= w_size;
					block_start -= w_size;
					num2 = hash_size;
					int num3 = num2;
					do
					{
						int num4 = head[--num3] & 0xFFFF;
						head[num3] = (short)((num4 >= w_size) ? (num4 - w_size) : 0);
					}
					while (--num2 != 0);
					num2 = w_size;
					num3 = num2;
					do
					{
						int num4 = prev[--num3] & 0xFFFF;
						prev[num3] = (short)((num4 >= w_size) ? (num4 - w_size) : 0);
					}
					while (--num2 != 0);
					num += w_size;
				}
				if (_codec.AvailableBytesIn == 0)
				{
					break;
				}
				num2 = _codec.read_buf(window, strstart + lookahead, num);
				lookahead += num2;
				if (lookahead >= MIN_MATCH)
				{
					ins_h = window[strstart] & 0xFF;
					ins_h = ((ins_h << hash_shift) ^ (window[strstart + 1] & 0xFF)) & hash_mask;
				}
			}
			while (lookahead < MIN_LOOKAHEAD && _codec.AvailableBytesIn != 0);
		}

		internal BlockState DeflateFast(FlushType flush)
		{
			int num = 0;
			while (true)
			{
				if (lookahead < MIN_LOOKAHEAD)
				{
					_fillWindow();
					if (lookahead < MIN_LOOKAHEAD && flush == FlushType.None)
					{
						return BlockState.NeedMore;
					}
					if (lookahead == 0)
					{
						break;
					}
				}
				if (lookahead >= MIN_MATCH)
				{
					ins_h = ((ins_h << hash_shift) ^ (window[strstart + (MIN_MATCH - 1)] & 0xFF)) & hash_mask;
					num = head[ins_h] & 0xFFFF;
					prev[strstart & w_mask] = head[ins_h];
					head[ins_h] = (short)strstart;
				}
				if (num != 0L && ((strstart - num) & 0xFFFF) <= w_size - MIN_LOOKAHEAD && compressionStrategy != CompressionStrategy.HuffmanOnly)
				{
					match_length = longest_match(num);
				}
				bool flag;
				if (match_length >= MIN_MATCH)
				{
					flag = _tr_tally(strstart - match_start, match_length - MIN_MATCH);
					lookahead -= match_length;
					if (match_length <= config.MaxLazy && lookahead >= MIN_MATCH)
					{
						match_length--;
						do
						{
							strstart++;
							ins_h = ((ins_h << hash_shift) ^ (window[strstart + (MIN_MATCH - 1)] & 0xFF)) & hash_mask;
							num = head[ins_h] & 0xFFFF;
							prev[strstart & w_mask] = head[ins_h];
							head[ins_h] = (short)strstart;
						}
						while (--match_length != 0);
						strstart++;
					}
					else
					{
						strstart += match_length;
						match_length = 0;
						ins_h = window[strstart] & 0xFF;
						ins_h = ((ins_h << hash_shift) ^ (window[strstart + 1] & 0xFF)) & hash_mask;
					}
				}
				else
				{
					flag = _tr_tally(0, window[strstart] & 0xFF);
					lookahead--;
					strstart++;
				}
				if (flag)
				{
					flush_block_only(eof: false);
					if (_codec.AvailableBytesOut == 0)
					{
						return BlockState.NeedMore;
					}
				}
			}
			flush_block_only(flush == FlushType.Finish);
			if (_codec.AvailableBytesOut == 0)
			{
				if (flush == FlushType.Finish)
				{
					return BlockState.FinishStarted;
				}
				return BlockState.NeedMore;
			}
			if (flush != FlushType.Finish)
			{
				return BlockState.BlockDone;
			}
			return BlockState.FinishDone;
		}

		internal BlockState DeflateSlow(FlushType flush)
		{
			int num = 0;
			while (true)
			{
				if (lookahead < MIN_LOOKAHEAD)
				{
					_fillWindow();
					if (lookahead < MIN_LOOKAHEAD && flush == FlushType.None)
					{
						return BlockState.NeedMore;
					}
					if (lookahead == 0)
					{
						break;
					}
				}
				if (lookahead >= MIN_MATCH)
				{
					ins_h = ((ins_h << hash_shift) ^ (window[strstart + (MIN_MATCH - 1)] & 0xFF)) & hash_mask;
					num = head[ins_h] & 0xFFFF;
					prev[strstart & w_mask] = head[ins_h];
					head[ins_h] = (short)strstart;
				}
				prev_length = match_length;
				prev_match = match_start;
				match_length = MIN_MATCH - 1;
				if (num != 0 && prev_length < config.MaxLazy && ((strstart - num) & 0xFFFF) <= w_size - MIN_LOOKAHEAD)
				{
					if (compressionStrategy != CompressionStrategy.HuffmanOnly)
					{
						match_length = longest_match(num);
					}
					if (match_length <= 5 && (compressionStrategy == CompressionStrategy.Filtered || (match_length == MIN_MATCH && strstart - match_start > 4096)))
					{
						match_length = MIN_MATCH - 1;
					}
				}
				if (prev_length >= MIN_MATCH && match_length <= prev_length)
				{
					int num2 = strstart + lookahead - MIN_MATCH;
					bool flag = _tr_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH);
					lookahead -= prev_length - 1;
					prev_length -= 2;
					do
					{
						if (++strstart <= num2)
						{
							ins_h = ((ins_h << hash_shift) ^ (window[strstart + (MIN_MATCH - 1)] & 0xFF)) & hash_mask;
							num = head[ins_h] & 0xFFFF;
							prev[strstart & w_mask] = head[ins_h];
							head[ins_h] = (short)strstart;
						}
					}
					while (--prev_length != 0);
					match_available = 0;
					match_length = MIN_MATCH - 1;
					strstart++;
					if (flag)
					{
						flush_block_only(eof: false);
						if (_codec.AvailableBytesOut == 0)
						{
							return BlockState.NeedMore;
						}
					}
				}
				else if (match_available != 0)
				{
					if (_tr_tally(0, window[strstart - 1] & 0xFF))
					{
						flush_block_only(eof: false);
					}
					strstart++;
					lookahead--;
					if (_codec.AvailableBytesOut == 0)
					{
						return BlockState.NeedMore;
					}
				}
				else
				{
					match_available = 1;
					strstart++;
					lookahead--;
				}
			}
			if (match_available != 0)
			{
				bool flag = _tr_tally(0, window[strstart - 1] & 0xFF);
				match_available = 0;
			}
			flush_block_only(flush == FlushType.Finish);
			if (_codec.AvailableBytesOut == 0)
			{
				if (flush == FlushType.Finish)
				{
					return BlockState.FinishStarted;
				}
				return BlockState.NeedMore;
			}
			if (flush != FlushType.Finish)
			{
				return BlockState.BlockDone;
			}
			return BlockState.FinishDone;
		}

		internal int longest_match(int cur_match)
		{
			int num = config.MaxChainLength;
			int num2 = strstart;
			int num3 = prev_length;
			int num4 = ((strstart > w_size - MIN_LOOKAHEAD) ? (strstart - (w_size - MIN_LOOKAHEAD)) : 0);
			int niceLength = config.NiceLength;
			int num5 = w_mask;
			int num6 = strstart + MAX_MATCH;
			byte b = window[num2 + num3 - 1];
			byte b2 = window[num2 + num3];
			if (prev_length >= config.GoodLength)
			{
				num >>= 2;
			}
			if (niceLength > lookahead)
			{
				niceLength = lookahead;
			}
			do
			{
				int num7 = cur_match;
				if (window[num7 + num3] != b2 || window[num7 + num3 - 1] != b || window[num7] != window[num2] || window[++num7] != window[num2 + 1])
				{
					continue;
				}
				num2 += 2;
				num7++;
				while (window[++num2] == window[++num7] && window[++num2] == window[++num7] && window[++num2] == window[++num7] && window[++num2] == window[++num7] && window[++num2] == window[++num7] && window[++num2] == window[++num7] && window[++num2] == window[++num7] && window[++num2] == window[++num7] && num2 < num6)
				{
				}
				int num8 = MAX_MATCH - (num6 - num2);
				num2 = num6 - MAX_MATCH;
				if (num8 > num3)
				{
					match_start = cur_match;
					num3 = num8;
					if (num8 >= niceLength)
					{
						break;
					}
					b = window[num2 + num3 - 1];
					b2 = window[num2 + num3];
				}
			}
			while ((cur_match = prev[cur_match & num5] & 0xFFFF) > num4 && --num != 0);
			if (num3 <= lookahead)
			{
				return num3;
			}
			return lookahead;
		}

		internal int Initialize(ZlibCodec codec, CompressionLevel level)
		{
			return Initialize(codec, level, 15);
		}

		internal int Initialize(ZlibCodec codec, CompressionLevel level, int bits)
		{
			return Initialize(codec, level, bits, MEM_LEVEL_DEFAULT, CompressionStrategy.Default);
		}

		internal int Initialize(ZlibCodec codec, CompressionLevel level, int bits, CompressionStrategy compressionStrategy)
		{
			return Initialize(codec, level, bits, MEM_LEVEL_DEFAULT, compressionStrategy);
		}

		internal int Initialize(ZlibCodec codec, CompressionLevel level, int windowBits, int memLevel, CompressionStrategy strategy)
		{
			_codec = codec;
			_codec.Message = null;
			if (windowBits < 9 || windowBits > 15)
			{
				throw new ZlibException("windowBits must be in the range 9..15.");
			}
			if (memLevel < 1 || memLevel > MEM_LEVEL_MAX)
			{
				throw new ZlibException($"memLevel must be in the range 1.. {MEM_LEVEL_MAX}");
			}
			_codec.dstate = this;
			w_bits = windowBits;
			w_size = 1 << w_bits;
			w_mask = w_size - 1;
			hash_bits = memLevel + 7;
			hash_size = 1 << hash_bits;
			hash_mask = hash_size - 1;
			hash_shift = (hash_bits + MIN_MATCH - 1) / MIN_MATCH;
			window = new byte[w_size * 2];
			prev = new short[w_size];
			head = new short[hash_size];
			lit_bufsize = 1 << memLevel + 6;
			pending = new byte[lit_bufsize * 4];
			_distanceOffset = lit_bufsize;
			_lengthOffset = 3 * lit_bufsize;
			compressionLevel = level;
			compressionStrategy = strategy;
			Reset();
			return 0;
		}

		internal void Reset()
		{
			_codec.TotalBytesIn = (_codec.TotalBytesOut = 0L);
			_codec.Message = null;
			pendingCount = 0;
			nextPending = 0;
			Rfc1950BytesEmitted = false;
			status = (WantRfc1950HeaderBytes ? INIT_STATE : BUSY_STATE);
			_codec._Adler32 = Adler.Adler32(0u, null, 0, 0);
			last_flush = 0;
			_InitializeTreeData();
			_InitializeLazyMatch();
		}

		internal int End()
		{
			if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE)
			{
				return -2;
			}
			pending = null;
			head = null;
			prev = null;
			window = null;
			if (status != BUSY_STATE)
			{
				return 0;
			}
			return -3;
		}

		private void SetDeflater()
		{
			switch (config.Flavor)
			{
			case DeflateFlavor.Store:
				DeflateFunction = DeflateNone;
				break;
			case DeflateFlavor.Fast:
				DeflateFunction = DeflateFast;
				break;
			case DeflateFlavor.Slow:
				DeflateFunction = DeflateSlow;
				break;
			}
		}

		internal int SetParams(CompressionLevel level, CompressionStrategy strategy)
		{
			int result = 0;
			if (compressionLevel != level)
			{
				Config config = Config.Lookup(level);
				if (config.Flavor != this.config.Flavor && _codec.TotalBytesIn != 0L)
				{
					result = _codec.Deflate(FlushType.Partial);
				}
				compressionLevel = level;
				this.config = config;
				SetDeflater();
			}
			compressionStrategy = strategy;
			return result;
		}

		internal int SetDictionary(byte[] dictionary)
		{
			int num = dictionary.Length;
			int sourceIndex = 0;
			if (dictionary == null || status != INIT_STATE)
			{
				throw new ZlibException("Stream error.");
			}
			_codec._Adler32 = Adler.Adler32(_codec._Adler32, dictionary, 0, dictionary.Length);
			if (num < MIN_MATCH)
			{
				return 0;
			}
			if (num > w_size - MIN_LOOKAHEAD)
			{
				num = w_size - MIN_LOOKAHEAD;
				sourceIndex = dictionary.Length - num;
			}
			Array.Copy(dictionary, sourceIndex, window, 0, num);
			strstart = num;
			block_start = num;
			ins_h = window[0] & 0xFF;
			ins_h = ((ins_h << hash_shift) ^ (window[1] & 0xFF)) & hash_mask;
			for (int i = 0; i <= num - MIN_MATCH; i++)
			{
				ins_h = ((ins_h << hash_shift) ^ (window[i + (MIN_MATCH - 1)] & 0xFF)) & hash_mask;
				prev[i & w_mask] = head[ins_h];
				head[ins_h] = (short)i;
			}
			return 0;
		}

		internal int Deflate(FlushType flush)
		{
			if (_codec.OutputBuffer == null || (_codec.InputBuffer == null && _codec.AvailableBytesIn != 0) || (status == FINISH_STATE && flush != FlushType.Finish))
			{
				_codec.Message = _ErrorMessage[4];
				throw new ZlibException($"Something is fishy. [{_codec.Message}]");
			}
			if (_codec.AvailableBytesOut == 0)
			{
				_codec.Message = _ErrorMessage[7];
				throw new ZlibException("OutputBuffer is full (AvailableBytesOut == 0)");
			}
			int num = last_flush;
			last_flush = (int)flush;
			if (status == INIT_STATE)
			{
				int num2 = Z_DEFLATED + (w_bits - 8 << 4) << 8;
				int num3 = (int)((compressionLevel - 1) & (CompressionLevel)255) >> 1;
				if (num3 > 3)
				{
					num3 = 3;
				}
				num2 |= num3 << 6;
				if (strstart != 0)
				{
					num2 |= PRESET_DICT;
				}
				num2 += 31 - num2 % 31;
				status = BUSY_STATE;
				pending[pendingCount++] = (byte)(num2 >> 8);
				pending[pendingCount++] = (byte)num2;
				if (strstart != 0)
				{
					pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF000000u) >> 24);
					pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF0000) >> 16);
					pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF00) >> 8);
					pending[pendingCount++] = (byte)(_codec._Adler32 & 0xFFu);
				}
				_codec._Adler32 = Adler.Adler32(0u, null, 0, 0);
			}
			if (pendingCount != 0)
			{
				_codec.flush_pending();
				if (_codec.AvailableBytesOut == 0)
				{
					last_flush = -1;
					return 0;
				}
			}
			else if (_codec.AvailableBytesIn == 0 && (int)flush <= num && flush != FlushType.Finish)
			{
				return 0;
			}
			if (status == FINISH_STATE && _codec.AvailableBytesIn != 0)
			{
				_codec.Message = _ErrorMessage[7];
				throw new ZlibException("status == FINISH_STATE && _codec.AvailableBytesIn != 0");
			}
			if (_codec.AvailableBytesIn != 0 || lookahead != 0 || (flush != 0 && status != FINISH_STATE))
			{
				BlockState blockState = DeflateFunction(flush);
				if (blockState == BlockState.FinishStarted || blockState == BlockState.FinishDone)
				{
					status = FINISH_STATE;
				}
				switch (blockState)
				{
				case BlockState.NeedMore:
				case BlockState.FinishStarted:
					if (_codec.AvailableBytesOut == 0)
					{
						last_flush = -1;
					}
					return 0;
				case BlockState.BlockDone:
					if (flush == FlushType.Partial)
					{
						_tr_align();
					}
					else
					{
						_tr_stored_block(0, 0, eof: false);
						if (flush == FlushType.Full)
						{
							for (int i = 0; i < hash_size; i++)
							{
								head[i] = 0;
							}
						}
					}
					_codec.flush_pending();
					if (_codec.AvailableBytesOut == 0)
					{
						last_flush = -1;
						return 0;
					}
					break;
				}
			}
			if (flush != FlushType.Finish)
			{
				return 0;
			}
			if (!WantRfc1950HeaderBytes || Rfc1950BytesEmitted)
			{
				return 1;
			}
			pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF000000u) >> 24);
			pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF0000) >> 16);
			pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF00) >> 8);
			pending[pendingCount++] = (byte)(_codec._Adler32 & 0xFFu);
			_codec.flush_pending();
			Rfc1950BytesEmitted = true;
			if (pendingCount == 0)
			{
				return 1;
			}
			return 0;
		}
	}
	public class DeflateStream : Stream
	{
		internal ZlibBaseStream _baseStream;

		internal Stream _innerStream;

		private bool _disposed;

		public virtual FlushType FlushMode
		{
			get
			{
				return _baseStream._flushMode;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("DeflateStream");
				}
				_baseStream._flushMode = value;
			}
		}

		public int BufferSize
		{
			get
			{
				return _baseStream._bufferSize;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("DeflateStream");
				}
				if (_baseStream._workingBuffer != null)
				{
					throw new ZlibException("The working buffer is already set.");
				}
				if (value < 1024)
				{
					throw new ZlibException($"Don't be silly. {value} bytes?? Use a bigger buffer, at least {1024}.");
				}
				_baseStream._bufferSize = value;
			}
		}

		public CompressionStrategy Strategy
		{
			get
			{
				return _baseStream.Strategy;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("DeflateStream");
				}
				_baseStream.Strategy = value;
			}
		}

		public virtual long TotalIn => _baseStream._z.TotalBytesIn;

		public virtual long TotalOut => _baseStream._z.TotalBytesOut;

		public override bool CanRead
		{
			get
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("DeflateStream");
				}
				return _baseStream._stream.CanRead;
			}
		}

		public override bool CanSeek => false;

		public override bool CanWrite
		{
			get
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("DeflateStream");
				}
				return _baseStream._stream.CanWrite;
			}
		}

		public override long Length
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		public override long Position
		{
			get
			{
				if (_baseStream._streamMode == ZlibBaseStream.StreamMode.Writer)
				{
					return _baseStream._z.TotalBytesOut;
				}
				if (_baseStream._streamMode == ZlibBaseStream.StreamMode.Reader)
				{
					return _baseStream._z.TotalBytesIn;
				}
				return 0L;
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		public DeflateStream(Stream stream, CompressionMode mode)
			: this(stream, mode, CompressionLevel.Default, leaveOpen: false)
		{
		}

		public DeflateStream(Stream stream, CompressionMode mode, CompressionLevel level)
			: this(stream, mode, level, leaveOpen: false)
		{
		}

		public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen)
			: this(stream, mode, CompressionLevel.Default, leaveOpen)
		{
		}

		public DeflateStream(Stream stream, CompressionMode mode, CompressionLevel level, bool leaveOpen)
		{
			_innerStream = stream;
			_baseStream = new ZlibBaseStream(stream, mode, level, ZlibStreamFlavor.DEFLATE, leaveOpen);
		}

		protected override void Dispose(bool disposing)
		{
			try
			{
				if (!_disposed)
				{
					if (disposing)
					{
						_baseStream?.Dispose();
					}
					_disposed = true;
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}

		public override void Flush()
		{
			if (_disposed)
			{
				throw new ObjectDisposedException("DeflateStream");
			}
			_baseStream.Flush();
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			if (_disposed)
			{
				throw new ObjectDisposedException("DeflateStream");
			}
			return _baseStream.Read(buffer, offset, count);
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotImplementedException();
		}

		public override void SetLength(long value)
		{
			throw new NotImplementedException();
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (_disposed)
			{
				throw new ObjectDisposedException("DeflateStream");
			}
			_baseStream.Write(buffer, offset, count);
		}

		public static byte[] CompressString(string s)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream compressor = new DeflateStream(memoryStream, CompressionMode.Compress, CompressionLevel.BestCompression);
			ZlibBaseStream.CompressString(s, compressor);
			return memoryStream.ToArray();
		}

		public static byte[] CompressBuffer(byte[] b)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream compressor = new DeflateStream(memoryStream, CompressionMode.Compress, CompressionLevel.BestCompression);
			ZlibBaseStream.CompressBuffer(b, compressor);
			return memoryStream.ToArray();
		}

		public static string UncompressString(byte[] compressed)
		{
			using MemoryStream stream = new MemoryStream(compressed);
			Stream decompressor = new DeflateStream(stream, CompressionMode.Decompress);
			return ZlibBaseStream.UncompressString(compressed, decompressor);
		}

		public static byte[] UncompressBuffer(byte[] compressed)
		{
			using MemoryStream stream = new MemoryStream(compressed);
			Stream decompressor = new DeflateStream(stream, CompressionMode.Decompress);
			return ZlibBaseStream.UncompressBuffer(compressed, decompressor);
		}
	}
	public class GZipStream : Stream, IDisposable
	{
		public DateTime? LastModified;

		private int _headerByteCount;

		internal ZlibBaseStream _baseStream;

		private bool _disposed;

		private bool _firstReadDone;

		private string _FileName;

		private string _Comment;

		private int _Crc32;

		internal static readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

		internal static readonly Encoding iso8859dash1 = Encoding.GetEncoding("iso-8859-1");

		public string Comment
		{
			get
			{
				return _Comment;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("GZipStream");
				}
				_Comment = value;
			}
		}

		public string FileName
		{
			get
			{
				return _FileName;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("GZipStream");
				}
				_FileName = value;
				if (_FileName != null)
				{
					if (_FileName.IndexOf("/") != -1)
					{
						_FileName = _FileName.Replace("/", "\\");
					}
					if (_FileName.EndsWith("\\"))
					{
						throw new Exception("Illegal filename");
					}
					if (_FileName.IndexOf("\\") != -1)
					{
						_FileName = Path.GetFileName(_FileName);
					}
				}
			}
		}

		public int Crc32 => _Crc32;

		public virtual FlushType FlushMode
		{
			get
			{
				return _baseStream._flushMode;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("GZipStream");
				}
				_baseStream._flushMode = value;
			}
		}

		public int BufferSize
		{
			get
			{
				return _baseStream._bufferSize;
			}
			set
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("GZipStream");
				}
				if (_baseStream._workingBuffer != null)
				{
					throw new ZlibException("The working buffer is already set.");
				}
				if (value < 1024)
				{
					throw new ZlibException($"Don't be silly. {value} bytes?? Use a bigger buffer, at least {1024}.");
				}
				_baseStream._bufferSize = value;
			}
		}

		public virtual long TotalIn => _baseStream._z.TotalBytesIn;

		public virtual long TotalOut => _baseStream._z.TotalBytesOut;

		public override bool CanRead
		{
			get
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("GZipStream");
				}
				return _baseStream._stream.CanRead;
			}
		}

		public override bool CanSeek => false;

		public override bool CanWrite
		{
			get
			{
				if (_disposed)
				{
					throw new ObjectDisposedException("GZipStream");
				}
				return _baseStream._stream.CanWrite;
			}
		}

		public override long Length
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		public override long Position
		{
			get
			{
				if (_baseStream._streamMode == ZlibBaseStream.StreamMode.Writer)
				{
					return _baseStream._z.TotalBytesOut + _headerByteCount;
				}
				if (_baseStream._streamMode == ZlibBaseStream.StreamMode.Reader)
				{
					return _baseStream._z.TotalBytesIn + _baseStream._gzipHeaderByteCount;
				}
				return 0L;
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		public GZipStream(Stream stream, CompressionMode mode)
			: this(stream, mode, CompressionLevel.Default, leaveOpen: false)
		{
		}

		public GZipStream(Stream stream, CompressionMode mode, CompressionLevel level)
			: this(stream, mode, level, leaveOpen: false)
		{
		}

		public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen)
			: this(stream, mode, CompressionLevel.Default, leaveOpen)
		{
		}

		public GZipStream(Stream stream, CompressionMode mode, CompressionLevel level, bool leaveOpen)
		{
			_baseStream = new ZlibBaseStream(stream, mode, level, ZlibStreamFlavor.GZIP, leaveOpen);
		}

		protected override void Dispose(bool disposing)
		{
			try
			{
				if (!_disposed)
				{
					if (disposing && _baseStream != null)
					{
						_baseStream.Dispose();
						_Crc32 = _baseStream.Crc32;
					}
					_disposed = true;
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}

		public override void Flush()
		{
			if (_disposed)
			{
				throw new ObjectDisposedException("GZipStream");
			}
			_baseStream.Flush();
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			if (_disposed)
			{
				throw new ObjectDisposedException("GZipStream");
			}
			int result = _baseStream.Read(buffer, offset, count);
			if (!_firstReadDone)
			{
				_firstReadDone = true;
				FileName = _baseStream._GzipFileName;
				Comment = _baseStream._GzipComment;
			}
			return result;
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotImplementedException();
		}

		public override void SetLength(long value)
		{
			throw new NotImplementedException();
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (_disposed)
			{
				throw new ObjectDisposedException("GZipStream");
			}
			if (_baseStream._streamMode == ZlibBaseStream.StreamMode.Undefined)
			{
				if (!_baseStream._wantCompress)
				{
					throw new InvalidOperationException();
				}
				_headerByteCount = EmitHeader();
			}
			_baseStream.Write(buffer, offset, count);
		}

		private int EmitHeader()
		{
			byte[] array = ((Comment == null) ? null : iso8859dash1.GetBytes(Comment));
			byte[] array2 = ((FileName == null) ? null : iso8859dash1.GetBytes(FileName));
			int num = ((Comment != null) ? (array.Length + 1) : 0);
			int num2 = ((FileName != null) ? (array2.Length + 1) : 0);
			byte[] array3 = new byte[10 + num + num2];
			int num3 = 0;
			array3[num3++] = 31;
			array3[num3++] = 139;
			array3[num3++] = 8;
			byte b = 0;
			if (Comment != null)
			{
				b = (byte)(b ^ 0x10u);
			}
			if (FileName != null)
			{
				b = (byte)(b ^ 8u);
			}
			array3[num3++] = b;
			if (!LastModified.HasValue)
			{
				LastModified = DateTime.Now;
			}
			Array.Copy(BitConverter.GetBytes((int)(LastModified.Value - _unixEpoch).TotalSeconds), 0, array3, num3, 4);
			num3 += 4;
			array3[num3++] = 0;
			array3[num3++] = byte.MaxValue;
			if (num2 != 0)
			{
				Array.Copy(array2, 0, array3, num3, num2 - 1);
				num3 += num2 - 1;
				array3[num3++] = 0;
			}
			if (num != 0)
			{
				Array.Copy(array, 0, array3, num3, num - 1);
				num3 += num - 1;
				array3[num3++] = 0;
			}
			_baseStream._stream.Write(array3, 0, array3.Length);
			return array3.Length;
		}

		public static byte[] CompressString(string s)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream compressor = new GZipStream(memoryStream, CompressionMode.Compress, CompressionLevel.BestCompression);
			ZlibBaseStream.CompressString(s, compressor);
			return memoryStream.ToArray();
		}

		public static byte[] CompressBuffer(byte[] b)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream compressor = new GZipStream(memoryStream, CompressionMode.Compress, CompressionLevel.BestCompression);
			ZlibBaseStream.CompressBuffer(b, compressor);
			return memoryStream.ToArray();
		}

		public static string UncompressString(byte[] compressed)
		{
			using MemoryStream stream = new MemoryStream(compressed);
			Stream decompressor = new GZipStream(stream, CompressionMode.Decompress);
			return ZlibBaseStream.UncompressString(compressed, decompressor);
		}

		public static byte[] UncompressBuffer(byte[] compressed)
		{
			using MemoryStream stream = new MemoryStream(compressed);
			Stream decompressor = new GZipStream(stream, CompressionMode.Decompress);
			return ZlibBaseStream.UncompressBuffer(compressed, decompressor);
		}
	}
	internal sealed class InflateBlocks
	{
		private enum InflateBlockMode
		{
			TYPE,
			LENS,
			STORED,
			TABLE,
			BTREE,
			DTREE,
			CODES,
			DRY,
			DONE,
			BAD
		}

		private const int MANY = 1440;

		internal static readonly int[] border = new int[19]
		{
			16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
			11, 4, 12, 3, 13, 2, 14, 1, 15
		};

		private InflateBlockMode mode;

		internal int left;

		internal int table;

		internal int index;

		internal int[] blens;

		internal int[] bb = new int[1];

		internal int[] tb = new int[1];

		internal InflateCodes codes = new InflateCodes();

		internal int last;

		internal ZlibCodec _codec;

		internal int bitk;

		internal int bitb;

		internal int[] hufts;

		internal byte[] window;

		internal int end;

		internal int readAt;

		internal int writeAt;

		internal object checkfn;

		internal uint check;

		internal InfTree inftree = new InfTree();

		internal InflateBlocks(ZlibCodec codec, object checkfn, int w)
		{
			_codec = codec;
			hufts = new int[4320];
			window = new byte[w];
			end = w;
			this.checkfn = checkfn;
			mode = InflateBlockMode.TYPE;
			Reset();
		}

		internal uint Reset()
		{
			uint result = check;
			mode = InflateBlockMode.TYPE;
			bitk = 0;
			bitb = 0;
			readAt = (writeAt = 0);
			if (checkfn != null)
			{
				_codec._Adler32 = (check = Adler.Adler32(0u, null, 0, 0));
			}
			return result;
		}

		internal int Process(int r)
		{
			int num = _codec.NextIn;
			int num2 = _codec.AvailableBytesIn;
			int num3 = bitb;
			int i = bitk;
			int num4 = writeAt;
			int num5 = ((num4 < readAt) ? (readAt - num4 - 1) : (end - num4));
			while (true)
			{
				switch (mode)
				{
				case InflateBlockMode.TYPE:
				{
					for (; i < 3; i += 8)
					{
						if (num2 != 0)
						{
							r = 0;
							num2--;
							num3 |= (_codec.InputBuffer[num++] & 0xFF) << i;
							continue;
						}
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					int num6 = num3 & 7;
					last = num6 & 1;
					switch ((uint)(num6 >>> 1))
					{
					case 0u:
						num3 >>= 3;
						i -= 3;
						num6 = i & 7;
						num3 >>= num6;
						i -= num6;
						mode = InflateBlockMode.LENS;
						break;
					case 1u:
					{
						int[] array = new int[1];
						int[] array2 = new int[1];
						int[][] array3 = new int[1][];
						int[][] array4 = new int[1][];
						InfTree.inflate_trees_fixed(array, array2, array3, array4, _codec);
						codes.Init(array[0], array2[0], array3[0], 0, array4[0], 0);
						num3 >>= 3;
						i -= 3;
						mode = InflateBlockMode.CODES;
						break;
					}
					case 2u:
						num3 >>= 3;
						i -= 3;
						mode = InflateBlockMode.TABLE;
						break;
					case 3u:
						num3 >>= 3;
						i -= 3;
						mode = InflateBlockMode.BAD;
						_codec.Message = "invalid block type";
						r = -3;
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					break;
				}
				case InflateBlockMode.LENS:
					for (; i < 32; i += 8)
					{
						if (num2 != 0)
						{
							r = 0;
							num2--;
							num3 |= (_codec.InputBuffer[num++] & 0xFF) << i;
							continue;
						}
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					if (((~num3 >> 16) & 0xFFFF) != (num3 & 0xFFFF))
					{
						mode = InflateBlockMode.BAD;
						_codec.Message = "invalid stored block lengths";
						r = -3;
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					left = num3 & 0xFFFF;
					num3 = (i = 0);
					mode = ((left != 0) ? InflateBlockMode.STORED : ((last != 0) ? InflateBlockMode.DRY : InflateBlockMode.TYPE));
					break;
				case InflateBlockMode.STORED:
				{
					if (num2 == 0)
					{
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					if (num5 == 0)
					{
						if (num4 == end && readAt != 0)
						{
							num4 = 0;
							num5 = ((num4 < readAt) ? (readAt - num4 - 1) : (end - num4));
						}
						if (num5 == 0)
						{
							writeAt = num4;
							r = Flush(r);
							num4 = writeAt;
							num5 = ((num4 < readAt) ? (readAt - num4 - 1) : (end - num4));
							if (num4 == end && readAt != 0)
							{
								num4 = 0;
								num5 = ((num4 < readAt) ? (readAt - num4 - 1) : (end - num4));
							}
							if (num5 == 0)
							{
								bitb = num3;
								bitk = i;
								_codec.AvailableBytesIn = num2;
								_codec.TotalBytesIn += num - _codec.NextIn;
								_codec.NextIn = num;
								writeAt = num4;
								return Flush(r);
							}
						}
					}
					r = 0;
					int num6 = left;
					if (num6 > num2)
					{
						num6 = num2;
					}
					if (num6 > num5)
					{
						num6 = num5;
					}
					Array.Copy(_codec.InputBuffer, num, window, num4, num6);
					num += num6;
					num2 -= num6;
					num4 += num6;
					num5 -= num6;
					if ((left -= num6) == 0)
					{
						mode = ((last != 0) ? InflateBlockMode.DRY : InflateBlockMode.TYPE);
					}
					break;
				}
				case InflateBlockMode.TABLE:
				{
					for (; i < 14; i += 8)
					{
						if (num2 != 0)
						{
							r = 0;
							num2--;
							num3 |= (_codec.InputBuffer[num++] & 0xFF) << i;
							continue;
						}
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					int num6 = (table = num3 & 0x3FFF);
					if ((num6 & 0x1F) > 29 || ((num6 >> 5) & 0x1F) > 29)
					{
						mode = InflateBlockMode.BAD;
						_codec.Message = "too many length or distance symbols";
						r = -3;
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					num6 = 258 + (num6 & 0x1F) + ((num6 >> 5) & 0x1F);
					if (blens == null || blens.Length < num6)
					{
						blens = new int[num6];
					}
					else
					{
						Array.Clear(blens, 0, num6);
					}
					num3 >>= 14;
					i -= 14;
					index = 0;
					mode = InflateBlockMode.BTREE;
					goto case InflateBlockMode.BTREE;
				}
				case InflateBlockMode.BTREE:
				{
					while (index < 4 + (table >> 10))
					{
						for (; i < 3; i += 8)
						{
							if (num2 != 0)
							{
								r = 0;
								num2--;
								num3 |= (_codec.InputBuffer[num++] & 0xFF) << i;
								continue;
							}
							bitb = num3;
							bitk = i;
							_codec.AvailableBytesIn = num2;
							_codec.TotalBytesIn += num - _codec.NextIn;
							_codec.NextIn = num;
							writeAt = num4;
							return Flush(r);
						}
						blens[border[index++]] = num3 & 7;
						num3 >>= 3;
						i -= 3;
					}
					while (index < 19)
					{
						blens[border[index++]] = 0;
					}
					bb[0] = 7;
					int num6 = inftree.inflate_trees_bits(blens, bb, tb, hufts, _codec);
					if (num6 != 0)
					{
						r = num6;
						if (r == -3)
						{
							blens = null;
							mode = InflateBlockMode.BAD;
						}
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					index = 0;
					mode = InflateBlockMode.DTREE;
					goto case InflateBlockMode.DTREE;
				}
				case InflateBlockMode.DTREE:
				{
					int num6;
					while (true)
					{
						num6 = table;
						if (index >= 258 + (num6 & 0x1F) + ((num6 >> 5) & 0x1F))
						{
							break;
						}
						for (num6 = bb[0]; i < num6; i += 8)
						{
							if (num2 != 0)
							{
								r = 0;
								num2--;
								num3 |= (_codec.InputBuffer[num++] & 0xFF) << i;
								continue;
							}
							bitb = num3;
							bitk = i;
							_codec.AvailableBytesIn = num2;
							_codec.TotalBytesIn += num - _codec.NextIn;
							_codec.NextIn = num;
							writeAt = num4;
							return Flush(r);
						}
						num6 = hufts[(tb[0] + (num3 & InternalInflateConstants.InflateMask[num6])) * 3 + 1];
						int num7 = hufts[(tb[0] + (num3 & InternalInflateConstants.InflateMask[num6])) * 3 + 2];
						if (num7 < 16)
						{
							num3 >>= num6;
							i -= num6;
							blens[index++] = num7;
							continue;
						}
						int num8 = ((num7 == 18) ? 7 : (num7 - 14));
						int num9 = ((num7 == 18) ? 11 : 3);
						for (; i < num6 + num8; i += 8)
						{
							if (num2 != 0)
							{
								r = 0;
								num2--;
								num3 |= (_codec.InputBuffer[num++] & 0xFF) << i;
								continue;
							}
							bitb = num3;
							bitk = i;
							_codec.AvailableBytesIn = num2;
							_codec.TotalBytesIn += num - _codec.NextIn;
							_codec.NextIn = num;
							writeAt = num4;
							return Flush(r);
						}
						num3 >>= num6;
						i -= num6;
						num9 += num3 & InternalInflateConstants.InflateMask[num8];
						num3 >>= num8;
						i -= num8;
						num8 = index;
						num6 = table;
						if (num8 + num9 > 258 + (num6 & 0x1F) + ((num6 >> 5) & 0x1F) || (num7 == 16 && num8 < 1))
						{
							blens = null;
							mode = InflateBlockMode.BAD;
							_codec.Message = "invalid bit length repeat";
							r = -3;
							bitb = num3;
							bitk = i;
							_codec.AvailableBytesIn = num2;
							_codec.TotalBytesIn += num - _codec.NextIn;
							_codec.NextIn = num;
							writeAt = num4;
							return Flush(r);
						}
						num7 = ((num7 == 16) ? blens[num8 - 1] : 0);
						do
						{
							blens[num8++] = num7;
						}
						while (--num9 != 0);
						index = num8;
					}
					tb[0] = -1;
					int[] array5 = new int[1] { 9 };
					int[] array6 = new int[1] { 6 };
					int[] array7 = new int[1];
					int[] array8 = new int[1];
					num6 = table;
					num6 = inftree.inflate_trees_dynamic(257 + (num6 & 0x1F), 1 + ((num6 >> 5) & 0x1F), blens, array5, array6, array7, array8, hufts, _codec);
					if (num6 != 0)
					{
						if (num6 == -3)
						{
							blens = null;
							mode = InflateBlockMode.BAD;
						}
						r = num6;
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					codes.Init(array5[0], array6[0], hufts, array7[0], hufts, array8[0]);
					mode = InflateBlockMode.CODES;
					goto case InflateBlockMode.CODES;
				}
				case InflateBlockMode.CODES:
					bitb = num3;
					bitk = i;
					_codec.AvailableBytesIn = num2;
					_codec.TotalBytesIn += num - _codec.NextIn;
					_codec.NextIn = num;
					writeAt = num4;
					r = codes.Process(this, r);
					if (r != 1)
					{
						return Flush(r);
					}
					r = 0;
					num = _codec.NextIn;
					num2 = _codec.AvailableBytesIn;
					num3 = bitb;
					i = bitk;
					num4 = writeAt;
					num5 = ((num4 < readAt) ? (readAt - num4 - 1) : (end - num4));
					if (last == 0)
					{
						mode = InflateBlockMode.TYPE;
						break;
					}
					mode = InflateBlockMode.DRY;
					goto case InflateBlockMode.DRY;
				case InflateBlockMode.DRY:
					writeAt = num4;
					r = Flush(r);
					num4 = writeAt;
					num5 = ((num4 < readAt) ? (readAt - num4 - 1) : (end - num4));
					if (readAt != writeAt)
					{
						bitb = num3;
						bitk = i;
						_codec.AvailableBytesIn = num2;
						_codec.TotalBytesIn += num - _codec.NextIn;
						_codec.NextIn = num;
						writeAt = num4;
						return Flush(r);
					}
					mode = InflateBlockMode.DONE;
					goto case InflateBlockMode.DONE;
				case InflateBlockMode.DONE:
					r = 1;
					bitb = num3;
					bitk = i;
					_codec.AvailableBytesIn = num2;
					_codec.TotalBytesIn += num - _codec.NextIn;
					_codec.NextIn = num;
					writeAt = num4;
					return Flush(r);
				case InflateBlockMode.BAD:
					r = -3;
					bitb = num3;
					bitk = i;
					_codec.AvailableBytesIn = num2;
					_codec.TotalBytesIn += num - _codec.NextIn;
					_codec.NextIn = num;
					writeAt = num4;
					return Flush(r);
				default:
					r = -2;
					bitb = num3;
					bitk = i;
					_codec.AvailableBytesIn = num2;
					_codec.TotalBytesIn += num - _codec.NextIn;
					_codec.NextIn = num;
					writeAt = num4;
					return Flush(r);
				}
			}
		}

		internal void Free()
		{
			Reset();
			window = null;
			hufts = null;
		}

		internal void SetDictionary(byte[] d, int start, int n)
		{
			Array.Copy(d, start, window, 0, n);
			readAt = (writeAt = n);
		}

		internal int SyncPoint()
		{
			if (mode != InflateBlockMode.LENS)
			{
				return 0;
			}
			return 1;
		}

		internal int Flush(int r)
		{
			for (int i = 0; i < 2; i++)
			{
				int num = ((i != 0) ? (writeAt - readAt) : (((readAt <= writeAt) ? writeAt : end) - readAt));
				if (num == 0)
				{
					if (r == -5)
					{
						r = 0;
					}
					return r;
				}
				if (num > _codec.AvailableBytesOut)
				{
					num = _codec.AvailableBytesOut;
				}
				if (num != 0 && r == -5)
				{
					r = 0;
				}
				_codec.AvailableBytesOut -= num;
				_codec.TotalBytesOut += num;
				if (checkfn != null)
				{
					_codec._Adler32 = (check = Adler.Adler32(check, window, readAt, num));
				}
				Array.Copy(window, readAt, _codec.OutputBuffer, _codec.NextOut, num);
				_codec.NextOut += num;
				readAt += num;
				if (readAt == end && i == 0)
				{
					readAt = 0;
					if (writeAt == end)
					{
						writeAt = 0;
					}
				}
				else
				{
					i++;
				}
			}
			return r;
		}
	}
	internal static class InternalInflateConstants
	{
		internal static readonly int[] InflateMask = new int[17]
		{
			0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
			1023, 2047, 4095, 8191, 16383, 32767, 65535
		};
	}
	internal sealed class InflateCodes
	{
		private const int START = 0;

		private const int LEN = 1;

		private const int LENEXT = 2;

		private const int DIST = 3;

		private const int DISTEXT = 4;

		private const int COPY = 5;

		private const int LIT = 6;

		private const int WASH = 7;

		private const int END = 8;

		private const int BADCODE = 9;

		internal int mode;

		internal int len;

		internal int[] tree;

		internal int tree_index;

		internal int need;

		internal int lit;

		internal int bitsToGet;

		internal int dist;

		internal byte lbits;

		internal byte dbits;

		internal int[] ltree;

		internal int ltree_index;

		internal int[] dtree;

		internal int dtree_index;

		internal InflateCodes()
		{
		}

		internal void Init(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index)
		{
			mode = 0;
			lbits = (byte)bl;
			dbits = (byte)bd;
			ltree = tl;
			ltree_index = tl_index;
			dtree = td;
			dtree_index = td_index;
			tree = null;
		}

		internal int Process(InflateBlocks blocks, int r)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			ZlibCodec codec = blocks._codec;
			num3 = codec.NextIn;
			int num4 = codec.AvailableBytesIn;
			num = blocks.bitb;
			num2 = blocks.bitk;
			int num5 = blocks.writeAt;
			int num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
			while (true)
			{
				switch (mode)
				{
				case 0:
					if (num6 >= 258 && num4 >= 10)
					{
						blocks.bitb = num;
						blocks.bitk = num2;
						codec.AvailableBytesIn = num4;
						codec.TotalBytesIn += num3 - codec.NextIn;
						codec.NextIn = num3;
						blocks.writeAt = num5;
						r = InflateFast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, blocks, codec);
						num3 = codec.NextIn;
						num4 = codec.AvailableBytesIn;
						num = blocks.bitb;
						num2 = blocks.bitk;
						num5 = blocks.writeAt;
						num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
						if (r != 0)
						{
							mode = ((r == 1) ? 7 : 9);
							break;
						}
					}
					need = lbits;
					tree = ltree;
					tree_index = ltree_index;
					mode = 1;
					goto case 1;
				case 1:
				{
					int num7;
					for (num7 = need; num2 < num7; num2 += 8)
					{
						if (num4 != 0)
						{
							r = 0;
							num4--;
							num |= (codec.InputBuffer[num3++] & 0xFF) << num2;
							continue;
						}
						blocks.bitb = num;
						blocks.bitk = num2;
						codec.AvailableBytesIn = num4;
						codec.TotalBytesIn += num3 - codec.NextIn;
						codec.NextIn = num3;
						blocks.writeAt = num5;
						return blocks.Flush(r);
					}
					int num8 = (tree_index + (num & InternalInflateConstants.InflateMask[num7])) * 3;
					num >>= tree[num8 + 1];
					num2 -= tree[num8 + 1];
					int num9 = tree[num8];
					if (num9 == 0)
					{
						lit = tree[num8 + 2];
						mode = 6;
						break;
					}
					if (((uint)num9 & 0x10u) != 0)
					{
						bitsToGet = num9 & 0xF;
						len = tree[num8 + 2];
						mode = 2;
						break;
					}
					if ((num9 & 0x40) == 0)
					{
						need = num9;
						tree_index = num8 / 3 + tree[num8 + 2];
						break;
					}
					if (((uint)num9 & 0x20u) != 0)
					{
						mode = 7;
						break;
					}
					mode = 9;
					codec.Message = "invalid literal/length code";
					r = -3;
					blocks.bitb = num;
					blocks.bitk = num2;
					codec.AvailableBytesIn = num4;
					codec.TotalBytesIn += num3 - codec.NextIn;
					codec.NextIn = num3;
					blocks.writeAt = num5;
					return blocks.Flush(r);
				}
				case 2:
				{
					int num7;
					for (num7 = bitsToGet; num2 < num7; num2 += 8)
					{
						if (num4 != 0)
						{
							r = 0;
							num4--;
							num |= (codec.InputBuffer[num3++] & 0xFF) << num2;
							continue;
						}
						blocks.bitb = num;
						blocks.bitk = num2;
						codec.AvailableBytesIn = num4;
						codec.TotalBytesIn += num3 - codec.NextIn;
						codec.NextIn = num3;
						blocks.writeAt = num5;
						return blocks.Flush(r);
					}
					len += num & InternalInflateConstants.InflateMask[num7];
					num >>= num7;
					num2 -= num7;
					need = dbits;
					tree = dtree;
					tree_index = dtree_index;
					mode = 3;
					goto case 3;
				}
				case 3:
				{
					int num7;
					for (num7 = need; num2 < num7; num2 += 8)
					{
						if (num4 != 0)
						{
							r = 0;
							num4--;
							num |= (codec.InputBuffer[num3++] & 0xFF) << num2;
							continue;
						}
						blocks.bitb = num;
						blocks.bitk = num2;
						codec.AvailableBytesIn = num4;
						codec.TotalBytesIn += num3 - codec.NextIn;
						codec.NextIn = num3;
						blocks.writeAt = num5;
						return blocks.Flush(r);
					}
					int num8 = (tree_index + (num & InternalInflateConstants.InflateMask[num7])) * 3;
					num >>= tree[num8 + 1];
					num2 -= tree[num8 + 1];
					int num9 = tree[num8];
					if (((uint)num9 & 0x10u) != 0)
					{
						bitsToGet = num9 & 0xF;
						dist = tree[num8 + 2];
						mode = 4;
						break;
					}
					if ((num9 & 0x40) == 0)
					{
						need = num9;
						tree_index = num8 / 3 + tree[num8 + 2];
						break;
					}
					mode = 9;
					codec.Message = "invalid distance code";
					r = -3;
					blocks.bitb = num;
					blocks.bitk = num2;
					codec.AvailableBytesIn = num4;
					codec.TotalBytesIn += num3 - codec.NextIn;
					codec.NextIn = num3;
					blocks.writeAt = num5;
					return blocks.Flush(r);
				}
				case 4:
				{
					int num7;
					for (num7 = bitsToGet; num2 < num7; num2 += 8)
					{
						if (num4 != 0)
						{
							r = 0;
							num4--;
							num |= (codec.InputBuffer[num3++] & 0xFF) << num2;
							continue;
						}
						blocks.bitb = num;
						blocks.bitk = num2;
						codec.AvailableBytesIn = num4;
						codec.TotalBytesIn += num3 - codec.NextIn;
						codec.NextIn = num3;
						blocks.writeAt = num5;
						return blocks.Flush(r);
					}
					dist += num & InternalInflateConstants.InflateMask[num7];
					num >>= num7;
					num2 -= num7;
					mode = 5;
					goto case 5;
				}
				case 5:
				{
					int i;
					for (i = num5 - dist; i < 0; i += blocks.end)
					{
					}
					while (len != 0)
					{
						if (num6 == 0)
						{
							if (num5 == blocks.end && blocks.readAt != 0)
							{
								num5 = 0;
								num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
							}
							if (num6 == 0)
							{
								blocks.writeAt = num5;
								r = blocks.Flush(r);
								num5 = blocks.writeAt;
								num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
								if (num5 == blocks.end && blocks.readAt != 0)
								{
									num5 = 0;
									num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
								}
								if (num6 == 0)
								{
									blocks.bitb = num;
									blocks.bitk = num2;
									codec.AvailableBytesIn = num4;
									codec.TotalBytesIn += num3 - codec.NextIn;
									codec.NextIn = num3;
									blocks.writeAt = num5;
									return blocks.Flush(r);
								}
							}
						}
						blocks.window[num5++] = blocks.window[i++];
						num6--;
						if (i == blocks.end)
						{
							i = 0;
						}
						len--;
					}
					mode = 0;
					break;
				}
				case 6:
					if (num6 == 0)
					{
						if (num5 == blocks.end && blocks.readAt != 0)
						{
							num5 = 0;
							num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
						}
						if (num6 == 0)
						{
							blocks.writeAt = num5;
							r = blocks.Flush(r);
							num5 = blocks.writeAt;
							num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
							if (num5 == blocks.end && blocks.readAt != 0)
							{
								num5 = 0;
								num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
							}
							if (num6 == 0)
							{
								blocks.bitb = num;
								blocks.bitk = num2;
								codec.AvailableBytesIn = num4;
								codec.TotalBytesIn += num3 - codec.NextIn;
								codec.NextIn = num3;
								blocks.writeAt = num5;
								return blocks.Flush(r);
							}
						}
					}
					r = 0;
					blocks.window[num5++] = (byte)lit;
					num6--;
					mode = 0;
					break;
				case 7:
					if (num2 > 7)
					{
						num2 -= 8;
						num4++;
						num3--;
					}
					blocks.writeAt = num5;
					r = blocks.Flush(r);
					num5 = blocks.writeAt;
					num6 = ((num5 < blocks.readAt) ? (blocks.readAt - num5 - 1) : (blocks.end - num5));
					if (blocks.readAt != blocks.writeAt)
					{
						blocks.bitb = num;
						blocks.bitk = num2;
						codec.AvailableBytesIn = num4;
						codec.TotalBytesIn += num3 - codec.NextIn;
						codec.NextIn = num3;
						blocks.writeAt = num5;
						return blocks.Flush(r);
					}
					mode = 8;
					goto case 8;
				case 8:
					r = 1;
					blocks.bitb = num;
					blocks.bitk = num2;
					codec.AvailableBytesIn = num4;
					codec.TotalBytesIn += num3 - codec.NextIn;
					codec.NextIn = num3;
					blocks.writeAt = num5;
					return blocks.Flush(r);
				case 9:
					r = -3;
					blocks.bitb = num;
					blocks.bitk = num2;
					codec.AvailableBytesIn = num4;
					codec.TotalBytesIn += num3 - codec.NextIn;
					codec.NextIn = num3;
					blocks.writeAt = num5;
					return blocks.Flush(r);
				default:
					r = -2;
					blocks.bitb = num;
					blocks.bitk = num2;
					codec.AvailableBytesIn = num4;
					codec.TotalBytesIn += num3 - codec.NextIn;
					codec.NextIn = num3;
					blocks.writeAt = num5;
					return blocks.Flush(r);
				}
			}
		}

		internal int InflateFast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InflateBlocks s, ZlibCodec z)
		{
			int nextIn = z.NextIn;
			int num = z.AvailableBytesIn;
			int num2 = s.bitb;
			int num3 = s.bitk;
			int num4 = s.writeAt;
			int num5 = ((num4 < s.readAt) ? (s.readAt - num4 - 1) : (s.end - num4));
			int num6 = InternalInflateConstants.InflateMask[bl];
			int num7 = InternalInflateConstants.InflateMask[bd];
			int num12;
			while (true)
			{
				if (num3 < 20)
				{
					num--;
					num2 |= (z.InputBuffer[nextIn++] & 0xFF) << num3;
					num3 += 8;
					continue;
				}
				int num8 = num2 & num6;
				int[] array = tl;
				int num9 = tl_index;
				int num10 = (num9 + num8) * 3;
				int num11;
				if ((num11 = array[num10]) == 0)
				{
					num2 >>= array[num10 + 1];
					num3 -= array[num10 + 1];
					s.window[num4++] = (byte)array[num10 + 2];
					num5--;
				}
				else
				{
					while (true)
					{
						num2 >>= array[num10 + 1];
						num3 -= array[num10 + 1];
						if (((uint)num11 & 0x10u) != 0)
						{
							num11 &= 0xF;
							num12 = array[num10 + 2] + (num2 & InternalInflateConstants.InflateMask[num11]);
							num2 >>= num11;
							for (num3 -= num11; num3 < 15; num3 += 8)
							{
								num--;
								num2 |= (z.InputBuffer[nextIn++] & 0xFF) << num3;
							}
							num8 = num2 & num7;
							array = td;
							num9 = td_index;
							num10 = (num9 + num8) * 3;
							num11 = array[num10];
							while (true)
							{
								num2 >>= array[num10 + 1];
								num3 -= array[num10 + 1];
								if (((uint)num11 & 0x10u) != 0)
								{
									break;
								}
								if ((num11 & 0x40) == 0)
								{
									num8 += array[num10 + 2];
									num8 += num2 & InternalInflateConstants.InflateMask[num11];
									num10 = (num9 + num8) * 3;
									num11 = array[num10];
									continue;
								}
								z.Message = "invalid distance code";
								num12 = z.AvailableBytesIn - num;
								num12 = ((num3 >> 3 < num12) ? (num3 >> 3) : num12);
								num += num12;
								nextIn -= num12;
								num3 -= num12 << 3;
								s.bitb = num2;
								s.bitk = num3;
								z.AvailableBytesIn = num;
								z.TotalBytesIn += nextIn - z.NextIn;
								z.NextIn = nextIn;
								s.writeAt = num4;
								return -3;
							}
							for (num11 &= 0xF; num3 < num11; num3 += 8)
							{
								num--;
								num2 |= (z.InputBuffer[nextIn++] & 0xFF) << num3;
							}
							int num13 = array[num10 + 2] + (num2 & InternalInflateConstants.InflateMask[num11]);
							num2 >>= num11;
							num3 -= num11;
							num5 -= num12;
							int num14;
							if (num4 >= num13)
							{
								num14 = num4 - num13;
								if (num4 - num14 > 0 && 2 > num4 - num14)
								{
									s.window[num4++] = s.window[num14++];
									s.window[num4++] = s.window[num14++];
									num12 -= 2;
								}
								else
								{
									Array.Copy(s.window, num14, s.window, num4, 2);
									num4 += 2;
									num14 += 2;
									num12 -= 2;
								}
							}
							else
							{
								num14 = num4 - num13;
								do
								{
									num14 += s.end;
								}
								while (num14 < 0);
								num11 = s.end - num14;
								if (num12 > num11)
								{
									num12 -= num11;
									if (num4 - num14 > 0 && num11 > num4 - num14)
									{
										do
										{
											s.window[num4++] = s.window[num14++];
										}
										while (--num11 != 0);
									}
									else
									{
										Array.Copy(s.window, num14, s.window, num4, num11);
										num4 += num11;
										num14 += num11;
										num11 = 0;
									}
									num14 = 0;
								}
							}
							if (num4 - num14 > 0 && num12 > num4 - num14)
							{
								do
								{
									s.window[num4++] = s.window[num14++];
								}
								while (--num12 != 0);
								break;
							}
							Array.Copy(s.window, num14, s.window, num4, num12);
							num4 += num12;
							num14 += num12;
							num12 = 0;
							break;
						}
						if ((num11 & 0x40) == 0)
						{
							num8 += array[num10 + 2];
							num8 += num2 & InternalInflateConstants.InflateMask[num11];
							num10 = (num9 + num8) * 3;
							if ((num11 = array[num10]) == 0)
							{
								num2 >>= array[num10 + 1];
								num3 -= array[num10 + 1];
								s.window[num4++] = (byte)array[num10 + 2];
								num5--;
								break;
							}
							continue;
						}
						if (((uint)num11 & 0x20u) != 0)
						{
							num12 = z.AvailableBytesIn - num;
							num12 = ((num3 >> 3 < num12) ? (num3 >> 3) : num12);
							num += num12;
							nextIn -= num12;
							num3 -= num12 << 3;
							s.bitb = num2;
							s.bitk = num3;
							z.AvailableBytesIn = num;
							z.TotalBytesIn += nextIn - z.NextIn;
							z.NextIn = nextIn;
							s.writeAt = num4;
							return 1;
						}
						z.Message = "invalid literal/length code";
						num12 = z.AvailableBytesIn - num;
						num12 = ((num3 >> 3 < num12) ? (num3 >> 3) : num12);
						num += num12;
						nextIn -= num12;
						num3 -= num12 << 3;
						s.bitb = num2;
						s.bitk = num3;
						z.AvailableBytesIn = num;
						z.TotalBytesIn += nextIn - z.NextIn;
						z.NextIn = nextIn;
						s.writeAt = num4;
						return -3;
					}
				}
				if (num5 < 258 || num < 10)
				{
					break;
				}
			}
			num12 = z.AvailableBytesIn - num;
			num12 = ((num3 >> 3 < num12) ? (num3 >> 3) : num12);
			num += num12;
			nextIn -= num12;
			num3 -= num12 << 3;
			s.bitb = num2;
			s.bitk = num3;
			z.AvailableBytesIn = num;
			z.TotalBytesIn += nextIn - z.NextIn;
			z.NextIn = nextIn;
			s.writeAt = num4;
			return 0;
		}
	}
	internal sealed class InflateManager
	{
		private enum InflateManagerMode
		{
			METHOD,
			FLAG,
			DICT4,
			DICT3,
			DICT2,
			DICT1,
			DICT0,
			BLOCKS,
			CHECK4,
			CHECK3,
			CHECK2,
			CHECK1,
			DONE,
			BAD
		}

		private const int PRESET_DICT = 32;

		private const int Z_DEFLATED = 8;

		private InflateManagerMode mode;

		internal ZlibCodec _codec;

		internal int method;

		internal uint computedCheck;

		internal uint expectedCheck;

		internal int marker;

		private bool _handleRfc1950HeaderBytes = true;

		internal int wbits;

		internal InflateBlocks blocks;

		private static readonly byte[] mark = new byte[4] { 0, 0, 255, 255 };

		internal bool HandleRfc1950HeaderBytes
		{
			get
			{
				return _handleRfc1950HeaderBytes;
			}
			set
			{
				_handleRfc1950HeaderBytes = value;
			}
		}

		public InflateManager()
		{
		}

		public InflateManager(bool expectRfc1950HeaderBytes)
		{
			_handleRfc1950HeaderBytes = expectRfc1950HeaderBytes;
		}

		internal int Reset()
		{
			_codec.TotalBytesIn = (_codec.TotalBytesOut = 0L);
			_codec.Message = null;
			mode = ((!HandleRfc1950HeaderBytes) ? InflateManagerMode.BLOCKS : InflateManagerMode.METHOD);
			blocks.Reset();
			return 0;
		}

		internal int End()
		{
			if (blocks != null)
			{
				blocks.Free();
			}
			blocks = null;
			return 0;
		}

		internal int Initialize(ZlibCodec codec, int w)
		{
			_codec = codec;
			_codec.Message = null;
			blocks = null;
			if (w < 8 || w > 15)
			{
				End();
				throw new ZlibException("Bad window size.");
			}
			wbits = w;
			blocks = new InflateBlocks(codec, HandleRfc1950HeaderBytes ? this : null, 1 << w);
			Reset();
			return 0;
		}

		internal int Inflate(FlushType flush)
		{
			if (_codec.InputBuffer == null)
			{
				throw new ZlibException("InputBuffer is null. ");
			}
			int num = 0;
			int num2 = -5;
			while (true)
			{
				switch (mode)
				{
				case InflateManagerMode.METHOD:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					if (((method = _codec.InputBuffer[_codec.NextIn++]) & 0xF) != 8)
					{
						mode = InflateManagerMode.BAD;
						_codec.Message = $"unknown compression method (0x{method:X2})";
						marker = 5;
					}
					else if ((method >> 4) + 8 > wbits)
					{
						mode = InflateManagerMode.BAD;
						_codec.Message = $"invalid window size ({(method >> 4) + 8})";
						marker = 5;
					}
					else
					{
						mode = InflateManagerMode.FLAG;
					}
					break;
				case InflateManagerMode.FLAG:
				{
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					int num3 = _codec.InputBuffer[_codec.NextIn++] & 0xFF;
					if (((method << 8) + num3) % 31 != 0)
					{
						mode = InflateManagerMode.BAD;
						_codec.Message = "incorrect header check";
						marker = 5;
					}
					else
					{
						mode = (((num3 & 0x20) == 0) ? InflateManagerMode.BLOCKS : InflateManagerMode.DICT4);
					}
					break;
				}
				case InflateManagerMode.DICT4:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck = (uint)((_codec.InputBuffer[_codec.NextIn++] << 24) & 0xFF000000u);
					mode = InflateManagerMode.DICT3;
					break;
				case InflateManagerMode.DICT3:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 16) & 0xFF0000);
					mode = InflateManagerMode.DICT2;
					break;
				case InflateManagerMode.DICT2:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 8) & 0xFF00);
					mode = InflateManagerMode.DICT1;
					break;
				case InflateManagerMode.DICT1:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck += (uint)(_codec.InputBuffer[_codec.NextIn++] & 0xFF);
					_codec._Adler32 = expectedCheck;
					mode = InflateManagerMode.DICT0;
					return 2;
				case InflateManagerMode.DICT0:
					mode = InflateManagerMode.BAD;
					_codec.Message = "need dictionary";
					marker = 0;
					return -2;
				case InflateManagerMode.BLOCKS:
					num2 = blocks.Process(num2);
					switch (num2)
					{
					case -3:
						mode = InflateManagerMode.BAD;
						marker = 0;
						goto end_IL_0025;
					case 0:
						num2 = num;
						break;
					}
					if (num2 != 1)
					{
						return num2;
					}
					num2 = num;
					computedCheck = blocks.Reset();
					if (!HandleRfc1950HeaderBytes)
					{
						mode = InflateManagerMode.DONE;
						return 1;
					}
					mode = InflateManagerMode.CHECK4;
					break;
				case InflateManagerMode.CHECK4:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck = (uint)((_codec.InputBuffer[_codec.NextIn++] << 24) & 0xFF000000u);
					mode = InflateManagerMode.CHECK3;
					break;
				case InflateManagerMode.CHECK3:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 16) & 0xFF0000);
					mode = InflateManagerMode.CHECK2;
					break;
				case InflateManagerMode.CHECK2:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 8) & 0xFF00);
					mode = InflateManagerMode.CHECK1;
					break;
				case InflateManagerMode.CHECK1:
					if (_codec.AvailableBytesIn == 0)
					{
						return num2;
					}
					num2 = num;
					_codec.AvailableBytesIn--;
					_codec.TotalBytesIn++;
					expectedCheck += (uint)(_codec.InputBuffer[_codec.NextIn++] & 0xFF);
					if (computedCheck != expectedCheck)
					{
						mode = InflateManagerMode.BAD;
						_codec.Message = "incorrect data check";
						marker = 5;
						break;
					}
					mode = InflateManagerMode.DONE;
					return 1;
				case InflateManagerMode.DONE:
					return 1;
				case InflateManagerMode.BAD:
					throw new ZlibException($"Bad state ({_codec.Message})");
				default:
					{
						throw new ZlibException("Stream error.");
					}
					end_IL_0025:
					break;
				}
			}
		}

		internal int SetDictionary(byte[] dictionary)
		{
			int start = 0;
			int num = dictionary.Length;
			if (mode != InflateManagerMode.DICT0)
			{
				throw new ZlibException("Stream error.");
			}
			if (Adler.Adler32(1u, dictionary, 0, dictionary.Length) != _codec._Adler32)
			{
				return -3;
			}
			_codec._Adler32 = Adler.Adler32(0u, null, 0, 0);
			if (num >= 1 << wbits)
			{
				num = (1 << wbits) - 1;
				start = dictionary.Length - num;
			}
			blocks.SetDictionary(dictionary, start, num);
			mode = InflateManagerMode.BLOCKS;
			return 0;
		}

		internal int Sync()
		{
			if (mode != InflateManagerMode.BAD)
			{
				mode = InflateManagerMode.BAD;
				marker = 0;
			}
			int num;
			if ((num = _codec.AvailableBytesIn) == 0)
			{
				return -5;
			}
			int num2 = _codec.NextIn;
			int num3 = marker;
			while (num != 0 && num3 < 4)
			{
				num3 = ((_codec.InputBuffer[num2] != mark[num3]) ? ((_codec.InputBuffer[num2] == 0) ? (4 - num3) : 0) : (num3 + 1));
				num2++;
				num--;
			}
			_codec.TotalBytesIn += num2 - _codec.NextIn;
			_codec.NextIn = num2;
			_codec.AvailableBytesIn = num;
			marker = num3;
			if (num3 != 4)
			{
				return -3;
			}
			long totalBytesIn = _codec.TotalBytesIn;
			long totalBytesOut = _codec.TotalBytesOut;
			Reset();
			_codec.TotalBytesIn = totalBytesIn;
			_codec.TotalBytesOut = totalBytesOut;
			mode = InflateManagerMode.BLOCKS;
			return 0;
		}

		internal int SyncPoint(ZlibCodec z)
		{
			return blocks.SyncPoint();
		}
	}
	internal sealed class InfTree
	{
		private const int MANY = 1440;

		private const int Z_OK = 0;

		private const int Z_STREAM_END = 1;

		private const int Z_NEED_DICT = 2;

		private const int Z_ERRNO = -1;

		private const int Z_STREAM_ERROR = -2;

		private const int Z_DATA_ERROR = -3;

		private const int Z_MEM_ERROR = -4;

		private const int Z_BUF_ERROR = -5;

		private const int Z_VERSION_ERROR = -6;

		internal const int fixed_bl = 9;

		internal const int fixed_bd = 5;

		internal static readonly int[] fixed_tl = new int[1536]
		{
			96, 7, 256, 0, 8, 80, 0, 8, 16, 84,
			8, 115, 82, 7, 31, 0, 8, 112, 0, 8,
			48, 0, 9, 192, 80, 7, 10, 0, 8, 96,
			0, 8, 32, 0, 9, 160, 0, 8, 0, 0,
			8, 128, 0, 8, 64, 0, 9, 224, 80, 7,
			6, 0, 8, 88, 0, 8, 24, 0, 9, 144,
			83, 7, 59, 0, 8, 120, 0, 8, 56, 0,
			9, 208, 81, 7, 17, 0, 8, 104, 0, 8,
			40, 0, 9, 176, 0, 8, 8, 0, 8, 136,
			0, 8, 72, 0, 9, 240, 80, 7, 4, 0,
			8, 84, 0, 8, 20, 85, 8, 227, 83, 7,
			43, 0, 8, 116, 0, 8, 52, 0, 9, 200,
			81, 7, 13, 0, 8, 100, 0, 8, 36, 0,
			9, 168, 0, 8, 4, 0, 8, 132, 0, 8,
			68, 0, 9, 232, 80, 7, 8, 0, 8, 92,
			0, 8, 28, 0, 9, 152, 84, 7, 83, 0,
			8, 124, 0, 8, 60, 0, 9, 216, 82, 7,
			23, 0, 8, 108, 0, 8, 44, 0, 9, 184,
			0, 8, 12, 0, 8, 140, 0, 8, 76, 0,
			9, 248, 80, 7, 3, 0, 8, 82, 0, 8,
			18, 85, 8, 163, 83, 7, 35, 0, 8, 114,
			0, 8, 50, 0, 9, 196, 81, 7, 11, 0,
			8, 98, 0, 8, 34, 0, 9, 164, 0, 8,
			2, 0, 8, 130, 0, 8, 66, 0, 9, 228,
			80, 7, 7, 0, 8, 90, 0, 8, 26, 0,
			9, 148, 84, 7, 67, 0, 8, 122, 0, 8,
			58, 0, 9, 212, 82, 7, 19, 0, 8, 106,
			0, 8, 42, 0, 9, 180, 0, 8, 10, 0,
			8, 138, 0, 8, 74, 0, 9, 244, 80, 7,
			5, 0, 8, 86, 0, 8, 22, 192, 8, 0,
			83, 7, 51, 0, 8, 118, 0, 8, 54, 0,
			9, 204, 81, 7, 15, 0, 8, 102, 0, 8,
			38, 0, 9, 172, 0, 8, 6, 0, 8, 134,
			0, 8, 70, 0, 9, 236, 80, 7, 9, 0,
			8, 94, 0, 8, 30, 0, 9, 156, 84, 7,
			99, 0, 8, 126, 0, 8, 62, 0, 9, 220,
			82, 7, 27, 0, 8, 110, 0, 8, 46, 0,
			9, 188, 0, 8, 14, 0, 8, 142, 0, 8,
			78, 0, 9, 252, 96, 7, 256, 0, 8, 81,
			0, 8, 17, 85, 8, 131, 82, 7, 31, 0,
			8, 113, 0, 8, 49, 0, 9, 194, 80, 7,
			10, 0, 8, 97, 0, 8, 33, 0, 9, 162,
			0, 8, 1, 0, 8, 129, 0, 8, 65, 0,
			9, 226, 80, 7, 6, 0, 8, 89, 0, 8,
			25, 0, 9, 146, 83, 7, 59, 0, 8, 121,
			0, 8, 57, 0, 9, 210, 81, 7, 17, 0,
			8, 105, 0, 8, 41, 0, 9, 178, 0, 8,
			9, 0, 8, 137, 0, 8, 73, 0, 9, 242,
			80, 7, 4, 0, 8, 85, 0, 8, 21, 80,
			8, 258, 83, 7, 43, 0, 8, 117, 0, 8,
			53, 0, 9, 202, 81, 7, 13, 0, 8, 101,
			0, 8, 37, 0, 9, 170, 0, 8, 5, 0,
			8, 133, 0, 8, 69, 0, 9, 234, 80, 7,
			8, 0, 8, 93, 0, 8, 29, 0, 9, 154,
			84, 7, 83, 0, 8, 125, 0, 8, 61, 0,
			9, 218, 82, 7, 23, 0, 8, 109, 0, 8,
			45, 0, 9, 186, 0, 8, 13, 0, 8, 141,
			0, 8, 77, 0, 9, 250, 80, 7, 3, 0,
			8, 83, 0, 8, 19, 85, 8, 195, 83, 7,
			35, 0, 8, 115, 0, 8, 51, 0, 9, 198,
			81, 7, 11, 0, 8, 99, 0, 8, 35, 0,
			9, 166, 0, 8, 3, 0, 8, 131, 0, 8,
			67, 0, 9, 230, 80, 7, 7, 0, 8, 91,
			0, 8, 27, 0, 9, 150, 84, 7, 67, 0,
			8, 123, 0, 8, 59, 0, 9, 214, 82, 7,
			19, 0, 8, 107, 0, 8, 43, 0, 9, 182,
			0, 8, 11, 0, 8, 139, 0, 8, 75, 0,
			9, 246, 80, 7, 5, 0, 8, 87, 0, 8,
			23, 192, 8, 0, 83, 7, 51, 0, 8, 119,
			0, 8, 55, 0, 9, 206, 81, 7, 15, 0,
			8, 103, 0, 8, 39, 0, 9, 174, 0, 8,
			7, 0, 8, 135, 0, 8, 71, 0, 9, 238,
			80, 7, 9, 0, 8, 95, 0, 8, 31, 0,
			9, 158, 84, 7, 99, 0, 8, 127, 0, 8,
			63, 0, 9, 222, 82, 7, 27, 0, 8, 111,
			0, 8, 47, 0, 9, 190, 0, 8, 15, 0,
			8, 143, 0, 8, 79, 0, 9, 254, 96, 7,
			256, 0, 8, 80, 0, 8, 16, 84, 8, 115,
			82, 7, 31, 0, 8, 112, 0, 8, 48, 0,
			9, 193, 80, 7, 10, 0, 8, 96, 0, 8,
			32, 0, 9, 161, 0, 8, 0, 0, 8, 128,
			0, 8, 64, 0, 9, 225, 80, 7, 6, 0,
			8, 88, 0, 8, 24, 0, 9, 145, 83, 7,
			59, 0, 8, 120, 0, 8, 56, 0, 9, 209,
			81, 7, 17, 0, 8, 104, 0, 8, 40, 0,
			9, 177, 0, 8, 8, 0, 8, 136, 0, 8,
			72, 0, 9, 241, 80, 7, 4, 0, 8, 84,
			0, 8, 20, 85, 8, 227, 83, 7, 43, 0,
			8, 116, 0, 8, 52, 0, 9, 201, 81, 7,
			13, 0, 8, 100, 0, 8, 36, 0, 9, 169,
			0, 8, 4, 0, 8, 132, 0, 8, 68, 0,
			9, 233, 80, 7, 8, 0, 8, 92, 0, 8,
			28, 0, 9, 153, 84, 7, 83, 0, 8, 124,
			0, 8, 60, 0, 9, 217, 82, 7, 23, 0,
			8, 108, 0, 8, 44, 0, 9, 185, 0, 8,
			12, 0, 8, 140, 0, 8, 76, 0, 9, 249,
			80, 7, 3, 0, 8, 82, 0, 8, 18, 85,
			8, 163, 83, 7, 35, 0, 8, 114, 0, 8,
			50, 0, 9, 197, 81, 7, 11, 0, 8, 98,
			0, 8, 34, 0, 9, 165, 0, 8, 2, 0,
			8, 130, 0, 8, 66, 0, 9, 229, 80, 7,
			7, 0, 8, 90, 0, 8, 26, 0, 9, 149,
			84, 7, 67, 0, 8, 122, 0, 8, 58, 0,
			9, 213, 82, 7, 19, 0, 8, 106, 0, 8,
			42, 0, 9, 181, 0, 8, 10, 0, 8, 138,
			0, 8, 74, 0, 9, 245, 80, 7, 5, 0,
			8, 86, 0, 8, 22, 192, 8, 0, 83, 7,
			51, 0, 8, 118, 0, 8, 54, 0, 9, 205,
			81, 7, 15, 0, 8, 102, 0, 8, 38, 0,
			9, 173, 0, 8, 6, 0, 8, 134, 0, 8,
			70, 0, 9, 237, 80, 7, 9, 0, 8, 94,
			0, 8, 30, 0, 9, 157, 84, 7, 99, 0,
			8, 126, 0, 8, 62, 0, 9, 221, 82, 7,
			27, 0, 8, 110, 0, 8, 46, 0, 9, 189,
			0, 8, 14, 0, 8, 142, 0, 8, 78, 0,
			9, 253, 96, 7, 256, 0, 8, 81, 0, 8,
			17, 85, 8, 131, 82, 7, 31, 0, 8, 113,
			0, 8, 49, 0, 9, 195, 80, 7, 10, 0,
			8, 97, 0, 8, 33, 0, 9, 163, 0, 8,
			1, 0, 8, 129, 0, 8, 65, 0, 9, 227,
			80, 7, 6, 0, 8, 89, 0, 8, 25, 0,
			9, 147, 83, 7, 59, 0, 8, 121, 0, 8,
			57, 0, 9, 211, 81, 7, 17, 0, 8, 105,
			0, 8, 41, 0, 9, 179, 0, 8, 9, 0,
			8, 137, 0, 8, 73, 0, 9, 243, 80, 7,
			4, 0, 8, 85, 0, 8, 21, 80, 8, 258,
			83, 7, 43, 0, 8, 117, 0, 8, 53, 0,
			9, 203, 81, 7, 13, 0, 8, 101, 0, 8,
			37, 0, 9, 171, 0, 8, 5, 0, 8, 133,
			0, 8, 69, 0, 9, 235, 80, 7, 8, 0,
			8, 93, 0, 8, 29, 0, 9, 155, 84, 7,
			83, 0, 8, 125, 0, 8, 61, 0, 9, 219,
			82, 7, 23, 0, 8, 109, 0, 8, 45, 0,
			9, 187, 0, 8, 13, 0, 8, 141, 0, 8,
			77, 0, 9, 251, 80, 7, 3, 0, 8, 83,
			0, 8, 19, 85, 8, 195, 83, 7, 35, 0,
			8, 115, 0, 8, 51, 0, 9, 199, 81, 7,
			11, 0, 8, 99, 0, 8, 35, 0, 9, 167,
			0, 8, 3, 0, 8, 131, 0, 8, 67, 0,
			9, 231, 80, 7, 7, 0, 8, 91, 0, 8,
			27, 0, 9, 151, 84, 7, 67, 0, 8, 123,
			0, 8, 59, 0, 9, 215, 82, 7, 19, 0,
			8, 107, 0, 8, 43, 0, 9, 183, 0, 8,
			11, 0, 8, 139, 0, 8, 75, 0, 9, 247,
			80, 7, 5, 0, 8, 87, 0, 8, 23, 192,
			8, 0, 83, 7, 51, 0, 8, 119, 0, 8,
			55, 0, 9, 207, 81, 7, 15, 0, 8, 103,
			0, 8, 39, 0, 9, 175, 0, 8, 7, 0,
			8, 135, 0, 8, 71, 0, 9, 239, 80, 7,
			9, 0, 8, 95, 0, 8, 31, 0, 9, 159,
			84, 7, 99, 0, 8, 127, 0, 8, 63, 0,
			9, 223, 82, 7, 27, 0, 8, 111, 0, 8,
			47, 0, 9, 191, 0, 8, 15, 0, 8, 143,
			0, 8, 79, 0, 9, 255
		};

		internal static readonly int[] fixed_td = new int[96]
		{
			80, 5, 1, 87, 5, 257, 83, 5, 17, 91,
			5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5,
			65, 93, 5, 16385, 80, 5, 3, 88, 5, 513,
			84, 5, 33, 92, 5, 8193, 82, 5, 9, 90,
			5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5,
			2, 87, 5, 385, 83, 5, 25, 91, 5, 6145,
			81, 5, 7, 89, 5, 1537, 85, 5, 97, 93,
			5, 24577, 80, 5, 4, 88, 5, 769, 84, 5,
			49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073,
			86, 5, 193, 192, 5, 24577
		};

		internal static readonly int[] cplens = new int[31]
		{
			3, 4, 5, 6, 7, 8, 9, 10, 11, 13,
			15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
			67, 83, 99, 115, 131, 163, 195, 227, 258, 0,
			0
		};

		internal static readonly int[] cplext = new int[31]
		{
			0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
			1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
			4, 4, 4, 4, 5, 5, 5, 5, 0, 112,
			112
		};

		internal static readonly int[] cpdist = new int[30]
		{
			1, 2, 3, 4, 5, 7, 9, 13, 17, 25,
			33, 49, 65, 97, 129, 193, 257, 385, 513, 769,
			1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
		};

		internal static readonly int[] cpdext = new int[30]
		{
			0, 0, 0, 0, 1, 1, 2, 2, 3, 3,
			4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
			9, 9, 10, 10, 11, 11, 12, 12, 13, 13
		};

		internal const int BMAX = 15;

		internal int[] hn;

		internal int[] v;

		internal int[] c;

		internal int[] r;

		internal int[] u;

		internal int[] x;

		private int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v)
		{
			int num = 0;
			int num2 = n;
			do
			{
				c[b[bindex + num]]++;
				num++;
				num2--;
			}
			while (num2 != 0);
			if (c[0] == n)
			{
				t[0] = -1;
				m[0] = 0;
				return 0;
			}
			int num3 = m[0];
			int i;
			for (i = 1; i <= 15 && c[i] == 0; i++)
			{
			}
			int j = i;
			if (num3 < i)
			{
				num3 = i;
			}
			num2 = 15;
			while (num2 != 0 && c[num2] == 0)
			{
				num2--;
			}
			int num4 = num2;
			if (num3 > num2)
			{
				num3 = num2;
			}
			m[0] = num3;
			int num5 = 1 << i;
			while (i < num2)
			{
				if ((num5 -= c[i]) < 0)
				{
					return -3;
				}
				i++;
				num5 <<= 1;
			}
			if ((num5 -= c[num2]) < 0)
			{
				return -3;
			}
			c[num2] += num5;
			i = (x[1] = 0);
			num = 1;
			int num6 = 2;
			while (--num2 != 0)
			{
				i = (x[num6] = i + c[num]);
				num6++;
				num++;
			}
			num2 = 0;
			num = 0;
			do
			{
				if ((i = b[bindex + num]) != 0)
				{
					v[x[i]++] = num2;
				}
				num++;
			}
			while (++num2 < n);
			n = x[num4];
			num2 = (x[0] = 0);
			num = 0;
			int num7 = -1;
			int num8 = -num3;
			u[0] = 0;
			int num9 = 0;
			int num10 = 0;
			for (; j <= num4; j++)
			{
				int num11 = c[j];
				while (num11-- != 0)
				{
					int num12;
					while (j > num8 + num3)
					{
						num7++;
						num8 += num3;
						num10 = num4 - num8;
						num10 = ((num10 > num3) ? num3 : num10);
						if ((num12 = 1 << (i = j - num8)) > num11 + 1)
						{
							num12 -= num11 + 1;
							num6 = j;
							if (i < num10)
							{
								while (++i < num10 && (num12 <<= 1) > c[++num6])
								{
									num12 -= c[num6];
								}
							}
						}
						num10 = 1 << i;
						if (hn[0] + num10 > 1440)
						{
							return -3;
						}
						num9 = (u[num7] = hn[0]);
						hn[0] += num10;
						if (num7 != 0)
						{
							x[num7] = num2;
							r[0] = (sbyte)i;
							r[1] = (sbyte)num3;
							i = SharedUtils.URShift(num2, num8 - num3);
							r[2] = num9 - u[num7 - 1] - i;
							Array.Copy(r, 0, hp, (u[num7 - 1] + i) * 3, 3);
						}
						else
						{
							t[0] = num9;
						}
					}
					r[1] = (sbyte)(j - num8);
					if (num >= n)
					{
						r[0] = 192;
					}
					else if (v[num] < s)
					{
						r[0] = (sbyte)((v[num] >= 256) ? 96 : 0);
						r[2] = v[num++];
					}
					else
					{
						r[0] = (sbyte)(e[v[num] - s] + 16 + 64);
						r[2] = d[v[num++] - s];
					}
					num12 = 1 << j - num8;
					for (i = SharedUtils.URShift(num2, num8); i < num10; i += num12)
					{
						Array.Copy(r, 0, hp, (num9 + i) * 3, 3);
					}
					i = 1 << j - 1;
					while ((num2 & i) != 0)
					{
						num2 ^= i;
						i = SharedUtils.URShift(i, 1);
					}
					num2 ^= i;
					int num13 = (1 << num8) - 1;
					while ((num2 & num13) != x[num7])
					{
						num7--;
						num8 -= num3;
						num13 = (1 << num8) - 1;
					}
				}
			}
			if (num5 == 0 || num4 == 1)
			{
				return 0;
			}
			return -5;
		}

		internal int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZlibCodec z)
		{
			initWorkArea(19);
			hn[0] = 0;
			int num = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
			if (num == -3)
			{
				z.Message = "oversubscribed dynamic bit lengths tree";
			}
			else if (num == -5 || bb[0] == 0)
			{
				z.Message = "incomplete dynamic bit lengths tree";
				num = -3;
			}
			return num;
		}

		internal int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZlibCodec z)
		{
			initWorkArea(288);
			hn[0] = 0;
			int num = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
			if (num != 0 || bl[0] == 0)
			{
				switch (num)
				{
				case -3:
					z.Message = "oversubscribed literal/length tree";
					break;
				default:
					z.Message = "incomplete literal/length tree";
					num = -3;
					break;
				case -4:
					break;
				}
				return num;
			}
			initWorkArea(288);
			num = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
			if (num != 0 || (bd[0] == 0 && nl > 257))
			{
				switch (num)
				{
				case -3:
					z.Message = "oversubscribed distance tree";
					break;
				case -5:
					z.Message = "incomplete distance tree";
					num = -3;
					break;
				default:
					z.Message = "empty distance tree with lengths";
					num = -3;
					break;
				case -4:
					break;
				}
				return num;
			}
			return 0;
		}

		internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)
		{
			bl[0] = 9;
			bd[0] = 5;
			tl[0] = fixed_tl;
			td[0] = fixed_td;
			return 0;
		}

		private void initWorkArea(int vsize)
		{
			if (hn == null)
			{
				hn = new int[1];
				v = new int[vsize];
				c = new int[16];
				r = new int[3];
				u = new int[15];
				x = new int[16];
				return;
			}
			if (v.Length < vsize)
			{
				v = new int[vsize];
			}
			Array.Clear(v, 0, vsize);
			Array.Clear(c, 0, 16);
			r[0] = 0;
			r[1] = 0;
			r[2] = 0;
			Array.Clear(u, 0, 15);
			Array.Clear(x, 0, 16);
		}
	}
	internal sealed class Tree
	{
		private static readonly int HEAP_SIZE = 2 * InternalConstants.L_CODES + 1;

		internal static readonly int[] ExtraLengthBits = new int[29]
		{
			0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
			1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
			4, 4, 4, 4, 5, 5, 5, 5, 0
		};

		internal static readonly int[] ExtraDistanceBits = new int[30]
		{
			0, 0, 0, 0, 1, 1, 2, 2, 3, 3,
			4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
			9, 9, 10, 10, 11, 11, 12, 12, 13, 13
		};

		internal static readonly int[] extra_blbits = new int[19]
		{
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 2, 3, 7
		};

		internal static readonly sbyte[] bl_order = new sbyte[19]
		{
			16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
			11, 4, 12, 3, 13, 2, 14, 1, 15
		};

		internal const int Buf_size = 16;

		private static readonly sbyte[] _dist_code = new sbyte[512]
		{
			0, 1, 2, 3, 4, 4, 5, 5, 6, 6,
			6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
			8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
			9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
			10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
			11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
			11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
			12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
			12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
			12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
			13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
			13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
			13, 13, 13, 13, 13, 13, 13, 13, 14, 14,
			14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
			14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
			14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
			14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
			14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
			14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
			14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
			15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
			15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
			15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
			15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
			15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
			15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
			18, 18, 19, 19, 20, 20, 20, 20, 21, 21,
			21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
			23, 23, 23, 23, 23, 23, 23, 23, 24, 24,
			24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
			24, 24, 24, 24, 25, 25, 25, 25, 25, 25,
			25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
			26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
			26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
			26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
			26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
			27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
			27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
			27, 27, 27, 27, 28, 28, 28, 28, 28, 28,
			28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
			28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
			28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
			28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
			28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
			28, 28, 28, 28, 28, 28, 28, 28, 29, 29,
			29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
			29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
			29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
			29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
			29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
			29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
			29, 29
		};

		internal static readonly sbyte[] LengthCode = new sbyte[256]
		{
			0, 1, 2, 3, 4, 5, 6, 7, 8, 8,
			9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
			13, 13, 13, 13, 14, 14, 14, 14, 15, 15,
			15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
			17, 17, 17, 17, 17, 17, 17, 17, 18, 18,
			18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
			19, 19, 19, 19, 20, 20, 20, 20, 20, 20,
			20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
			21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
			21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
			22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
			22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
			23, 23, 23, 23, 23, 23, 23, 23, 24, 24,
			24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
			24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
			24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
			25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
			25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
			25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
			25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
			26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
			26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
			26, 26, 26, 26, 27, 27, 27, 27, 27, 27,
			27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
			27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
			27, 27, 27, 27, 27, 28
		};

		internal static readonly int[] LengthBase = new int[29]
		{
			0, 1, 2, 3, 4, 5, 6, 7, 8, 10,
			12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
			64, 80, 96, 112, 128, 160, 192, 224, 0
		};

		internal static readonly int[] DistanceBase = new int[30]
		{
			0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
			32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
			1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
		};

		internal short[] dyn_tree;

		internal int max_code;

		internal StaticTree staticTree;

		internal static int DistanceCode(int dist)
		{
			if (dist >= 256)
			{
				return _dist_code[256 + SharedUtils.URShift(dist, 7)];
			}
			return _dist_code[dist];
		}

		internal void gen_bitlen(DeflateManager s)
		{
			short[] array = dyn_tree;
			short[] treeCodes = staticTree.treeCodes;
			int[] extraBits = staticTree.extraBits;
			int extraBase = staticTree.extraBase;
			int maxLength = staticTree.maxLength;
			int num = 0;
			for (int i = 0; i <= InternalConstants.MAX_BITS; i++)
			{
				s.bl_count[i] = 0;
			}
			array[s.heap[s.heap_max] * 2 + 1] = 0;
			int j;
			for (j = s.heap_max + 1; j < HEAP_SIZE; j++)
			{
				int num2 = s.heap[j];
				int i = array[array[num2 * 2 + 1] * 2 + 1] + 1;
				if (i > maxLength)
				{
					i = maxLength;
					num++;
				}
				array[num2 * 2 + 1] = (short)i;
				if (num2 <= max_code)
				{
					s.bl_count[i]++;
					int num3 = 0;
					if (num2 >= extraBase)
					{
						num3 = extraBits[num2 - extraBase];
					}
					short num4 = array[num2 * 2];
					s.opt_len += num4 * (i + num3);
					if (treeCodes != null)
					{
						s.static_len += num4 * (treeCodes[num2 * 2 + 1] + num3);
					}
				}
			}
			if (num == 0)
			{
				return;
			}
			do
			{
				int i = maxLength - 1;
				while (s.bl_count[i] == 0)
				{
					i--;
				}
				s.bl_count[i]--;
				s.bl_count[i + 1] = (short)(s.bl_count[i + 1] + 2);
				s.bl_count[maxLength]--;
				num -= 2;
			}
			while (num > 0);
			for (int i = maxLength; i != 0; i--)
			{
				int num2 = s.bl_count[i];
				while (num2 != 0)
				{
					int num5 = s.heap[--j];
					if (num5 <= max_code)
					{
						if (array[num5 * 2 + 1] != i)
						{
							s.opt_len = (int)(s.opt_len + ((long)i - (long)array[num5 * 2 + 1]) * array[num5 * 2]);
							array[num5 * 2 + 1] = (short)i;
						}
						num2--;
					}
				}
			}
		}

		internal void build_tree(DeflateManager s)
		{
			short[] array = dyn_tree;
			short[] treeCodes = staticTree.treeCodes;
			int elems = staticTree.elems;
			int num = -1;
			s.heap_len = 0;
			s.heap_max = HEAP_SIZE;
			for (int i = 0; i < elems; i++)
			{
				if (array[i * 2] != 0)
				{
					num = (s.heap[++s.heap_len] = i);
					s.depth[i] = 0;
				}
				else
				{
					array[i * 2 + 1] = 0;
				}
			}
			int num2;
			while (s.heap_len < 2)
			{
				num2 = (s.heap[++s.heap_len] = ((num < 2) ? (++num) : 0));
				array[num2 * 2] = 1;
				s.depth[num2] = 0;
				s.opt_len--;
				if (treeCodes != null)
				{
					s.static_len -= treeCodes[num2 * 2 + 1];
				}
			}
			max_code = num;
			for (int i = s.heap_len / 2; i >= 1; i--)
			{
				s.pqdownheap(array, i);
			}
			num2 = elems;
			do
			{
				int i = s.heap[1];
				s.heap[1] = s.heap[s.heap_len--];
				s.pqdownheap(array, 1);
				int num3 = s.heap[1];
				s.heap[--s.heap_max] = i;
				s.heap[--s.heap_max] = num3;
				array[num2 * 2] = (short)(array[i * 2] + array[num3 * 2]);
				s.depth[num2] = (sbyte)(Math.Max((byte)s.depth[i], (byte)s.depth[num3]) + 1);
				array[i * 2 + 1] = (array[num3 * 2 + 1] = (short)num2);
				s.heap[1] = num2++;
				s.pqdownheap(ar

System.IO.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("System.IO")]
[assembly: AssemblyDescription("System.IO")]
[assembly: AssemblyDefaultAlias("System.IO")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.24705.01")]
[assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyVersion("4.1.1.0")]
[assembly: TypeForwardedTo(typeof(BinaryReader))]
[assembly: TypeForwardedTo(typeof(BinaryWriter))]
[assembly: TypeForwardedTo(typeof(BufferedStream))]
[assembly: TypeForwardedTo(typeof(EndOfStreamException))]
[assembly: TypeForwardedTo(typeof(FileNotFoundException))]
[assembly: TypeForwardedTo(typeof(InvalidDataException))]
[assembly: TypeForwardedTo(typeof(IOException))]
[assembly: TypeForwardedTo(typeof(MemoryStream))]
[assembly: TypeForwardedTo(typeof(SeekOrigin))]
[assembly: TypeForwardedTo(typeof(Stream))]
[assembly: TypeForwardedTo(typeof(StreamReader))]
[assembly: TypeForwardedTo(typeof(StreamWriter))]
[assembly: TypeForwardedTo(typeof(StringReader))]
[assembly: TypeForwardedTo(typeof(StringWriter))]
[assembly: TypeForwardedTo(typeof(TextReader))]
[assembly: TypeForwardedTo(typeof(TextWriter))]

System.Runtime.Extensions.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FxResources.System.Runtime.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyTitle("System.Runtime.Extensions")]
[assembly: AssemblyDescription("System.Runtime.Extensions")]
[assembly: AssemblyDefaultAlias("System.Runtime.Extensions")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.27406.03")]
[assembly: AssemblyInformationalVersion("4.6.27406.03. Commit Hash: 26264e3fd68356ff1a98375161b67b4426d02774")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.1.1.1")]
[assembly: TypeForwardedTo(typeof(BitConverter))]
[assembly: TypeForwardedTo(typeof(Convert))]
[assembly: TypeForwardedTo(typeof(Stopwatch))]
[assembly: TypeForwardedTo(typeof(Environment))]
[assembly: TypeForwardedTo(typeof(Path))]
[assembly: TypeForwardedTo(typeof(Math))]
[assembly: TypeForwardedTo(typeof(MidpointRounding))]
[assembly: TypeForwardedTo(typeof(WebUtility))]
[assembly: TypeForwardedTo(typeof(Progress<>))]
[assembly: TypeForwardedTo(typeof(Random))]
[assembly: TypeForwardedTo(typeof(FrameworkName))]
[assembly: TypeForwardedTo(typeof(StringComparer))]
[assembly: TypeForwardedTo(typeof(UriBuilder))]
[module: UnverifiableCode]
namespace FxResources.System.Runtime.Extensions
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class SR
	{
		private static ResourceManager s_resourceManager;

		private const string s_resourcesName = "FxResources.System.Runtime.Extensions.SR";

		private static ResourceManager ResourceManager
		{
			get
			{
				if (s_resourceManager == null)
				{
					s_resourceManager = new ResourceManager(ResourceType);
				}
				return s_resourceManager;
			}
		}

		internal static string Argument_AddingDuplicate => GetResourceString("Argument_AddingDuplicate", null);

		internal static string Argument_FrameworkNameMissingVersion => GetResourceString("Argument_FrameworkNameMissingVersion", null);

		internal static string Argument_FrameworkNameInvalid => GetResourceString("Argument_FrameworkNameInvalid", null);

		internal static string Argument_FrameworkNameInvalidVersion => GetResourceString("Argument_FrameworkNameInvalidVersion", null);

		internal static string Argument_FrameworkNameTooShort => GetResourceString("Argument_FrameworkNameTooShort", null);

		internal static string net_emptystringcall => GetResourceString("net_emptystringcall", null);

		internal static string Arg_ArrayPlusOffTooSmall => GetResourceString("Arg_ArrayPlusOffTooSmall", null);

		internal static string ArgumentOutOfRange_Index => GetResourceString("ArgumentOutOfRange_Index", null);

		internal static string ArgumentOutOfRange_GenericPositive => GetResourceString("ArgumentOutOfRange_GenericPositive", null);

		internal static string ArgumentOutOfRange_StartIndex => GetResourceString("ArgumentOutOfRange_StartIndex", null);

		internal static string ArgumentOutOfRange_LengthTooLarge => GetResourceString("ArgumentOutOfRange_LengthTooLarge", null);

		internal static string ArgumentOutOfRange_NeedNonNegNum => GetResourceString("ArgumentOutOfRange_NeedNonNegNum", null);

		internal static string ArgumentOutOfRange_FileLengthTooBig => GetResourceString("ArgumentOutOfRange_FileLengthTooBig", null);

		internal static string Arg_InvalidSearchPattern => GetResourceString("Arg_InvalidSearchPattern", null);

		internal static string Arg_PathGlobalRoot => GetResourceString("Arg_PathGlobalRoot", null);

		internal static string Arg_PathIllegal => GetResourceString("Arg_PathIllegal", null);

		internal static string Arg_PathIllegalUNC => GetResourceString("Arg_PathIllegalUNC", null);

		internal static string Arg_Path2IsRooted => GetResourceString("Arg_Path2IsRooted", null);

		internal static string Argument_InvalidPathChars => GetResourceString("Argument_InvalidPathChars", null);

		internal static string Argument_PathEmpty => GetResourceString("Argument_PathEmpty", null);

		internal static string Argument_MinMaxValue => GetResourceString("Argument_MinMaxValue", null);

		internal static string Argument_PathFormatNotSupported => GetResourceString("Argument_PathFormatNotSupported", null);

		internal static string Argument_PathUriFormatNotSupported => GetResourceString("Argument_PathUriFormatNotSupported", null);

		internal static string ArgumentOutOfRange_MustBePositive => GetResourceString("ArgumentOutOfRange_MustBePositive", null);

		internal static string IO_PathTooLong => GetResourceString("IO_PathTooLong", null);

		internal static string IO_FileNotFound => GetResourceString("IO_FileNotFound", null);

		internal static string UnauthorizedAccess_IODenied_NoPathName => GetResourceString("UnauthorizedAccess_IODenied_NoPathName", null);

		internal static string UnauthorizedAccess_IODenied_Path => GetResourceString("UnauthorizedAccess_IODenied_Path", null);

		internal static string IO_SharingViolation_NoFileName => GetResourceString("IO_SharingViolation_NoFileName", null);

		internal static string IO_FileNotFound_FileName => GetResourceString("IO_FileNotFound_FileName", null);

		internal static string IO_PathNotFound_NoPathName => GetResourceString("IO_PathNotFound_NoPathName", null);

		internal static string IO_PathNotFound_Path => GetResourceString("IO_PathNotFound_Path", null);

		internal static string IO_AlreadyExists_Name => GetResourceString("IO_AlreadyExists_Name", null);

		internal static string IO_SharingViolation_File => GetResourceString("IO_SharingViolation_File", null);

		internal static string IO_FileExists_Name => GetResourceString("IO_FileExists_Name", null);

		internal static string InvalidOperation_Cryptography => GetResourceString("InvalidOperation_Cryptography", null);

		internal static string UnknownError_Num => GetResourceString("UnknownError_Num", null);

		internal static Type ResourceType => typeof(SR);

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static bool UsingResourceKeys()
		{
			return false;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string text = null;
			try
			{
				text = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal))
			{
				return defaultString;
			}
			return text;
		}

		internal static string Format(string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + string.Join(", ", args);
				}
				return string.Format(resourceFormat, args);
			}
			return resourceFormat;
		}

		internal static string Format(string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(resourceFormat, p1);
		}

		internal static string Format(string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(resourceFormat, p1, p2);
		}

		internal static string Format(string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(resourceFormat, p1, p2, p3);
		}
	}
}

UltraSkins.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BatonPassLogger;
using BatonPassLogger.EX;
using BatonPassLogger.GUI;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Ionic.Zlib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UltraSkins.API;
using UltraSkins.UI;
using UltraSkins.Utils;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using plog;
using plog.Models;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UltraSkins")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("UltraSkins")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: AssemblyInformationalVersion("7.0.0+174d6e1bc3a39d9e51adb7df0d1460bb98b1cc28")]
[assembly: AssemblyProduct("UltraSkins")]
[assembly: AssemblyTitle("UltraSkins")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("7.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UltraSkins
{
	public class TextureOverWatch : MonoBehaviour
	{
		public Material[] cachedMaterials;

		public Renderer renderer;

		public bool forceswap;

		private string swapType = "weapon";

		public string iChange;

		private void OnEnable()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			ShotgunHammer componentInParent = ((Component)this).GetComponentInParent<ShotgunHammer>();
			Coin componentInParent2 = ((Component)this).GetComponentInParent<Coin>();
			if (Object.op_Implicit((Object)(object)((Component)this).GetComponentInParent<Nail>()))
			{
				swapType = "projectile";
			}
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				swapType = "projectile";
				if (ULTRASKINHand.HoldEm.Check("coin01_3"))
				{
					componentInParent2.uselessMaterial.mainTexture = ULTRASKINHand.HoldEm.Call("coin01_3");
				}
			}
			if ((Object)(object)componentInParent != (Object)null)
			{
				ULTRASKINHand.ReadOut.SwapTheDial(this);
				ULTRASKINHand.ReadOut.updateMeter(componentInParent, forceUpdateTexture: true);
			}
			if (Object.op_Implicit((Object)(object)((Component)this).GetComponentInParent<Grenade>()))
			{
				swapType = (((Component)this).GetComponentInParent<Grenade>().rocket ? "rocket" : "grenade");
				if (swapType == "rocket" && Object.op_Implicit((Object)(object)((Component)this).GetComponent<ChangeMaterials>()))
				{
					Material[] materials = ((Component)this).GetComponent<ChangeMaterials>().materials;
					Material val = new Material(materials[0]);
					materials[0] = val;
					if (ULTRASKINHand.HoldEm.Check("skull2rocketcharge"))
					{
						materials[0].mainTexture = ULTRASKINHand.HoldEm.Call("skull2rocketcharge");
					}
					if (ULTRASKINHand.HoldEm.Check("skull2rocketbonuscharge"))
					{
						materials[1].mainTexture = ULTRASKINHand.HoldEm.Call("skull2rocketbonuscharge");
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)renderer))
			{
				renderer = ((Component)this).GetComponent<Renderer>();
				Material[] materials2 = renderer.materials;
				foreach (Material val2 in materials2)
				{
					iChange = ((val2.HasProperty("_MainTex") && (Object)(object)val2.mainTexture != (Object)null) ? ((Object)val2.mainTexture).name : null);
					string key = "Swapped_" + swapType + "_" + ((Object)val2).name;
					if (!ULTRASKINHand.HandInstance.MaterialNames.ContainsKey(key))
					{
						string value = ((val2.HasProperty("_MainTex") && (Object)(object)val2.mainTexture != (Object)null) ? ((Object)val2.mainTexture).name : null);
						ULTRASKINHand.HandInstance.MaterialNames.Add(key, value);
					}
				}
			}
			if (renderer.materials != cachedMaterials)
			{
				UpdateMaterials();
			}
		}

		public void UpdateMaterials()
		{
			if (Object.op_Implicit((Object)(object)renderer) && renderer.materials != cachedMaterials)
			{
				Material[] materials = renderer.materials;
				for (int i = 0; i < materials.Length; i++)
				{
					ULTRASKINHand.PerformTheSwap(materials[i], forceswap, ((Component)((Component)this).transform).GetComponent<TextureOverWatch>(), swapType);
				}
				cachedMaterials = renderer.materials;
			}
			((Behaviour)((Component)((Component)this).transform).GetComponent<TextureOverWatch>()).enabled = false;
		}
	}
	public class TowStorage : MonoBehaviour
	{
		[SerializeField]
		public List<TextureOverWatch> TOWS;
	}
	[BepInPlugin("ultrakill.UltraSkins.bobthecorn", "UltraSkins", "7.0.0")]
	public class ULTRASKINHand : BaseUnityPlugin
	{
		[HarmonyPatch]
		public class HarmonyUIPatcher
		{
			[HarmonyPatch(typeof(StyleHUD), "Start")]
			[HarmonyPostfix]
			private static void StyleHudStartPost(StyleHUD __instance)
			{
				RANKTITLESWAPPER.swapthestylerank(__instance);
			}
		}

		[HarmonyPatch]
		public class HarmonyGunPatcher
		{
			public static List<TextureOverWatch> AddPTOWs(GameObject gameobject, bool refresh)
			{
				List<TextureOverWatch> list = new List<TextureOverWatch>();
				Renderer[] componentsInChildren = gameobject.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val in componentsInChildren)
				{
					if ((Object)(object)val != (Object)null && ((object)val).GetType() != typeof(ParticleSystemRenderer) && ((object)val).GetType() != typeof(CanvasRenderer) && ((object)val).GetType() != typeof(LineRenderer))
					{
						if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<TextureOverWatch>()))
						{
							TextureOverWatch item = ((Component)val).gameObject.AddComponent<TextureOverWatch>();
							list.Add(item);
						}
						else
						{
							((Behaviour)((Component)val).GetComponent<TextureOverWatch>()).enabled = refresh;
						}
					}
				}
				return list;
			}

			public static List<TextureOverWatch> AddTOWs(GameObject gameobject, bool toself = true, bool tochildren = false, bool toparent = false, bool refresh = false)
			{
				BatonPass.Debug("added " + ((Object)gameobject).name + "to textureoverwatch");
				List<TextureOverWatch> list = new List<TextureOverWatch>();
				if (toself)
				{
					if (!Object.op_Implicit((Object)(object)gameobject.GetComponent<TextureOverWatch>()))
					{
						TextureOverWatch item = gameobject.AddComponent<TextureOverWatch>();
						list.Add(item);
					}
					else
					{
						((Behaviour)gameobject.GetComponent<TextureOverWatch>()).enabled = refresh;
					}
				}
				if (toparent)
				{
					Renderer[] componentsInParent = gameobject.GetComponentsInParent<Renderer>();
					foreach (Renderer val in componentsInParent)
					{
						if ((Object)(object)val != (Object)null && ((object)val).GetType() != typeof(ParticleSystemRenderer) && ((object)val).GetType() != typeof(CanvasRenderer) && ((object)val).GetType() != typeof(LineRenderer))
						{
							if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<TextureOverWatch>()))
							{
								TextureOverWatch item2 = ((Component)val).gameObject.AddComponent<TextureOverWatch>();
								list.Add(item2);
							}
							else
							{
								((Behaviour)((Component)val).GetComponent<TextureOverWatch>()).enabled = refresh;
							}
						}
					}
				}
				if (tochildren)
				{
					Renderer[] componentsInParent = gameobject.GetComponentsInChildren<Renderer>();
					foreach (Renderer val2 in componentsInParent)
					{
						if ((Object)(object)val2 != (Object)null && ((object)val2).GetType() != typeof(ParticleSystemRenderer) && ((object)val2).GetType() != typeof(CanvasRenderer) && ((object)val2).GetType() != typeof(LineRenderer))
						{
							if (!Object.op_Implicit((Object)(object)((Component)val2).GetComponent<TextureOverWatch>()))
							{
								TextureOverWatch item3 = ((Component)val2).gameObject.AddComponent<TextureOverWatch>();
								list.Add(item3);
							}
							else
							{
								((Behaviour)((Component)val2).GetComponent<TextureOverWatch>()).enabled = refresh;
							}
						}
					}
				}
				return list;
			}

			[HarmonyPatch(typeof(GunControl), "SwitchWeapon", new Type[]
			{
				typeof(int),
				typeof(int?),
				typeof(bool),
				typeof(bool),
				typeof(bool)
			})]
			[HarmonyPostfix]
			public static void SwitchWeaponPost(GunControl __instance, int targetSlotIndex, int? targetVariationIndex = null, bool useRetainedVariation = false, bool cycleSlot = false, bool cycleVariation = false)
			{
			}

			[HarmonyPatch(typeof(ShopZone), "Start")]
			[HarmonyPostfix]
			public static void Start(ShopZone __instance)
			{
			}

			[HarmonyPatch(typeof(GunControl), "YesWeapon")]
			[HarmonyPostfix]
			public static void WeaponYesPost(GunControl __instance)
			{
				if (!__instance.noWeapons)
				{
					ReloadTextureOverWatch(__instance.currentWeapon.GetComponentsInChildren<TextureOverWatch>(true));
				}
			}

			[HarmonyPatch(typeof(GunControl), "UpdateWeaponList", new Type[] { typeof(bool) })]
			[HarmonyPostfix]
			public static void UpdateWeaponListPost(GunControl __instance, bool firstTime = false)
			{
				InitOWGameObjects(firsttime: true);
				ReloadTextureOverWatch(((Component)MonoSingleton<CameraController>.Instance).gameObject.GetComponentsInChildren<TextureOverWatch>(true));
			}

			[HarmonyPatch(typeof(FistControl), "YesFist")]
			[HarmonyPostfix]
			public static void YesFistPost(FistControl __instance)
			{
				if (Object.op_Implicit((Object)(object)__instance.currentArmObject))
				{
					ReloadTextureOverWatch(__instance.currentArmObject.GetComponentsInChildren<TextureOverWatch>(true));
				}
			}

			[HarmonyPatch(typeof(FistControl), "ArmChange", new Type[] { typeof(int) })]
			[HarmonyPostfix]
			public static void SwitchFistPost(FistControl __instance, int orderNum)
			{
				try
				{
					ReloadTextureOverWatch(__instance.currentArmObject.GetComponentsInChildren<TextureOverWatch>(true));
				}
				catch (ArgumentOutOfRangeException ex)
				{
					BatonPass.Warn("HEAR YEE HEAR YEE CurrentArmObject Argument Out of Range " + ex.ToString());
					BatonPass.Warn("currentArmObject is empty, this is normal if you are in 5-S, P-1 or P-2  CODE -\"USHAND-GUNPATCHER-FC_ARMCHANGE_SFP-ARG_OUT_OF_RANGE\"");
				}
			}

			[HarmonyPatch(typeof(FistControl), "ResetFists")]
			[HarmonyPostfix]
			public static void ResetFistsPost(FistControl __instance)
			{
				InitOWGameObjects();
				ReloadTextureOverWatch(__instance.currentArmObject.GetComponentsInChildren<TextureOverWatch>(true));
			}

			[HarmonyPatch(typeof(DualWieldPickup), "PickedUp")]
			[HarmonyPostfix]
			public static void DPickedupPost(DualWieldPickup __instance)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Invalid comparison between Unknown and I4
				if (!Object.op_Implicit((Object)(object)MonoSingleton<GunControl>.Instance) || (int)MonoSingleton<PlayerTracker>.Instance.playerType == 1)
				{
					return;
				}
				DualWield[] componentsInChildren = ((Component)MonoSingleton<GunControl>.Instance).GetComponentsInChildren<DualWield>(true);
				foreach (DualWield val in componentsInChildren)
				{
					if (!Object.op_Implicit((Object)(object)val))
					{
						continue;
					}
					Renderer[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val2 in componentsInChildren2)
					{
						if (Object.op_Implicit((Object)(object)val2) && ((Component)val2).gameObject.layer == 13 && !Object.op_Implicit((Object)(object)((Component)val2).gameObject.GetComponent<ParticleSystemRenderer>()) && !Object.op_Implicit((Object)(object)((Component)val2).gameObject.GetComponent<CanvasRenderer>()) && !Object.op_Implicit((Object)(object)((Component)val2).gameObject.GetComponent<TextureOverWatch>()))
						{
							((Component)val2).gameObject.AddComponent<TextureOverWatch>();
						}
					}
				}
			}

			[HarmonyPatch(typeof(DualWield), "UpdateWeapon")]
			[HarmonyPostfix]
			public static void DUpdateWPost(DualWield __instance)
			{
				ReloadTextureOverWatch(((Component)__instance).GetComponentsInChildren<TextureOverWatch>(true));
			}

			[HarmonyPatch(typeof(PlayerTracker), "ChangeToFPS")]
			[HarmonyPostfix]
			public static void ChangeToFPSPost(PlayerTracker __instance)
			{
				ReloadTextureOverWatch(GameObject.FindGameObjectWithTag("GunControl").GetComponent<GunControl>().currentWeapon.GetComponentsInChildren<TextureOverWatch>(true));
				ReloadTextureOverWatch(GameObject.FindGameObjectWithTag("MainCamera").GetComponentInChildren<FistControl>().currentArmObject.GetComponentsInChildren<TextureOverWatch>(true));
			}

			public static void ReloadTextureOverWatch(TextureOverWatch[] TOWS)
			{
				for (int i = 0; i < TOWS.Length; i++)
				{
					((Behaviour)TOWS[i]).enabled = true;
				}
			}
		}

		[HarmonyPatch]
		public class HarmonyProjectilePatcher
		{
			[HarmonyPatch(typeof(Nail), "Start")]
			[HarmonyPostfix]
			public static void NailPost(Nail __instance)
			{
				if (__instance.sawblade)
				{
					AddTOWs(((Component)__instance).gameObject, toself: false, tochildren: true);
				}
			}

			[HarmonyPatch(typeof(Magnet), "Start")]
			[HarmonyPostfix]
			public static void MagnetPost(Magnet __instance)
			{
				AddTOWs(((Component)((Component)__instance).transform.parent).gameObject, toself: false, tochildren: true);
			}

			[HarmonyPatch(typeof(Grenade), "Start")]
			[HarmonyPostfix]
			public static void GrenadePost(Grenade __instance)
			{
				AddTOWs(((Component)__instance).gameObject, toself: false, tochildren: true);
			}

			[HarmonyPatch(typeof(Coin), "Start")]
			[HarmonyPostfix]
			public static void coinPost(Coin __instance)
			{
				AddTOWs(((Component)__instance).gameObject, toself: false, tochildren: true);
			}

			public static void ReloadTextureOverWatch(TextureOverWatch[] TOWS)
			{
				for (int i = 0; i < TOWS.Length; i++)
				{
					((Behaviour)TOWS[i]).enabled = true;
				}
			}

			public static void AddTOWs(GameObject gameobject, bool toself = true, bool tochildren = false, bool toparent = false, bool refresh = false)
			{
				BatonPass.Debug("added " + ((Object)gameobject).name + "to textureoverwatch");
				if (toself)
				{
					if (!Object.op_Implicit((Object)(object)gameobject.GetComponent<TextureOverWatch>()))
					{
						gameobject.AddComponent<TextureOverWatch>();
					}
					else
					{
						((Behaviour)gameobject.GetComponent<TextureOverWatch>()).enabled = refresh;
					}
				}
				Renderer[] componentsInParent;
				if (toparent)
				{
					componentsInParent = gameobject.GetComponentsInParent<Renderer>();
					foreach (Renderer val in componentsInParent)
					{
						if ((Object)(object)val != (Object)null && ((object)val).GetType() != typeof(ParticleSystemRenderer) && ((object)val).GetType() != typeof(CanvasRenderer) && ((object)val).GetType() != typeof(LineRenderer))
						{
							if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<TextureOverWatch>()))
							{
								((Component)val).gameObject.AddComponent<TextureOverWatch>();
							}
							else
							{
								((Behaviour)((Component)val).GetComponent<TextureOverWatch>()).enabled = refresh;
							}
						}
					}
				}
				if (!tochildren)
				{
					return;
				}
				componentsInParent = gameobject.GetComponentsInChildren<Renderer>();
				foreach (Renderer val2 in componentsInParent)
				{
					if ((Object)(object)val2 != (Object)null && ((object)val2).GetType() != typeof(ParticleSystemRenderer) && ((object)val2).GetType() != typeof(CanvasRenderer) && ((object)val2).GetType() != typeof(LineRenderer))
					{
						if (!Object.op_Implicit((Object)(object)((Component)val2).GetComponent<TextureOverWatch>()))
						{
							((Component)val2).gameObject.AddComponent<TextureOverWatch>();
						}
						else
						{
							((Behaviour)((Component)val2).GetComponent<TextureOverWatch>()).enabled = refresh;
						}
					}
				}
			}
		}

		internal class RANKTITLESWAPPER
		{
			internal static void swapthestylerank(StyleHUD stylehudINST)
			{
				BatonPass.Debug("stylehud has started");
				foreach (StyleRank rank in stylehudINST.ranks)
				{
					string name = ((Object)rank.sprite).name;
					BatonPass.Debug("looking for " + name);
					if (HoldEm.Bluff(HoldEm.HoldemType.SC, name))
					{
						rank.sprite = HoldEm.Draw<Sprite>(HoldEm.HoldemType.SC, name);
						BatonPass.Debug("found in bluff");
					}
				}
			}

			internal static void makethestylerank(USAPI.TextureLoadEventArgs e)
			{
				if (!e.Failed)
				{
					string[] obj = new string[8] { "RankSSS", "RankSS", "RankS", "RankA", "RankB", "RankC", "RankD", "RankU" };
					BatonPass.Debug("stylehud has started");
					string[] array = obj;
					foreach (string text in array)
					{
						HoldEm.Bet(HoldEm.HoldemType.SC, text, HoldEm.Call(text));
						BatonPass.Debug("Betting " + text);
					}
				}
			}
		}

		internal class ReadOut
		{
			internal delegate void UpdateMeterDelegate(ShotgunHammer instance, bool forceUpdateTexture = false);

			private static readonly FieldRef<ShotgunHammer, Texture[]> meterEmissivesRef = AccessTools.FieldRefAccess<ShotgunHammer, Texture[]>("meterEmissives");

			private static readonly FieldRef<ShotgunHammer, Image> secondaryMeterRef = AccessTools.FieldRefAccess<ShotgunHammer, Image>("secondaryMeter");

			private static MethodInfo updateMeterMethod = AccessTools.Method(typeof(ShotgunHammer), "UpdateMeter", (Type[])null, (Type[])null);

			internal static UpdateMeterDelegate updateMeter = AccessTools.MethodDelegate<UpdateMeterDelegate>(updateMeterMethod, (object)null, true);

			internal static void SwapTheDial(TextureOverWatch TOW)
			{
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Expected O, but got Unknown
				if (meterEmissivesRef == null)
				{
					BatonPass.Error("Failed to find 'meterEmissives' field.");
					return;
				}
				ShotgunHammer componentInParent = ((Component)TOW).GetComponentInParent<ShotgunHammer>();
				Texture[] array = meterEmissivesRef.Invoke(componentInParent);
				Image val = secondaryMeterRef.Invoke(componentInParent);
				Texture val2 = ((!HoldEm.Check("T_DialGlow1")) ? array[0] : HoldEm.Call("T_DialGlow1"));
				Texture val3 = ((!HoldEm.Check("T_DialGlow2")) ? array[1] : HoldEm.Call("T_DialGlow2"));
				Texture val4 = ((!HoldEm.Check("T_DialGlow3")) ? array[2] : HoldEm.Call("T_DialGlow3"));
				meterEmissivesRef.Invoke(componentInParent) = (Texture[])(object)new Texture[3] { val2, val3, val4 };
				if (HoldEm.Check("T_DialMask"))
				{
					Texture val5 = HoldEm.Call("T_DialMask");
					Sprite sprite = Sprite.Create((Texture2D)val5, new Rect(0f, 0f, (float)val5.width, (float)val5.height), new Vector2(0.5f, 0.5f));
					val.sprite = sprite;
				}
			}
		}

		public enum archivetype
		{
			folder,
			zip,
			gcskin
		}

		public class TexOpData
		{
			public List<(string name, byte[] data)> RawData = new List<(string, byte[])>();

			public float ProgressState { get; set; }

			public bool FailState { get; set; }
		}

		public class UniOpData
		{
			public float ProgressState { get; set; }

			public bool FailState { get; set; }
		}

		public class HoldEm
		{
			public enum HoldemType
			{
				ASC,
				OGS,
				IC,
				SC
			}

			public static Texture Call(string key)
			{
				if (autoSwapCache.TryGetValue(key, out var value))
				{
					BatonPass.Debug("ASC Call:" + key);
					return value;
				}
				if (HandInstance.ogSkinsManager.OGSKINS.TryGetValue(key, out var value2))
				{
					BatonPass.Debug("OGS Call:" + key);
					return value2;
				}
				BatonPass.Debug("Call NoKeyFound" + key);
				return null;
			}

			public static bool Check(string key)
			{
				if (autoSwapCache.ContainsKey(key))
				{
					BatonPass.Debug("ASC Check:" + key);
					return true;
				}
				if (HandInstance.ogSkinsManager.OGSKINS.ContainsKey(key))
				{
					BatonPass.Debug("OGS Check:" + key);
					return true;
				}
				BatonPass.Debug("Check NoKeyFound" + key);
				return false;
			}

			public static void Discard(HoldemType holdemType, string name)
			{
				switch (holdemType)
				{
				case HoldemType.ASC:
					if (autoSwapCache.ContainsKey(name))
					{
						Object.Destroy((Object)(object)autoSwapCache[name]);
						autoSwapCache.Remove(name);
					}
					break;
				case HoldemType.OGS:
					if (HandInstance.ogSkinsManager.OGSKINS.ContainsKey(name))
					{
						Object.Destroy((Object)(object)HandInstance.ogSkinsManager.OGSKINS[name]);
						HandInstance.ogSkinsManager.OGSKINS.Remove(name);
					}
					break;
				case HoldemType.IC:
					if (HandInstance.IconCache.ContainsKey(name))
					{
						HandInstance.IconCache.Remove(name);
					}
					break;
				case HoldemType.SC:
					if (HandInstance.SpriteCache.ContainsKey(name))
					{
						HandInstance.SpriteCache.Remove(name);
					}
					break;
				}
			}

			public static void Bet(HoldemType holdemType, string TextureName, Texture texture2D)
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				switch (holdemType)
				{
				case HoldemType.ASC:
					autoSwapCache.Add(TextureName, texture2D);
					break;
				case HoldemType.OGS:
					HandInstance.ogSkinsManager.OGSKINS.Add(TextureName, texture2D);
					break;
				case HoldemType.IC:
					HandInstance.IconCache.Add(TextureName, (Texture2D)(object)((texture2D is Texture2D) ? texture2D : null));
					break;
				case HoldemType.SC:
				{
					texture2D.filterMode = (FilterMode)1;
					Sprite value = Sprite.Create((Texture2D)(object)((texture2D is Texture2D) ? texture2D : null), new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), new Vector2(0.5f, 0.5f));
					HandInstance.SpriteCache.Add(TextureName, value);
					break;
				}
				}
			}

			public static T Draw<T>(HoldemType holdemType, string name) where T : class
			{
				switch (holdemType)
				{
				case HoldemType.ASC:
				{
					autoSwapCache.TryGetValue(name, out var value4);
					return ((value4 is Texture2D) ? value4 : null) as T;
				}
				case HoldemType.OGS:
				{
					HandInstance.ogSkinsManager.OGSKINS.TryGetValue(name, out var value3);
					return ((value3 is Texture2D) ? value3 : null) as T;
				}
				case HoldemType.IC:
				{
					HandInstance.IconCache.TryGetValue(name, out var value2);
					return value2 as T;
				}
				case HoldemType.SC:
				{
					HandInstance.SpriteCache.TryGetValue(name, out var value);
					return value as T;
				}
				default:
					return null;
				}
			}

			public static bool Bluff(HoldemType holdemType, string name)
			{
				return holdemType switch
				{
					HoldemType.ASC => autoSwapCache.ContainsKey(name), 
					HoldemType.OGS => HandInstance.ogSkinsManager.OGSKINS.ContainsKey(name), 
					HoldemType.IC => HandInstance.IconCache.ContainsKey(name), 
					HoldemType.SC => HandInstance.SpriteCache.ContainsKey(name), 
					_ => false, 
				};
			}

			public static void Fold(HoldemType holdemType)
			{
				switch (holdemType)
				{
				case HoldemType.ASC:
					foreach (KeyValuePair<string, Texture> item in autoSwapCache)
					{
						string key2 = item.Key;
						BatonPass.Debug("Deleting " + key2 + " from Holdem ASC");
						Object.Destroy((Object)(object)autoSwapCache[key2]);
					}
					autoSwapCache.Clear();
					break;
				case HoldemType.OGS:
					foreach (KeyValuePair<string, Texture> oGSKIN in HandInstance.ogSkinsManager.OGSKINS)
					{
						string key3 = oGSKIN.Key;
						BatonPass.Debug("Deleting " + key3 + " from Holdem ASC");
						Object.Destroy((Object)(object)HandInstance.ogSkinsManager.OGSKINS[key3]);
					}
					HandInstance.ogSkinsManager.OGSKINS.Clear();
					break;
				case HoldemType.IC:
					HandInstance.IconCache.Clear();
					break;
				case HoldemType.SC:
					foreach (KeyValuePair<string, Sprite> item2 in HandInstance.SpriteCache)
					{
						string key = item2.Key;
						BatonPass.Debug("Deleting " + key + " from Holdem SC");
						Object.Destroy((Object)(object)HandInstance.SpriteCache[key]);
					}
					HandInstance.SpriteCache.Clear();
					break;
				}
			}
		}

		public const string PLUGIN_NAME = "UltraSkins";

		public const string PLUGIN_GUID = "ultrakill.UltraSkins.bobthecorn";

		public const string PLUGIN_VERSION = "7.0.0";

		private string modFolderPath;

		public bool loadTextureLock;

		public BPGUIManager BPGUI;

		private string skinfolderdir;

		public string[] filepathArray;

		private List<Sprite> _default;

		private List<Sprite> _edited;

		private bool firstmenu = true;

		public string folderupdater;

		public static Dictionary<string, Texture> autoSwapCache = new Dictionary<string, Texture>();

		public OGSkinsManager ogSkinsManager;

		public Dictionary<string, string> MaterialNames = new Dictionary<string, string>();

		public string[] directories;

		public string serializedSet = "";

		public bool swapped;

		public SettingsManager settingsmanager;

		public TowStorage PtowStorage;

		public Dictionary<string, Texture2D> IconCache = new Dictionary<string, Texture2D>();

		public Dictionary<string, Sprite> SpriteCache = new Dictionary<string, Sprite>();

		private Harmony UKSHarmony;

		public bool ThunderStoreMode;

		public string[] ThunderProfInfo;

		public bool OldSaveDataFound;

		public static ManualLogSource BatonPassLogger = new ManualLogSource("BatonPass");

		public static ULTRASKINHand HandInstance { get; private set; }

		private void Awake()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			Logger.Sources.Add((ILogSource)(object)BatonPassLogger);
			BatonPass.RegisterTerminal(new BepInExTerminal(BatonPassLogger));
			BatonPass.RegisterTerminal(new UKPlog("UltraSkins"));
			if ((Object)(object)HandInstance == (Object)null)
			{
				HandInstance = this;
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
			BatonPass.Info("Attempting to start");
			BatonPass.Debug("Plugin path set to " + USC.MODPATH);
			BatonPass.Debug("NAVI: APPDATAPATH AT: " + USC.GCDIR);
			BatonPass.Debug("Starting addressables");
			Assembly.Load(File.ReadAllBytes(Path.Combine(USC.MODPATH, "usUI.dll")));
			BatonPass.Debug("Looking for the Config");
			Addressables.LoadContentCatalogAsync(Path.Combine(USC.MODPATH, "catalog.json"), true, (string)null).WaitForCompletion();
			BatonPass.Info("Finishing setup");
			SceneManager.activeSceneChanged += SceneManagerOnsceneLoaded;
			BatonPass.Info("Scenemanager Created");
			USAPI.OnTexLoadFinished += RANKTITLESWAPPER.makethestylerank;
			BatonPass.Info("Subscribing to the API");
			BatonPass.Debug("INIT BATON PASS: ONMODLOADED()");
			OnModLoaded();
		}

		private void Start()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			BatonPass.Info("Starting BatonPassGUI");
			if ((Object)(object)BPGUIManager.BPGUIinstance == (Object)null)
			{
				new GameObject("BPGUIManager").AddComponent<BPGUIManager>();
				BPGUI = BPGUIManager.BPGUIinstance;
			}
			MenuCreator.CreateSMan();
		}

		public void OnModLoaded()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			UKSHarmony = new Harmony("Gcorn.UltraSkins");
			UKSHarmony.PatchAll(typeof(HarmonyGunPatcher));
			UKSHarmony.PatchAll(typeof(HarmonyProjectilePatcher));
			UKSHarmony.PatchAll();
			BatonPass.Success("BATON PASS: Welcome To Ultraskins, We are on the ONMODLOADED() STEP");
			try
			{
				BatonPass.Debug("Creating the SkinEvent Handler");
				ThunderProfInfo = SkinEventHandler.GetThunderstoreProfileName();
				if (ThunderProfInfo != null)
				{
					ThunderStoreMode = true;
				}
				SkinEventHandler skinEventHandler = new SkinEventHandler();
				BatonPass.Debug("INIT BATON PASS: GETMODFOLDERPATH()");
				BatonPass.Debug("BATON PASS: WELCOME BACK TO ONMODLOADED() WE RECIEVED " + skinEventHandler.GetModFolderPath());
				HandInstance.MaterialNames.Add("Swapped_weapon_GreenArm (Instance)(Clone) (Instance)", "T_GreenArm");
				HandInstance.MaterialNames.Add("Swapped_weapon_FeedbackerLit (Instance)(Clone) (Instance)", "T_Feedbacker");
				HandInstance.MaterialNames.Add("Swapped_weapon_RedArmLit (Instance)(Clone) (Instance)", "v2_armtex");
				HandInstance.MaterialNames.Add("Swapped_weapon_MainArmLit (Instance)(Clone) (Instance)", "T_MainArm");
			}
			catch (Exception ex)
			{
				BatonPass.Error("Hear Ye Hear Ye, ULTRASKINS HAS FAILED Error -\"USHAND-ONMODLOADED\"" + ex.Message);
			}
		}

		public void refreshskins(string[] clickedButtons)
		{
			BatonPass.Debug("BATON PASS: WE ARE IN REFRESHSKINS()");
			SkinEventHandler.StringSerializer stringSerializer = new SkinEventHandler.StringSerializer();
			BatonPass.Debug("Created The Serializer");
			BatonPass.Debug("looking for the dll, appdata paths and merging the directory strings");
			string dataFile = SkinEventHandler.getDataFile();
			List<string> list = new List<string>();
			string[] array = clickedButtons;
			foreach (string text in array)
			{
				list.Add(Path.Combine(text));
				BatonPass.Debug("added " + text);
			}
			filepathArray = list.ToArray();
			array = filepathArray;
			for (int i = 0; i < array.Length; i++)
			{
				BatonPass.Debug(array[i]);
			}
			BatonPass.Debug("folderis: " + list);
			stringSerializer.SerializeStringToFile(filepathArray, Path.Combine(dataFile));
			BatonPass.Success("Saved to data.USGC");
			BatonPass.Debug("INIT BATON PASS: RELOADTEXTURES(TRUE," + list?.ToString() + ")");
			ReloadTextures(filepathArray);
			BatonPass.Debug("BATON PASS: WELCOME BACK TO REFRESHSKINS()");
			BatonPass.Info("Closing panel");
		}

		private void refreshskins()
		{
			BatonPass.Debug("BATON PASS: WE ARE IN REFRESHSKINS(), THERE ARE NO OTHER ARGUMENTS");
			SkinEventHandler.StringSerializer stringSerializer = new SkinEventHandler.StringSerializer();
			BatonPass.Debug("Created The Serializer");
			BatonPass.Debug("looking for the dll, appdata paths and merging the directory strings");
			string dataFile = SkinEventHandler.getDataFile();
			filepathArray = stringSerializer.DeserializeStringFromFile(dataFile);
			BatonPass.Info("Read data.USGC from " + filepathArray);
			BatonPass.Debug("INIT BATON PASS: RELOADTEXTURES(TRUE," + filepathArray?.ToString() + ")");
			ReloadTextures(filepathArray, firsttime: true);
		}

		public static Transform FindDeepChildByPathIncludeInactive(Transform root, string path)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			string[] array = path.Split('/');
			Transform val = root;
			string[] array2 = array;
			foreach (string text in array2)
			{
				bool flag = false;
				foreach (Transform item in val)
				{
					Transform val2 = item;
					if (((Object)val2).name == text)
					{
						val = val2;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					return null;
				}
			}
			return val;
		}

		private void SceneManagerOnsceneLoaded(Scene scene, Scene mode)
		{
			BatonPass.Debug("BATON PASS: WE ARE IN SceneManagerOnsceneLoaded()");
			swapped = false;
			BatonPass.Debug("Checking for Null CCE");
			BatonPass.Info("The Scene is: " + ((Scene)(ref mode)).name);
			BatonPass.Debug("INIT BATON PASS: REFRESHSKINS()");
			if (((Scene)(ref mode)).name == "b3e7f2f8052488a45b35549efb98d902")
			{
				MenuCreator.makethemenu();
				if (firstmenu)
				{
					firstmenu = false;
					refreshskins();
				}
			}
			else if (((Scene)(ref mode)).name == "Bootstrap")
			{
				BatonPass.Info("Cant make menu, currently straping my boots");
			}
			else if (((Scene)(ref mode)).name == "241a6a8caec7a13438a5ee786040de32")
			{
				BatonPass.Info("Cant make menu, currently watching a movie");
			}
		}

		public static Texture ResolveTheTextureProperty(Material mat, string property, string texturename, string propertyfallback = "_MainTex")
		{
			if ((Object)(object)mat != (Object)null && texturename == null)
			{
				return null;
			}
			string text = "";
			if (Object.op_Implicit((Object)(object)mat) && !texturename.StartsWith("TNR_") && property != "_Cube")
			{
				switch (property)
				{
				case "_MainTex":
					text = texturename;
					break;
				case "_EmissiveTex":
					switch (texturename)
					{
					case "T_NailgunNew_NoGlow":
						text = "T_Nailgun_New_Glow";
						break;
					case "T_RocketLauncher_Desaturated":
						text = "T_RocketLauncher_Emissive";
						if (HoldEm.Check(text))
						{
							mat.EnableKeyword("EMISSIVE");
							mat.SetInt("_UseAlbedoAsEmissive", 0);
						}
						break;
					case "T_ImpactHammer":
						text = "T_ImpactHammer_Glow";
						break;
					default:
						text = texturename + "_Emissive";
						if (HoldEm.Check(text))
						{
							mat.EnableKeyword("EMISSIVE");
							mat.SetInt("_UseAlbedoAsEmissive", 0);
						}
						break;
					}
					break;
				case "_IDTex":
					text = ((Object)mat.mainTexture).name switch
					{
						"T_RocketLauncher_Desaturated" => "T_RocketLauncher_ID", 
						"T_NailgunNew_NoGlow" => "T_NailgunNew_ID", 
						"Railgun_Main_AlphaGlow" => "T_Railgun_ID", 
						_ => ((Object)mat.mainTexture).name + "_ID", 
					};
					break;
				case "ROCKIT":
					text = ((((Object)mat).name.Contains("Swapped_rocket_AltarUnlitRed") && !texturename.StartsWith("T_")) ? "skull2rocketbonus" : (texturename.Contains("T_Sakuya") ? "" : "skull2rocket"));
					break;
				case "THROWITBACK":
					text = "skull2grenade";
					break;
				default:
					text = "";
					break;
				}
				if (text != "" && HoldEm.Check(text))
				{
					return HoldEm.Call(text);
				}
			}
			return mat.GetTexture(propertyfallback);
		}

		private string GetTextureName(string materialName)
		{
			if (HandInstance.MaterialNames.TryGetValue(materialName, out var value))
			{
				return value;
			}
			return null;
		}

		public static void PerformTheSwap(Material mat, bool forceswap = false, TextureOverWatch TOW = null, string swapType = "weapon")
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0131: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)mat) || !(!((Object)mat).name.StartsWith("Swapped_") || forceswap))
			{
				return;
			}
			if (!((Object)mat).name.StartsWith("Swapped_"))
			{
				((Object)mat).name = "Swapped_" + swapType + "_" + ((Object)mat).name;
			}
			forceswap = false;
			Texture val = new Texture();
			string textureName = HandInstance.GetTextureName(((Object)mat).name);
			BatonPass.Info("I should change" + TOW.iChange);
			BatonPass.Debug("requested " + ((Object)mat).name + " got " + textureName);
			switch (swapType)
			{
			case "weapon":
			{
				string[] texturePropertyNames = mat.GetTexturePropertyNames();
				foreach (string text in texturePropertyNames)
				{
					val = ResolveTheTextureProperty(mat, text, textureName, text);
					if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)null && mat.HasProperty(text) && (Object)(object)mat.GetTexture(text) != (Object)(object)val)
					{
						mat.SetTexture(text, val);
					}
					if ((Object)(object)TOW != (Object)null && mat.HasProperty("_EmissiveColor"))
					{
						if (((Object)mat).name.ToString() == "Swapped_weapon_ImpactHammerDial (Instance)")
						{
							break;
						}
						Color varationColor = GetVarationColor(TOW);
						new Color(255f, 255f, 255f, 255f);
						mat.SetColor("_EmissiveColor", varationColor);
					}
				}
				break;
			}
			case "projectile":
				val = ResolveTheTextureProperty(mat, "_MainTex", textureName);
				if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)null && mat.HasProperty("_MainTex") && (Object)(object)mat.GetTexture("_MainTex") != (Object)(object)val)
				{
					mat.SetTexture("_MainTex", val);
				}
				break;
			case "grenade":
				val = ResolveTheTextureProperty(mat, "THROWITBACK", textureName);
				if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)null && mat.HasProperty("_MainTex") && (Object)(object)mat.GetTexture("_MainTex") != (Object)(object)val)
				{
					mat.SetTexture("_MainTex", val);
				}
				break;
			case "rocket":
				val = ResolveTheTextureProperty(mat, "ROCKIT", textureName);
				if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)null && mat.HasProperty("_MainTex") && (Object)(object)mat.GetTexture("_MainTex") != (Object)(object)val)
				{
					mat.SetTexture("_MainTex", val);
				}
				break;
			}
		}

		public static Color GetVarationColor(TextureOverWatch TOW)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			Color result = default(Color);
			((Color)(ref result))..ctor(0f, 0f, 0f, 0f);
			if (Object.op_Implicit((Object)(object)((Component)TOW).GetComponentInParent<WeaponIcon>()))
			{
				WeaponIcon componentInParent = ((Component)TOW).GetComponentInParent<WeaponIcon>();
				int num = (int)((object)componentInParent).GetType().GetProperty("variationColor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentInParent);
				((Color)(ref result))..ctor(MonoSingleton<ColorBlindSettings>.Instance.variationColors[num].r, MonoSingleton<ColorBlindSettings>.Instance.variationColors[num].g, MonoSingleton<ColorBlindSettings>.Instance.variationColors[num].b, 1f);
			}
			else if (Object.op_Implicit((Object)(object)((Component)TOW).GetComponentInParent<Punch>()))
			{
				FistType type = ((Component)TOW).GetComponentInParent<Punch>().type;
				if ((int)type != 0)
				{
					if ((int)type == 1)
					{
						((Color)(ref result))..ctor(MonoSingleton<ColorBlindSettings>.Instance.variationColors[2].r, MonoSingleton<ColorBlindSettings>.Instance.variationColors[2].g, MonoSingleton<ColorBlindSettings>.Instance.variationColors[2].b, 1f);
					}
				}
				else
				{
					((Color)(ref result))..ctor(MonoSingleton<ColorBlindSettings>.Instance.variationColors[0].r, MonoSingleton<ColorBlindSettings>.Instance.variationColors[0].g, MonoSingleton<ColorBlindSettings>.Instance.variationColors[0].b, 1f);
				}
			}
			else if (Object.op_Implicit((Object)(object)((Component)TOW).GetComponentInParent<HookArm>()))
			{
				((Color)(ref result))..ctor(MonoSingleton<ColorBlindSettings>.Instance.variationColors[1].r, MonoSingleton<ColorBlindSettings>.Instance.variationColors[1].g, MonoSingleton<ColorBlindSettings>.Instance.variationColors[1].b, 1f);
			}
			else
			{
				Object.op_Implicit((Object)(object)((Component)TOW).GetComponentInParent<BandScroller>());
			}
			return result;
		}

		public static bool CheckTextureInCache(string name)
		{
			if (autoSwapCache.ContainsKey(name))
			{
				return true;
			}
			return false;
		}

		public async void ReloadTextures(string[] path, bool firsttime = false)
		{
			BatonPass.Debug("BATON PASS: WE ARE IN ReloadTextures() We have variables \n FIRSTTIME:" + firsttime + "\n PATH:" + path);
			BatonPass.Debug("Start Comparing");
			BatonPass.Debug("INIT BATON PASS: INITOWGAMEOBJECTS(" + firsttime + ")");
			BatonPass.Debug("BATON PASS: WELCOME BACK TO RELOADTEXTURES()");
			BatonPass.Debug("INIT BATON PASS: LOADTEXTURES(" + path?.ToString() + ")");
			if (firsttime)
			{
				await LoadTextures(path, firsttime);
			}
			else
			{
				MenuManager.MMinstance.DisableButtons();
				await LoadTextures(path, firsttime);
				MenuManager.MMinstance.EnableButtons();
			}
			InitOWGameObjects(firsttime);
			foreach (KeyValuePair<string, string> materialName in HandInstance.MaterialNames)
			{
				BatonPass.Debug("Key: " + materialName.Key + ", Value: " + materialName.Value);
			}
		}

		private bool AssetInUse(Object asset)
		{
			return Resources.FindObjectsOfTypeAll<Component>().Any(delegate(Component c)
			{
				Renderer val = (Renderer)(object)((c is Renderer) ? c : null);
				if (val == null || !val.sharedMaterials.Any((Material m) => Object.op_Implicit((Object)(object)m) && m.HasProperty("_MainTex") && (Object)(object)m.mainTexture == asset))
				{
					Image val2 = (Image)(object)((c is Image) ? c : null);
					if (val2 == null || !Object.op_Implicit((Object)(object)val2.sprite) || !((Object)(object)val2.sprite.texture == asset))
					{
						RawImage val3 = (RawImage)(object)((c is RawImage) ? c : null);
						if (val3 != null)
						{
							return (Object)(object)val3.texture == asset;
						}
						return false;
					}
				}
				return true;
			});
		}

		public static void InitOWGameObjects(bool firsttime = false)
		{
			Renderer[] componentsInChildren = GameObject.FindGameObjectWithTag("MainCamera").GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (((Component)val).gameObject.layer == 13 && !Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<ParticleSystemRenderer>()) && !Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<TrailRenderer>()) && !Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<LineRenderer>()))
				{
					if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<TextureOverWatch>()) && !firsttime)
					{
						TextureOverWatch component = ((Component)val).GetComponent<TextureOverWatch>();
						((Behaviour)component).enabled = true;
						component.forceswap = true;
					}
					else if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<TextureOverWatch>()))
					{
						((Behaviour)((Component)val).gameObject.AddComponent<TextureOverWatch>()).enabled = true;
					}
				}
			}
			foreach (TextureOverWatch tOW in HandInstance.PtowStorage.TOWS)
			{
				((Behaviour)tOW).enabled = true;
				tOW.forceswap = true;
			}
		}

		public async Task LoadTextures(string[] fpaths, bool firsttime = false)
		{
			float num = 0f;
			if (!firsttime)
			{
				BPGUI.ShowGUI("Loading:Gathering Info");
				BatonPass.Info("Loading: Gathering Info");
			}
			float num2 = autoSwapCache.Count;
			for (int i = 0; i < fpaths.Length; i++)
			{
				FileInfo[] files = new DirectoryInfo(fpaths[i]).GetFiles("*.png");
				num2 += (float)files.Length;
			}
			BatonPass.Debug("BATON PASS: WE ARE IN LOADTEXTURES() we have the variable FPATH");
			BPGUI.EnableTerminal(10);
			BPGUI.ShowProgressBar(num2);
			foreach (KeyValuePair<string, Texture> item in autoSwapCache)
			{
				num += 1f;
				BPGUI.updatebar(num);
				string key = item.Key;
				BatonPass.Debug("Deleting " + key + " from Holdem ASC");
				BPGUI.AddTermLine("Creating " + key + " from Holdem ASC");
				Object.Destroy((Object)(object)autoSwapCache[key]);
			}
			autoSwapCache.Clear();
			HoldEm.Fold(HoldEm.HoldemType.SC);
			Array.Reverse(fpaths);
			BatonPass.Debug("starting ForEach");
			bool failed = false;
			foreach (string text in fpaths)
			{
				TexOpData texOpData = new TexOpData();
				if (TypeDetection(text) == archivetype.folder)
				{
					texOpData = await LoadTexturesFromFolder(text);
				}
				await ConvertToTextures(texOpData);
			}
			if (!failed)
			{
				BPGUI.DisableTerminal();
				BPGUI.HideProgressBar();
				BPGUI.BatonPassAnnoucement(Color.green, "success");
			}
			if (!firsttime)
			{
				BPGUI.HideGUI(2f);
			}
			USAPI.BroadcastTextureFinished(new USAPI.TextureLoadEventArgs(failed));
		}

		public archivetype TypeDetection(string path)
		{
			if (Path.GetExtension(path).Equals(".zip", StringComparison.OrdinalIgnoreCase))
			{
				return archivetype.zip;
			}
			return archivetype.folder;
		}

		public async Task<TexOpData> LoadTexturesFromFolder(string fpath, float ProgressDone = 0f, bool failed = false)
		{
			TexOpData texOpData = new TexOpData();
			try
			{
				BatonPass.Info("ULTRASKINS IS SEARCHING " + fpath.ToString());
				DirectoryInfo directoryInfo = new DirectoryInfo(fpath);
				if (!directoryInfo.Exists)
				{
					BPGUI.DisableTerminal();
					BPGUI.BatonPassAnnoucement(Color.red, "failed, CODE - \"USHAND-LOADTEXTURES-DIR_NOT_FOUND\" \n FILEPATH:" + fpath);
					BatonPass.Error("Dir does not exist, CODE - \"USHAND-LOADTEXTURES-DIR_NOT_FOUND\" ");
					failed = true;
					BPGUI.HideGUI(5f);
					return null;
				}
				FileInfo[] files = directoryInfo.GetFiles("*.png");
				BatonPass.Debug("Beginning file swap loop");
				if (files.Length != 0)
				{
					_ = files.Length;
					FileInfo[] array = files;
					foreach (FileInfo file in array)
					{
						if (file.Exists)
						{
							try
							{
								byte[] item = await File.ReadAllBytesAsync(file.FullName);
								string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
								if (autoSwapCache.ContainsKey(fileNameWithoutExtension))
								{
									Object.Destroy((Object)(object)autoSwapCache[fileNameWithoutExtension]);
									autoSwapCache.Remove(fileNameWithoutExtension);
								}
								BatonPass.Debug("Reading " + file.FullName.ToString());
								texOpData.RawData.Add((fileNameWithoutExtension, item));
								BPGUI.AddTermLine("Creating " + fileNameWithoutExtension);
							}
							catch (Exception ex)
							{
								((BaseUnityPlugin)this).Logger.LogError((object)("Error reading or processing texture file: " + file.Name + " Error: " + ex.Message));
								failed = true;
								BPGUI.DisableTerminal();
								BPGUI.BatonPassAnnoucement(Color.red, "failed");
							}
						}
						else
						{
							BatonPass.Error("HEAR YE HEAR YE, They got away, CODE -\"USHAND-LOADTEXTURES-CACHEFAIL\"");
							failed = true;
							BPGUI.DisableTerminal();
							BPGUI.BatonPassAnnoucement(Color.red, "failed");
						}
						ProgressDone++;
						BPGUI.updatebar(ProgressDone);
					}
					if (!failed)
					{
						BatonPass.Info("We Got the Textures from " + fpath);
					}
				}
				else
				{
					BatonPass.Error("HEAR YE HEAR YE The length of the files in " + fpath + " is zero, CODE -\"USHAND-LOADTEXTURES-0INDEX\"");
					BPGUI.DisableTerminal();
					BPGUI.HideProgressBar();
					failed = true;
					BPGUI.BatonPassAnnoucement(Color.yellow, "No files found in " + fpath + ", CODE -\\\"USHAND-LOADTEXTURES-0INDEX\\\"\"");
				}
			}
			catch (Exception ex2)
			{
				BatonPass.Error("Failed to load all textures from \" + Path.GetFileName(fpath) + \".\\nPlease ensure all of the Texture Files names are Correct.");
				BatonPass.Error("HEAR YE HEAR YE, The Search Was Fruitless, CODE -\"USHAND-LOADTEXTURES-EX\" " + ex2.Message);
				BatonPass.Error("HEAR YE HEAR YE, The Search Was Fruitless, CODE -\"USHAND-LOADTEXTURES-EX\" " + ex2.ToString());
				BPGUI.BatonPassAnnoucement(Color.red, "Failed to load all textures from " + Path.GetFileName(fpath) + ".\nPlease ensure all of the Texture Files names are Correct.");
			}
			texOpData.FailState = failed;
			texOpData.ProgressState = ProgressDone;
			return texOpData;
		}

		public async Task<UniOpData> ConvertToTextures(TexOpData texOpData)
		{
			UniOpData uniOpData = new UniOpData();
			bool failState = texOpData.FailState;
			float num = texOpData.ProgressState;
			foreach (var rawDatum in texOpData.RawData)
			{
				string item = rawDatum.name;
				byte[] item2 = rawDatum.data;
				Texture2D val = new Texture2D(2, 2);
				((Object)val).name = item;
				BatonPass.Debug("Creating " + ((Object)val).name);
				((Texture)val).filterMode = (FilterMode)0;
				ImageConversion.LoadImage(val, item2);
				BatonPass.Debug("Loading Image Data");
				val.Apply();
				Texture val2 = (Texture)(object)val;
				BatonPass.Debug("Setting texture");
				autoSwapCache.Add(item, val2);
				BatonPass.Debug("Adding to Cache " + ((Object)val2).name + " " + item);
				num += 1f;
			}
			uniOpData.ProgressState = num;
			uniOpData.FailState = failState;
			return uniOpData;
		}
	}
	internal static class USC
	{
		public const string VERSION = "7.0.0";

		public static readonly string[] SupportedPackFormats = new string[1] { "4.0" };

		public const string GCSKINVERSION = "4.0";

		public const string SAVEDATA = "SaveData";

		public const string UNISKIN = "GlobalSkins";

		public const string VERNAME = "Versions";

		public const string BUILDTYPE = "Release";

		public const string DATAFILE = "Data.USGC";

		public const string SETTINGSFILE = "Settings.USGC";

		public const string DEFAULTSETTINGS = "DefaultSettings.USGC";

		public const string MDFILE = "metadata.GCMD";

		public const string PACKFILE = "pack.GCMD";

		public const string TSMANIFEST = "manifest.json";

		public static readonly Dictionary<string, string> ReservedNameJokes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			{ "CON", "SmileOS doesnt support that kind of CONSOLE" },
			{ "PRN", "Try naming it 'homework' instead." },
			{ "AUX", "I'm still mad Apple removed those, guess you need to remove it from your skin name too" },
			{ "NUL", "Its so empty in here, I'm cold" },
			{ "COM1", "Do people still even use COM ports" },
			{ "COM2", "Do people still even use COM ports" },
			{ "COM3", "Really? your still trying to name your skin COM?" },
			{ "COM4", "So you're still trying to use COM" },
			{ "COM5", "wow, it worked, oh wait, no" },
			{ "COM6", "Sooooooo, while you'rehere, maybe star the project on github," },
			{ "COM7", "Why specifically COM7" },
			{ "COM8", "you're either reading the source or just trying everything, arnt you" },
			{ "COM9", "hmm, i guess you're really set on using COM, COM10 should work" },
			{ "COM¹", "How did you even get that character? this font doesnt even support superscript" },
			{ "COM²", "I can't calculate COM squared" },
			{ "COM³", "I could calculate COM cubed, i just dont feel like it" },
			{ "LPT1", "I'm not going to print your skins" },
			{ "LPT2", "I'm not going to print your skins" },
			{ "LPT3", "does the L stand for ligma, no.... ok" },
			{ "LPT4", "Who just has 4 printers" },
			{ "LPT5", "Is this funny yet" },
			{ "LPT6", "Really think, When was the last time you used a Parallel port" },
			{ "LPT7", "hmmm i wonder if V1 has a Parallel port" },
			{ "LPT8", "If you really need to print your skins, Try using Photoshop file > print" },
			{ "LPT9", "Yes i really did spend my sunday morning writing dialog for each windows reserved name" },
			{ "LPT¹", "wow thats a fancy lookin unicode character, please dont use it" },
			{ "LPT²", "i dont want to square your printer, you only need one" },
			{ "LPT³", "Most printers are already cubes" },
			{ "OG-SKINS", "Very funny" }
		};

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

		public static string GCDIR => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bobthecorn2000", "ULTRAKILL", "ultraskinsGC-V2");

		public static string LEGACYGCDIR => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bobthecorn2000", "ULTRAKILL", "ultraskinsGC");
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "UltraSkins";

		public const string PLUGIN_NAME = "UltraSkins";

		public const string PLUGIN_VERSION = "7.0.0";
	}
}
namespace UltraSkins.API
{
	public class USAPI
	{
		public class TextureLoadEventArgs : EventArgs
		{
			public bool Failed { get; }

			public TextureLoadEventArgs(bool failed)
			{
				Failed = failed;
			}
		}

		public static event Action<TextureLoadEventArgs?> OnTexLoadFinished;

		internal static void BroadcastTextureFinished(TextureLoadEventArgs TLEA)
		{
			USAPI.OnTexLoadFinished?.Invoke(TLEA);
		}
	}
}
namespace UltraSkins.Utils
{
	public class SkinEventHandler : MonoBehaviour
	{
		public class Metadata
		{
			public string FileVersion { get; set; }

			public string FileName { get; set; }

			public string FileDescription { get; set; }
		}

		public class saveinfo
		{
			public string ModVersion { get; set; }

			public string[] SkinLocation { get; set; }
		}

		public class StringSerializer
		{
			public void SerializeStringToFile(string[] data, string filePath)
			{
				string text = JsonConvert.SerializeObject((object)new saveinfo
				{
					SkinLocation = data,
					ModVersion = "7.0.0"
				});
				BatonPass.Info("Encoding " + text);
				File.WriteAllText(filePath, text);
			}

			public string[] DeserializeStringFromFile(string filePath)
			{
				string text = File.ReadAllText(filePath);
				string[] array = new string[1] { "deserializedData Failed" };
				try
				{
					saveinfo saveinfo = JsonConvert.DeserializeObject<saveinfo>(text);
					array = saveinfo?.SkinLocation;
					if (saveinfo.ModVersion != "7.0.0")
					{
						SerializeStringToFile(saveinfo?.SkinLocation, filePath);
						BatonPass.Warn("Wrong version, correcting");
						return new string[1] { "Wrong Version" };
					}
					return array;
				}
				catch
				{
					BatonPass.Error("deserializedData Failed");
					return new string[1] { "deserializedData Failed" };
				}
			}
		}

		public GameObject Activator;

		public string path;

		public string pname;

		public static ULTRASKINHand UKSH = ULTRASKINHand.HandInstance;

		public static string getDataFile()
		{
			string[] thunderProfInfo = UKSH.ThunderProfInfo;
			string text = null;
			if (thunderProfInfo != null && thunderProfInfo.Length == 2)
			{
				string text2 = thunderProfInfo[0];
				string text3 = thunderProfInfo[1];
				return Path.Combine(USC.GCDIR, "SaveData", text3, text2, "Data.USGC");
			}
			return Path.Combine(USC.GCDIR, "SaveData", "Release", "Data.USGC");
		}

		public static string getUserSettingsFile()
		{
			string[] thunderProfInfo = UKSH.ThunderProfInfo;
			string text = null;
			if (thunderProfInfo != null && thunderProfInfo.Length == 2)
			{
				string text2 = thunderProfInfo[0];
				string text3 = thunderProfInfo[1];
				return Path.Combine(USC.GCDIR, "SaveData", text3, text2, "Settings.USGC");
			}
			return Path.Combine(USC.GCDIR, "SaveData", "Release", "Settings.USGC");
		}

		public string[] GetModFolderPath()
		{
			BatonPass.Debug("BATON PASS: GETMODFOLDERPATH()");
			string text = Path.Combine(USC.GCDIR, "Versions", "7.0.0");
			string text2 = null;
			string[] thunderProfInfo = UKSH.ThunderProfInfo;
			if (thunderProfInfo != null && thunderProfInfo.Length == 2)
			{
				string path = thunderProfInfo[0];
				string path2 = thunderProfInfo[1];
				text2 = Path.Combine(USC.GCDIR, "SaveData", path2, path);
			}
			else
			{
				text2 = Path.Combine(USC.GCDIR, "SaveData", "Release");
			}
			string text3 = Path.Combine(USC.GCDIR, "GlobalSkins");
			USC.MODPATH.Split(Path.DirectorySeparatorChar);
			string path3 = null;
			BatonPass.Debug("Checking Directories");
			if (!Directory.Exists(USC.GCDIR))
			{
				BatonPass.Warn("The AppData Directiory is missing. Fixing");
				Directory.CreateDirectory(USC.GCDIR);
				BatonPass.Success("Fixed");
			}
			if (!Directory.Exists(text))
			{
				BatonPass.Warn("The Versions Directiory is missing. Fixing");
				Directory.CreateDirectory(text);
				BatonPass.Success("Fixed");
			}
			if (text2 != null && !Directory.Exists(text2))
			{
				BatonPass.Warn("The Current Profile's Directiory is missing. Fixing");
				Directory.CreateDirectory(text2);
				BatonPass.Success("Fixed");
			}
			if (!Directory.Exists(text3))
			{
				BatonPass.Warn("The Global SaveData Directiory is missing. Fixing");
				Directory.CreateDirectory(text3);
				BatonPass.Success("Fixed");
			}
			BatonPass.Debug("Done");
			string[] data = new string[0];
			if (text2 != null)
			{
				path3 = text2;
			}
			StringSerializer stringSerializer = new StringSerializer();
			string filePath = Path.Combine(path3, "Data.USGC");
			if (!File.Exists(Path.Combine(path3, "Data.USGC")))
			{
				stringSerializer.SerializeStringToFile(data, filePath);
			}
			if (!File.Exists(Path.Combine(path3, "Settings.USGC")))
			{
				File.Create(Path.Combine(path3, "Settings.USGC"));
			}
			string[] array = stringSerializer.DeserializeStringFromFile(filePath);
			if (array[0] == "deserializedData Failed")
			{
				stringSerializer.SerializeStringToFile(data, filePath);
				array = stringSerializer.DeserializeStringFromFile(filePath);
			}
			if (array[0] == "Wrong Version")
			{
				array = stringSerializer.DeserializeStringFromFile(filePath);
			}
			return array;
		}

		public static Dictionary<string, string> GetCurrentLocations()
		{
			string fullName = Directory.GetParent(USC.MODPATH).FullName;
			string[] thunderProfInfo = UKSH.ThunderProfInfo;
			string text = null;
			string text2 = Path.Combine(USC.GCDIR, "GlobalSkins");
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("Global", text2);
			BatonPass.Info("Location Found: Global " + text2);
			if (thunderProfInfo != null && thunderProfInfo.Length == 2)
			{
				_ = thunderProfInfo[0];
				text = thunderProfInfo[1];
				BatonPass.Info("Location Found: " + text + " " + fullName);
				dictionary.Add(text, fullName);
			}
			return dictionary;
		}

		public static void ExtractSkin(string skinFilePath, string storage)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			string extractFolder = Path.Combine(skinFilePath, Path.GetFileNameWithoutExtension(storage));
			Directory.CreateDirectory(extractFolder);
			using FileStream fileStream = File.OpenRead(storage);
			ZlibStream val = new ZlibStream((Stream)fileStream, (CompressionMode)1);
			try
			{
				ExtractFromZlibStream(val, extractFolder);
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}

		private static void ExtractFromZlibStream(ZlibStream zlibStream, string extractFolder)
		{
			byte[] array = new byte[4096];
			bool flag = false;
			while (true)
			{
				string text = ReadLineFromZlibStream(zlibStream)?.Trim();
				if (string.IsNullOrEmpty(text))
				{
					break;
				}
				if (flag)
				{
					string text2 = Path.Combine(extractFolder, text);
					string directoryName = Path.GetDirectoryName(text2);
					if (!Directory.Exists(directoryName))
					{
						Directory.CreateDirectory(directoryName);
					}
					byte[] array2 = new byte[8];
					((Stream)(object)zlibStream).Read(array2, 0, array2.Length);
					long num = BitConverter.ToInt64(array2, 0);
					using FileStream fileStream = File.Create(text2);
					long num2 = num;
					while (num2 > 0)
					{
						int count = (int)Math.Min(num2, array.Length);
						int num3 = ((Stream)(object)zlibStream).Read(array, 0, count);
						if (num3 == 0)
						{
							throw new Exception("Unexpected end of stream.");
						}
						fileStream.Write(array, 0, num3);
						num2 -= num3;
					}
				}
				else
				{
					flag = true;
				}
			}
		}

		private static string ReadLineFromZlibStream(ZlibStream zlibStream)
		{
			try
			{
				MemoryStream memoryStream = new MemoryStream();
				int num;
				while ((num = ((Stream)(object)zlibStream).ReadByte()) != -1 && num != 10)
				{
					memoryStream.WriteByte((byte)num);
				}
				return Encoding.UTF8.GetString(memoryStream.ToArray());
			}
			catch (Exception)
			{
				return null;
			}
		}

		public static string[] GetThunderstoreProfileName()
		{
			string[] array = Assembly.GetExecutingAssembly().Location.Split(Path.DirectorySeparatorChar);
			bool flag = false;
			bool flag2 = false;
			string text = null;
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (text2.Equals("Thunderstore Mod Manager", StringComparison.OrdinalIgnoreCase))
				{
					flag = true;
					text = "Thunderstore";
					break;
				}
				if (text2.Equals("r2modmanPlus-local", StringComparison.OrdinalIgnoreCase))
				{
					flag2 = true;
					text = "r2modman";
					break;
				}
			}
			if (!flag && !flag2)
			{
				return null;
			}
			for (int j = 0; j < array.Length - 1; j++)
			{
				if (array[j].Equals("profiles", StringComparison.OrdinalIgnoreCase))
				{
					return new string[2]
					{
						array[j + 1],
						text
					};
				}
			}
			return null;
		}
	}
}
namespace UltraSkins.UI
{
	internal class MenuCreator : MonoBehaviour
	{
		private static ULTRASKINHand handInstance = ULTRASKINHand.HandInstance;

		public static string folderupdater;

		private static GameObject batonpassGUIInst = null;

		private static SettingsManager sMan
		{
			get
			{
				return ULTRASKINHand.HandInstance.settingsmanager;
			}
			set
			{
				ULTRASKINHand.HandInstance.settingsmanager = value;
			}
		}

		public static void makethemenu()
		{
			//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_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			BatonPass.Debug("BATON PASS: WE ARE IN MAKETHEMENU()");
			Scene activeScene = SceneManager.GetActiveScene();
			BatonPass.Info("The Scene is: " + ((Scene)(ref activeScene)).name);
			GameObject fallNoiseOn = null;
			GameObject fallNoiseOff = null;
			try
			{
				foreach (GameObject item in from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
					where ((Object)obj).name == "FallSound"
					select obj)
				{
					fallNoiseOn = ((Component)item.transform.Find("ToOne")).gameObject;
					fallNoiseOff = ((Component)item.transform.Find("ToZero")).gameObject;
				}
				foreach (GameObject item2 in from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
					where ((Object)obj).name == "Canvas"
					select obj)
				{
					BatonPass.Info("entered a foreach");
					GameObject mainmenu = ((Component)item2.transform.Find("Main Menu (1)")).gameObject;
					BatonPass.Info("finished search");
					BatonPass.Info("HEARYEE HEAR YEE TRANSFORM IS " + ((object)mainmenu).ToString());
					if (sMan.GetSettingValue<bool>("V1Color"))
					{
						BatonPass.Info(MonoSingleton<ColorBlindSettings>.Instance.variationColors[2].r + " " + MonoSingleton<ColorBlindSettings>.Instance.variationColors[2].g + " " + MonoSingleton<ColorBlindSettings>.Instance.variationColors[2].b);
						GameObject gameObject = ((Component)mainmenu.transform.Find("V1")).gameObject;
						ColorBlindGet obj2 = gameObject.AddComponent<ColorBlindGet>();
						obj2.variationColor = true;
						obj2.variationNumber = 0;
						obj2.UpdateColor();
						ColorBlindGet obj3 = ((Component)gameObject.transform.Find("Wings")).gameObject.AddComponent<ColorBlindGet>();
						obj3.variationColor = true;
						obj3.variationNumber = 0;
						obj3.UpdateColor();
						ColorBlindGet obj4 = ((Component)gameObject.transform.Find("Knuckleblaster")).gameObject.AddComponent<ColorBlindGet>();
						obj4.variationColor = true;
						obj4.variationNumber = 2;
						obj4.UpdateColor();
						ColorBlindGet obj5 = ((Component)gameObject.transform.Find("Whiplash")).gameObject.AddComponent<ColorBlindGet>();
						obj5.variationColor = true;
						obj5.variationNumber = 1;
						obj5.UpdateColor();
						mainmenu.GetComponentInChildren<Button>();
					}
					GameObject leftside = ((Component)mainmenu.transform.Find("LeftSide")).gameObject;
					AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/UltraskinsEditmenu.prefab");
					GameObject prefabmenu;
					GameObject UltraskinsConfigmenu;
					GameObject Editorpanel;
					val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
					{
						//IL_0002: Unknown result type (might be due to invalid IL or missing references)
						//IL_0008: Invalid comparison between Unknown and I4
						//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
						//IL_0100: Expected O, but got Unknown
						//IL_025b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0260: Unknown result type (might be due to invalid IL or missing references)
						if ((int)handle.Status == 1)
						{
							prefabmenu = handle.Result;
							UltraskinsConfigmenu = Object.Instantiate<GameObject>(prefabmenu);
							Transform[] componentsInChildren = UltraskinsConfigmenu.GetComponentsInChildren<Transform>();
							for (int i = 0; i < componentsInChildren.Length; i++)
							{
								_ = componentsInChildren[i];
							}
							Editorpanel = ((Component)UltraskinsConfigmenu.transform.Find("Canvas/editor")).gameObject;
							Animator menuanimator = Editorpanel.gameObject.GetComponent<Animator>();
							MenuManager Mman = UltraskinsConfigmenu.AddComponent<MenuManager>();
							Editorpanel.SetActive(false);
							BatonPass.Info("looking for content");
							EditMenuManager EMM = UltraskinsConfigmenu.GetComponent<EditMenuManager>();
							Mman.SD = EMM.skindetails;
							((UnityEvent)EMM.campCreator.CreateButton.onClick).AddListener((UnityAction)delegate
							{
								Mman.CreateSkinFromEditor(EMM);
							});
							GameObject ReturnButton = ((Component)Editorpanel.transform.Find("PanelLeft/ReturnButton")).gameObject;
							GameObject ApplyButton = ((Component)Editorpanel.transform.Find("PanelLeft/Apply")).gameObject;
							GameObject contentfolder = ((Component)UltraskinsConfigmenu.transform.Find("Canvas/editor/PanelLeft/Scroll View/Viewport/Content/UltraButton")).gameObject;
							ObjectActivateInSequence activateanimator = contentfolder.AddComponent<ObjectActivateInSequence>();
							Mman.GenerateButtons(contentfolder, activateanimator);
							Mman.RefreshableActivateAnimator = activateanimator;
							Mman.RefreshableContentFolder = contentfolder;
							if (Directory.Exists(USC.LEGACYGCDIR))
							{
								sMan.aboutMenu.MDtag.SetActive(true);
								EMM.MigrationToolButton.SetActive(true);
								Mman.PopulateMigrateMenu(EMM.MigrationPage, EMM);
								EMM.MigrationPage.ActivateMigratorTool();
							}
							if (handInstance.ThunderStoreMode)
							{
								sMan.aboutMenu.TStag.SetActive(true);
								EMM.ThunderstoreFixButton.SetActive(true);
								Mman.PopulateThunderstoreMenu(EMM.thunderstoreHandle, EMM);
							}
							AsyncOperationHandle<GameObject> val2 = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/ultraskinsmenubutton.prefab");
							UnityAction val3 = default(UnityAction);
							UnityAction val4 = default(UnityAction);
							UnityAction val5 = default(UnityAction);
							val2.Completed += delegate(AsyncOperationHandle<GameObject> buttonHandle)
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								//IL_0008: Invalid comparison between Unknown and I4
								//IL_0045: Unknown result type (might be due to invalid IL or missing references)
								//IL_0064: Unknown result type (might be due to invalid IL or missing references)
								//IL_008a: Unknown result type (might be due to invalid IL or missing references)
								//IL_008f: Unknown result type (might be due to invalid IL or missing references)
								//IL_0091: Expected O, but got Unknown
								//IL_0096: Expected O, but got Unknown
								//IL_00be: Unknown result type (might be due to invalid IL or missing references)
								//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
								//IL_00c5: Expected O, but got Unknown
								//IL_00ca: Expected O, but got Unknown
								//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
								//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
								//IL_00f9: Expected O, but got Unknown
								//IL_00fe: Expected O, but got Unknown
								if ((int)buttonHandle.Status == 1)
								{
									GameObject obj6 = Object.Instantiate<GameObject>(buttonHandle.Result, leftside.transform);
									obj6.SetActive(true);
									obj6.transform.localPosition = new Vector3(450f, -330f, 0f);
									obj6.transform.localScale = new Vector3(1.5f, 1.5f, 1f);
									ButtonClickedEvent onClick = obj6.GetComponentInChildren<Button>().onClick;
									UnityAction obj7 = val3;
									if (obj7 == null)
									{
										UnityAction val6 = delegate
										{
											Openskineditor(mainmenu, menuanimator, Editorpanel, fallNoiseOn, EMM);
										};
										UnityAction val7 = val6;
										val3 = val6;
										obj7 = val7;
									}
									((UnityEvent)onClick).AddListener(obj7);
									ButtonClickedEvent onClick2 = ReturnButton.GetComponent<Button>().onClick;
									UnityAction obj8 = val4;
									if (obj8 == null)
									{
										UnityAction val8 = delegate
										{
											Mman.Closeskineditor(mainmenu, Editorpanel, fallNoiseOff, menuanimator, activateanimator, contentfolder);
										};
										UnityAction val7 = val8;
										val4 = val8;
										obj8 = val7;
									}
									((UnityEvent)onClick2).AddListener(obj8);
									ButtonClickedEvent onClick3 = ApplyButton.GetComponent<Button>().onClick;
									UnityAction obj9 = val5;
									if (obj9 == null)
									{
										UnityAction val9 = delegate
										{
											Mman.applyskins(contentfolder);
										};
										UnityAction val7 = val9;
										val5 = val9;
										obj9 = val7;
									}
									((UnityEvent)onClick3).AddListener(obj9);
									BatonPass.Debug("Successfully loaded and instantiated ultraskinsMenuButton.");
								}
								else
								{
									BatonPass.Error("Failed to load ultraskinsMenuButton: " + buttonHandle.OperationException.Message);
									BatonPass.Error("Ultraskins will still work, but the button to access the config menu was disabled. CODE -\"MCREATE-MAKETHEMENU-USBUTTON-ASSET_BUNDLE_FAILED\"");
								}
							};
						}
						else
						{
							BatonPass.Error("Failed to load UltraskinsConfigmenu: " + handle.OperationException.Message);
							BatonPass.Error("Ultraskins will still work, but the menu will be disabled. CODE -\"MCREATE-MAKETHEMENU-CONFIGMENU-ASSET_BUNDLE_FAILED\"");
						}
					};
				}
			}
			catch (Exception ex)
			{
				BatonPass.Error("HEAR YEE HEAR YEE MainConfigMenu not loaded " + ex.ToString());
				BatonPass.Error("Ultraskins may still work, but the MainConfigMenu will not be accessible. CODE -\"MCREATE-MAKETHEMENU-EX\"");
			}
			BatonPass.Debug("INIT BATON PASS: We are returning");
		}

		public static void CreateSMan()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			List<TextureOverWatch> list = new List<TextureOverWatch>();
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/Settings.prefab");
			GameObject val2 = val.WaitForCompletion();
			if ((int)val.Status == 1)
			{
				BatonPass.Debug("Creating the Settings Menu");
				GameObject val3 = Object.Instantiate<GameObject>(val2);
				val3.SetActive(true);
				sMan = val3.GetComponent<SettingsManager>();
				handInstance.ogSkinsManager = val3.GetComponent<OGSkinsManager>();
				sMan.aboutMenu.SetAboutVersionInfo("7.0.0", "Release", "4.0", USC.SupportedPackFormats);
				sMan.aboutMenu.HPtag.SetActive(Chainloader.PluginInfos.ContainsKey("dev.flazhik.handpaint"));
				string userSettingsFile = SkinEventHandler.getUserSettingsFile();
				BatonPass.Debug("loading user settings");
				try
				{
					sMan.loadUserSettings(userSettingsFile);
				}
				catch (Exception)
				{
					BatonPass.Warn("Users custom settings dont exist, using defaults CODE -\"MCREATE-MAKETHEMENU-USERSETTINGSFILE-CORRUPTED_OR_MISSING\"");
				}
				BatonPass.Debug("loading settings options");
				try
				{
					sMan.LoadSettingsFromJson(USC.MODPATH + Path.DirectorySeparatorChar + "DefaultSettings.USGC");
				}
				catch (Exception)
				{
					BatonPass.Fatal("HEAR YE, HEAR YE! Critical failure: Default Settings and their constructor are missing, UltraSkins will be unstable at best. CODE -\"MCREATE-MAKETHEMENU-SETTINGSFILE-CORRUPTED_OR_MISSING\"");
					handInstance.BPGUI.ShowGUI("Error");
					handInstance.BPGUI.BatonPassAnnoucement(Color.red, "Fatal Error, Default Settings and their constructor are missing, UltraSkins will be unstable at best. CODE -\"MCREATE-MAKETHEMENU-SETTINGSFILE-CORRUPTED_OR_MISSING\"");
				}
				BatonPass.Debug("loading settings UI");
				sMan.BuildSettingsUI();
				try
				{
					BatonPass.Debug("finding previewer");
					GameObject gameObject = ((Component)val3.transform.Find("previewfather")).gameObject;
					BatonPass.Debug("clearing PTOW");
					list.Clear();
					BatonPass.Debug("adding new tows");
					list = ULTRASKINHand.HarmonyGunPatcher.AddPTOWs(gameObject, refresh: true);
					BatonPass.Success("Added TOW");
					handInstance.PtowStorage = gameObject.gameObject.AddComponent<TowStorage>();
					handInstance.PtowStorage.TOWS = list;
					return;
				}
				catch (Exception ex3)
				{
					BatonPass.Error("Cannot make PTOW. CODE -\"MCREATE-MAKETHEMENU-SKIN_PREVIEWER-UNABLE_TO_LOAD\"");
					BatonPass.Error(ex3.Message);
					return;
				}
			}
			BatonPass.Error("Failed to load UltraskinsSettingsmenu: " + val.OperationException.Message);
			BatonPass.Error("Ultraskins will still work, but the menu will be disabled. CODE -\"MCREATE-MAKETHEMENU-SETTINGMENU-ASSET_BUNDLE_FAILED\"");
		}

		public static void Openskineditor(GameObject mainmenucanvas, Animator animator, GameObject Configmenu, GameObject fallnoiseon, EditMenuManager emm)
		{
			BatonPass.Debug("opened the editor");
			mainmenucanvas.SetActive(false);
			fallnoiseon.SetActive(true);
			Configmenu.SetActive(true);
			emm.EnableMenuSound.Play();
			animator.Play("MenuOpen");
			handInstance.settingsmanager.ShowSettingsAssets(true);
			handInstance.settingsmanager.ShowPreviewWireFrame(true);
		}

		public static void Openpausedskineditor(GameObject mainmenucanvas, GameObject Configmenu, GameObject backdrop, OptionsManager controller)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			GameStateManager.Instance.RegisterState(new GameState("configpause", backdrop)
			{
				cursorLock = (LockMode)2,
				cameraInputLock = (LockMode)1,
				playerInputLock = (LockMode)1
			});
			mainmenucanvas.SetActive(false);
			Cursor.visible = true;
			backdrop.SetActive(true);
			Configmenu.SetActive(true);
			handInstance.settingsmanager.ShowSettingsAssets(true);
			handInstance.settingsmanager.ShowPreviewWireFrame(true);
		}

		public static void Closepauseskineditor(GameObject mainmenucanvas, GameObject Configmenu, OptionsManager controller)
		{
			controller.UnPause();
			Configmenu.SetActive(false);
		}

		public static void makethePausemenu()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			BatonPass.Debug("BATON PASS: WE ARE IN MAKETHEPAUSEMENU()");
			Scene scene = SceneManager.GetActiveScene();
			BatonPass.Info("The Scene is: " + ((Scene)(ref scene)).name);
			try
			{
				foreach (GameObject item in from obj in ((Scene)(ref scene)).GetRootGameObjects()
					where ((Object)obj).name == "Canvas"
					select obj)
				{
					GameObject Pausemenu = ((Component)item.transform.Find("PauseMenu")).gameObject;
					AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/UltraskinsPausedEditmenu.prefab");
					GameObject prefabmenu;
					GameObject UltraskinsConfigmenu;
					val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
					{
						//IL_0002: Unknown result type (might be due to invalid IL or missing references)
						//IL_0008: Invalid comparison between Unknown and I4
						//IL_0184: Unknown result type (might be due to invalid IL or missing references)
						//IL_0189: Unknown result type (might be due to invalid IL or missing references)
						if ((int)handle.Status == 1)
						{
							prefabmenu = handle.Result;
							UltraskinsConfigmenu = Object.Instantiate<GameObject>(prefabmenu);
							UltraskinsConfigmenu.SetActive(false);
							Transform[] componentsInChildren = UltraskinsConfigmenu.GetComponentsInChildren<Transform>();
							for (int i = 0; i < componentsInChildren.Length; i++)
							{
								BatonPass.Debug(((Object)componentsInChildren[i]).name);
							}
							BatonPass.Debug("looking for content");
							GameObject backdrop = ((Component)UltraskinsConfigmenu.transform.Find("Canvas/Backdrop")).gameObject;
							MenuManager menuManager = backdrop.AddComponent<MenuManager>();
							GameObject gameObject = ((Component)backdrop.transform.Find("Scroll View/Viewport/Content/UltraButton")).gameObject;
							_ = ULTRASKINHand.HandInstance;
							menuManager.GenerateButtons(gameObject);
							BatonPass.Debug("contentfolder found");
							HudOpenEffect obj2 = backdrop.AddComponent<HudOpenEffect>();
							backdrop.AddComponent<MenuEsc>();
							BatonPass.Debug("set animator to buttons");
							obj2.speed = 30f;
							BatonPass.Debug("Successfully loaded and instantiated UltraskinsConfigmenu.");
							GameObject val2 = null;
							foreach (GameObject item2 in from obj in ((Scene)(ref scene)).GetRootGameObjects()
								where ((Object)obj).name == "GameController"
								select obj)
							{
								val2 = item2;
							}
							BatonPass.Debug("Successfully loaded the gamecontroller");
							OptionsManager controller = val2.GetComponentInChildren<OptionsManager>();
							AsyncOperationHandle<GameObject> val3 = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/ultraskinsmenubutton.prefab");
							UnityAction val4 = default(UnityAction);
							UnityAction val5 = default(UnityAction);
							val3.Completed += delegate(AsyncOperationHandle<GameObject> buttonHandle)
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								//IL_0008: Invalid comparison between Unknown and I4
								//IL_0045: 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_0070: Unknown result type (might be due to invalid IL or missing references)
								//IL_0072: Expected O, but got Unknown
								//IL_0077: Expected O, but got Unknown
								//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
								//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
								//IL_00ab: Expected O, but got Unknown
								//IL_00b0: Expected O, but got Unknown
								if ((int)buttonHandle.Status == 1)
								{
									GameObject obj3 = Object.Instantiate<GameObject>(buttonHandle.Result, Pausemenu.transform);
									obj3.SetActive(true);
									obj3.transform.localPosition = new Vector3(-100f, -90f, 0f);
									ButtonClickedEvent onClick = obj3.GetComponentInChildren<Button>().onClick;
									UnityAction obj4 = val4;
									if (obj4 == null)
									{
										UnityAction val6 = delegate
										{
											Openpausedskineditor(Pausemenu, UltraskinsConfigmenu, backdrop, controller);
										};
										UnityAction val7 = val6;
										val4 = val6;
										obj4 = val7;
									}
									((UnityEvent)onClick).AddListener(obj4);
									ButtonClickedEvent onClick2 = UltraskinsConfigmenu.GetComponentInChildren<Button>().onClick;
									UnityAction obj5 = val5;
									if (obj5 == null)
									{
										UnityAction val8 = delegate
										{
											Closepauseskineditor(Pausemenu, backdrop, controller);
										};
										UnityAction val7 = val8;
										val5 = val8;
										obj5 = val7;
									}
									((UnityEvent)onClick2).AddListener(obj5);
									BatonPass.Debug("Successfully loaded and instantiated ultraskinsButton.");
								}
								else
								{
									BatonPass.Error("HEAR YEE HEAR YEE UltraskinsPausedConfigmenu not loaded " + buttonHandle.OperationException.Message);
									BatonPass.Error("Ultraskins will still work, but the button to access the config menu was disabled. CODE -\"MCREATE-MAKETHEPAUSEMENU-USBUTTON-ASSET_BUNDLE_FAILED\"");
								}
							};
						}
						else
						{
							BatonPass.Error("Failed to load UltraskinsPausedConfigmenu: " + handle.OperationException.Message);
							BatonPass.Error("Ultraskins will still work, but the menu will be disabled. CODE -\"MCREATE-MAKETHEPAUSEMENU-CONFIGMENU-ASSET_BUNDLE_FAILED\"");
						}
					};
				}
			}
			catch (Exception ex)
			{
				BatonPass.Error("HEAR YEE HEAR YEE PausedConfigMenu not loaded " + ex.ToString());
				BatonPass.Error("Ultraskins may still work, but the PausedConfigMenu will not be accessible. CODE -\"MCREATE-MAKETHEPAUSEMENU-EX\"");
			}
			BatonPass.Debug("INIT BATON PASS: We are returning");
		}
	}
	internal class MenuManager : MonoBehaviour
	{
		internal struct TaskStatus
		{
			public enum status
			{
				Success,
				WithErrors,
				Failed
			}

			public status CurrentStatus { get; set; }

			public List<string>? FailedValues { get; set; }

			public string ExtraNote { get; set; }

			public TaskStatus(status status, List<string>? failedValues = null, string extraNote = "")
			{
				CurrentStatus = status;
				FailedValues = failedValues;
				ExtraNote = extraNote;
			}
		}

		public struct UnsafeNotice
		{
			public bool IsSafe;

			public string Reason1;

			public string Reason2;

			public UnsafeNotice(bool isSafe, string reason1, string reason2 = "")
			{
				IsSafe = isSafe;
				Reason1 = reason1;
				Reason2 = reason2;
			}

			public static UnsafeNotice Safe()
			{
				return new UnsafeNotice(isSafe: true, "");
			}

			public static UnsafeNotice Unsafe(string reason1, string reason2 = "")
			{
				return new UnsafeNotice(isSafe: false, reason1, reason2);
			}
		}

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

			private object <>2__current;

			public Dictionary<string, Texture> SKINTEXs;

			public MenuManager <>4__this;

			public int MAXBATCH;

			public Action<Dictionary<string, byte[]>> complete;

			private Dictionary<string, byte[]> <SKINPNGs>5__2;

			private int <batch>5__3;

			private Dictionary<string, Texture>.Enumerator <>7__wrap3;

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

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

			[DebuggerHidden]
			public <ConvertToPNG>d__26(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();
					}
				}
				<SKINPNGs>5__2 = null;
				<>7__wrap3 = default(Dictionary<string, Texture>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					int num = <>1__state;
					MenuManager menuManager = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<SKINPNGs>5__2 = new Dictionary<string, byte[]>();
						<batch>5__3 = 0;
						<>7__wrap3 = SKINTEXs.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						break;
					}
					while (<>7__wrap3.MoveNext())
					{
						KeyValuePair<string, Texture> current = <>7__wrap3.Current;
						Texture2D val = menuManager.ConvertToReadable(current.Value);
						if ((Object)(object)val != (Object)null)
						{
							byte[] value = ImageConversion.EncodeToPNG(val);
							<SKINPNGs>5__2.Add(current.Key, value);
							Object.Destroy((Object)(object)val);
						}
						else
						{
							BatonPass.Warn(current.Key + ": Not a Texture2D");
							<SKINPNGs>5__2.Add(current.Key, null);
						}
						<batch>5__3++;
						if (<batch>5__3 >= MAXBATCH)
						{
							<batch>5__3 = 0;
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
					}
					<>m__Finally1();
					<>7__wrap3 = default(Dictionary<string, Texture>.Enumerator);
					complete?.Invoke(<SKINPNGs>5__2);
					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;
				((IDisposable)<>7__wrap3).Dispose();
			}

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

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

			private object <>2__current;

			public GameObject Configmenu;

			public GameObject mainmenucanvas;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.4167f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Configmenu.SetActive(false);
					mainmenucanvas.SetActive(true);
					return false;
				}
			}

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

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

		private ULTRASKINHand handInstance = ULTRASKINHand.HandInstance;

		private List<GameObject> loadedButtons = new List<GameObject>();

		private Dictionary<string, Button> AvailbleSkins = new Dictionary<string, Button>();

		public SkinDetails SD;

		public GameObject RefreshableContentFolder;

		public ObjectActivateInSequence RefreshableActivateAnimator;

		public BPGUIManager BPGUI = MonoSingleton<BPGUIManager>.Instance;

		internal static MenuManager MMinstance { get; private set; }

		private void Awake()
		{
			MMinstance = this;
		}

		public void Closeskineditor(GameObject mainmenucanvas, GameObject Configmenu, GameObject fallnoiseoff, Animator animator, ObjectActivateInSequence oais, GameObject content)
		{
			MMinstance.orderifier(oais, content);
			fallnoiseoff.SetActive(true);
			handInstance.settingsmanager.ShowPreviewWireFrame(false);
			handInstance.settingsmanager.ShowSettingsAssets(false);
			animator.Play("menuclose");
			((MonoBehaviour)MMinstance).StartCoroutine(MMinstance.DisableAfterCloseAnimation(mainmenucanvas, Configmenu, animator));
		}

		[IteratorStateMachine(typeof(<DisableAfterCloseAnimation>d__13))]
		private IEnumerator DisableAfterCloseAnimation(GameObject mainmenucanvas, GameObject Configmenu, Animator animator)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableAfterCloseAnimation>d__13(0)
			{
				mainmenucanvas = mainmenucanvas,
				Configmenu = Configmenu
			};
		}

		public void GenerateButtons(GameObject contentfolder, ObjectActivateInSequence activateanimator)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, string> Locations = SkinEventHandler.GetCurrentLocations();
			metadataReader MDR = new metadataReader();
			AvailbleSkins.Clear();
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/ultraskinsButton.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> buttonHandle)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				if ((int)buttonHandle.Status == 1)
				{
					foreach (string key in Locations.Keys)
					{
						string[] directories = Directory.GetDirectories(Locations[key]);
						_ = directories.Length;
						int num = 0;
						GameObject result = buttonHandle.Result;
						string[] array = directories;
						foreach (string text in array)
						{
							string fileName = Path.GetFileName(text);
							string text2 = Path.Combine(text, "metadata.GCMD");
							string text3 = Path.Combine(text, "pack.GCMD");
							if (!File.Exists(text2) && !File.Exists(text3) && key != "Global" && key != "Version")
							{
								BatonPass.Debug("Skipping: " + fileName + " at " + text2);
							}
							else
							{
								if (File.Exists(text3))
								{
									GCPACK gCPACK = MDR.ReadPack(text3);
									try
									{
										string[] subDirectories = gCPACK.SubDirectories;
										foreach (string text4 in subDirectories)
										{
											UnsafeNotice unsafeNotice = CheckIfUnsafe(text4);
											if (unsafeNotice.IsSafe)
											{
												string text5 = Path.Combine(text, text4);
												if (Directory.Exists(text5) && unsafeNotice.IsSafe)
												{
													BuildButton(key, contentfolder, MDR, result, text5);
												}
												else
												{
													BatonPass.Warn("\"" + text5 + "\" does not exist in the Pack. This is most likely an incorrect folder name in the Pack.GCMD file located in \"" + text3 + "\". Code -\"MMAN-GENERATEBUTTONS-MAINMENU-PACKPATH_MISSING_LOCATION\"");
												}
											}
											else
											{
												BatonPass.Warn("Refusing to load Subdirectory at " + text4);
												BatonPass.Warn(unsafeNotice.Reason1);
												BatonPass.Warn(unsafeNotice.Reason2);
											}
										}
									}
									catch (Exception ex)
									{
										BatonPass.Error("Could not reach subdirectories due to a possible failed deserialization,this error should be accompanied by \"MMAN-MDR-READPACK-PACK_READ_WARNING\". Pack " + fileName + " will be skipped. CODE -\"MMAN-MAINMENU-PACK_READ_FAILURE\"");
										BatonPass.Error(ex.Message);
									}
								}
								else
								{
									BuildButton(key, contentfolder, MDR, result, text);
								}
								num++;
							}
						}
					}
					orderfixer(contentfolder);
					orderifier(activateanimator, contentfolder);
				}
				else
				{
					BatonPass.Error("Failed to load ultraskinsButton: " + buttonHandle.OperationException.Message);
					BatonPass.Error("Ultraskins will still work, but skin changes via the menu will be disabled. CODE -\"MMAN-GENERATEBUTTONS-MAINMENU-ASSET_BUNDLE_FAILED\"");
				}
			};
		}

		public void BuildButton(string Location, GameObject contentfolder, metadataReader MDR, GameObject prefab, string subfolder)
		{
			BatonPass.Debug("Building Button for " + subfolder);
			string fileName = Path.GetFileName(subfolder);
			string text = Path.Combine(subfolder, "metadata.GCMD");
			Path.Combine(subfolder, "pack.GCMD");
			GameObject val = Object.Instantiate<GameObject>(prefab, contentfolder.transform);
			val.SetActive(true);
			Button componentInChildren = val.GetComponentInChildren<Button>();
			BatonPass.Debug("Looking for BEM");
			ButtonEnableManager component = val.GetComponent<ButtonEnableManager>();
			component.skinDetails = SD;
			if (Location == "r2modman" || Location == "Thunderstore")
			{
				component.thunderstore = true;
			}
			if (File.Exists(text))
			{
				try
				{
					GCMD gCMD = MDR.ReadMD(text);
					string text2 = null;
					if (gCMD != null)
					{
						if (Utility.IsNullOrWhiteSpace(gCMD.PackFormat))
						{
							component.warning = true;
							text2 = "Pack Format is missing, Skin may have issues";
						}
						else if (!USC.SupportedPackFormats.Contains(gCMD.PackFormat))
						{
							text2 = "Made for a different version of ultraskins";
							component.warning = true;
						}
						if (!Utility.IsNullOrWhiteSpace(gCMD.Description))
						{
							component.SkinDescription = gCMD.Description;
						}
						else
						{
							component.SkinDescription = "No Info";
						}
						if (!Utility.IsNullOrWhiteSpace(gCMD.SkinName))
						{
							component.SkinName = gCMD.SkinName;
							((TMP_Text)((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>()).text = gCMD.SkinName;
						}
						else
						{
							component.SkinName = fileName;
						}
						if (!Utility.IsNullOrWhiteSpace(gCMD.Author))
						{
							component.Author = gCMD.Author;
						}
						else
						{
							component.Author = "Unknown";
						}
						if (gCMD.SupportedPlugins != null && gCMD.SupportedPlugins.Count >= 1)
						{
							component.isplugin = true;
						}
						if (!Utility.IsNullOrWhiteSpace(gCMD.Version))
						{
							component.VerNum = gCMD.Version;
						}
						if (!string.IsNullOrWhiteSpace(gCMD.IconOveride))
						{
							if (CheckIfUnsafe(gCMD.IconOveride).IsSafe)
							{
								ICFinder(subfolder, component, gCMD.IconOveride);
							}
							else
							{
								BatonPass.Warn("Skipping Unsafe Icon for " + gCMD.IconOveride);
							}
						}
						else
						{
							ICFinder(subfolder, component);
						}
					}
					else
					{
						((TMP_Text)((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>()).text = fileName;
						component.SkinName = fileName;
						component.warning = true;
						text2 = "The metadata file is null";
						ICFinder(subfolder, component);
					}
					if (text2 != null)
					{
						component.warningmessage = text2;
					}
				}
				catch (Exception ex)
				{
					BatonPass.Error("Something went wrong with the metadata formatting, falling back");
					component.SkinName = fileName;
					BatonPass.Error(ex.ToString());
				}
			}
			else
			{
				((TMP_Text)((Component)componentInChildren).GetComponentInChildren<TextMeshProUGUI>()).text = fileName;
				component.SkinName = fileName;
			}
			((Object)val).name = fileName;
			component.filePath = subfolder;
			AvailbleSkins.Add(fileName + subfolder.GetHashCode(), componentInChildren);
			component.DecideColor();
			component.makeObject();
			BatonPass.Debug("Successfully loaded and instantiated ultraskinsButton.");
		}

		public async void ICFinder(string subfolder, ButtonEnableManager BEM, string IconName = "icon.png")
		{
			try
			{
				string subhash = subfolder.GetHashCode().ToString();
				if (handInstance.IconCache.TryGetValue(subhash, out var value))
				{
					BEM.RawIcon = value;
					BEM.RawIcon.Apply();
					return;
				}
				string text = Path.Combine(subfolder, IconName);
				if (File.Exists(text))
				{
					BatonPass.Debug("Searching for icon " + text);
					byte[] array = await LoadSingleIcon(text);
					Texture2D val = new Texture2D(2, 2);
					((Object)val).name = IconName;
					BatonPass.Debug("Creating " + ((Object)val).name);
					BEM.RawIcon = val;
					((Texture)val).filterMode = (FilterMode)0;
					ULTRASKINHand.HoldEm.Bet(ULTRASKINHand.HoldEm.HoldemType.IC, subhash, (Texture)(object)val);
					ImageConversion.LoadImage(BEM.RawIcon, array);
					BEM.RawIcon.Apply();
				}
			}
			catch (Exception ex)
			{
				BatonPass.Error(ex.Message + ", Code -\"MMAN-ICFINDER-EX\"");
				BatonPass.Error(ex.ToString());
			}
		}

		private void orderifier(ObjectActivateInSequence activateanimator, GameObject contentfolder)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			loadedButtons.Clear();
			foreach (Transform item in contentfolder.transform)
			{
				Transform val = item;
				loadedButtons.Add(((Component)val).gameObject);
			}
			GameObject gameObject = ((Component)((Component)contentfolder.transform.parent).gameObject.transform.Find("Special")).gameObject;
			loadedButtons.Add(gameObject);
			foreach (Transform item2 in gameObject.transform)
			{
				Transform val2 = item2;
				loadedButtons.Add(((Component)val2).gameObject);
			}
			BatonPass.Debug("All buttons loaded, setting up activation sequence.");
			activateanimator.objectsToActivate = loadedButtons.ToArray();
			activateanimator.delay = 0.05f;
			BatonPass.Debug("Successfully set up ObjectActivateInSequence.");
		}

		private void orderfixer(GameObject contentfolder)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			BatonPass.Debug("attempting to order files");
			string[] array = handInstance.filepathArray.Reverse().ToArray();
			List<(Transform, int, ButtonEnableManager)> list = new List<(Transform, int, ButtonEnableManager)>();
			foreach (Transform item2 in contentfolder.transform)
			{
				Transform val = item2;
				ButtonEnableManager component = ((Component)val).GetComponent<ButtonEnableManager>();
				string filePath = component.filePath;
				if (array.Contains(filePath))
				{
					int item = Array.IndexOf(array, filePath);
					BatonPass.Debug(((Object)val).name + " has path: " + filePath + " and index of: " + item);
					list.Add((val, item, component));
				}
				else
				{
					BatonPass.Debug("no match for " + filePath);
				}
			}
			foreach (var (val2, siblingIndex, val3) in list.OrderBy<(Transform, int, ButtonEnableManager), int>(((Transform trans, int spot, ButtonEnableManager bem) x) => x.spot))
			{
				val2.SetSiblingIndex(siblingIndex);
				val3.IsEnabled = true;
			}
		}

		[Obsolete("To Be Removed")]
		public void GenerateButtons(GameObject contentfolder)
		{
			//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)
			Dictionary<string, string> Locations = SkinEventHandler.GetCurrentLocations();
			metadataReader MDR = new metadataReader();
			AvailbleSkins.Clear();
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/ultraskins/ultraskinsButton.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> buttonHandle)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unkno

usUI.dll

Decompiled 2 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UltraSkins.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
public class CameraOrthoPerspectiveSwitcher : MonoBehaviour
{
	public Camera cam;

	public float transitionDuration = 2f;

	private bool isOrtho = true;

	private Coroutine transitionRoutine;

	private void Start()
	{
		if ((Object)(object)cam == (Object)null)
		{
			cam = Camera.main;
		}
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)32) && transitionRoutine == null)
		{
			transitionRoutine = ((MonoBehaviour)this).StartCoroutine(SwitchCameraMode());
		}
	}

	private IEnumerator SwitchCameraMode()
	{
		float elapsed = 0f;
		float startOrthoSize = cam.orthographicSize;
		_ = cam.fieldOfView;
		_ = ((Component)cam).transform.position;
		float targetOrthoSize = 5f;
		float targetFOV = 60f;
		float camZOrtho = -10f;
		float camZPersp = -10f;
		if (isOrtho)
		{
			while (elapsed < transitionDuration)
			{
				float num = elapsed / transitionDuration;
				cam.orthographicSize = Mathf.Lerp(startOrthoSize, 0.01f, num);
				cam.fieldOfView = Mathf.Lerp(1f, targetFOV, num);
				((Component)cam).transform.position = Vector3.Lerp(new Vector3(0f, 0f, camZOrtho), new Vector3(0f, 0f, camZPersp), num);
				elapsed += Time.deltaTime;
				yield return null;
			}
			cam.orthographic = false;
		}
		else
		{
			cam.orthographic = true;
			while (elapsed < transitionDuration)
			{
				float num2 = elapsed / transitionDuration;
				cam.orthographicSize = Mathf.Lerp(0.01f, targetOrthoSize, num2);
				cam.fieldOfView = Mathf.Lerp(targetFOV, 1f, num2);
				((Component)cam).transform.position = Vector3.Lerp(new Vector3(0f, 0f, camZPersp), new Vector3(0f, 0f, camZOrtho), num2);
				elapsed += Time.deltaTime;
				yield return null;
			}
		}
		isOrtho = !isOrtho;
		transitionRoutine = null;
	}
}
public class LerpRectTransformFull : MonoBehaviour
{
	[Header("Transforms")]
	public RectTransform startTransform;

	public RectTransform endTransform;

	public float lerpDuration = 2f;

	[Header("External UI Controls")]
	public RotateObject spinnyboi;

	public ChildCycler cyclechild;

	public BandScroller bandScroller;

	private RectTransform rt;

	private Coroutine lerpCoroutine;

	public Quaternion lerpinresetRot = Quaternion.Euler(0f, 90f, 0f);

	public Vector3 lerpresetLoc = new Vector3(0f, 0f, 0f);

	public Vector3 lerpresetScale = new Vector3(1f, 1f, 1f);

	public Quaternion lerpoutresetRot = Quaternion.Euler(0f, 0f, 0f);

	public Image image_mask;

	public GameObject Stylization;

	private void Awake()
	{
		rt = ((Component)this).GetComponent<RectTransform>();
	}

	public void MenuModeOn()
	{
		StartLerpRoutine(startTransform, endTransform, forward: true);
	}

	public void MenuModeOff()
	{
		StartLerpRoutine(endTransform, startTransform, forward: false);
	}

	public void StartLerpRoutine(RectTransform from, RectTransform to, bool forward)
	{
		if (lerpCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(lerpCoroutine);
		}
		lerpCoroutine = ((MonoBehaviour)this).StartCoroutine(LerpSequence(from, to, forward));
	}

	private IEnumerator LerpSequence(RectTransform from, RectTransform to, bool forward)
	{
		if (forward)
		{
			spinnyboi.pause = true;
			spinnyboi.allowDrag = true;
			spinnyboi.allowPanZoom = true;
			spinnyboi.LerptoRot(lerpinresetRot, 0.5f);
			bandScroller.scrollin(1f, 0f);
			cyclechild.isPaused = true;
		}
		else
		{
			((Behaviour)image_mask).enabled = false;
			spinnyboi.pause = false;
			spinnyboi.allowDrag = false;
			spinnyboi.allowPanZoom = false;
			spinnyboi.LerptoRot(lerpoutresetRot, 0.5f);
			spinnyboi.LerptoScale(lerpresetScale, 0.5f);
			spinnyboi.LerptoPos(lerpresetLoc, 0.5f);
			cyclechild.isPaused = false;
			bandScroller.scrollin(1f, 1f);
			Stylization.SetActive(false);
		}
		float startTime = Time.realtimeSinceStartup;
		while (Time.realtimeSinceStartup - startTime < lerpDuration)
		{
			float num = (Time.realtimeSinceStartup - startTime) / lerpDuration;
			((Transform)rt).position = Vector3.Lerp(((Transform)from).position, ((Transform)to).position, num);
			((Transform)rt).localScale = Vector3.Lerp(((Transform)from).localScale, ((Transform)to).localScale, num);
			((Transform)rt).rotation = Quaternion.Lerp(((Transform)from).rotation, ((Transform)to).rotation, num);
			rt.sizeDelta = Vector2.Lerp(from.sizeDelta, to.sizeDelta, num);
			yield return null;
		}
		((Transform)rt).position = ((Transform)to).position;
		((Transform)rt).localScale = ((Transform)to).localScale;
		((Transform)rt).rotation = ((Transform)to).rotation;
		rt.sizeDelta = to.sizeDelta;
		if (forward)
		{
			((Behaviour)image_mask).enabled = true;
			Stylization.SetActive(true);
		}
		lerpCoroutine = null;
	}

	private IEnumerator AnimateMask(float from, float to)
	{
		float duration = 0.5f;
		float time = 0f;
		while (time < duration)
		{
			float num = time / duration;
			Mathf.Lerp(from, to, num);
			time += Time.deltaTime;
			yield return null;
		}
	}
}
public class ReturnTo : MonoBehaviour
{
	public Animator animator;

	public GameObject mainmenucanvas;

	public GameObject Configmenu;

	public GameObject fallnoiseoff;

	public void Closeskineditor()
	{
		fallnoiseoff.SetActive(true);
		animator.Play("closemenu");
		((MonoBehaviour)this).StartCoroutine(DisableAfterAnimation());
	}

	private IEnumerator DisableAfterAnimation()
	{
		AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
		float length = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length;
		yield return (object)new WaitForSeconds(length);
		mainmenucanvas.SetActive(true);
		Configmenu.SetActive(false);
	}
}
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[1855]
		{
			0, 0, 0, 1, 0, 0, 0, 39, 92, 65,
			115, 115, 101, 116, 115, 92, 117, 108, 116, 114,
			97, 115, 107, 105, 110, 115, 92, 83, 99, 114,
			105, 112, 116, 115, 92, 65, 98, 111, 117, 116,
			77, 101, 110, 117, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 42, 92, 65, 115, 115, 101,
			116, 115, 92, 117, 108, 116, 114, 97, 115, 107,
			105, 110, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 66, 97, 110, 100, 83, 99, 114, 111,
			108, 108, 101, 114, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 49, 92, 65, 115, 115, 101,
			116, 115, 92, 117, 108, 116, 114, 97, 115, 107,
			105, 110, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 66, 117, 116, 116, 111, 110, 69, 110,
			97, 98, 108, 101, 77, 97, 110, 97, 103, 101,
			114, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 40, 92, 65, 115, 115, 101, 116, 115, 92,
			117, 108, 116, 114, 97, 115, 107, 105, 110, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 67,
			97, 109, 101, 114, 97, 83, 116, 101, 112, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 37,
			92, 65, 115, 115, 101, 116, 115, 92, 117, 108,
			116, 114, 97, 115, 107, 105, 110, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 67, 97, 109,
			76, 101, 114, 112, 46, 99, 115, 0, 0, 0,
			2, 0, 0, 0, 41, 92, 65, 115, 115, 101,
			116, 115, 92, 117, 108, 116, 114, 97, 115, 107,
			105, 110, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 67, 97, 109, 112, 67, 114, 101, 97,
			116, 111, 114, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 40, 92, 65, 115, 115, 101, 116,
			115, 92, 117, 108, 116, 114, 97, 115, 107, 105,
			110, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 67, 104, 105, 108, 100, 67, 121, 99, 108,
			101, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 46, 92, 65, 115, 115, 101, 116, 115, 92,
			117, 108, 116, 114, 97, 115, 107, 105, 110, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 67,
			114, 101, 97, 116, 111, 114, 83, 116, 97, 116,
			101, 72, 97, 110, 100, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 43, 92, 65, 115, 115,
			101, 116, 115, 92, 117, 108, 116, 114, 97, 115,
			107, 105, 110, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 68, 121, 110, 83, 116, 97, 116,
			77, 97, 116, 114, 105, 120, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 45, 92, 65, 115,
			115, 101, 116, 115, 92, 117, 108, 116, 114, 97,
			115, 107, 105, 110, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 69, 100, 105, 116, 77, 101,
			110, 117, 73, 110, 102, 111, 66, 111, 120, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 45,
			92, 65, 115, 115, 101, 116, 115, 92, 117, 108,
			116, 114, 97, 115, 107, 105, 110, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 69, 100, 105,
			116, 77, 101, 110, 117, 77, 97, 110, 97, 103,
			101, 114, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 35, 92, 65, 115, 115, 101, 116, 115,
			92, 117, 108, 116, 114, 97, 115, 107, 105, 110,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			69, 88, 109, 97, 110, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 34, 92, 65, 115, 115,
			101, 116, 115, 92, 117, 108, 116, 114, 97, 115,
			107, 105, 110, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 71, 111, 84, 111, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 48, 92, 65,
			115, 115, 101, 116, 115, 92, 117, 108, 116, 114,
			97, 115, 107, 105, 110, 115, 92, 83, 99, 114,
			105, 112, 116, 115, 92, 76, 105, 103, 104, 116,
			98, 111, 120, 67, 111, 110, 116, 114, 111, 108,
			108, 101, 114, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 43, 92, 65, 115, 115, 101, 116,
			115, 92, 117, 108, 116, 114, 97, 115, 107, 105,
			110, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 77, 105, 103, 114, 97, 116, 105, 111, 110,
			80, 97, 103, 101, 46, 99, 115, 0, 0, 0,
			2, 0, 0, 0, 44, 92, 65, 115, 115, 101,
			116, 115, 92, 117, 108, 116, 114, 97, 115, 107,
			105, 110, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 79, 71, 83, 107, 105, 110, 115, 77,
			97, 110, 97, 103, 101, 114, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 40, 92, 65, 115,
			115, 101, 116, 115, 92, 117, 108, 116, 114, 97,
			115, 107, 105, 110, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 79, 110, 69, 100, 105, 116,
			79, 112, 101, 110, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 46, 92, 65, 115, 115, 101,
			116, 115, 92, 117, 108, 116, 114, 97, 115, 107,
			105, 110, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 79, 112, 101, 110, 70, 105, 108, 101,
			69, 120, 112, 108, 111, 114, 101, 114, 46, 99,
			115, 0, 0, 0, 1, 0, 0, 0, 42, 92,
			65, 115, 115, 101, 116, 115, 92, 117, 108, 116,
			114, 97, 115, 107, 105, 110, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 79, 114, 100, 101,
			114, 77, 97, 110, 97, 103, 101, 114, 46, 99,
			115, 0, 0, 0, 1, 0, 0, 0, 49, 92,
			65, 115, 115, 101, 116, 115, 92, 117, 108, 116,
			114, 97, 115, 107, 105, 110, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 112, 111, 105, 110,
			116, 101, 114, 104, 111, 118, 101, 114, 116, 114,
			97, 99, 107, 101, 114, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 46, 92, 65, 115, 115,
			101, 116, 115, 92, 117, 108, 116, 114, 97, 115,
			107, 105, 110, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 80, 114, 101, 118, 87, 101, 97,
			112, 111, 110, 66, 117, 116, 116, 111, 110, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 43,
			92, 65, 115, 115, 101, 116, 115, 92, 117, 108,
			116, 114, 97, 115, 107, 105, 110, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 80, 114, 111,
			112, 101, 114, 116, 121, 77, 97, 107, 101, 114,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			37, 92, 65, 115, 115, 101, 116, 115, 92, 117,
			108, 116, 114, 97, 115, 107, 105, 110, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 80, 87,
			101, 112, 84, 97, 103, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 38, 92, 65, 115, 115,
			101, 116, 115, 92, 117, 108, 116, 114, 97, 115,
			107, 105, 110, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 82, 101, 116, 117, 114, 110, 84,
			111, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 42, 92, 65, 115, 115, 101, 116, 115, 92,
			117, 108, 116, 114, 97, 115, 107, 105, 110, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 82,
			101, 116, 117, 114, 110, 84, 111, 77, 101, 110,
			117, 46, 99, 115, 0, 0, 0, 3, 0, 0,
			0, 44, 92, 65, 115, 115, 101, 116, 115, 92,
			117, 108, 116, 114, 97, 115, 107, 105, 110, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 83,
			101, 116, 116, 105, 110, 103, 77, 97, 110, 97,
			103, 101, 114, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 51, 92, 65, 115, 115, 101, 116,
			115, 92, 117, 108, 116, 114, 97, 115, 107, 105,
			110, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 83, 101, 116, 116, 105, 110, 103, 115, 66,
			117, 116, 116, 111, 110, 83, 99, 114, 105, 112,
			116, 115, 46, 99, 115, 0, 0, 0, 2, 0,
			0, 0, 43, 92, 65, 115, 115, 101, 116, 115,
			92, 117, 108, 116, 114, 97, 115, 107, 105, 110,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			83, 101, 116, 116, 105, 110, 103, 83, 116, 114,
			117, 99, 116, 46, 99, 115, 0, 0, 0, 2,
			0, 0, 0, 41, 92, 65, 115, 115, 101, 116,
			115, 92, 117, 108, 116, 114, 97, 115, 107, 105,
			110, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 83, 107, 105, 110, 68, 101, 116, 97, 105,
			108, 115, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 40, 92, 65, 115, 115, 101, 116, 115,
			92, 117, 108, 116, 114, 97, 115, 107, 105, 110,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			83, 108, 105, 100, 101, 114, 84, 101, 120, 116,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			45, 92, 65, 115, 115, 101, 116, 115, 92, 117,
			108, 116, 114, 97, 115, 107, 105, 110, 115, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 83, 109,
			105, 108, 101, 70, 105, 108, 101, 66, 117, 116,
			116, 111, 110, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 34, 92, 65, 115, 115, 101, 116,
			115, 92, 117, 108, 116, 114, 97, 115, 107, 105,
			110, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 83, 112, 105, 110, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 39, 92, 65, 115, 115,
			101, 116, 115, 92, 117, 108, 116, 114, 97, 115,
			107, 105, 110, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 83, 116, 97, 114, 116, 76, 101,
			114, 112, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 48, 92, 65, 115, 115, 101, 116, 115,
			92, 117, 108, 116, 114, 97, 115, 107, 105, 110,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			84, 104, 117, 110, 100, 101, 114, 115, 116, 111,
			114, 101, 72, 97, 110, 100, 108, 101, 46, 99,
			115, 0, 0, 0, 1, 0, 0, 0, 37, 92,
			65, 115, 115, 101, 116, 115, 92, 117, 108, 116,
			114, 97, 115, 107, 105, 110, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 84, 105, 108, 101,
			77, 97, 110, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 40, 92, 65, 115, 115, 101, 116,
			115, 92, 117, 108, 116, 114, 97, 115, 107, 105,
			110, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 84, 121, 112, 101, 87, 114, 105, 116, 101,
			114, 46, 99, 115, 0, 0, 0, 1, 0, 0,
			0, 43, 92, 65, 115, 115, 101, 116, 115, 92,
			117, 108, 116, 114, 97, 115, 107, 105, 110, 115,
			92, 83, 99, 114, 105, 112, 116, 115, 92, 85,
			73, 67, 111, 108, 111, 114, 83, 108, 105, 100,
			101, 114, 46, 99, 115
		};
		result.TypesData = new byte[1395]
		{
			0, 0, 0, 0, 23, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 65,
			98, 111, 117, 116, 77, 101, 110, 117, 0, 0,
			0, 0, 26, 85, 108, 116, 114, 97, 83, 107,
			105, 110, 115, 46, 85, 73, 124, 66, 97, 110,
			100, 83, 99, 114, 111, 108, 108, 101, 114, 0,
			0, 0, 0, 33, 85, 108, 116, 114, 97, 83,
			107, 105, 110, 115, 46, 85, 73, 124, 66, 117,
			116, 116, 111, 110, 69, 110, 97, 98, 108, 101,
			77, 97, 110, 97, 103, 101, 114, 0, 0, 0,
			0, 31, 124, 67, 97, 109, 101, 114, 97, 79,
			114, 116, 104, 111, 80, 101, 114, 115, 112, 101,
			99, 116, 105, 118, 101, 83, 119, 105, 116, 99,
			104, 101, 114, 0, 0, 0, 0, 22, 124, 76,
			101, 114, 112, 82, 101, 99, 116, 84, 114, 97,
			110, 115, 102, 111, 114, 109, 70, 117, 108, 108,
			0, 0, 0, 0, 25, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 67,
			97, 109, 112, 67, 114, 101, 97, 116, 111, 114,
			0, 0, 0, 0, 34, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 46, 67,
			97, 109, 112, 67, 114, 101, 97, 116, 111, 114,
			124, 84, 69, 77, 80, 71, 67, 77, 68, 0,
			0, 0, 0, 25, 85, 108, 116, 114, 97, 83,
			107, 105, 110, 115, 46, 85, 73, 124, 67, 104,
			105, 108, 100, 67, 121, 99, 108, 101, 114, 0,
			0, 0, 0, 30, 85, 108, 116, 114, 97, 83,
			107, 105, 110, 115, 46, 85, 73, 124, 67, 114,
			101, 97, 116, 111, 114, 83, 116, 97, 116, 101,
			72, 97, 110, 100, 0, 0, 0, 0, 27, 85,
			108, 116, 114, 97, 83, 107, 105, 110, 115, 46,
			85, 73, 124, 68, 121, 110, 83, 116, 97, 116,
			77, 97, 116, 114, 105, 120, 0, 0, 0, 0,
			29, 85, 108, 116, 114, 97, 83, 107, 105, 110,
			115, 46, 85, 73, 124, 69, 100, 105, 116, 77,
			101, 110, 117, 73, 110, 102, 111, 66, 111, 120,
			0, 0, 0, 0, 29, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 69,
			100, 105, 116, 77, 101, 110, 117, 77, 97, 110,
			97, 103, 101, 114, 0, 0, 0, 0, 19, 85,
			108, 116, 114, 97, 83, 107, 105, 110, 115, 46,
			85, 73, 124, 69, 120, 77, 97, 110, 0, 0,
			0, 0, 30, 85, 108, 116, 114, 97, 83, 107,
			105, 110, 115, 46, 85, 73, 124, 71, 111, 116,
			111, 83, 101, 116, 116, 105, 110, 103, 115, 80,
			97, 103, 101, 0, 0, 0, 0, 32, 85, 108,
			116, 114, 97, 83, 107, 105, 110, 115, 46, 85,
			73, 124, 76, 105, 103, 104, 116, 98, 111, 120,
			67, 111, 110, 116, 114, 111, 108, 108, 101, 114,
			0, 0, 0, 0, 27, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 77,
			105, 103, 114, 97, 116, 105, 111, 110, 80, 97,
			103, 101, 0, 0, 0, 0, 25, 85, 108, 116,
			114, 97, 83, 107, 105, 110, 115, 124, 79, 71,
			83, 107, 105, 110, 115, 77, 97, 110, 97, 103,
			101, 114, 0, 0, 0, 0, 24, 85, 108, 116,
			114, 97, 83, 107, 105, 110, 115, 124, 79, 71,
			84, 101, 120, 116, 117, 114, 101, 80, 97, 105,
			114, 0, 0, 0, 0, 24, 85, 108, 116, 114,
			97, 83, 107, 105, 110, 115, 46, 85, 73, 124,
			79, 110, 69, 100, 105, 116, 79, 112, 101, 110,
			0, 0, 0, 0, 30, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 79,
			112, 101, 110, 70, 105, 108, 101, 69, 120, 112,
			108, 111, 114, 101, 114, 0, 0, 0, 0, 26,
			85, 108, 116, 114, 97, 83, 107, 105, 110, 115,
			46, 85, 73, 124, 79, 114, 100, 101, 114, 77,
			97, 110, 97, 103, 101, 114, 0, 0, 0, 0,
			33, 85, 108, 116, 114, 97, 83, 107, 105, 110,
			115, 46, 85, 73, 124, 112, 111, 105, 110, 116,
			101, 114, 104, 111, 118, 101, 114, 116, 114, 97,
			99, 107, 101, 114, 0, 0, 0, 0, 30, 85,
			108, 116, 114, 97, 83, 107, 105, 110, 115, 46,
			85, 73, 124, 80, 114, 101, 118, 87, 101, 97,
			112, 111, 110, 66, 117, 116, 116, 111, 110, 0,
			0, 0, 0, 27, 85, 108, 116, 114, 97, 83,
			107, 105, 110, 115, 46, 85, 73, 124, 80, 114,
			111, 112, 101, 114, 116, 121, 77, 97, 107, 101,
			114, 0, 0, 0, 0, 21, 85, 108, 116, 114,
			97, 83, 107, 105, 110, 115, 46, 85, 73, 124,
			80, 87, 101, 112, 84, 97, 103, 0, 0, 0,
			0, 9, 124, 82, 101, 116, 117, 114, 110, 84,
			111, 0, 0, 0, 0, 26, 85, 108, 116, 114,
			97, 83, 107, 105, 110, 115, 46, 85, 73, 124,
			82, 101, 116, 117, 114, 110, 84, 111, 77, 101,
			110, 117, 0, 0, 0, 0, 29, 85, 108, 116,
			114, 97, 83, 107, 105, 110, 115, 46, 85, 73,
			124, 83, 101, 116, 116, 105, 110, 103, 115, 77,
			97, 110, 97, 103, 101, 114, 0, 0, 0, 0,
			42, 85, 108, 116, 114, 97, 83, 107, 105, 110,
			115, 46, 85, 73, 46, 83, 101, 116, 116, 105,
			110, 103, 115, 77, 97, 110, 97, 103, 101, 114,
			124, 83, 101, 116, 116, 105, 110, 103, 69, 110,
			116, 114, 121, 0, 0, 0, 0, 42, 85, 108,
			116, 114, 97, 83, 107, 105, 110, 115, 46, 85,
			73, 46, 83, 101, 116, 116, 105, 110, 103, 115,
			77, 97, 110, 97, 103, 101, 114, 124, 83, 97,
			118, 101, 100, 83, 101, 116, 116, 105, 110, 103,
			0, 0, 0, 0, 35, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 83,
			101, 116, 116, 105, 110, 103, 115, 66, 117, 116,
			116, 111, 110, 83, 99, 114, 105, 112, 116, 115,
			0, 0, 0, 0, 26, 85, 108, 116, 114, 97,
			83, 107, 105, 110, 115, 46, 85, 73, 124, 83,
			101, 116, 116, 105, 110, 103, 69, 110, 116, 114,
			121, 0, 0, 0, 0, 32, 85, 108, 116, 114,
			97, 83, 107, 105, 110, 115, 46, 85, 73, 124,
			83, 101, 116, 116, 105, 110, 103, 76, 105, 115,
			116, 87, 114, 97, 112, 112, 101, 114, 0, 0,
			0, 0, 25, 85, 108, 116, 114, 97, 83, 107,
			105, 110, 115, 46, 85, 73, 124, 83, 107, 105,
			110, 68, 101, 116, 97, 105, 108, 115, 0, 0,
			0, 0, 26, 85, 108, 116, 114, 97, 83, 107,
			105, 110, 115, 46, 85, 73, 124, 68, 101, 116,
			97, 105, 108, 79, 98, 106, 101, 99, 116, 0,
			0, 0, 0, 24, 85, 108, 116, 114, 97, 83,
			107, 105, 110, 115, 46, 85, 73, 124, 83, 108,
			105, 100, 101, 114, 84, 101, 120, 116, 0, 0,
			0, 0, 29, 85, 108, 116, 114, 97, 83, 107,
			105, 110, 115, 46, 85, 73, 124, 83, 109, 105,
			108, 101, 70, 105, 108, 101, 66, 117, 116, 116,
			111, 110, 0, 0, 0, 0, 26, 85, 108, 116,
			114, 97, 83, 107, 105, 110, 115, 46, 85, 73,
			124, 82, 111, 116, 97, 116, 101, 79, 98, 106,
			101, 99, 116, 0, 0, 0, 0, 23, 85, 108,
			116, 114, 97, 83, 107, 105, 110, 115, 46, 85,
			73, 124, 83, 116, 97, 114, 116, 76, 101, 114,
			112, 0, 0, 0, 0, 32, 85, 108, 116, 114,
			97, 83, 107, 105, 110, 115, 46, 85, 73, 124,
			84, 104, 117, 110, 100, 101, 114, 115, 116, 111,
			114, 101, 72, 97, 110, 100, 108, 101, 0, 0,
			0, 0, 21, 85, 108, 116, 114, 97, 83, 107,
			105, 110, 115, 46, 85, 73, 124, 84, 105, 108,
			101, 77, 97, 110, 0, 0, 0, 0, 24, 85,
			108, 116, 114, 97, 83, 107, 105, 110, 115, 46,
			85, 73, 124, 84, 121, 112, 101, 87, 114, 105,
			116, 101, 114, 0, 0, 0, 0, 27, 85, 108,
			116, 114, 97, 83, 107, 105, 110, 115, 46, 85,
			73, 124, 85, 73, 67, 111, 108, 111, 114, 83,
			108, 105, 100, 101, 114
		};
		result.TotalFiles = 37;
		result.TotalTypes = 43;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace UltraSkins
{
	public class OGSkinsManager : MonoBehaviour
	{
		[SerializeField]
		public List<OGTexturePair> RawSkins;

		public List<Texture> RawTex;

		public List<string> RawNames;

		public Dictionary<string, Texture> OGSKINS = new Dictionary<string, Texture>();

		private void Awake()
		{
			Debug.Log((object)("OGSkinsManager attached to GameObject: " + ((Object)((Component)this).gameObject).name));
			Debug.Log((object)string.Format("RawSkins is {0}, count: {1}", (RawSkins == null) ? "NULL" : "NOT NULL", RawSkins?.Count ?? (-1)));
			BuildDictionary();
		}

		public void BuildDictionary()
		{
			for (int i = 0; i < Mathf.Min(RawNames.Count, RawTex.Count); i++)
			{
				if (!string.IsNullOrEmpty(RawNames[i]) && (Object)(object)RawTex[i] != (Object)null)
				{
					if (!OGSKINS.ContainsKey(RawNames[i]))
					{
						OGSKINS.Add(RawNames[i], RawTex[i]);
					}
					else
					{
						Debug.LogWarning((object)("Duplicate key found in OGSkinsManager: " + RawNames[i]));
					}
				}
			}
		}
	}
	[Serializable]
	public class OGTexturePair
	{
		public string key;

		public Texture texture;
	}
}
namespace UltraSkins.UI
{
	public class AboutMenu : MonoBehaviour
	{
		[Header("GameObjects for the about page")]
		public TextMeshProUGUI verblock;

		public TextMeshProUGUI GCblock;

		public TextMeshProUGUI SPFblock;

		public GameObject HPtag;

		public GameObject MDtag;

		public GameObject TStag;

		private void Start()
		{
		}

		public void SetAboutVersionInfo(string version, string buildtype, string ogskinsverson, string[] supportedformats)
		{
			((TMP_Text)verblock).text = version + "-" + buildtype;
			((TMP_Text)GCblock).text = ogskinsverson;
			((TMP_Text)SPFblock).text = string.Join(", ", supportedformats);
		}

		private void Update()
		{
		}
	}
	public class BandScroller : MonoBehaviour
	{
		public float bandValue;

		public float scrollSpeed = 1f;

		public bool pause = true;

		private void Start()
		{
			Shader.SetGlobalFloat("_BandPosition", bandValue);
		}

		private void Update()
		{
		}

		public void scrollin(float dur, float amountfill)
		{
			((MonoBehaviour)this).StartCoroutine(scrollincoroutine(dur, amountfill));
		}

		private IEnumerator scrollincoroutine(float duration, float amountfill)
		{
			float startRotation = bandValue;
			float timeElapsed = 0f;
			while (timeElapsed < duration)
			{
				bandValue = Mathf.Lerp(startRotation, amountfill, timeElapsed / duration);
				timeElapsed += Time.unscaledDeltaTime;
				Shader.SetGlobalFloat("_BandPosition", bandValue);
				yield return null;
			}
		}
	}
	public class ButtonEnableManager : MonoBehaviour
	{
		[SerializeField]
		private Behaviour componentToToggle;

		[SerializeField]
		private bool isEnabled = true;

		[SerializeField]
		public bool thunderstore;

		public Image border;

		public SkinDetails skinDetails;

		public Texture2D RawIcon;

		private Sprite Icon;

		public bool warning;

		public bool error;

		public string filePath;

		[Header("Data")]
		public string SkinName;

		public string SkinDescription;

		public string VerNum;

		public string warningmessage;

		public string Author;

		public bool isplugin;

		public DetailObject DETOB = new DetailObject();

		public bool IsEnabled
		{
			get
			{
				return isEnabled;
			}
			set
			{
				isEnabled = value;
				if ((Object)(object)componentToToggle != (Object)null)
				{
					componentToToggle.enabled = isEnabled;
				}
			}
		}

		public void DecideColor()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (error)
			{
				((Graphic)border).color = Color.red;
			}
			else if (warning)
			{
				((Graphic)border).color = Color.yellow;
			}
			else if (thunderstore)
			{
				((Graphic)border).color = Color32.op_Implicit(new Color32((byte)23, byte.MaxValue, (byte)176, byte.MaxValue));
			}
			else
			{
				((Graphic)border).color = Color.white;
			}
		}

		private void OnDestroy()
		{
			Object.Destroy((Object)(object)Icon);
		}

		public void Toggle()
		{
			isEnabled = !isEnabled;
			if ((Object)(object)componentToToggle != (Object)null)
			{
				componentToToggle.enabled = isEnabled;
			}
		}

		private void Start()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Icon = Sprite.Create(RawIcon, new Rect(0f, 0f, (float)((Texture)RawIcon).width, (float)((Texture)RawIcon).height), new Vector2(0.5f, 0.5f));
			if ((Object)(object)componentToToggle != (Object)null)
			{
				componentToToggle.enabled = isEnabled;
			}
			makeObject();
		}

		public void callRefresh()
		{
			if ((Object)(object)skinDetails != (Object)null)
			{
				skinDetails.OnRefreshDetails(DETOB);
			}
		}

		public void makeObject()
		{
			if (SkinDescription != null)
			{
				DETOB.SkinDescription = SkinDescription;
			}
			if ((Object)(object)Icon != (Object)null)
			{
				DETOB.icon = Icon;
			}
			if (Author != null)
			{
				DETOB.Author = Author;
			}
			if (warningmessage != null)
			{
				DETOB.warningmessage = warningmessage;
			}
			if (VerNum != null)
			{
				DETOB.versionNumber = VerNum;
			}
			DETOB.isPlugin = isplugin;
			if (SkinName != null)
			{
				DETOB.SkinName = SkinName;
			}
		}

		private void OnValidate()
		{
			if ((Object)(object)componentToToggle != (Object)null)
			{
				componentToToggle.enabled = isEnabled;
			}
		}
	}
	public class CampCreator : MonoBehaviour
	{
		public class TEMPGCMD
		{
			public string Name { get; set; }

			public string Description { get; set; }

			public string Author { get; set; }

			public string? iconpath { get; set; }

			public string? Version { get; set; }
		}

		public bool TemplateMode;

		public string SkinName;

		public string SkinDescription;

		public string SkinAuthor;

		public TMP_InputField tmpSkinName;

		public string skinIconPath;

		public TextMeshProUGUI iconNoteField;

		public OpenFileExplorer IconSkinExp;

		public TMP_InputField tmpVer;

		public TMP_InputField tmpAuthor;

		public TMP_InputField tmpDesc;

		public Button CreateButton;

		public string SkinIconPath
		{
			get
			{
				return skinIconPath;
			}
			set
			{
				if (!(skinIconPath == value))
				{
					skinIconPath = value;
					if (!string.IsNullOrWhiteSpace(value))
					{
						((TMP_Text)iconNoteField).text = "Selected: <color=green>" + Path.GetFileName(value) + "</color>";
					}
					else
					{
						((TMP_Text)iconNoteField).text = "<color=red>NO VALUE</color> is currently selected";
					}
				}
			}
		}

		private void Start()
		{
			IconSkinExp.OnPathSelected = delegate(string path)
			{
				SkinIconPath = path;
			};
			((UnityEvent<string>)(object)tmpSkinName.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				skinnamechange();
			});
			((UnityEvent<string>)(object)tmpDesc.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				Descnamechange();
			});
			((UnityEvent<string>)(object)tmpSkinName.onEndEdit).AddListener((UnityAction<string>)delegate
			{
				validatetext();
			});
			((UnityEvent<string>)(object)tmpDesc.onEndEdit).AddListener((UnityAction<string>)delegate
			{
				validatetext();
			});
		}

		public void SetTemplateMode(bool value)
		{
			TemplateMode = value;
		}

		private void skinnamechange()
		{
			SkinName = tmpSkinName.text;
		}

		private void Descnamechange()
		{
			SkinDescription = tmpDesc.text;
		}

		private void Authnamechange()
		{
			SkinAuthor = tmpAuthor.text;
		}

		private void validatetext()
		{
			if (!string.IsNullOrWhiteSpace(SkinName) && !string.IsNullOrWhiteSpace(SkinDescription))
			{
				((Selectable)CreateButton).interactable = true;
			}
			else
			{
				((Selectable)CreateButton).interactable = false;
			}
		}

		public TEMPGCMD GatherInfo()
		{
			TEMPGCMD tEMPGCMD = new TEMPGCMD();
			tEMPGCMD.Name = SkinName;
			tEMPGCMD.Description = SkinDescription;
			if (!string.IsNullOrWhiteSpace(SkinIconPath))
			{
				tEMPGCMD.iconpath = SkinIconPath;
			}
			if (!string.IsNullOrWhiteSpace(tmpVer.text))
			{
				tEMPGCMD.Version = tmpVer.text;
			}
			if (!string.IsNullOrWhiteSpace(tmpAuthor.text))
			{
				tEMPGCMD.Author = tmpAuthor.text;
			}
			return tEMPGCMD;
		}

		public void ClearAllEntrys()
		{
			tmpSkinName.text = "";
			tmpDesc.text = "";
			tmpVer.text = "";
			IconSkinExp.returnedValue = "";
			SkinIconPath = "";
		}
	}
	public class ChildCycler : MonoBehaviour
	{
		public enum PWeaponModel
		{
			Revolver,
			Slab,
			Shotgun,
			Hammer,
			Nailgun,
			Sawblade,
			Railcannon,
			RocketLauncher,
			MainArm,
			Feedbacker,
			Knuckleblaster,
			Whiplash
		}

		public float cycleDuration = 2f;

		public bool isPaused;

		private float timer;

		private Dictionary<PWeaponModel, PWepTag> pWepMap = new Dictionary<PWeaponModel, PWepTag>();

		private PWeaponModel currentPwep;

		public UIColorSlider UICS;

		private void Start()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			pWepMap.Clear();
			foreach (Transform item in ((Component)this).transform)
			{
				Transform val = item;
				PWepTag component = ((Component)val).GetComponent<PWepTag>();
				if ((Object)(object)component != (Object)null && !pWepMap.ContainsKey(component.pWeaponModel))
				{
					pWepMap[component.pWeaponModel] = component;
					((Component)val).gameObject.SetActive(false);
				}
			}
			ShowChildAt(currentPwep);
		}

		private void Update()
		{
			if (((Component)this).transform.childCount != 0 && pWepMap.Count != 0 && !isPaused)
			{
				timer += Time.deltaTime;
				if (timer >= cycleDuration)
				{
					timer = 0f;
					currentPwep = GetNextPwep(currentPwep);
					ShowChildAt(currentPwep);
				}
			}
		}

		public void ShowChildAt(PWeaponModel pWeaponModel)
		{
			foreach (KeyValuePair<PWeaponModel, PWepTag> item in pWepMap)
			{
				((Component)item.Value).gameObject.SetActive(item.Key == pWeaponModel);
			}
			if (pWepMap.TryGetValue(pWeaponModel, out var value))
			{
				UICS.SupportID(value.SupportID);
				if (!value.SupportID)
				{
					UICS.modechange(change: false);
					UICS.SupportID(supported: false);
				}
				else
				{
					UICS.SupportID(supported: true);
				}
			}
			currentPwep = pWeaponModel;
			timer = 0f;
		}

		private PWeaponModel GetNextPwep(PWeaponModel current)
		{
			PWeaponModel[] array = (PWeaponModel[])Enum.GetValues(typeof(PWeaponModel));
			int num = (Array.IndexOf(array, current) + 1) % array.Length;
			Debug.Log((object)$"Showing stage {current} next {num}");
			return array[num];
		}
	}
	public class CreatorStateHand : MonoBehaviour
	{
		public GameObject PlusIcon;

		public List<GameObject> TextToEnableTemp;

		public List<GameObject> TextToEnableScratch;

		public Animator animator;

		public GameObject blocker;

		public string CreationName;

		public string CreationDescription;

		public string CreationDepend;

		private void Start()
		{
		}

		public void PlayAnimationFromStart(string animationName)
		{
			animator.Play(animationName, -1, 0f);
		}

		public void UpdateName(string newtext)
		{
			CreationName = newtext;
		}

		public void UpdateDesc(string newtext)
		{
			CreationDescription = newtext;
		}
	}
	public class DynStatMatrix : MonoBehaviour
	{
		public List<GameObject> DynamicObjects;

		public List<GameObject> StaticObjects;

		public List<Behaviour> DynamicComp;

		public List<Behaviour> StaticComp;

		public void ShowStaticAssets()
		{
			foreach (GameObject dynamicObject in DynamicObjects)
			{
				dynamicObject.SetActive(false);
			}
			foreach (GameObject staticObject in StaticObjects)
			{
				staticObject.SetActive(true);
			}
		}

		public void ShowDynamicAssets()
		{
			foreach (GameObject staticObject in StaticObjects)
			{
				staticObject.SetActive(false);
			}
			foreach (GameObject dynamicObject in DynamicObjects)
			{
				dynamicObject.SetActive(true);
			}
		}

		public void HideAllAssets()
		{
			foreach (GameObject dynamicObject in DynamicObjects)
			{
				dynamicObject.SetActive(false);
			}
			foreach (GameObject staticObject in StaticObjects)
			{
				staticObject.SetActive(false);
			}
		}
	}
	public class EditMenuInfoBox : MonoBehaviour
	{
		public enum SpinState
		{
			Good,
			Bad
		}

		public Image Border;

		public Image PlusImage;

		public Transform PlusTransform;

		public Animator plusAnimator;

		public TextMeshProUGUI TextSlot1;

		public TextMeshProUGUI TextSlot2;

		public float spinSpeed = 180f;

		public Button OpenFolder;

		public Button ReturnToMainMenu;

		public Button GoBack;

		private Coroutine spinRoutine;

		private bool isSpinning;

		public void Start()
		{
		}

		public void StartThrobber()
		{
			plusAnimator.SetTrigger("StartLoop");
		}

		public void StopThrobber(SpinState spinstate)
		{
			((MonoBehaviour)this).StartCoroutine(SpinToFinalPosition(spinstate));
		}

		private IEnumerator SpinToFinalPosition(SpinState spinstate)
		{
			yield return null;
			switch (spinstate)
			{
			case SpinState.Good:
				plusAnimator.SetTrigger("Good");
				break;
			case SpinState.Bad:
				plusAnimator.SetTrigger("Bad");
				break;
			}
		}

		public void ForceSetThrobber(float degree, Color color)
		{
			//IL_0011: 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)
			PlusTransform.rotation = Quaternion.Euler(0f, 0f, degree);
			((Graphic)PlusImage).color = color;
		}

		public void setText1(string text)
		{
			((TMP_Text)TextSlot1).text = text;
		}

		public void setText2(string text)
		{
			((TMP_Text)TextSlot2).text = text;
		}
	}
	public class EditMenuManager : MonoBehaviour
	{
		public SkinDetails skindetails;

		public CampCreator campCreator;

		public GameObject Editor;

		public EditMenuInfoBox editMenuInfoBox;

		public ThunderstoreHandle thunderstoreHandle;

		public MigrationPage MigrationPage;

		[Header("Special Buttons for Versions")]
		public GameObject ThunderstoreFixButton;

		public GameObject MigrationToolButton;

		[Header("Audio Sources")]
		public AudioSource EnableMenuSound;

		public void returntomenu()
		{
			((Component)editMenuInfoBox).gameObject.SetActive(false);
			Editor.SetActive(true);
			campCreator.ClearAllEntrys();
		}
	}
	public class ExMan : MonoBehaviour
	{
		public enum Types
		{
			Free,
			Restricted
		}

		public enum presets
		{
			Desktop,
			Downloads,
			Documents,
			Pictures,
			Music,
			Videos,
			Ultraskins
		}

		private string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

		private string downloads = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");

		private string documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

		private string pictures = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

		private string music = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);

		private string videos = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);

		private string UltraskinsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bobthecorn2000", "ULTRAKILL");

		private string currentdir;

		public Types Type;

		public GameObject buttonholder;

		public GameObject nofilefoundblocker;

		public TMP_InputField pathArea;

		[SerializeField]
		private ToggleGroup fileToggleGroup;

		public List<string> filter;

		public GameObject content;

		public GameObject fileButton;

		public GameObject loadblocker;

		public Button upbutton;

		public string directoryabove;

		public Scrollbar scrollbar;

		public OpenFileExplorer sourcebutton;

		public GameObject errorModel;

		public TextMeshProUGUI errorModelText;

		private void Start()
		{
			switch (Type)
			{
			case Types.Free:
				ChangeDir(desktop);
				break;
			case Types.Restricted:
				buttonholder.SetActive(false);
				((Selectable)pathArea).interactable = false;
				((Component)((Component)pathArea).transform.Find("Button")).gameObject.SetActive(false);
				break;
			}
		}

		public void ChangeDir(string path)
		{
			if (path != currentdir)
			{
				((MonoBehaviour)this).StartCoroutine(ChangeDirCo(path));
			}
		}

		public void ChangeDirFolder(string path)
		{
			if (path != currentdir)
			{
				((MonoBehaviour)this).StartCoroutine(FolderSelector(path));
			}
		}

		public void ChangeWithBar()
		{
			ChangeDir(pathArea.text);
		}

		public void CreateErrorModel(string text)
		{
			errorModel.SetActive(true);
			((TMP_Text)errorModelText).text = text;
		}

		public void upOneDir()
		{
			ChangeDir(directoryabove);
		}

		public IEnumerator ChangeDirCo(string dir)
		{
			if (!Directory.Exists(dir))
			{
				string text = "SmileOS can't find \"" + dir + "\". Check the spelling and try again.";
				CreateErrorModel(text);
				yield break;
			}
			loadblocker.SetActive(true);
			yield return null;
			((Selectable)scrollbar).interactable = false;
			((Selectable)pathArea).interactable = false;
			pathArea.text = dir;
			currentdir = dir;
			foreach (Transform item in content.transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			DirectoryInfo directoryInfo = new DirectoryInfo(dir);
			if (directoryInfo.Parent != null)
			{
				((Selectable)upbutton).interactable = true;
				directoryabove = directoryInfo.Parent.FullName;
			}
			else
			{
				((Selectable)upbutton).interactable = false;
				directoryabove = "";
			}
			DirectoryInfo[] directories = directoryInfo.GetDirectories();
			foreach (DirectoryInfo directoryInfo2 in directories)
			{
				if ((directoryInfo2.Attributes & (FileAttributes.Hidden | FileAttributes.System)) == 0)
				{
					GameObject val = Object.Instantiate<GameObject>(fileButton, content.transform);
					SmileFileButton btn = val.GetComponent<SmileFileButton>();
					val.SetActive(false);
					btn.FileName = directoryInfo2.Name;
					btn.FullPath = directoryInfo2.FullName;
					btn.isfolder = true;
					btn.icontype = SmileFileButton.IconType.Folder;
					((UnityEvent)btn.button.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
					{
						ChangeDir(btn.FullPath);
					});
					val.SetActive(true);
				}
			}
			int num = 0;
			bool flag = false;
			FileInfo[] files = directoryInfo.GetFiles();
			foreach (FileInfo fileInfo in files)
			{
				if ((fileInfo.Attributes & (FileAttributes.Hidden | FileAttributes.System)) != 0 || (filter != null && filter.Count > 0 && !filter.Contains(fileInfo.Extension.ToLower())))
				{
					continue;
				}
				if ((fileInfo.Extension == ".png" || fileInfo.Extension == ".jpg" || fileInfo.Extension == ".jpeg" || fileInfo.Extension == ".tga" || fileInfo.Extension == ".gif") && !flag)
				{
					num++;
					if (num > SettingsManager.Instance.GetSettingValue<int>("TN_MaxAmount"))
					{
						flag = true;
					}
				}
				GameObject obj = Object.Instantiate<GameObject>(fileButton, content.transform);
				SmileFileButton component = obj.GetComponent<SmileFileButton>();
				obj.SetActive(false);
				component.FileName = fileInfo.Name;
				component.FullPath = fileInfo.FullName;
				component.hardcap = flag;
				component.isfolder = false;
				component.icontype = GetIconType(fileInfo.Extension);
				component.toggletype.GetComponent<Toggle>().group = fileToggleGroup;
				obj.SetActive(true);
			}
			if (content.transform.childCount == 0)
			{
				nofilefoundblocker.SetActive(true);
			}
			else
			{
				nofilefoundblocker.SetActive(false);
			}
			loadblocker.SetActive(false);
			((Selectable)scrollbar).interactable = true;
			((Selectable)pathArea).interactable = true;
		}

		public IEnumerator FolderSelector(string dir, bool detection = false)
		{
			if (!Directory.Exists(dir))
			{
				string text = "SmileOS can't find \"" + dir + "\". Check the spelling and try again.";
				CreateErrorModel(text);
				yield break;
			}
			loadblocker.SetActive(true);
			yield return null;
			currentdir = dir;
			DirectoryInfo[] directories = new DirectoryInfo(dir).GetDirectories();
			foreach (DirectoryInfo directoryInfo in directories)
			{
				bool flag = true;
				if (detection)
				{
					FileInfo[] files = directoryInfo.GetFiles();
					foreach (FileInfo fileInfo in files)
					{
						if (fileInfo.Extension == ".gcmd" || fileInfo.Extension == ".gcpack")
						{
							flag = false;
							break;
						}
					}
				}
				if (flag)
				{
					GameObject obj = Object.Instantiate<GameObject>(fileButton, content.transform);
					SmileFileButton component = obj.GetComponent<SmileFileButton>();
					obj.SetActive(false);
					component.FileName = directoryInfo.Name;
					component.FullPath = directoryInfo.FullName;
					component.isfolder = false;
					component.icontype = SmileFileButton.IconType.Folder;
					obj.SetActive(true);
				}
			}
			loadblocker.SetActive(false);
		}

		public void onsubmit()
		{
			foreach (Toggle item in fileToggleGroup.ActiveToggles())
			{
				SmileFileButton componentInParent = ((Component)item).GetComponentInParent<SmileFileButton>();
				if ((Object)(object)componentInParent != (Object)null && item.isOn)
				{
					sourcebutton.onvalueget(componentInParent.FullPath);
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		public void oncancel()
		{
			sourcebutton.onvalueget("");
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void gotopreset(presets preset)
		{
			switch (preset)
			{
			case presets.Desktop:
				ChangeDir(desktop);
				break;
			case presets.Downloads:
				ChangeDir(downloads);
				break;
			case presets.Documents:
				ChangeDir(documents);
				break;
			case presets.Pictures:
				ChangeDir(pictures);
				break;
			case presets.Music:
				ChangeDir(music);
				break;
			case presets.Videos:
				ChangeDir(videos);
				break;
			case presets.Ultraskins:
				ChangeDir(UltraskinsPath);
				break;
			}
		}

		public void GoToDesktop()
		{
			gotopreset(presets.Desktop);
		}

		public void GoToDownloads()
		{
			gotopreset(presets.Downloads);
		}

		public void GoToDocuments()
		{
			gotopreset(presets.Documents);
		}

		public void GoToPictures()
		{
			gotopreset(presets.Pictures);
		}

		public void GoToMusic()
		{
			gotopreset(presets.Music);
		}

		public void GoToVideos()
		{
			gotopreset(presets.Videos);
		}

		public void GoToUltraskins()
		{
			gotopreset(presets.Ultraskins);
		}

		private SmileFileButton.IconType GetIconType(string extension)
		{
			switch (extension.ToLower())
			{
			case ".png":
			case ".jpg":
			case ".jpeg":
			case ".gif":
			case ".tga":
				return SmileFileButton.IconType.Image;
			case ".zip":
				return SmileFileButton.IconType.Zip;
			case ".gcskin":
				return SmileFileButton.IconType.GCskin;
			case ".mp3":
			case ".wav":
			case ".ogg":
				return SmileFileButton.IconType.Music;
			case ".mp4":
			case ".mov":
			case ".avi":
			case ".webm":
				return SmileFileButton.IconType.Video;
			case ".txt":
			case ".json":
			case ".xml":
			case ".csv":
			case ".cs":
			case ".log":
			case ".cfg":
				return SmileFileButton.IconType.Text;
			case ".usgc":
			case ".gcpack":
			case ".gcmd":
				return SmileFileButton.IconType.Internal;
			default:
				return SmileFileButton.IconType.Unknown;
			}
		}
	}
	public class GotoSettingsPage : MonoBehaviour
	{
		[SerializeField]
		public int targetPageIndex;

		[SerializeField]
		public GameObject rootpanel;

		[SerializeField]
		public bool UseStaticPage;

		private int previousPageIndex = -1;

		private void Start()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((UnityEvent)((Component)this).GetComponent<Button>().onClick).AddListener(new UnityAction(OnClick));
		}

		private void OnClick()
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			SettingsManager manager = SettingsManager.Instance;
			if ((Object)(object)rootpanel != (Object)null)
			{
				rootpanel.SetActive(false);
			}
			previousPageIndex = manager.GetCurrentPageIndex();
			if (previousPageIndex != -1)
			{
				manager.HidePage(previousPageIndex);
			}
			else
			{
				manager.ShowPagesContainer();
			}
			if (!UseStaticPage)
			{
				manager.ShowPage(targetPageIndex);
			}
			else
			{
				manager.ShowPagePause(targetPageIndex);
			}
			Button backButton = manager.GetBackButton(targetPageIndex);
			if ((Object)(object)backButton == (Object)null)
			{
				Debug.LogWarning((object)"Back button not assigned for target page");
				return;
			}
			((UnityEventBase)backButton.onClick).RemoveAllListeners();
			((UnityEvent)backButton.onClick).AddListener((UnityAction)delegate
			{
				manager.HidePage(targetPageIndex);
				if ((Object)(object)rootpanel != (Object)null)
				{
					rootpanel.SetActive(true);
				}
				if (previousPageIndex != -1)
				{
					if (!UseStaticPage)
					{
						manager.ShowPage(previousPageIndex);
					}
					else
					{
						manager.ShowPagePause(previousPageIndex);
					}
				}
				else
				{
					manager.HidePagesContainer();
				}
			});
		}
	}
	public class LightboxController : MonoBehaviour
	{
		public enum OpenType
		{
			FirstParty,
			ThirdParty
		}

		public TextMeshProUGUI textbox;

		private string runtimelocation;

		private string licensecache;

		private string Tlicensecache;

		public GameObject Lightbox;

		private void Awake()
		{
			runtimelocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}

		public static string ReadTextFile(string filePath)
		{
			if (!File.Exists(filePath))
			{
				return "License File Missing";
			}
			return File.ReadAllText(filePath);
		}

		public void OpenLightBox(int type)
		{
			switch ((OpenType)type)
			{
			case OpenType.FirstParty:
				if (licensecache == null)
				{
					licensecache = ReadTextFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "LICENSE.txt"));
				}
				((TMP_Text)textbox).text = licensecache;
				break;
			case OpenType.ThirdParty:
				if (Tlicensecache == null)
				{
					Tlicensecache = ReadTextFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "THIRD-PARTY-LICENSE.txt"));
				}
				((TMP_Text)textbox).text = Tlicensecache;
				break;
			}
			Lightbox.SetActive(true);
		}

		public void CloseLightbox()
		{
			Lightbox.SetActive(false);
			((TMP_Text)textbox).text = "";
		}
	}
	public class MigrationPage : MonoBehaviour
	{
		public GameObject SkinTilePrefab;

		public GameObject UI;

		public GameObject NoDataBlocker;

		[Header("Good parent")]
		public GameObject GoodParent;

		public GameObject GParNone;

		[Header("Bad parent")]
		public GameObject BadParent;

		public GameObject BParNone;

		public Button continuebutton;

		public List<string> migratableFolders = new List<string>();

		private void Start()
		{
		}

		private void OnEnable()
		{
			if (GoodParent.transform.childCount > 0)
			{
				GParNone.SetActive(false);
				((Selectable)continuebutton).interactable = true;
			}
			else
			{
				GParNone.SetActive(true);
				((Selectable)continuebutton).interactable = false;
			}
			if (BadParent.transform.childCount > 0)
			{
				BParNone.SetActive(false);
			}
			else
			{
				BParNone.SetActive(true);
			}
		}

		public void ActivateMigratorTool()
		{
			NoDataBlocker.SetActive(false);
			UI.SetActive(true);
		}

		public void AddOptionToSupported(string file)
		{
			TileMan component = Object.Instantiate<GameObject>(SkinTilePrefab, GoodParent.transform).GetComponent<TileMan>();
			component.FolderPath = file;
			if (!migratableFolders.Contains(file))
			{
				migratableFolders.Add(file);
			}
			component.ChangeText(Path.GetFileName(file));
		}

		public void RemoveOptionFromSupported()
		{
		}

		public void AddOptionToUnsupported(string file)
		{
			TileMan component = Object.Instantiate<GameObject>(SkinTilePrefab, BadParent.transform).GetComponent<TileMan>();
			component.FolderPath = file;
			component.ChangeText(Path.GetFileName(file));
		}

		public void ClearMenu()
		{
			for (int num = GoodParent.transform.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)GoodParent.transform.GetChild(num)).gameObject);
			}
			migratableFolders.Clear();
			GParNone.SetActive(true);
			for (int num2 = BadParent.transform.childCount - 1; num2 >= 0; num2--)
			{
				Object.Destroy((Object)(object)((Component)BadParent.transform.GetChild(num2)).gameObject);
			}
			BParNone.SetActive(true);
		}
	}
	public class OnEditOpen : MonoBehaviour
	{
		private void OnEnable()
		{
			SettingsManager.Instance.ShowPreviewWireFrame(toggle: true);
			SettingsManager.Instance.ShowSettingsAssets(toggle: true);
		}

		private void OnDisable()
		{
			SettingsManager.Instance.ShowPreviewWireFrame(toggle: false);
			SettingsManager.Instance.ShowSettingsAssets(toggle: false);
		}
	}
	public class OpenFileExplorer : MonoBehaviour
	{
		private Button button;

		public TextMeshProUGUI NoteField;

		public List<string> filter = new List<string>();

		public Action<string> OnPathSelected;

		public string returnedValue;

		public GameObject ExplororPrefab;

		private void Start()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			button = ((Component)this).GetComponent<Button>();
			if ((Object)(object)button != (Object)null)
			{
				((UnityEvent)button.onClick).AddListener(new UnityAction(createExplorer));
			}
		}

		public void createExplorer()
		{
			ExMan component = Object.Instantiate<GameObject>(ExplororPrefab).GetComponent<ExMan>();
			component.filter = filter;
			component.sourcebutton = this;
		}

		public void onvalueget(string value)
		{
			if (value != null)
			{
				returnedValue = value;
				OnPathSelected?.Invoke(value);
				if (Object.op_Implicit((Object)(object)NoteField))
				{
					((TMP_Text)NoteField).text = "Selected: <color=green>" + returnedValue + "</color>";
				}
			}
			else if (Object.op_Implicit((Object)(object)NoteField))
			{
				((TMP_Text)NoteField).text = "<color=red>NO VALUE</color> is currently selected";
			}
		}

		private void Update()
		{
		}
	}
	public class OrderManager : MonoBehaviour
	{
		[SerializeField]
		private Button moveUpButton;

		[SerializeField]
		private Button moveDownButton;

		public bool disabled;

		private Transform lastParent;

		private int lastSiblingIndex;

		public void Start()
		{
			if (disabled)
			{
				((Selectable)moveUpButton).interactable = false;
				((Selectable)moveDownButton).interactable = false;
			}
			if (((Behaviour)this).enabled)
			{
				UpdateButtons();
			}
		}

		public void MoveUp()
		{
			int siblingIndex = ((Component)this).transform.GetSiblingIndex();
			if (siblingIndex > 0)
			{
				lastParent = ((Component)this).transform.parent;
				lastSiblingIndex = ((Component)this).transform.GetSiblingIndex();
				((Component)this).transform.SetSiblingIndex(siblingIndex - 1);
				UpdateButtons();
			}
		}

		public void MoveDown()
		{
			int siblingIndex = ((Component)this).transform.GetSiblingIndex();
			int childCount = ((Component)this).transform.parent.childCount;
			if (siblingIndex < childCount - 1)
			{
				((Component)this).transform.SetSiblingIndex(siblingIndex + 1);
				UpdateButtons();
			}
		}

		private void UpdateButtons()
		{
			int siblingIndex = ((Component)this).transform.GetSiblingIndex();
			int childCount = ((Component)this).transform.parent.childCount;
			if ((Object)(object)moveUpButton != (Object)null)
			{
				((Selectable)moveUpButton).interactable = siblingIndex > 0;
			}
			if ((Object)(object)moveDownButton != (Object)null)
			{
				((Selectable)moveDownButton).interactable = siblingIndex < childCount - 1;
			}
		}

		private void Update()
		{
			if ((Object)(object)((Component)this).transform.parent != (Object)(object)lastParent || ((Component)this).transform.GetSiblingIndex() != lastSiblingIndex)
			{
				lastParent = ((Component)this).transform.parent;
				lastSiblingIndex = ((Component)this).transform.GetSiblingIndex();
				UpdateButtons();
			}
		}
	}
	public class pointerhovertracker : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler
	{
		public ButtonEnableManager targetObject;

		public void OnPointerEnter(PointerEventData eventData)
		{
			targetObject.callRefresh();
		}
	}
	public class PrevWeaponButton : MonoBehaviour
	{
		public ChildCycler.PWeaponModel changetotype;

		public ChildCycler childCycler;

		public UIColorSlider uiColorSlider;

		private void Start()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Button component = ((Component)this).GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				((UnityEvent)component.onClick).AddListener(new UnityAction(OnButtonClicked));
			}
			else
			{
				Debug.LogWarning((object)("No Button component found on " + ((Object)((Component)this).gameObject).name));
			}
		}

		private void OnButtonClicked()
		{
			childCycler.ShowChildAt(changetotype);
		}
	}
	public class PropertyMaker : MonoBehaviour
	{
		public enum Mode
		{
			Settings,
			Title
		}

		[Header("Mode Selection")]
		public Mode currentMode;

		[Header("Shared References")]
		public GameObject backdrop;

		[Header("Settings Mode")]
		public GameObject[] selectableComponents;

		public GameObject Reload;

		public GameObject Disclaimer;

		public TextMeshProUGUI settingName;

		[Header("Title Mode")]
		public TextMeshProUGUI CatLabel;

		[Header("Settings Mode Options")]
		public int activeComponentIndex;

		public bool enableReload;

		public bool enableDisclaimer;

		public string settingsLabelText = "Default Settings Name";

		public string DisclaimerText = "Default";

		public bool enableBackdrop = true;

		[Header("Title Mode Options")]
		public string titleText = "-- Temp --\n<size=30>small temp</size>";

		[Header("Setting ID")]
		public string settingID;

		private void Start()
		{
		}

		private void OnValidate()
		{
			ApplyMode();
		}

		public void ApplyMode()
		{
			if (currentMode == Mode.Settings)
			{
				for (int i = 0; i < selectableComponents.Length; i++)
				{
					if ((Object)(object)selectableComponents[i] != (Object)null)
					{
						selectableComponents[i].SetActive(i == activeComponentIndex);
					}
				}
				if ((Object)(object)Reload != (Object)null)
				{
					Reload.SetActive(enableReload);
				}
				if ((Object)(object)Disclaimer != (Object)null)
				{
					Disclaimer.SetActive(enableDisclaimer);
					((TMP_Text)Disclaimer.GetComponent<TextMeshProUGUI>()).text = DisclaimerText;
				}
				if ((Object)(object)settingName != (Object)null)
				{
					((TMP_Text)settingName).text = settingsLabelText;
				}
				if ((Object)(object)backdrop != (Object)null)
				{
					backdrop.SetActive(enableBackdrop);
				}
				if ((Object)(object)CatLabel != (Object)null)
				{
					((Component)CatLabel).gameObject.SetActive(false);
				}
			}
			else
			{
				if (currentMode != Mode.Title)
				{
					return;
				}
				GameObject[] array = selectableComponents;
				foreach (GameObject val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.SetActive(false);
					}
				}
				if ((Object)(object)Reload != (Object)null)
				{
					Reload.SetActive(false);
				}
				if ((Object)(object)Disclaimer != (Object)null)
				{
					Disclaimer.SetActive(false);
				}
				if ((Object)(object)backdrop != (Object)null)
				{
					backdrop.SetActive(false);
				}
				if ((Object)(object)settingName != (Object)null)
				{
					((TMP_Text)settingName).text = "";
				}
				if ((Object)(object)CatLabel != (Object)null)
				{
					((TMP_Text)CatLabel).text = titleText;
					((Component)CatLabel).gameObject.SetActive(true);
				}
			}
		}
	}
	public class PWepTag : MonoBehaviour
	{
		public ChildCycler.PWeaponModel pWeaponModel;

		public bool SupportID;

		public bool SupportEmissive;
	}
	public class ReturnToMenu : MonoBehaviour
	{
		public GameObject pageRoot;

		public Button backButton;

		private GameObject returnTarget;

		private void Awake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if ((Object)(object)backButton != (Object)null)
			{
				((UnityEvent)backButton.onClick).AddListener(new UnityAction(Return));
			}
		}

		public void SetReturnTarget(GameObject target)
		{
			returnTarget = target;
		}

		public void Return()
		{
			if ((Object)(object)pageRoot != (Object)null)
			{
				pageRoot.SetActive(false);
			}
			if ((Object)(object)returnTarget != (Object)null)
			{
				returnTarget.SetActive(true);
			}
		}
	}
	public class SettingsManager : MonoBehaviour
	{
		private class SettingEntry
		{
			[JsonProperty("id")]
			public string ID { get; set; }

			[JsonProperty("label")]
			public string Label { get; set; }

			[JsonProperty("type")]
			public string Type { get; set; }

			[JsonProperty("disclaimer")]
			public string Disclaimer { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public bool DefaultBool { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public int DefaultInt { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public List<string> Options { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public string DefaultOption { get; set; }
		}

		public class SavedSetting
		{
			[JsonProperty("id")]
			public string ID { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public bool? SavedBool { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public int? SavedInt { get; set; }

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public string SavedOption { get; set; }
		}

		public SettingsButtonScripts SBS;

		public AboutMenu aboutMenu;

		[Header("Prefab & UI Setup")]
		[Tooltip("Prefab with PropertyMaker component")]
		public GameObject propertyBlockPrefab;

		[Tooltip("Parent transform where setting blocks will be instantiated")]
		public Transform settingsParent;

		private List<SettingEntry> settingsData = new List<SettingEntry>();

		public List<SavedSetting> SavedSettings = new List<SavedSetting>();

		[Header("Menu and System")]
		public GameObject wireframe;

		public GameObject PreviewCam;

		public GameObject CameraModels;

		public GameObject Canvas;

		[SerializeField]
		private GameObject pagesContainer;

		[SerializeField]
		private List<GameObject> pages;

		[SerializeField]
		private List<Button> backButtons;

		public string SaveSettingPath;

		private int currentPageIndex = -1;

		public static SettingsManager Instance { get; private set; }

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Shader.SetGlobalColor("_US_ECP", new Color(0f, 0f, 0f, 1f));
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		public void LoadSettingsFromJson(string USGCPath)
		{
			//IL_0036: Expected O, but got Unknown
			if (!File.Exists(USGCPath))
			{
				Debug.LogError((object)("Settings USGC file not found at: " + USGCPath));
				return;
			}
			try
			{
				string text = File.ReadAllText(USGCPath);
				settingsData = JsonConvert.DeserializeObject<List<SettingEntry>>(text);
				ClearSettingsUI();
			}
			catch (JsonException val)
			{
				JsonException val2 = val;
				Debug.LogError((object)("Error parsing settings USGC: " + ((Exception)(object)val2).Message));
			}
		}

		public void loadUserSettings(string path)
		{
			//IL_004b: Expected O, but got Unknown
			if (!File.Exists(path))
			{
				Debug.LogError((object)("Saved settings file not found: " + path));
				SavedSettings.Clear();
				return;
			}
			try
			{
				string text = File.ReadAllText(path);
				SaveSettingPath = path;
				SavedSettings = JsonConvert.DeserializeObject<List<SavedSetting>>(text) ?? new List<SavedSetting>();
			}
			catch (JsonException val)
			{
				JsonException val2 = val;
				Debug.LogError((object)("Failed to parse saved settings: " + ((Exception)(object)val2).Message));
			}
		}

		public void BuildSettingsUI()
		{
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			if ((Object)(object)settingsParent == (Object)null)
			{
				Debug.LogError((object)"SettingsManager: settingsParent not assigned.");
				return;
			}
			ClearSettingsUI();
			foreach (SettingEntry setting in settingsData)
			{
				PropertyMaker component = Object.Instantiate<GameObject>(propertyBlockPrefab, settingsParent).GetComponent<PropertyMaker>();
				int num = MapTypeToComponentIndex(setting.Type);
				if ((Object)(object)component == (Object)null)
				{
					Debug.LogWarning((object)"PropertyMaker component missing on prefab.");
					continue;
				}
				if (num == -1)
				{
					component.currentMode = PropertyMaker.Mode.Title;
					component.titleText = setting.Label;
				}
				else
				{
					component.currentMode = PropertyMaker.Mode.Settings;
					component.settingsLabelText = setting.Label;
					component.activeComponentIndex = num;
					component.settingID = setting.ID;
					if (setting.Disclaimer != null)
					{
						component.enableDisclaimer = true;
						component.DisclaimerText = setting.Disclaimer;
					}
					if (setting.Options != null)
					{
						component.selectableComponents[2].GetComponent<TMP_Dropdown>().AddOptions(((IEnumerable<string>)setting.Options).Select((Func<string, OptionData>)((string option) => new OptionData(option))).ToList());
					}
				}
				component.ApplyMode();
				if (num == 0)
				{
					Toggle toggle = component.selectableComponents[0].GetComponent<Toggle>();
					bool settingValue = GetSettingValue<bool>(setting.ID);
					toggle.isOn = settingValue;
					((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
					{
						SetSavedSetting(setting.ID, toggle.isOn);
					});
				}
				if (num == 1)
				{
					Button component2 = component.selectableComponents[1].GetComponent<Button>();
					TextMeshProUGUI componentInChildren = ((Component)component2).GetComponentInChildren<TextMeshProUGUI>();
					string iD = setting.ID;
					if (!(iD == "BTN_GlobalSkinFolder"))
					{
						if (iD == "BTN_AboutMenu")
						{
							((Component)component2).gameObject.AddComponent<GotoSettingsPage>().targetPageIndex = 2;
							((TMP_Text)componentInChildren).text = "View";
						}
					}
					else
					{
						((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
						{
							SBS.OpenUltraskinsGlobalFolder();
						});
						((TMP_Text)componentInChildren).text = "Launch";
					}
				}
				if (num == 2)
				{
					TMP_Dropdown dropdown = component.selectableComponents[2].GetComponent<TMP_Dropdown>();
					int num2 = dropdown.options.FindIndex((OptionData option) => option.text == GetSettingValue<string>(setting.ID));
					if (num2 >= 0)
					{
						dropdown.value = num2;
						dropdown.RefreshShownValue();
					}
					((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate
					{
						SetSavedSetting(setting.ID, dropdown.options[dropdown.value].text);
					});
				}
				if (num == 3)
				{
					TMP_InputField inputfield = component.selectableComponents[3].GetComponent<TMP_InputField>();
					int settingValue2 = GetSettingValue<int>(setting.ID);
					inputfield.text = settingValue2.ToString();
					((UnityEvent<string>)(object)inputfield.onEndEdit).AddListener((UnityAction<string>)delegate
					{
						SetSavedSetting(setting.ID, int.Parse(inputfield.text));
					});
				}
			}
		}

		private void ClearSettingsUI()
		{
			if (!((Object)(object)settingsParent == (Object)null))
			{
				for (int num = settingsParent.childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)settingsParent.GetChild(num)).gameObject);
				}
			}
		}

		private int MapTypeToComponentIndex(string type)
		{
			return type?.ToLower() switch
			{
				"category" => -1, 
				"toggle" => 0, 
				"button" => 1, 
				"dropdown" => 2, 
				"int" => 3, 
				_ => 0, 
			};
		}

		public T GetSettingValue<T>(string id)
		{
			SavedSetting savedSetting = SavedSettings.FirstOrDefault((SavedSetting s) => s.ID == id);
			if (savedSetting != null)
			{
				if (typeof(T) == typeof(bool) && savedSetting.SavedBool.HasValue)
				{
					return (T)(object)savedSetting.SavedBool.Value;
				}
				if (typeof(T) == typeof(string) && !string.IsNullOrEmpty(savedSetting.SavedOption))
				{
					return (T)(object)savedSetting.SavedOption;
				}
				if (typeof(T) == typeof(int) && savedSetting.SavedInt.HasValue)
				{
					return (T)(object)savedSetting.SavedInt.Value;
				}
			}
			SettingEntry settingEntry = settingsData.FirstOrDefault((SettingEntry s) => s.ID == id);
			if (settingEntry != null)
			{
				if (typeof(T) == typeof(bool) && settingEntry.Type == "toggle")
				{
					return (T)(object)settingEntry.DefaultBool;
				}
				if (typeof(T) == typeof(string) && settingEntry.Type == "dropdown" && !string.IsNullOrEmpty(settingEntry.DefaultOption))
				{
					return (T)(object)settingEntry.DefaultOption;
				}
				if (typeof(T) == typeof(int) && settingEntry.Type == "int")
				{
					return (T)(object)settingEntry.DefaultInt;
				}
			}
			return default(T);
		}

		public void SetSavedSetting(string id, object value)
		{
			SavedSetting savedSetting = SavedSettings.FirstOrDefault((SavedSetting s) => s.ID == id);
			if (savedSetting == null)
			{
				savedSetting = new SavedSetting
				{
					ID = id
				};
				SavedSettings.Add(savedSetting);
			}
			if (value is bool value2)
			{
				savedSetting.SavedBool = value2;
				savedSetting.SavedOption = null;
			}
			else if (value is string savedOption)
			{
				savedSetting.SavedOption = savedOption;
				savedSetting.SavedBool = null;
			}
			else if (value is int value3)
			{
				savedSetting.SavedInt = value3;
				savedSetting.SavedBool = null;
			}
			SaveSettings(SaveSettingPath);
		}

		public void ShowSettingsAssets(bool toggle)
		{
			if (toggle)
			{
				Canvas.SetActive(true);
			}
			else
			{
				Canvas.SetActive(false);
			}
		}

		public void ShowPreviewWireFrame(bool toggle)
		{
			if (toggle)
			{
				PreviewCam.SetActive(true);
				wireframe.SetActive(true);
				CameraModels.SetActive(true);
			}
			else
			{
				PreviewCam.SetActive(false);
				wireframe.SetActive(false);
				CameraModels.SetActive(false);
			}
		}

		public void ShowPage(int index)
		{
			if (index < 0 || index >= pages.Count)
			{
				Debug.LogWarning((object)"Page index out of range");
				return;
			}
			if ((Object)(object)pagesContainer != (Object)null && !pagesContainer.activeSelf)
			{
				pagesContainer.SetActive(true);
			}
			foreach (GameObject page in pages)
			{
				page.SetActive(false);
			}
			pages[index].SetActive(true);
			pages[index].GetComponent<DynStatMatrix>().ShowDynamicAssets();
			currentPageIndex = index;
		}

		public void ShowPagePause(int index)
		{
			if (index < 0 || index >= pages.Count)
			{
				Debug.LogWarning((object)"Page index out of range");
				return;
			}
			if ((Object)(object)pagesContainer != (Object)null && !pagesContainer.activeSelf)
			{
				pagesContainer.SetActive(true);
			}
			foreach (GameObject page in pages)
			{
				page.SetActive(false);
			}
			pages[index].SetActive(true);
			pages[index].GetComponent<DynStatMatrix>().ShowStaticAssets();
			currentPageIndex = index;
		}

		public void HidePage(int index)
		{
			if (index >= 0 && index < pages.Count)
			{
				pages[index].SetActive(false);
				if ((Object)(object)pagesContainer != (Object)null && !AnyPageActive())
				{
					pagesContainer.SetActive(false);
				}
				if (currentPageIndex == index)
				{
					currentPageIndex = -1;
				}
			}
		}

		public Button GetBackButton(int pageIndex)
		{
			if (pageIndex < 0 || pageIndex >= backButtons.Count)
			{
				return null;
			}
			return backButtons[pageIndex];
		}

		public bool AnyPageActive()
		{
			foreach (GameObject page in pages)
			{
				if (page.activeSelf)
				{
					return true;
				}
			}
			return false;
		}

		public void ShowPagesContainer()
		{
			if ((Object)(object)pagesContainer != (Object)null)
			{
				pagesContainer.SetActive(true);
			}
		}

		public void HidePagesContainer()
		{
			if ((Object)(object)pagesContainer != (Object)null)
			{
				pagesContainer.SetActive(false);
			}
		}

		public int GetCurrentPageIndex()
		{
			return currentPageIndex;
		}

		public void SaveSettings(string filePath)
		{
			try
			{
				string contents = JsonConvert.SerializeObject((object)SavedSettings, (Formatting)1);
				File.WriteAllText(filePath, contents);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error saving settings: " + ex.Message));
			}
		}
	}
	public class SettingsButtonScripts : MonoBehaviour
	{
		private string UltraskinsPath;

		private void Start()
		{
			UltraskinsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bobthecorn2000", "ULTRAKILL", "ultraskinsGC-V2", "GlobalSkins");
		}

		public void OpenUltraskinsGlobalFolder()
		{
			if (Directory.Exists(UltraskinsPath))
			{
				Process.Start(new ProcessStartInfo
				{
					FileName = UltraskinsPath,
					UseShellExecute = true
				});
			}
		}
	}
	[Serializable]
	public class SettingEntry
	{
		public string type;

		public string key;

		public string label;

		public bool defaultBool;

		public float defaultFloat;

		public float min;

		public float max;
	}
	[Serializable]
	public class SettingListWrapper
	{
		public List<SettingEntry> entries;
	}
	public class SkinDetails : MonoBehaviour
	{
		public TMP_Text skinNameHolder;

		public TMP_Text skinDescHolder;

		public TypeWriter TP;

		public GameObject container;

		public Animator animator;

		public Sprite FallBackIcon;

		public bool warningmode;

		public TMP_Text warningmessage;

		public TMP_Text AuthorHolder;

		public Image IconImage;

		public GameObject PluginLogo;

		public TMP_Text versionNumberHolder;

		public void OnRefreshDetails(DetailObject detob)
		{
			versionNumberHolder.text = "";
			if (detob.isPlugin)
			{
				PluginLogo.SetActive(true);
			}
			else
			{
				PluginLogo.SetActive(false);
			}
			skinNameHolder.text = detob.SkinName;
			((Component)TP).gameObject.SetActive(false);
			if (!string.IsNullOrEmpty(detob.SkinDescription))
			{
				skinDescHolder.text = detob.SkinDescription;
				TP.RefreshFullText(detob.SkinDescription);
			}
			else
			{
				skinDescHolder.text = "No Info";
				TP.RefreshFullText("No Info");
			}
			((Component)TP).gameObject.SetActive(true);
			if ((Object)(object)detob.icon != (Object)null)
			{
				IconImage.sprite = detob.icon;
			}
			else
			{
				IconImage.sprite = FallBackIcon;
			}
			if (!string.IsNullOrEmpty(detob.Author))
			{
				AuthorHolder.text = detob.Author;
			}
			else
			{
				AuthorHolder.text = "";
			}
			if (!string.IsNullOrEmpty(detob.versionNumber))
			{
				versionNumberHolder.text = "Ver: " + detob.versionNumber;
			}
			else
			{
				versionNumberHolder.text = "Ver: ???";
			}
			if (!string.IsNullOrEmpty(detob.warningmessage))
			{
				if (!warningmode)
				{
					animator.SetBool("IsWarningActive", true);
				}
				warningmode = true;
				warningmessage.text = detob.warningmessage;
			}
			else
			{
				if (warningmode)
				{
					animator.SetBool("IsWarningActive", false);
				}
				warningmode = false;
				warningmessage.text = "";
			}
		}

		private void Start()
		{
			container.SetActive(false);
			skinNameHolder.text = "";
			skinDescHolder.text = "";
			AuthorHolder.text = "";
			TP.RefreshFullText("");
			PluginLogo.SetActive(false);
			versionNumberHolder.text = "";
			container.SetActive(true);
		}
	}
	public class DetailObject
	{
		public string SkinName { get; set; }

		public string SkinDescription { get; set; }

		public bool isPlugin { get; set; }

		public Sprite icon { get; set; }

		public string versionNumber { get; set; }

		public string warningmessage { get; set; }

		public string Author { get; set; }
	}
	public class SliderText : MonoBehaviour
	{
		public Slider slider;

		public TextMeshProUGUI valueText;

		private void Start()
		{
			UpdateValueText(slider.value);
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)UpdateValueText);
		}

		private void UpdateValueText(float value)
		{
			int num = Mathf.RoundToInt(value * 100f);
			((TMP_Text)valueText).text = num.ToString();
		}
	}
	public class SmileFileButton : MonoBehaviour
	{
		public enum IconType
		{
			Unknown,
			Folder,
			Image,
			Zip,
			GCskin,
			Music,
			Video,
			Text,
			Internal
		}

		public string FileName;

		public string FullPath;

		public bool isfolder;

		public TextMeshProUGUI displayname;

		public IconType icontype;

		public GameObject button;

		public GameObject toggletype;

		public GameObject FolderIcon;

		public GameObject ImageIcon;

		public GameObject ZipIcon;

		public Image ThumbnailIcon;

		public GameObject GCskinIcon;

		public GameObject UnknownIcon;

		public GameObject InternalIcon;

		public GameObject VideoIcon;

		public GameObject TextIcon;

		public GameObject MusicIcon;

		public bool hardcap;

		private static int height = 64;

		private static int width = 64;

		private Sprite ThumbnailSprite;

		private Texture ThumbnailTexture;

		private void OnEnable()
		{
			((TMP_Text)displayname).text = FileName;
			iconselector(icontype);
			if (isfolder)
			{
				button.SetActive(true);
				toggletype.SetActive(false);
			}
			else
			{
				button.SetActive(false);
				toggletype.SetActive(true);
			}
		}

		public async Task<Sprite> LoadTextureFromFile(string path)
		{
			byte[] array = await File.ReadAllBytesAsync(path);
			if (array == null || array.Length == 0)
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, array))
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			RenderTexture temporary = RenderTexture.GetTemporary(width, height);
			Graphics.Blit((Texture)(object)val, temporary);
			RenderTexture.active = temporary;
			Texture2D val2 = new Texture2D(width, height, val.format, false);
			val2.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0);
			val2.Apply();
			RenderTexture.active = null;
			RenderTexture.ReleaseTemporary(temporary);
			Object.Destroy((Object)(object)val);
			Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f));
			if ((Object)(object)this == (Object)null)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					Object.Destroy((Object)(object)val3.texture);
				}
				if ((Object)(object)val3 != (Object)null)
				{
					Object.Destroy((Object)(object)val3);
				}
				return null;
			}
			return val3;
		}

		private void OnDestroy()
		{
			if ((Object)(object)ThumbnailSprite != (Object)null)
			{
				Object.Destroy((Object)(object)ThumbnailSprite);
				ThumbnailSprite = null;
			}
			if ((Object)(object)ThumbnailTexture != (Object)null)
			{
				Object.Destroy((Object)(object)ThumbnailTexture);
				ThumbnailTexture = null;
			}
			if ((Object)(object)ThumbnailIcon != (Object)null && (Object)(object)ThumbnailIcon.sprite != (Object)null)
			{
				Object.Destroy((Object)(object)ThumbnailIcon.sprite.texture);
				Object.Destroy((Object)(object)ThumbnailIcon.sprite);
				ThumbnailIcon.sprite = null;
			}
		}

		private async Task iconselector(IconType icontype)
		{
			FolderIcon.SetActive(false);
			ImageIcon.SetActive(false);
			ZipIcon.SetActive(false);
			GCskinIcon.SetActive(false);
			UnknownIcon.SetActive(false);
			VideoIcon.SetActive(false);
			TextIcon.SetActive(false);
			InternalIcon.SetActive(false);
			MusicIcon.SetActive(false);
			((Component)ThumbnailIcon).gameObject.SetActive(false);
			switch (icontype)
			{
			case IconType.Unknown:
				UnknownIcon.SetActive(true);
				break;
			case IconType.Folder:
				FolderIcon.SetActive(true);
				break;
			case IconType.Image:
				if (SettingsManager.Instance.GetSettingValue<bool>("TN_In_FileViewer") && !hardcap)
				{
					ImageIcon.SetActive(true);
					Sprite val = await LoadTextureFromFile(FullPath);
					if ((Object)(object)val != (Object)null)
					{
						ImageIcon.SetActive(false);
						((Component)ThumbnailIcon).gameObject.SetActive(true);
						ThumbnailSprite = val;
						ThumbnailTexture = (Texture)(object)val.texture;
						ThumbnailIcon.sprite = val;
					}
				}
				else
				{
					ImageIcon.SetActive(true);
				}
				break;
			case IconType.Zip:
				ZipIcon.SetActive(true);
				break;
			case IconType.GCskin:
				GCskinIcon.SetActive(true);
				break;
			case IconType.Internal:
				InternalIcon.SetActive(true);
				break;
			case IconType.Video:
				VideoIcon.SetActive(true);
				break;
			case IconType.Text:
				TextIcon.SetActive(true);
				break;
			case IconType.Music:
				MusicIcon.SetActive(true);
				break;
			}
		}
	}
	public class RotateObject : MonoBehaviour
	{
		public Vector3 rotationSpeed = new Vector3(0f, 30f, 0f);

		public bool pause;

		[Header("Drag Rotation")]
		public bool allowDrag;

		public RectTransform renderAreaUI;

		public float dragSpeed = 5f;

		[Header("Pan and Zoom")]
		public bool allowPanZoom;

		public float panSpeed = 0.1f;

		public float zoomSpeed = 2f;

		private bool isDragging;

		private Vector3 lastMousePosition;

		[SerializeField]
		private float minX = -10f;

		[SerializeField]
		private float maxX = 10f;

		[SerializeField]
		private float minY = -3f;

		[SerializeField]
		private float maxY = 3f;

		private bool isPanning;

		public Slider sliderX;

		public Slider sliderY;

		public Slider sliderZoom;

		private Vector3 initialPosition;

		private float initialScale = 1f;

		private void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			initialPosition = ((Component)this).transform.position;
			initialScale = ((Component)this).transform.localScale.x;
		}

		private void OnEnable()
		{
			((MonoBehaviour)this).StartCoroutine(UnscaledUpdateLoop());
		}

		private IEnumerator UnscaledUpdateLoop()
		{
			while (true)
			{
				if (allowDrag)
				{
					HandleDragRotation();
					HandlePan();
				}
				if (allowPanZoom)
				{
					HandleZoom();
				}
				if (!pause && !isDragging)
				{
					((Component)this).transform.Rotate(rotationSpeed * Time.unscaledDeltaTime);
				}
				yield return null;
			}
		}

		private void HandleDragRotation()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(renderAreaUI, Vector2.op_Implicit(Input.mousePosition)))
			{
				isDragging = true;
				lastMousePosition = Input.mousePosition;
			}
			if (Input.GetMouseButtonUp(0))
			{
				isDragging = false;
			}
			if (isDragging)
			{
				Vector3 val = Input.mousePosition - lastMousePosition;
				float num = val.y * dragSpeed * Time.deltaTime;
				float num2 = val.x * dragSpeed * Time.deltaTime;
				((Component)this).transform.Rotate(Vector3.down, num, (Space)0);
				((Component)this).transform.Rotate(Vector3.right, 0f - num2, (Space)0);
				lastMousePosition = Input.mousePosition;
			}
		}

		private void HandlePan()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetMouseButtonDown(1) && RectTransformUtility.RectangleContainsScreenPoint(renderAreaUI, Vector2.op_Implicit(Input.mousePosition)))
			{
				isPanning = true;
				lastMousePosition = Input.mousePosition;
			}
			else if (Input.GetMouseButtonUp(1))
			{
				isPanning = false;
			}
			if (isPanning)
			{
				Vector3 val = Input.mousePosition - lastMousePosition;
				float num = (0f - val.x) * panSpeed * Time.deltaTime;
				float num2 = val.y * panSpeed * Time.deltaTime;
				Vector3 val2 = ((Component)this).transform.position + new Vector3(num2, num, 0f);
				val2.x = Mathf.Clamp(val2.x, minX, maxX);
				val2.y = Mathf.Clamp(val2.y, minY, maxY);
				((Component)this).transform.position = val2;
				lastMousePosition = Input.mousePosition;
				sliderY.value = Mathf.InverseLerp(minX, maxX, val2.x);
				sliderX.value = Mathf.InverseLerp(minY, maxY, 0f - val2.y);
			}
		}

		private void HandleZoom()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (Input.mouseScrollDelta.y != 0f && RectTransformUtility.RectangleContainsScreenPoint(renderAreaUI, Vector2.op_Implicit(Input.mousePosition)))
			{
				float num = Input.mouseScrollDelta.y * zoomSpeed;
				((Component)this).transform.localScale = new Vector3(Mathf.Clamp(((Component)this).transform.localScale.x + num, 0.1f, 3f), Mathf.Clamp(((Component)this).transform.localScale.y + num, 0.1f, 3f), Mathf.Clamp(((Component)this).transform.localScale.z + num, 0.1f, 3f));
			}
			lastMousePosition = Input.mousePosition;
		}

		public void LerptoRot(Quaternion targetRotation, float lerpDuration)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(LerpToRotation(targetRotation, lerpDuration));
		}

		public void LerptoScale(Vector3 targetZoom, float lerpDuration)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(LerpToZoom(targetZoom, lerpDuration));
		}

		public void LerptoPos(Vector3 targetPos, float lerpDuration)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(LerpToLocation(targetPos, lerpDuration));
		}

		private IEnumerator LerpToRotation(Quaternion targetRotation, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Quaternion startRotation = ((Component)this).transform.rotation;
			float timeElapsed = 0f;
			while (timeElapsed < duration)
			{
				((Component)this).transform.rotation = Quaternion.Lerp(startRotation, targetRotation, timeElapsed / duration);
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			((Component)this).transform.rotation = targetRotation;
		}

		private IEnumerator LerpToZoom(Vector3 targetZoom, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 startZoom = ((Component)this).transform.localScale;
			float timeElapsed = 0f;
			while (timeElapsed < duration)
			{
				((Component)this).transform.localScale = Vector3.Lerp(startZoom, targetZoom, timeElapsed / duration);
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			((Component)this).transform.localScale = targetZoom;
		}

		private IEnumerator LerpToLocation(Vector3 targetLocation, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 startLocation = ((Component)this).transform.position;
			float timeElapsed = 0f;
			while (timeElapsed < duration)
			{
				((Component)this).transform.position = Vector3.Lerp(startLocation, targetLocation, timeElapsed / duration);
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			((Component)this).transform.position = targetLocation;
		}

		public void ResetToOriginal(float duration)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			LerptoPos(new Vector3(0f, 0f, 0f), duration);
			LerptoRot(Quaternion.Euler(0f, 90f, 0f), duration);
			LerptoScale(new Vector3(1f, 1f, 1f), duration);
		}
	}
	public class StartLerp : MonoBehaviour
	{
		public LerpRectTransformFull USPreview;

		private void OnEnable()
		{
			USPreview.MenuModeOn();
		}

		private void OnDisable()
		{
			USPreview.MenuModeOff();
		}
	}
	public class ThunderstoreHandle : MonoBehaviour
	{
		public GameObject SkinTilePrefab;

		public GameObject ContentHolder;

		public ToggleGroup toggleGroup;

		public GameObject PHnone;

		public Button ContinueButton;

		public Dictionary<Toggle, TileMan> SkinTiles = new Dictionary<Toggle, TileMan>();

		private void Start()
		{
		}

		private void OnEnable()
		{
			if (ContentHolder.transform.childCount > 0)
			{
				PHnone.SetActive(false);
			}
			else
			{
				PHnone.SetActive(true);
			}
		}

		public void AddOptionToUI(string file)
		{
			//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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			TileMan component = Object.Instantiate<GameObject>(SkinTilePrefab, ContentHolder.transform).GetComponent<TileMan>();
			component.IsToggle(value: true);
			component.AddToGroup(toggleGroup);
			component.FolderPath = file;
			SkinTiles.Add(component.toggle, component);
			ColorBlock colors = ((Selectable)component.toggle).colors;
			((ColorBlock)(ref colors)).normalColor = Color32.op_Implicit(new Color32((byte)31, (byte)31, (byte)66, byte.MaxValue));
			((ColorBlock)(ref colors)).selectedColor = Color32.op_Implicit(new Color32((byte)35, byte.MaxValue, (byte)176, byte.MaxValue));
			((ColorBlock)(ref colors)).highlightedColor = Color32.op_Implicit(new Color32((byte)80, (byte)217, (byte)159, byte.MaxValue));
			((ColorBlock)(ref colors)).pressedColor = Color32.op_Implicit(new Color32((byte)28, (byte)163, (byte)245, byte.MaxValue));
			((Selectable)component.toggle).colors = colors;
			component.ChangeText(Path.GetFileName(file));
			((UnityEvent<bool>)(object)component.toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				CheckIfAnySelected();
			});
		}

		public void RemoveOptionFromUI(GameObject tile)
		{
			throw new NotImplementedException("RemoveOptionFromUI not yet implemented.");
		}

		public void ClearUI()
		{
			foreach (TileMan value in SkinTiles.Values)
			{
				Object.Destroy((Object)(object)((Component)value).gameObject);
			}
			SkinTiles.Clear();
			PHnone.SetActive(true);
		}

		public string GetSelectedFile()
		{
			foreach (Toggle item in toggleGroup.ActiveToggles())
			{
				if (item.isOn)
				{
					SkinTiles.TryGetValue(item, out var value);
					return value.FolderPath;
				}
			}
			return null;
		}

		public GameObject GetSelectedGameObject()
		{
			return null;
		}

		private void CheckIfAnySelected()
		{
			bool interactable = false;
			foreach (Toggle item in toggleGroup.ActiveToggles())
			{
				if (item.isOn)
				{
					interactable = true;
					break;
				}
			}
			((Selectable)ContinueButton).interactable = interactable;
		}
	}
	public class TileMan : MonoBehaviour
	{
		public TextMeshProUGUI Text;

		public Image selected;

		public Image normal;

		public string FolderPath;

		public Toggle toggle;

		public void AddToGroup(ToggleGroup togglegroup)
		{
			toggle.group = togglegroup;
		}

		public void ChangeSelectedColor(Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)selected).color = color;
		}

		public void ChangeNormalColor(Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)normal).color = color;
		}

		public void IsToggle(bool value)
		{
			((Selectable)toggle).interactable = value;
		}

		public void ChangeText(string newtext)
		{
			((TMP_Text)Text).text = newtext;
		}
	}
	public class TypeWriter : MonoBehaviour
	{
		[Header("Text Settings")]
		[TextArea]
		private string fullText;

		public float timeBetweenLetters = 0.05f;

		[Header("Behavior Settings")]
		public bool runOnlyOnce;

		public bool showCursor = true;

		private AudioSource audioSource;

		private TextMeshProUGUI textMesh;

		private Coroutine typingCoroutine;

		private string currentText = "";

		private bool hasRun;

		private readonly string cursorChar = "█";

		private void Awake()
		{
			textMesh = ((Component)this).GetComponent<TextMeshProUGUI>();
			if ((Object)(object)textMesh == (Object)null)
			{
				Debug.LogError((object)"TypewriterText requires a TextMeshProUGUI component.");
			}
			fullText = ((TMP_Text)textMesh).text;
			audioSource = ((Component)this).GetComponent<AudioSource>();
		}

		public void RefreshFullText(string newfulltext)
		{
			fullText = newfulltext;
		}

		private void OnEnable()
		{
			if (!runOnlyOnce || !hasRun)
			{
				if (typingCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(typingCoroutine);
				}
				typingCoroutine = ((MonoBehaviour)this).StartCoroutine(TypeText());
			}
		}

		private IEnumerator TypeText()
		{
			hasRun = true;
			currentText = "";
			((TMP_Text)textMesh).text = "";
			for (int i = 0; i <= fullText.Length; i++)
			{
				currentText = fullText.Substring(0, i);
				((TMP_Text)textMesh).text = currentText + ((showCursor && i < fullText.Length) ? cursorChar : "");
				if (Object.op_Implicit((Object)(object)audioSource))
				{
					audioSource.Play();
				}
				yield return (object)new WaitForSecondsRealtime(timeBetweenLetters);
			}
			((TMP_Text)textMesh).text = currentText;
			typingCoroutine = null;
		}
	}
	public class UIColorSlider : MonoBehaviour
	{
		[SerializeField]
		private Slider sliderR;

		[SerializeField]
		private Slider sliderG;

		[SerializeField]
		private Slider sliderB;

		[SerializeField]
		private TMP_Dropdown dropdown;

		[SerializeField]
		private Toggle toggle;

		[SerializeField]
		private Image toggleimage;

		[SerializeField]
		private TMP_InputField HexCode;

		private bool Guard;

		private bool hexGuard;

		private void Start()
		{
			((UnityEvent<float>)(object)sliderR.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				SliderBroadcast();
			});
			((UnityEvent<float>)(object)sliderG.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				SliderBroadcast();
			});
			((UnityEvent<float>)(object)sliderB.onValueChanged).AddListener((UnityAction<float>)delegate
			{
				SliderBroadcast();
			});
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int thing)
			{
				dropValueChange(thing);
			});
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool thing)
			{
				modechange(thing);
			});
			((UnityEvent<string>)(object)HexCode.onValueChanged).AddListener((UnityAction<string>)delegate(string thing)
			{
				SetColorFromHex(thing);
			});
		}

		private void OnEnable()
		{
		}

		public void SliderBroadcast()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if (!Guard)
			{
				Color val = default(Color);
				((Color)(ref val))..ctor(sliderR.value, sliderG.value, sliderB.value);
				switch (dropdown.value)
				{
				case 0:
					Shader.SetGlobalColor("_US_ECP", val);
					break;
				case 1:
					Shader.SetGlobalFloat("_US_Pmode", 1f);
					Shader.SetGlobalColor("_US_CCP1", val);
					break;
				case 2:
					Shader.SetGlobalColor("_US_CCP2", val);
					break;
				case 3:
					Shader.SetGlobalColor("_US_CCP3", val);
					break;
				}
				hexGuard = true;
				HexCode.text = gethexcolor(val.r, val.g, val.b);
				HexCode.ForceLabelUpdate();
				hexGuard = false;
			}
		}

		public void dropValueChange(int selected)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			switch (selected)
			{
			case 0:
				val = Shader.GetGlobalColor("_US_ECP");
				break;
			case 1:
				val = Shader.GetGlobalColor("_US_CCP1");
				break;
			case 2:
				val = Shader.GetGlobalColor("_US_CCP2");
				break;
			case 3:
				val = Shader.GetGlobalColor("_US_CCP3");
				break;
			}
			Guard = true;
			if (((Compo