Decompiled source of CrabDevKit v1.3.2

BepInEx/patchers/lammas123.CrabDevPreloader.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.IL2CPP.Hook;
using BepInEx.Logging;
using BepInEx.Preloader.Core.Patching;
using HarmonyLib;
using HarmonyLib.Public.Patching;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CrabDevPreloader
{
	[PatcherPluginInfo("lammas123.CrabDevPreloader", "CrabDevPreloader", "1.3.2")]
	public sealed class CrabDevPreloader : BasePatcher
	{
		[CompilerGenerated]
		private sealed class <TranspileIL2CPPDetourMethodPatcherInit>d__14 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> instructions;

			public IEnumerable<CodeInstruction> <>3__instructions;

			private List<CodeInstruction> <codes>5__2;

			private bool <injected>5__3;

			private int <i>5__4;

			private CodeInstruction <code>5__5;

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

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

			[DebuggerHidden]
			public <TranspileIL2CPPDetourMethodPatcherInit>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<codes>5__2 = null;
				<code>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<codes>5__2 = instructions.ToList();
					<injected>5__3 = false;
					<i>5__4 = 0;
					break;
				case 1:
					<>1__state = -1;
					if (!<injected>5__3 && !(<code>5__5.opcode != OpCodes.Stloc_S) && <code>5__5.operand is LocalBuilder localBuilder && localBuilder.LocalIndex == 5 && !(localBuilder.LocalType != typeof(Exception)))
					{
						<>2__current = new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder);
						<>1__state = 2;
						return true;
					}
					goto IL_0173;
				case 2:
					<>1__state = -1;
					<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = CodeInstruction.Call(typeof(DetourFailures), "Record", (Type[])null, (Type[])null);
					<>1__state = 4;
					return true;
				case 4:
					{
						<>1__state = -1;
						((BasePatcher)Instance).Log.LogInfo((object)"Transpiled DetourFailures.Record after IL2CPPDetourMethodPatcher.Init's catch(Exception ex).");
						<injected>5__3 = true;
						<code>5__5 = null;
						goto IL_0173;
					}
					IL_0173:
					<i>5__4++;
					break;
				}
				if (<i>5__4 < <codes>5__2.Count)
				{
					<code>5__5 = <codes>5__2[<i>5__4];
					<>2__current = <code>5__5;
					<>1__state = 1;
					return true;
				}
				if (!<injected>5__3)
				{
					((BasePatcher)Instance).Log.LogWarning((object)"Failed to transpile DetourFailures.Record after IL2CPPDetourMethodPatcher.Init's catch(Exception ex)!");
				}
				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();
			}

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<TranspileIL2CPPDetourMethodPatcherInit>d__14 <TranspileIL2CPPDetourMethodPatcherInit>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<TranspileIL2CPPDetourMethodPatcherInit>d__ = this;
				}
				else
				{
					<TranspileIL2CPPDetourMethodPatcherInit>d__ = new <TranspileIL2CPPDetourMethodPatcherInit>d__14(0);
				}
				<TranspileIL2CPPDetourMethodPatcherInit>d__.instructions = <>3__instructions;
				return <TranspileIL2CPPDetourMethodPatcherInit>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		private MethodDefinition _downloadHandlerCtor;

		internal static CrabDevPreloader Instance { get; private set; }

		public override void Initialize()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
			Instance = this;
			((BasePatcher)this).Log.LogInfo((object)"Applying Harmony patches...");
			new Harmony("CrabDevPreloader").PatchAll(typeof(CrabDevPreloader));
			ManualLogSource log = ((BasePatcher)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized [");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrabDevPreloader");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.3.2");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]");
			}
			log.LogInfo(val);
		}

		private AssemblyDefinition ReadCoreAssembly(string assemblyName)
		{
			return AssemblyDefinition.ReadAssembly(Path.Combine(Paths.BepInExRootPath, "core", assemblyName));
		}

		private AssemblyDefinition ReadUnhollowedAssembly(string assemblyName)
		{
			return AssemblyDefinition.ReadAssembly(Path.Combine(Paths.BepInExRootPath, "unhollowed", assemblyName));
		}

		[TargetType("UnityEngine.AssetBundleModule.dll", "UnityEngine.AssetBundle")]
		public void PatchAssetBundle(TypeDefinition assetBundleType)
		{
			((BasePatcher)this).Log.LogInfo((object)"Patching AssetBundle...");
			PatchAssetBundleBaseType(assetBundleType);
			PatchAssetBundleIntPtrCtor(assetBundleType);
			((BasePatcher)this).Log.LogInfo((object)"Patched AssetBundle");
		}

		private void PatchAssetBundleBaseType(TypeDefinition assetBundleType)
		{
			TypeDefinition type = ReadCoreAssembly("UnhollowerBaseLib.dll").MainModule.GetType("UnhollowerBaseLib.Il2CppObjectBase");
			TypeReference baseType = assetBundleType.BaseType;
			if (((baseType != null) ? ((MemberReference)baseType).FullName : null) == ((MemberReference)type).FullName)
			{
				((BasePatcher)this).Log.LogInfo((object)"AssetBundle already inherits Il2CppObjectBase, skipping");
				return;
			}
			assetBundleType.BaseType = ((MemberReference)assetBundleType).Module.ImportReference((TypeReference)(object)type);
			((BasePatcher)this).Log.LogInfo((object)"Set AssetBundle.BaseType = Il2CppObjectBase");
		}

		private void PatchAssetBundleIntPtrCtor(TypeDefinition assetBundleType)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			if (((IEnumerable<MethodDefinition>)assetBundleType.Methods).Any((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 1 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.IntPtr"))
			{
				((BasePatcher)this).Log.LogInfo((object)"AssetBundle(IntPtr) constructor already exists, skipping");
				return;
			}
			MethodDefinition val = new MethodDefinition(".ctor", (MethodAttributes)6278, ((MemberReference)assetBundleType).Module.TypeSystem.Void);
			((MethodReference)val).Parameters.Add(new ParameterDefinition("ptr", (ParameterAttributes)0, ((MemberReference)assetBundleType).Module.TypeSystem.IntPtr));
			ILProcessor iLProcessor = val.Body.GetILProcessor();
			MethodDefinition val2 = ((IEnumerable<MethodDefinition>)ReadCoreAssembly("UnhollowerBaseLib.dll").MainModule.GetType("UnhollowerBaseLib.Il2CppObjectBase").Methods).First((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 1 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.IntPtr");
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_1));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Call, ((MemberReference)assetBundleType).Module.ImportReference((MethodReference)(object)val2)));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ret));
			assetBundleType.Methods.Add(val);
			((BasePatcher)this).Log.LogInfo((object)"Injected AssetBundle(IntPtr) constructor");
		}

		[TargetType("UnityEngine.UnityWebRequestModule.dll", "UnityEngine.Networking.DownloadHandler")]
		public void PatchDownloadHandler(TypeDefinition downloadHandlerType)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			((BasePatcher)this).Log.LogInfo((object)"Patching DownloadHandler...");
			if (((IEnumerable<MethodDefinition>)downloadHandlerType.Methods).Any((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 0))
			{
				((BasePatcher)this).Log.LogInfo((object)"DownloadHandler() constructor already exists, skipping");
				return;
			}
			_downloadHandlerCtor = new MethodDefinition(".ctor", (MethodAttributes)6278, ((MemberReference)downloadHandlerType).Module.TypeSystem.Void);
			ILProcessor iLProcessor = _downloadHandlerCtor.Body.GetILProcessor();
			MethodDefinition val = ((IEnumerable<MethodDefinition>)ReadUnhollowedAssembly("Il2Cppmscorlib.dll").MainModule.GetType("Il2CppSystem.Object").Methods).First((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 0);
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Call, ((MemberReference)downloadHandlerType).Module.ImportReference((MethodReference)(object)val)));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ret));
			downloadHandlerType.Methods.Add(_downloadHandlerCtor);
			((BasePatcher)this).Log.LogInfo((object)"Injected DownloadHandler() constructor");
		}

		[TargetType("UnityEngine.UnityWebRequestTextureModule.dll", "UnityEngine.Networking.DownloadHandlerTexture")]
		public void PatchDownloadHandlerTexture(TypeDefinition downloadHandlerTextureType)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Expected O, but got Unknown
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Expected O, but got Unknown
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Expected O, but got Unknown
			//IL_0aa4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abc: Expected O, but got Unknown
			//IL_0aed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af7: Expected O, but got Unknown
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			//IL_0821: Unknown result type (might be due to invalid IL or missing references)
			//IL_0832: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_0866: Unknown result type (might be due to invalid IL or missing references)
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0908: Unknown result type (might be due to invalid IL or missing references)
			//IL_0921: Unknown result type (might be due to invalid IL or missing references)
			//IL_093c: Unknown result type (might be due to invalid IL or missing references)
			//IL_094d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0960: Unknown result type (might be due to invalid IL or missing references)
			//IL_0973: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ddc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2a: Unknown result type (might be due to invalid IL or missing references)
			((BasePatcher)this).Log.LogInfo((object)"Patching DownloadHandlerTexture...");
			if (((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).Any((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 1 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.IntPtr"))
			{
				((BasePatcher)this).Log.LogInfo((object)"DownloadHandlerTexture(IntPtr) constructor already exists, skipping");
				return;
			}
			MethodDefinition val = new MethodDefinition(".ctor", (MethodAttributes)6278, ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Void);
			((MethodReference)val).Parameters.Add(new ParameterDefinition("ptr", (ParameterAttributes)0, ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.IntPtr));
			ILProcessor iLProcessor = val.Body.GetILProcessor();
			MethodDefinition val2 = ((IEnumerable<MethodDefinition>)_downloadHandlerCtor.DeclaringType.Methods).First((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 1 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.IntPtr");
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_1));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Call, ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)val2)));
			iLProcessor.Append(iLProcessor.Create(OpCodes.Ret));
			downloadHandlerTextureType.Methods.Add(val);
			((BasePatcher)this).Log.LogInfo((object)"Injected DownloadHandlerTexture(IntPtr) constructor");
			TypeDefinition type = ReadUnhollowedAssembly("UnityEngine.CoreModule.dll").MainModule.GetType("UnityEngine.Texture2D");
			TypeDefinition type2 = ReadUnhollowedAssembly("UnityEngine.UnityWebRequestModule.dll").MainModule.GetType("UnityEngine.Networking.UnityWebRequest");
			TypeDefinition type3 = ReadCoreAssembly("UnhollowerBaseLib.dll").MainModule.GetType("UnhollowerBaseLib.Il2CppObjectBase");
			TypeReference baseType = downloadHandlerTextureType.BaseType;
			if (((baseType != null) ? ((MemberReference)baseType).FullName : null) == ((MemberReference)_downloadHandlerCtor.DeclaringType).FullName)
			{
				((BasePatcher)this).Log.LogInfo((object)"DownloadHandlerTexture already inherits DownloadHandler, skipping");
				return;
			}
			downloadHandlerTextureType.BaseType = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((TypeReference)(object)_downloadHandlerCtor.DeclaringType);
			((BasePatcher)this).Log.LogInfo((object)"Set DownloadHandlerTexture.BaseType = DownloadHandler");
			AddField("mTexture", (TypeReference)(object)type);
			AddField("mHasTexture", ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Boolean);
			AddField("mNonReadable", ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Boolean);
			if (!((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).Any((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 0))
			{
				MethodDefinition val3 = new MethodDefinition(".ctor", (MethodAttributes)6278, ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Void);
				ILProcessor iLProcessor2 = val3.Body.GetILProcessor();
				MethodDefinition val4 = ((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "InternalCreateTexture");
				iLProcessor2.Append(iLProcessor2.Create(OpCodes.Ldarg_0));
				iLProcessor2.Append(iLProcessor2.Create(OpCodes.Call, ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)_downloadHandlerCtor)));
				iLProcessor2.Append(iLProcessor2.Create(OpCodes.Ldarg_0));
				iLProcessor2.Append(iLProcessor2.Create(OpCodes.Ldc_I4_1));
				iLProcessor2.Append(iLProcessor2.Create(OpCodes.Call, (MethodReference)(object)val4));
				iLProcessor2.Append(iLProcessor2.Create(OpCodes.Ret));
				downloadHandlerTextureType.Methods.Add(val3);
				((BasePatcher)this).Log.LogInfo((object)"Injected DownloadHandlerTexture()");
			}
			if (!((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).Any((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 1 && ((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType == ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Boolean))
			{
				MethodDefinition val5 = new MethodDefinition(".ctor", (MethodAttributes)6278, ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Void);
				((MethodReference)val5).Parameters.Add(new ParameterDefinition("readable", (ParameterAttributes)0, ((MemberReference)downloadHandlerTextureType).Module.TypeSystem.Boolean));
				ILProcessor iLProcessor3 = val5.Body.GetILProcessor();
				MethodDefinition val6 = ((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "InternalCreateTexture");
				FieldDefinition val7 = ((IEnumerable<FieldDefinition>)downloadHandlerTextureType.Fields).First((FieldDefinition f) => ((MemberReference)f).Name == "mNonReadable");
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ldarg_0));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Call, ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)_downloadHandlerCtor)));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ldarg_0));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ldarg_1));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Call, (MethodReference)(object)val6));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ldarg_0));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ldarg_1));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ldc_I4_0));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ceq));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Stfld, (FieldReference)(object)val7));
				iLProcessor3.Append(iLProcessor3.Create(OpCodes.Ret));
				downloadHandlerTextureType.Methods.Add(val5);
				((BasePatcher)this).Log.LogInfo((object)"Injected DownloadHandlerTexture(bool)");
			}
			MethodDefinition val8 = ((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "InternalGetTexture");
			if (((IEnumerable<Instruction>)val8.Body.Instructions).Any(delegate(Instruction i)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				if (i.OpCode == OpCodes.Newobj)
				{
					object operand2 = i.Operand;
					MethodReference val33 = (MethodReference)((operand2 is MethodReference) ? operand2 : null);
					if (val33 != null)
					{
						return ((MemberReference)((MemberReference)val33).DeclaringType).FullName.Contains("NotSupportedException");
					}
				}
				return false;
			}))
			{
				val8.Body = new MethodBody(val8)
				{
					InitLocals = false,
					MaxStackSize = 3
				};
				ILProcessor iLProcessor4 = val8.Body.GetILProcessor();
				FieldDefinition val9 = ((IEnumerable<FieldDefinition>)downloadHandlerTextureType.Fields).First((FieldDefinition f) => ((MemberReference)f).Name == "mTexture");
				FieldDefinition val10 = ((IEnumerable<FieldDefinition>)downloadHandlerTextureType.Fields).First((FieldDefinition f) => ((MemberReference)f).Name == "mHasTexture");
				FieldDefinition val11 = ((IEnumerable<FieldDefinition>)downloadHandlerTextureType.Fields).First((FieldDefinition f) => ((MemberReference)f).Name == "mNonReadable");
				MethodDefinition val12 = ((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "InternalGetTextureNative");
				MethodDefinition val13 = ((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "GetData");
				MethodDefinition val14 = ((IEnumerable<MethodDefinition>)type.Methods).First((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 2);
				MethodDefinition val15 = ((IEnumerable<MethodDefinition>)ReadUnhollowedAssembly("UnityEngine.ImageConversionModule.dll").MainModule.GetType("UnityEngine.ImageConversion").Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "LoadImage");
				Instruction val16 = iLProcessor4.Create(OpCodes.Nop);
				Instruction val17 = iLProcessor4.Create(OpCodes.Nop);
				Instruction val18 = iLProcessor4.Create(OpCodes.Nop);
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldfld, (FieldReference)(object)val10));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Brfalse, val16));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldfld, (FieldReference)(object)val9));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Brtrue, val17));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldc_I4_2));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldc_I4_2));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Newobj, ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)val14)));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Stfld, (FieldReference)(object)val9));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldfld, (FieldReference)(object)val9));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Callvirt, (MethodReference)(object)val13));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldfld, (FieldReference)(object)val11));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Call, ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)val15)));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Pop));
				iLProcessor4.Append(val17);
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Br, val18));
				iLProcessor4.Append(val16);
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldfld, (FieldReference)(object)val9));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Brtrue, val18));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Call, (MethodReference)(object)val12));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Stfld, (FieldReference)(object)val9));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldc_I4_1));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Stfld, (FieldReference)(object)val10));
				iLProcessor4.Append(val18);
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldarg_0));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ldfld, (FieldReference)(object)val9));
				iLProcessor4.Append(iLProcessor4.Create(OpCodes.Ret));
				((BasePatcher)this).Log.LogInfo((object)"Restored InternalGetTexture()");
			}
			MethodDefinition val19 = ((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "GetContent");
			if (((IEnumerable<Instruction>)val19.Body.Instructions).Any(delegate(Instruction i)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				if (i.OpCode == OpCodes.Newobj)
				{
					object operand = i.Operand;
					MethodReference val32 = (MethodReference)((operand is MethodReference) ? operand : null);
					if (val32 != null)
					{
						return ((MemberReference)((MemberReference)val32).DeclaringType).FullName.Contains("NotSupportedException");
					}
				}
				return false;
			}))
			{
				val19.Body = new MethodBody(val19)
				{
					InitLocals = false,
					MaxStackSize = 3
				};
				ILProcessor iLProcessor5 = val19.Body.GetILProcessor();
				AssemblyDefinition val20 = ((MemberReference)downloadHandlerTextureType).Module.AssemblyResolver.Resolve((AssemblyNameReference)((MemberReference)downloadHandlerTextureType).Module.TypeSystem.CoreLibrary);
				MethodReference val21 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)val20.MainModule.GetType("System.NullReferenceException").Methods).First((MethodDefinition m) => m.IsConstructor && ((MethodReference)m).Parameters.Count == 1 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.String"));
				MethodReference val22 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)val20.MainModule.GetType("System.InvalidOperationException").Methods).First((MethodDefinition m) => m.IsConstructor && ((MethodReference)m).Parameters.Count == 1 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.String"));
				MethodReference val23 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)type2.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "get_isDone"));
				MethodReference val24 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)type2.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "get_result"));
				MethodReference val25 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)type2.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "get_error"));
				MethodReference val26 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)type2.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "get_downloadHandler"));
				MethodReference val27 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)type3.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "get_Pointer"));
				MethodReference val28 = ((MemberReference)downloadHandlerTextureType).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)downloadHandlerTextureType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "get_texture"));
				((IEnumerable<TypeDefinition>)type2.NestedTypes).First((TypeDefinition t) => ((MemberReference)t).Name == "Result");
				Instruction val29 = iLProcessor5.Create(OpCodes.Nop);
				Instruction val30 = iLProcessor5.Create(OpCodes.Nop);
				Instruction val31 = iLProcessor5.Create(OpCodes.Nop);
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldarg_0));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Brfalse_S, val29));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldarg_0));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Callvirt, val23));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Brtrue_S, val30));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldstr, "Cannot get content from an unfinished UnityWebRequest object"));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Newobj, val22));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Throw));
				iLProcessor5.Append(val30);
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldarg_0));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Callvirt, val24));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldc_I4_3));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Bne_Un_S, val31));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldarg_0));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Callvirt, val25));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Newobj, val22));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Throw));
				iLProcessor5.Append(val31);
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldarg_0));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Callvirt, val26));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Callvirt, val27));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Newobj, (MethodReference)(object)val));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Callvirt, val28));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ret));
				iLProcessor5.Append(val29);
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Ldstr, "Cannot get content from a null UnityWebRequest object"));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Newobj, val21));
				iLProcessor5.Append(iLProcessor5.Create(OpCodes.Throw));
				((BasePatcher)this).Log.LogInfo((object)"Restored GetContent()");
			}
			void AddField(string name, TypeReference fieldType)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Expected O, but got Unknown
				if (!((IEnumerable<FieldDefinition>)downloadHandlerTextureType.Fields).Any((FieldDefinition f) => ((MemberReference)f).Name == name))
				{
					downloadHandlerTextureType.Fields.Add(new FieldDefinition(name, (FieldAttributes)1, ((MemberReference)downloadHandlerTextureType).Module.ImportReference(fieldType)));
				}
			}
		}

		[TargetType("UnityEngine.UnityWebRequestModule.dll", "UnityEngine.Networking.UnityWebRequest")]
		public void PatchUnityWebRequest(TypeDefinition unityWebRequestType)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: 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_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			((BasePatcher)this).Log.LogInfo((object)"Patching UnityWebRequest...");
			if (!((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).Any((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 4 && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[0]).ParameterType).FullName == "System.String" && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[1]).ParameterType).FullName == "System.String" && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[2]).ParameterType).FullName == "UnityEngine.Networking.DownloadHandler" && ((MemberReference)((ParameterReference)((MethodReference)m).Parameters[3]).ParameterType).FullName == "UnityEngine.Networking.UploadHandler"))
			{
				MethodDefinition val = new MethodDefinition(".ctor", (MethodAttributes)6278, ((MemberReference)unityWebRequestType).Module.TypeSystem.Void);
				((MethodReference)val).Parameters.Add(new ParameterDefinition("url", (ParameterAttributes)0, ((MemberReference)unityWebRequestType).Module.TypeSystem.String));
				((MethodReference)val).Parameters.Add(new ParameterDefinition("method", (ParameterAttributes)0, ((MemberReference)unityWebRequestType).Module.TypeSystem.String));
				TypeDefinition val2 = ((IEnumerable<TypeDefinition>)((MemberReference)unityWebRequestType).Module.Types).First((TypeDefinition t) => ((MemberReference)t).Name == "DownloadHandler");
				((MethodReference)val).Parameters.Add(new ParameterDefinition("downloadHandler", (ParameterAttributes)0, (TypeReference)(object)val2));
				TypeDefinition val3 = ((IEnumerable<TypeDefinition>)((MemberReference)unityWebRequestType).Module.Types).First((TypeDefinition t) => ((MemberReference)t).Name == "UploadHandler");
				ParameterDefinition val4 = new ParameterDefinition("uploadHandler", (ParameterAttributes)0, (TypeReference)(object)val3);
				((MethodReference)val).Parameters.Add(val4);
				ILProcessor iLProcessor = val.Body.GetILProcessor();
				MethodDefinition val5 = ((IEnumerable<MethodDefinition>)ReadUnhollowedAssembly("Il2Cppmscorlib.dll").MainModule.GetType("Il2CppSystem.Object").Methods).First((MethodDefinition m) => m.IsConstructor && !m.IsStatic && ((MethodReference)m).Parameters.Count == 0);
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, ((MemberReference)unityWebRequestType).Module.ImportReference((MethodReference)(object)val5)));
				MethodDefinition val6 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "Create");
				MethodDefinition val7 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "set_m_Ptr");
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val6));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val7));
				MethodDefinition val8 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "InternalSetDefaults");
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val8));
				MethodDefinition val9 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "set_url");
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_1));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val9));
				MethodDefinition val10 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "set_method");
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_2));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val10));
				MethodDefinition val11 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "set_downloadHandler");
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_3));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val11));
				MethodDefinition val12 = ((IEnumerable<MethodDefinition>)unityWebRequestType.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "set_uploadHandler");
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_S, val4));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val12));
				iLProcessor.Append(iLProcessor.Create(OpCodes.Ret));
				unityWebRequestType.Methods.Add(val);
				((BasePatcher)this).Log.LogInfo((object)"Injected UnityWebRequest(string, string, DownloadHandler, UploadHandler)");
			}
		}

		[IteratorStateMachine(typeof(<TranspileIL2CPPDetourMethodPatcherInit>d__14))]
		[HarmonyPatch(typeof(IL2CPPDetourMethodPatcher), "Init")]
		[HarmonyTranspiler]
		internal static IEnumerable<CodeInstruction> TranspileIL2CPPDetourMethodPatcherInit(IEnumerable<CodeInstruction> instructions)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TranspileIL2CPPDetourMethodPatcherInit>d__14(-2)
			{
				<>3__instructions = instructions
			};
		}
	}
	public static class DetourFailures
	{
		public static readonly List<string> failures = new List<string>();

		public static event Action FailureRecorded;

		public static void Record(Exception ex, IL2CPPDetourMethodPatcher patcher)
		{
			string message = ex.Message;
			MethodBase original = ((MethodPatcher)patcher).Original;
			failures.Add($"Detour failed for {original}: {message}");
			DetourFailures.FailureRecorded?.Invoke();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "lammas123.CrabDevPreloader";

		public const string PLUGIN_NAME = "CrabDevPreloader";

		public const string PLUGIN_VERSION = "1.3.2";
	}
}

BepInEx/plugins/lammas123.CrabDevKit.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.IL2CPP;
using BepInEx.IL2CPP.Utils;
using BepInEx.Logging;
using CodeStage.AntiCheat.ObscuredTypes;
using CrabDevKit.Intermediary;
using CrabDevKit.Utilities;
using CrabDevKit.Utilities.CrabUi;
using CrabDevPreloader;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Collections.ObjectModel;
using Il2CppSystem.IO;
using Il2CppSystem.Runtime.InteropServices;
using Il2CppSystem.Text;
using Il2CppSystem.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
using MilkShake;
using SteamworksNative;
using TMPro;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[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 CrabDevKit
{
	internal static class Patches
	{
		[HarmonyPatch(typeof(MonoBehaviourPublicGataInefObInUnique), "Method_Private_Void_GameObject_Boolean_Vector3_Quaternion_0")]
		[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "Method_Private_Void_0")]
		[HarmonyPrefix]
		internal static bool PreBepinexDetection()
		{
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicObInVoAwVoVoVoVoVoVoUnique), "Awake")]
		[HarmonyPostfix]
		internal static void PostMainManagerAwake()
		{
			TMP_Settings.instance.m_warningsDisabled = true;
		}
	}
	[BepInPlugin("lammas123.CrabDevKit", "CrabDevKit", "1.3.2")]
	public sealed class CrabDevKit : BasePlugin
	{
		internal static CrabDevKit Instance { get; private set; }

		internal static CrabNet CrabNet { get; private set; }

		public override void Load()
		{
			//IL_004c: 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_0091: Expected O, but got Unknown
			CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
			Instance = this;
			CrabNet = new CrabNet();
			FakeClients.Init();
			CommonUi.Init();
			UiComponents.Init();
			new Harmony("CrabDevKit").PatchAll(typeof(Patches));
			SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)DetourFailuresCheck);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized [");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrabDevKit");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.3.2");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]");
			}
			log.LogInfo(val);
		}

		private void DetourFailuresCheck(Scene _, LoadSceneMode __)
		{
			SceneManager.sceneLoaded -= UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)DetourFailuresCheck);
			DetourFailures.FailureRecorded += PromptDetourFailures;
			if (DetourFailures.failures.Count != 0)
			{
				PromptDetourFailures();
			}
		}

		private void PromptDetourFailures()
		{
			foreach (string failure in DetourFailures.failures)
			{
				MonoBehaviourPublicGaprLi1ObGaprInUnique.Instance.NewPrompt("CrabDevKit - DetourFailures", "<size=26>" + failure + "</size>");
			}
			DetourFailures.failures.Clear();
			MonoBehaviourPublicGaprLi1ObGaprInUnique.Instance.NewPrompt("CrabDevKit - DetourFailures", "<size=26>The most common way to fix these issue(s) is to restart your computer.\nHowever, if that doesn't help, then reach out on CrabGame+ for additional support!\n\nDiscord: <link=\"https://discord.gg/jBGMZqndT3\"><u>https://discord.gg/jBGMZqndT3</u></link></size>");
			List<GameObject> prompts = MonoBehaviourPublicGaprLi1ObGaprInUnique.Instance.prompts;
			((Component)prompts[prompts.Count - 1].GetComponent<MonoBehaviourPublicTehefiTeVeSiVeUnique>().filler).gameObject.AddComponent<MonoBehaviourPublicIPointerClickHandlerIEventSystemHandlerStStUnique>();
			MonoBehaviourPublicGaprLi1ObGaprInUnique.Instance.NewPrompt("CrabDevKit - DetourFailures", $"<size=26>Detour failed for {DetourFailures.failures.Count} Il2Cpp method(s).\n\nYou may find the failed patches in your console or LogOutput.txt, but they'll also be shown here!\n\nPress Continue for more.</size>");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "lammas123.CrabDevKit";

		public const string PLUGIN_NAME = "CrabDevKit";

		public const string PLUGIN_VERSION = "1.3.2";
	}
}
namespace CrabDevKit.Utilities
{
	[Obsolete("CrabDevKit.Utilities.AssetBundlePtr will be removed in the future! A way to properly fix Asset Bundles was found, making this obsolete.")]
	public sealed class AssetBundlePtr : IDisposable
	{
		internal IntPtr bundlePtr;

		private bool _disposed;

		internal AssetBundlePtr(IntPtr intPtr)
		{
			bundlePtr = intPtr;
		}

		~AssetBundlePtr()
		{
			Unload(unloadAllLoadedObjects: true);
		}

		public void Dispose()
		{
			Unload(unloadAllLoadedObjects: true);
		}

		public static AssetBundlePtr LoadFromFile(string path, uint crc = 0u, ulong offset = 0uL)
		{
			if (string.IsNullOrEmpty(path))
			{
				throw new ArgumentNullException("path", "The asset bundle file path cannot be null.");
			}
			if (!File.Exists(path))
			{
				throw new FileNotFoundException("The asset bundle file path does not point to a file that exists.", path);
			}
			if (offset > long.MaxValue)
			{
				throw new ArgumentOutOfRangeException("offset", "Offset is greater than long.MaxValue. (Why?)");
			}
			using FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
			if ((long)offset >= fileStream.Length)
			{
				throw new ArgumentOutOfRangeException("offset", "Offset is beyond end of file.");
			}
			fileStream.Seek((long)offset, SeekOrigin.Begin);
			long num = fileStream.Length - (long)offset;
			byte[] array = new byte[num];
			int num2 = fileStream.Read(array, 0, array.Length);
			if (num2 != num)
			{
				throw new IOException($"Expected {num} bytes, but read {num2}.");
			}
			return LoadFromMemory(array, crc);
		}

		public static AssetBundlePtr LoadFromMemory(byte[] binary, uint crc = 0u)
		{
			return AssetBundleManager.LoadBundle(binary, crc);
		}

		public bool Contains(string name)
		{
			if (_disposed)
			{
				return false;
			}
			if (string.IsNullOrEmpty(name))
			{
				throw new ArgumentNullException("name", "The input asset name cannot be null or empty.");
			}
			AssetBundleManager.MakeCurrentBundle(this);
			return AssetBundle.ContainsDelegateField.Invoke(bundlePtr, IL2CPP.ManagedStringToIl2Cpp(name));
		}

		public string[] GetAllAssetNames()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (_disposed)
			{
				return null;
			}
			AssetBundleManager.MakeCurrentBundle(this);
			IntPtr intPtr = AssetBundle.GetAllAssetNamesDelegateField.Invoke(bundlePtr);
			if (!(intPtr == IntPtr.Zero))
			{
				return ((IEnumerable<string>)new Il2CppStringArray(intPtr)).ToArray();
			}
			return null;
		}

		public string[] GetAllScenePaths()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (_disposed)
			{
				return null;
			}
			AssetBundleManager.MakeCurrentBundle(this);
			IntPtr intPtr = AssetBundle.GetAllScenePathsDelegateField.Invoke(bundlePtr);
			if (!(intPtr == IntPtr.Zero))
			{
				return ((IEnumerable<string>)new Il2CppStringArray(intPtr)).ToArray();
			}
			return null;
		}

		public void Unload(bool unloadAllLoadedObjects)
		{
			if (!_disposed)
			{
				AssetBundleManager.MakeCurrentBundle(this);
				AssetBundleManager.DisposeCurrentBundle(unloadAllLoadedObjects);
				GC.SuppressFinalize(this);
				_disposed = true;
			}
		}

		public Object[] LoadAllAssets(Type type)
		{
			if (_disposed)
			{
				return null;
			}
			if (type == null)
			{
				throw new ArgumentNullException("type", "The input type cannot be null.");
			}
			AssetBundleManager.MakeCurrentBundle(this);
			Type val = Il2CppType.From(type);
			IntPtr intPtr = AssetBundle.LoadAssetWithSubAssets_InternalDelegateField.Invoke(bundlePtr, IL2CPP.ManagedStringToIl2Cpp(string.Empty), IL2CPP.Il2CppObjectBaseToPtr((Il2CppObjectBase)(object)val));
			if (!(intPtr == IntPtr.Zero))
			{
				return ((IEnumerable<Object>)new Il2CppReferenceArray<Object>(intPtr)).ToArray();
			}
			return null;
		}

		public Object[] LoadAllAssets<T>() where T : Object
		{
			return LoadAllAssets(typeof(T));
		}

		public Object LoadAsset(string name, Type type)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			if (_disposed)
			{
				return null;
			}
			if (string.IsNullOrEmpty(name))
			{
				throw new ArgumentNullException("name", "The input asset name cannot be null or empty.");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type", "The input type cannot be null.");
			}
			AssetBundleManager.MakeCurrentBundle(this);
			Type val = Il2CppType.From(type);
			IntPtr intPtr = AssetBundle.LoadAsset_InternalDelegateField.Invoke(bundlePtr, IL2CPP.ManagedStringToIl2Cpp(name), IL2CPP.Il2CppObjectBaseToPtr((Il2CppObjectBase)(object)val));
			if (!(intPtr == IntPtr.Zero))
			{
				return new Object(intPtr);
			}
			return null;
		}

		public Object LoadAsset<T>(string name) where T : Object
		{
			return LoadAsset(name, typeof(T));
		}
	}
	internal static class AssetBundleManager
	{
		internal static Dictionary<AssetBundlePtr, (Il2CppStructArray<byte>, uint)> managedBundles = new Dictionary<AssetBundlePtr, (Il2CppStructArray<byte>, uint)>();

		internal static AssetBundlePtr currentBundle;

		internal static AssetBundlePtr LoadBundle(byte[] binary, uint crc)
		{
			MakeCurrentBundle(null);
			Il2CppStructArray<byte> val = new Il2CppStructArray<byte>(binary);
			IntPtr intPtr = AssetBundle.LoadFromMemory_InternalDelegateField.Invoke(IL2CPP.Il2CppObjectBaseToPtr((Il2CppObjectBase)(object)val), crc);
			if (intPtr == IntPtr.Zero)
			{
				throw new NullReferenceException("Failed to load the bundle. The bundle may not be valid, idk ask Unity lol.");
			}
			currentBundle = new AssetBundlePtr(intPtr);
			managedBundles.Add(currentBundle, (val, crc));
			return currentBundle;
		}

		internal static void MakeCurrentBundle(AssetBundlePtr bundle)
		{
			if (bundle == currentBundle)
			{
				return;
			}
			if (currentBundle != null)
			{
				UnloadCurrentBundle();
			}
			if (bundle != null)
			{
				IntPtr intPtr = AssetBundle.LoadFromMemory_InternalDelegateField.Invoke(IL2CPP.Il2CppObjectBaseToPtr((Il2CppObjectBase)(object)managedBundles[bundle].Item1), managedBundles[bundle].Item2);
				if (intPtr == IntPtr.Zero)
				{
					throw new NullReferenceException("Failed to make bundle the current bundle, odd. It didn't fail previously, so it should be valid, but maybe something went wrong with unloading the previous bundle.");
				}
				bundle.bundlePtr = intPtr;
				currentBundle = bundle;
			}
		}

		internal static void DisposeCurrentBundle(bool unloadAllLoadedObjects = false)
		{
			managedBundles.Remove(currentBundle);
			UnloadCurrentBundle(unloadAllLoadedObjects);
		}

		internal static void UnloadCurrentBundle(bool unloadAllLoadedObjects = false)
		{
			AssetBundle.UnloadDelegateField.Invoke(currentBundle.bundlePtr, unloadAllLoadedObjects);
			currentBundle.bundlePtr = IntPtr.Zero;
			currentBundle = null;
		}
	}
	public static class ChatUtil
	{
		public enum MessageType
		{
			Normal,
			Server,
			Styled
		}

		public static int MaxMessageLength
		{
			get
			{
				if (!((Object)(object)MonoBehaviourPublicRaovTMinTemeColoonCoUnique.Instance != (Object)null))
				{
					return 80;
				}
				return MonoBehaviourPublicRaovTMinTemeColoonCoUnique.Instance.get_maxMsgLength();
			}
		}

		public static int MaxConsecutiveChars
		{
			get
			{
				if (!((Object)(object)MonoBehaviourPublicRaovTMinTemeColoonCoUnique.Instance != (Object)null))
				{
					return 5;
				}
				return MonoBehaviourPublicRaovTMinTemeColoonCoUnique.Instance.get_deobf_maxConsecutiveChars();
			}
		}

		public static string FormatMessage(string str)
		{
			return Regex.Replace(str, $"(.)(?<=\\1{{{MaxConsecutiveChars}}})", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant);
		}

		public static void SendMessage(ulong recipientClientId, string message, MessageType messageType = MessageType.Server, string displayName = null)
		{
			SendMessage(message, messageType, displayName, new <>z__ReadOnlySingleElementList<ulong>(recipientClientId));
		}

		public static void SendMessage(string message, MessageType messageType = MessageType.Server, string displayName = null, IEnumerable<ulong> recipientClientIds = null)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			ulong value = 0uL;
			message = FormatMessage(message ?? string.Empty);
			if (messageType == MessageType.Server)
			{
				displayName = string.Empty;
				value = 1uL;
			}
			else if (displayName == null)
			{
				displayName = string.Empty;
			}
			ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique(2);
			val.Write(value);
			val.Write(displayName);
			val.Write(message);
			val.WriteLength();
			IEnumerable<ulong> enumerable = recipientClientIds;
			if (enumerable == null)
			{
				KeyCollection<ulong, int> keys = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys;
				int num = 0;
				ulong[] array = new ulong[keys.Count];
				Enumerator<ulong, int> enumerator = keys.GetEnumerator();
				while (enumerator.MoveNext())
				{
					ulong current = enumerator.Current;
					array[num] = current;
					num++;
				}
				enumerable = new <>z__ReadOnlyArray<ulong>(array);
			}
			foreach (ulong item in enumerable)
			{
				if (messageType == MessageType.Styled)
				{
					byte[] bytes = BitConverter.GetBytes(item);
					for (int i = 0; i < bytes.Length; i++)
					{
						val.field_Private_List_1_Byte_0[i + 8] = bytes[i];
					}
				}
				MonoBehaviourPublicInStInpabyDiInpaby2Unique.SendPacket(new CSteamID(item), val, ServerSendExtensions.get_deobf_reliable(), (EnumNPublicSealedvaTo3vToUnique)0);
			}
			val.Dispose();
		}

		public static string[] FormatGameModeDescription(string description)
		{
			List<string> list = description.Split('\n', StringSplitOptions.RemoveEmptyEntries).ToList();
			for (int i = 0; i < list.Count; i++)
			{
				list[i] = list[i].Replace('•', '*');
				while (list[i].Length > MaxMessageLength)
				{
					int num = list[i].LastIndexOf(' ', MaxMessageLength - 1, 20);
					if (num == -1)
					{
						num = MaxMessageLength;
					}
					int index = i + 1;
					string text = list[i];
					int num2 = num;
					list.Insert(index, text.Substring(num2, text.Length - num2));
					list[i] = list[i].Substring(0, num);
				}
			}
			return list.ToArray();
		}
	}
	public sealed class CrabNet
	{
		public delegate void MessageHandler(ulong clientId, ObjectPublicIDisposableLi1ByInByBoUnique packet);

		internal static class Patches
		{
			private static readonly Il2CppStructArray<IntPtr> _messagePtrs = new Il2CppStructArray<IntPtr>(70L);

			[HarmonyPatch(typeof(MonoBehaviourPublicInStInpabyDiInpaby2Unique), "CheckForPackets")]
			[HarmonyPostfix]
			internal static void PostSteamPacketManagerCheckForPackets()
			{
				int num;
				do
				{
					num = SteamNetworkingMessages.ReceiveMessagesOnChannel(123, _messagePtrs, 70);
					if (num == 0)
					{
						break;
					}
					for (int i = 0; i < num; i++)
					{
						SteamNetworkingMessage_t message = Marshal.PtrToStructure<SteamNetworkingMessage_t>(((Il2CppArrayBase<IntPtr>)(object)_messagePtrs)[i]);
						CrabDevKit.CrabNet.HandleMessage(message);
					}
				}
				while (num == 70);
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "Method_Private_Void_LobbyEnter_t_PDM_1")]
			[HarmonyPostfix]
			[HarmonyPriority(int.MaxValue)]
			internal static void PostSteamManagerLobbyEnter(LobbyEnter_t param_1)
			{
				//IL_0005: 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)
				if (MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_currentLobby().m_SteamID == param_1.m_ulSteamIDLobby)
				{
					CrabDevKit.CrabNet.RegisterMessageHandlers();
				}
			}
		}

		private uint _nextId;

		private readonly Dictionary<string, uint> _registeredMessageHandlers = new Dictionary<string, uint>();

		private readonly Dictionary<uint, MessageHandler> _messageHandlers = new Dictionary<uint, MessageHandler>();

		private const int SendFlag = 8;

		private const int MessageChannel = 123;

		private const int MessagesPerFrame = 70;

		internal CrabNet()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("CrabDevKit.CrabNet").PatchAll(typeof(Patches));
		}

		public static bool RegisterMessageHandler(string messageId, MessageHandler messageHandler)
		{
			if (CrabDevKit.CrabNet == null)
			{
				throw new InvalidOperationException("CrabNet has yet to be initialized. Ensure your plugin is depending on CrabDevKit, so that it initializes CrabNet before you use it!");
			}
			if (string.IsNullOrEmpty(messageId))
			{
				throw new ArgumentNullException("messageId", "messageId may not be null or empty.");
			}
			if (!messageId.Contains(':'))
			{
				throw new ArgumentException("A colon ':' separator character was expected in the messageId parameter. Your messageId should follow this format -> PluginName:MessageId", "messageId");
			}
			if (messageHandler == null)
			{
				throw new ArgumentNullException("messageHandler");
			}
			return CrabDevKit.CrabNet.RegisterMessageHandlerInternal(messageId, messageHandler);
		}

		private bool RegisterMessageHandlerInternal(string messageId, MessageHandler messageHandler)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			if (string.IsNullOrEmpty(messageId))
			{
				throw new ArgumentNullException("messageId", "messageId may not be null or empty.");
			}
			if (messageHandler == null)
			{
				throw new ArgumentNullException("messageHandler");
			}
			if (Object.op_Implicit((Object)(object)MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance))
			{
				((BasePlugin)CrabDevKit.Instance).Log.LogWarning((object)"Message handlers must be registered on plugin load!");
				return false;
			}
			bool flag = default(bool);
			if (_registeredMessageHandlers.ContainsKey(messageId))
			{
				ManualLogSource log = ((BasePlugin)CrabDevKit.Instance).Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Message handler '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(messageId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' already exists!");
				}
				log.LogWarning(val);
				return false;
			}
			uint nextId = _nextId;
			_nextId++;
			_registeredMessageHandlers.Add(messageId, nextId);
			_messageHandlers.Add(nextId, messageHandler);
			ManualLogSource log2 = ((BasePlugin)CrabDevKit.Instance).Log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Registered message handler: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(messageId);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<uint>(nextId);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
			}
			log2.LogInfo(val2);
			return true;
		}

		private void RegisterMessageHandlers()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			CSteamID val = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_currentLobby();
			SteamMatchmaking.SetLobbyMemberData(val, "CrabNetVersion", "1.3.2");
			foreach (var (text2, num2) in _registeredMessageHandlers)
			{
				SteamMatchmaking.SetLobbyMemberData(val, $"CrabNet:Message.{num2}", text2);
			}
			((BasePlugin)CrabDevKit.Instance).Log.LogInfo((object)"Registered message handlers for lobby.");
		}

		public static bool SendMessage(string messageId, ObjectPublicIDisposableLi1ByInByBoUnique packet, [ParamCollection] IEnumerable<ulong> clientIds)
		{
			if (CrabDevKit.CrabNet == null)
			{
				throw new InvalidOperationException("CrabNet has yet to be initialized. Ensure your plugin is depending on CrabDevKit, so that it initializes CrabNet before you use it!");
			}
			if (string.IsNullOrEmpty(messageId))
			{
				throw new ArgumentNullException("messageId", "messageId may not be null or empty.");
			}
			if (packet == null)
			{
				throw new ArgumentNullException("packet");
			}
			if (clientIds == null)
			{
				throw new ArgumentNullException("clientIds");
			}
			return CrabDevKit.CrabNet.SendMessageInternal(messageId, packet, clientIds.Select((Func<ulong, CSteamID>)((ulong clientId) => new CSteamID(clientId))));
		}

		public static bool SendMessage(string messageId, ObjectPublicIDisposableLi1ByInByBoUnique packet, [ParamCollection] IEnumerable<CSteamID> steamIds)
		{
			if (CrabDevKit.CrabNet == null)
			{
				throw new InvalidOperationException("CrabNet has yet to be initialized. Ensure your plugin is depending on CrabDevKit, so that it initializes CrabNet before you use it!");
			}
			if (string.IsNullOrEmpty(messageId))
			{
				throw new ArgumentNullException("messageId", "messageId may not be null or empty.");
			}
			if (packet == null)
			{
				throw new ArgumentNullException("packet");
			}
			if (steamIds == null)
			{
				throw new ArgumentNullException("steamIds");
			}
			return CrabDevKit.CrabNet.SendMessageInternal(messageId, packet, steamIds);
		}

		private bool SendMessageInternal(string messageId, ObjectPublicIDisposableLi1ByInByBoUnique packet, IEnumerable<CSteamID> steamIds)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(messageId))
			{
				throw new ArgumentNullException("messageId", "messageId may not be null or empty.");
			}
			if (packet == null)
			{
				throw new ArgumentNullException("packet");
			}
			if (steamIds == null)
			{
				throw new ArgumentNullException("steamIds");
			}
			bool flag = default(bool);
			if (!_registeredMessageHandlers.TryGetValue(messageId, out var value))
			{
				ManualLogSource log = ((BasePlugin)CrabDevKit.Instance).Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Message handler '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(messageId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' does not exist!");
				}
				log.LogWarning(val);
				return false;
			}
			ObjectPublicIDisposableLi1ByInByBoUnique val2 = new ObjectPublicIDisposableLi1ByInByBoUnique();
			val2.Write((int)value);
			val2.Write(packet.CloneBytes());
			foreach (CSteamID steamId in steamIds)
			{
				if (string.IsNullOrEmpty(SteamMatchmaking.GetLobbyMemberData(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_currentLobby(), steamId, "CrabNetVersion")))
				{
					ManualLogSource log2 = ((BasePlugin)CrabDevKit.Instance).Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(steamId.m_SteamID);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" does not have CrabNet, and cannot receive messages!");
					}
					log2.LogWarning(val);
				}
				else if (steamId == SteamUser.GetSteamID())
				{
					ObjectPublicIDisposableLi1ByInByBoUnique packet2 = new ObjectPublicIDisposableLi1ByInByBoUnique(Il2CppStructArray<byte>.op_Implicit(val2.CloneBytes()));
					HandleMessage(steamId.m_SteamID, packet2);
				}
				else
				{
					MonoBehaviourPublicInStInpabyDiInpaby2Unique.SendPacket(steamId, val2, 8, (EnumNPublicSealedvaTo3vToUnique)123);
				}
			}
			val2.Dispose();
			packet.Dispose();
			return true;
		}

		private void HandleMessage(SteamNetworkingMessage_t message)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			ulong steamID = message.m_identityPeer.GetSteamID64();
			int cbSize = message.m_cbSize;
			IntPtr pData = message.m_pData;
			Il2CppStructArray<byte> val = new Il2CppStructArray<byte>((long)cbSize);
			Marshal.Copy(pData, val, 0, cbSize);
			ObjectPublicIDisposableLi1ByInByBoUnique val2 = new ObjectPublicIDisposableLi1ByInByBoUnique();
			val2.SetBytes(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)val));
			HandleMessage(steamID, val2);
		}

		private void HandleMessage(ulong clientId, ObjectPublicIDisposableLi1ByInByBoUnique packet)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				uint value = (uint)packet.ReadInt();
				string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_currentLobby(), new CSteamID(clientId), $"CrabNet:Message.{value}");
				if (string.IsNullOrEmpty(lobbyMemberData))
				{
					ManualLogSource log = ((BasePlugin)CrabDevKit.Instance).Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(37, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unable to identify messageId from '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(value);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'!");
					}
					log.LogWarning(val);
				}
				else if (!_registeredMessageHandlers.TryGetValue(lobbyMemberData, out value))
				{
					ManualLogSource log2 = ((BasePlugin)CrabDevKit.Instance).Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(16, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lobbyMemberData);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is not defined!");
					}
					log2.LogWarning(val);
				}
				else
				{
					_messageHandlers[value](clientId, packet);
					packet.Dispose();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = ((BasePlugin)CrabDevKit.Instance).Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("An exception occurred handling a message:\n");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				log3.LogError(val2);
			}
		}
	}
	public static class DimensionalArrayUtil
	{
		public static T[,] ToManaged2D<T>(Il2CppObjectBase il2CppArray)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (il2CppArray == null || il2CppArray.Pointer == IntPtr.Zero)
			{
				throw new ArgumentNullException("il2CppArray");
			}
			Array val = new Array(il2CppArray.Pointer);
			if (val.Rank != 2)
			{
				throw new InvalidOperationException($"Expected rank-2 array, got rank {val.Rank}");
			}
			int length = val.GetLength(0);
			int length2 = val.GetLength(1);
			T[,] array = new T[length, length2];
			for (int i = 0; i < length; i++)
			{
				for (int j = 0; j < length2; j++)
				{
					object value = val.GetValue(i, j);
					Il2CppObjectBase val2 = (Il2CppObjectBase)((value is Il2CppObjectBase) ? value : null);
					if (val2 != null && typeof(T).IsAssignableFrom(((object)val2).GetType()))
					{
						array[i, j] = (T)(object)val2;
					}
					else if (value != null)
					{
						array[i, j] = (T)Convert.ChangeType(value, typeof(T));
					}
					else
					{
						array[i, j] = default(T);
					}
				}
			}
			return array;
		}

		public static Il2CppObjectBase FromManaged2D<T>(T[,] managed)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			if (managed == null)
			{
				throw new ArgumentNullException("managed");
			}
			int length = managed.GetLength(0);
			int length2 = managed.GetLength(1);
			IntPtr nativeClassPtr = Il2CppClassPointerStore<T>.NativeClassPtr;
			if (nativeClassPtr == IntPtr.Zero)
			{
				throw new InvalidOperationException($"Type {typeof(T)} is not defined in IL2CPP.");
			}
			IntPtr intPtr = CreateArray(nativeClassPtr, new int[2] { length, length2 });
			Array val = new Array(intPtr);
			for (int i = 0; i < length; i++)
			{
				for (int j = 0; j < length2; j++)
				{
					object obj = managed[i, j];
					if (obj == null)
					{
						val.SetValue((Object)null, i, j);
						continue;
					}
					Il2CppObjectBase val2 = (Il2CppObjectBase)((obj is Il2CppObjectBase) ? obj : null);
					if (val2 != null)
					{
						val.SetValue(val2.TryCast<Object>(), i, j);
						continue;
					}
					if (obj is string text)
					{
						IntPtr intPtr2 = IL2CPP.ManagedStringToIl2Cpp(text);
						val.SetValue((Object)new String(intPtr2), i, j);
						continue;
					}
					if (obj.GetType().IsValueType)
					{
						IntPtr intPtr3 = Marshal.AllocHGlobal(Marshal.SizeOf(obj.GetType()));
						Marshal.StructureToPtr(obj, intPtr3, fDeleteOld: false);
						IntPtr intPtr4 = IL2CPP.il2cpp_value_box(nativeClassPtr, intPtr3);
						Marshal.FreeHGlobal(intPtr3);
						val.SetValue(new Object(intPtr4), i, j);
						continue;
					}
					throw new NotImplementedException($"Unable to box type {obj.GetType()}.");
				}
			}
			return new Il2CppObjectBase(intPtr);
		}

		private static IntPtr CreateArray(IntPtr elementClass, int[] dims)
		{
			if (dims == null || dims.Length == 0)
			{
				throw new ArgumentException("dims");
			}
			int num = dims.Length;
			ulong[] array = new ulong[num];
			ulong[] array2 = new ulong[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = (ulong)dims[i];
				array2[i] = 0uL;
			}
			return IL2CPP.il2cpp_array_new_full(elementClass, ref array[0], ref array2[0]);
		}
	}
	public static class FakeClients
	{
		internal static class Patches
		{
			[HarmonyPatch(typeof(SteamMatchmaking), "LeaveLobby")]
			[HarmonyPostfix]
			internal static void PostSteamMatchmakingLeaveLobby()
			{
				fakeClientIds.Clear();
				fakeClients.Clear();
			}

			[HarmonyPatch(typeof(SteamMatchmaking), "GetNumLobbyMembers")]
			[HarmonyPostfix]
			internal static void PostSteamMatchmakingGetNumLobbyMembers(ref int __result)
			{
				__result += fakeClients.Count;
			}

			[HarmonyPatch(typeof(SteamMatchmaking), "GetLobbyMemberByIndex")]
			[HarmonyPrefix]
			internal static bool PreSteamMatchmakingGetLobbyMemberByIndex(CSteamID steamIDLobby, int iMember, ref CSteamID __result)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(steamIDLobby);
				int count = fakeClients.Count;
				int num = numLobbyMembers - count;
				if (iMember >= num && iMember < numLobbyMembers)
				{
					__result = new CSteamID(fakeClients[iMember - num].clientId);
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(SteamMatchmaking), "GetLobbyMemberData")]
			[HarmonyPrefix]
			internal static bool PreSteamMatchmakingGetLobbyMemberData(CSteamID steamIDUser, string pchKey, ref string __result)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				if (fakeClientIds.TryGetValue(steamIDUser.m_SteamID, out var value))
				{
					__result = (value.memberData.TryGetValue(pchKey, out var value2) ? value2 : __result);
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(SteamFriends), "GetFriendPersonaName")]
			[HarmonyPrefix]
			internal static bool PreSteamFriendsGetFriendPersonaName(CSteamID steamIDFriend, ref string __result)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				if (fakeClientIds.TryGetValue(steamIDFriend.m_SteamID, out var value))
				{
					__result = value.name;
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "NewAcceptP2P", new Type[] { typeof(SteamNetworkingIdentity) })]
			[HarmonyPrefix]
			internal static bool PreSteamManagerNewAcceptP2PIdentityRemote(SteamNetworkingIdentity param_1)
			{
				return !fakeClientIds.ContainsKey(param_1.GetSteamID64());
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "NewAcceptP2P", new Type[] { typeof(CSteamID) })]
			[HarmonyPrefix]
			internal static bool PreSteamManagerNewAcceptP2PCSteamID(CSteamID param_1)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return !fakeClientIds.ContainsKey(param_1.m_SteamID);
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicInStInpabyDiInpaby2Unique), "SendPacket")]
			[HarmonyPrefix]
			internal static bool PreSteamPacketManagerSendPacket(CSteamID param_0)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return !fakeClientIds.ContainsKey(param_0.m_SteamID);
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "LoadMap", new Type[]
			{
				typeof(int),
				typeof(int)
			})]
			[HarmonyPostfix]
			internal static void PostServerSendLoadMap()
			{
				foreach (FakeClient fakeClient in fakeClients)
				{
					fakeClient.FakeLoad();
				}
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "LoadMap", new Type[]
			{
				typeof(int),
				typeof(int),
				typeof(ulong)
			})]
			[HarmonyPrefix]
			internal static bool PreServerSendLoadMap(ulong param_2)
			{
				if (fakeClientIds.TryGetValue(param_2, out var value))
				{
					value.FakeLoad();
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(MonoBehaviourPublicDi2UIObacspDi2UIObUnique), "Start")]
			[HarmonyPostfix]
			internal static void PostGameManagerStart()
			{
				foreach (FakeClient fakeClient in fakeClients)
				{
					fakeClient.FakeSpawn();
				}
			}
		}

		internal const ulong MIN_ID = 10uL;

		private static readonly Dictionary<ulong, FakeClient> fakeClientIds = new Dictionary<ulong, FakeClient>();

		private static readonly List<FakeClient> fakeClients = new List<FakeClient>();

		internal static void Init()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("CrabDevKit.FakeClients").PatchAll(typeof(Patches));
		}

		public static FakeClient Create(string name = null, bool streamerMode = false, bool forceSpawnActive = false)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				return null;
			}
			ulong num;
			for (num = 10uL; MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.ContainsKey(num) || fakeClientIds.ContainsKey(num); num++)
			{
			}
			FakeClient fakeClient = new FakeClient(num, name, streamerMode, forceSpawnActive);
			fakeClientIds.Add(num, fakeClient);
			fakeClients.Add(fakeClient);
			LobbyChatUpdate_t val = default(LobbyChatUpdate_t);
			val.m_ulSteamIDLobby = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_currentLobby().m_SteamID;
			val.m_ulSteamIDUserChanged = num;
			val.m_ulSteamIDMakingChange = num;
			val.m_rgfChatMemberStateChange = 1u;
			LobbyChatUpdate_t ev = val;
			MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.PlayerJoinOrLeave(ev);
			ManualLogSource log = ((BasePlugin)CrabDevKit.Instance).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Created fake client: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<ulong>(num);
			}
			log.LogInfo(val2);
			return fakeClient;
		}

		public static void Remove(FakeClient fakeClient)
		{
			//IL_0021: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() && fakeClientIds.ContainsKey(fakeClient.clientId))
			{
				LobbyChatUpdate_t val = default(LobbyChatUpdate_t);
				val.m_ulSteamIDLobby = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_currentLobby().m_SteamID;
				val.m_ulSteamIDUserChanged = fakeClient.clientId;
				val.m_ulSteamIDMakingChange = fakeClient.clientId;
				val.m_rgfChatMemberStateChange = 2u;
				LobbyChatUpdate_t ev = val;
				MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.PlayerJoinOrLeave(ev);
				fakeClients.Remove(fakeClientIds[fakeClient.clientId]);
				fakeClientIds.Remove(fakeClient.clientId);
				ManualLogSource log = ((BasePlugin)CrabDevKit.Instance).Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Removed fake client: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<ulong>(fakeClient.clientId);
				}
				log.LogInfo(val2);
			}
		}
	}
	public sealed class FakeClient
	{
		public readonly ulong clientId;

		public readonly string name;

		public readonly bool streamerMode;

		private bool _forceSpawnActive;

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

		internal FakeClient(ulong fakeClientId, string name = null, bool streamerMode = false, bool forceSpawnActive = false)
		{
			clientId = fakeClientId;
			this.name = (string.IsNullOrEmpty(name) ? $"FakeClient {clientId - 10 + 1}" : name);
			this.streamerMode = streamerMode;
			_forceSpawnActive = forceSpawnActive;
		}

		internal void FakeLoad()
		{
			MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique.StartedLoading(clientId, (ObjectPublicIDisposableLi1ByInByBoUnique)null);
			MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique.LoadingRequestEnterGame(clientId, (ObjectPublicIDisposableLi1ByInByBoUnique)null);
			if (Object.op_Implicit((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance))
			{
				FakeSpawn();
			}
		}

		internal void FakeSpawn()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			if (!MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(clientId) && !MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.spectators.ContainsKey(clientId))
			{
				MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique.GameModeLoaded(clientId, (ObjectPublicIDisposableLi1ByInByBoUnique)null);
				if (_forceSpawnActive)
				{
					_forceSpawnActive = false;
					ObjectPublicBoInBoCSItBoInSiBySiUnique client = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.GetClient(clientId);
					MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.PlayerSpawnRequest(clientId, streamerMode, Il2CppStructArray<byte>.op_Implicit(client.get_deobf_drip()), client.get_deobf_dripLength());
				}
				else
				{
					ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
					val.SetBytes(BitConverter.GetBytes(streamerMode));
					MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique.GameRequestToSpawn(clientId, val);
					val.Dispose();
				}
			}
		}
	}
	public static class GiveUtil
	{
		[CompilerGenerated]
		private sealed class <GiveItemCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ulong clientId;

			public int itemId;

			public int ammo;

			private int <uniqueObjectId>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Expected O, but got Unknown
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<uniqueObjectId>5__2 = MonoBehaviourPublicDi2InObInObInUnique.Instance.GetNextId();
					MonoBehaviourPublicInInUnique.DropItem(clientId, itemId, <uniqueObjectId>5__2, ammo);
					<>2__current = (object)new WaitForSeconds(Mathf.Min((float)(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.get_clients()[MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID[clientId]].get_ping() + 50) / 1000f, 1f));
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					if (!MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(clientId) || MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[clientId].dead || !MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.ContainsKey(clientId) || !MonoBehaviourPublicDi2InObInObInUnique.Instance.get_sharedObjects().ContainsKey(<uniqueObjectId>5__2))
					{
						return false;
					}
					ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
					val.SetBytes(BitConverter.GetBytes(<uniqueObjectId>5__2));
					MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique.TryInteract(clientId, val);
					val.Dispose();
					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();
			}
		}

		public static void GiveItem(ulong clientId, int itemId, int ammo = -1)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Invalid comparison between Unknown and I4
			if (MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(clientId) && !MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[clientId].dead && MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem.ContainsKey(itemId))
			{
				if ((int)MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].type == 4 || (int)MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].type == 5)
				{
					MonoBehaviourPublicInInUnique.DropItem(clientId, itemId, MonoBehaviourPublicDi2InObInObInUnique.Instance.GetNextId(), (ammo < 0) ? MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].maxAmmo : ammo);
				}
				else if ((int)MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].type == 2 || (int)MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].type == 3 || ammo < 0 || ammo == MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].maxAmmo)
				{
					MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.ForceGiveWeapon(clientId, itemId, MonoBehaviourPublicDi2InObInObInUnique.Instance.GetNextId());
				}
				else
				{
					MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.Instance, GiveItemCoroutine(clientId, itemId, (ammo < 0) ? MonoBehaviourPublicDi2InItidGamoObInUnique.idToItem[itemId].maxAmmo : ammo));
				}
			}
		}

		[IteratorStateMachine(typeof(<GiveItemCoroutine>d__1))]
		private static IEnumerator GiveItemCoroutine(ulong clientId, int itemId, int ammo)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GiveItemCoroutine>d__1(0)
			{
				clientId = clientId,
				itemId = itemId,
				ammo = ammo
			};
		}
	}
}
namespace CrabDevKit.Utilities.CrabUi
{
	public abstract class BaseSettingComponent
	{
		protected Transform _parent;

		public BaseSettingComponent WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public abstract GameObject Build();
	}
	public sealed class ButtonComponent : BaseSettingComponent
	{
		private float _height = 40f;

		private Vector2 _size = new Vector2(151.92f, 39.3f);

		private float _glossWidth = 20f;

		private float _glossHeight = 12f;

		private readonly RectOffset _padding = new RectOffset
		{
			left = 0,
			right = 10,
			top = 0,
			bottom = 0
		};

		private Color _buttonColor = new Color(1f, 0f, 0.0285f, 1f);

		private ColorBlock _colors;

		private TMP_FontAsset _font;

		private Color _textColor;

		private CustomButtonCallback _callback;

		public ButtonComponent WithHeight(float height)
		{
			_height = height;
			return this;
		}

		public ButtonComponent WithSize(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_size = new Vector2(width, height);
			return this;
		}

		public ButtonComponent WithGlossWidth(float glossWidth)
		{
			_glossWidth = glossWidth;
			return this;
		}

		public ButtonComponent WithGlossHeight(float glossHeight)
		{
			_glossHeight = glossHeight;
			return this;
		}

		public ButtonComponent WithPadding(int left, int right, int top, int bottom)
		{
			_padding.left = left;
			_padding.right = right;
			_padding.top = top;
			_padding.bottom = bottom;
			return this;
		}

		public ButtonComponent WithPadding(int horizontal, int vertical)
		{
			_padding.left = horizontal;
			_padding.right = horizontal;
			_padding.top = vertical;
			_padding.bottom = vertical;
			return this;
		}

		public ButtonComponent WithPadding(int padding)
		{
			_padding.left = padding;
			_padding.right = padding;
			_padding.top = padding;
			_padding.bottom = padding;
			return this;
		}

		public ButtonComponent WithNormalColor(Color normalColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).normalColor = normalColor;
			return this;
		}

		public ButtonComponent WithHighlightedColor(Color highlightedColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).highlightedColor = highlightedColor;
			return this;
		}

		public ButtonComponent WithPressedColor(Color pressedColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).pressedColor = pressedColor;
			return this;
		}

		public ButtonComponent WithSelectedColor(Color selectedColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).selectedColor = selectedColor;
			return this;
		}

		public ButtonComponent WithDisabledColor(Color disabledColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).disabledColor = disabledColor;
			return this;
		}

		public ButtonComponent WithColorMultiplier(float colorMultiplier)
		{
			((ColorBlock)(ref _colors)).colorMultiplier = colorMultiplier;
			return this;
		}

		public ButtonComponent WithFadeDuration(float fadeDuration)
		{
			((ColorBlock)(ref _colors)).fadeDuration = fadeDuration;
			return this;
		}

		public ButtonComponent WithFont(TMP_FontAsset font)
		{
			_font = font;
			return this;
		}

		public ButtonComponent WithTextColor(Color textColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_textColor = textColor;
			return this;
		}

		public ButtonComponent WithCallback(CustomButtonCallback callback)
		{
			_callback = (CustomButtonCallback)Delegate.Combine(_callback, callback);
			return this;
		}

		public new ButtonComponent WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public override GameObject Build()
		{
			if ((Object)(object)_font == (Object)null)
			{
				throw new Exception("font cannot be null.");
			}
			if ((Object)(object)_parent == (Object)null)
			{
				throw new Exception("parent cannot be null.");
			}
			return null;
		}

		public ButtonComponent()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0073: 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_0080: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.7453f, 0.7453f, 0.7453f, 1f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.5f, 0.5f, 0.5f, 1f);
			((ColorBlock)(ref colors)).selectedColor = new Color(0.9608f, 0.9608f, 0.9608f, 1f);
			((ColorBlock)(ref colors)).disabledColor = new Color(0.7843f, 0.7843f, 0.7843f, 0.502f);
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			_colors = colors;
			_font = CommonUi.RobotoBoldUnderlayFont;
			_textColor = Color.white;
			base..ctor();
		}
	}
	public static class CommonUi
	{
		public static Dictionary<string, TMP_FontAsset> Fonts { get; private set; } = new Dictionary<string, TMP_FontAsset>();


		public static TMP_FontAsset RobotoBoldFont
		{
			get
			{
				if (!Fonts.TryGetValue("Roboto-Bold SDF", out var value))
				{
					return null;
				}
				return value;
			}
		}

		public static TMP_FontAsset RobotoBoldUnderlayFont
		{
			get
			{
				if (!Fonts.TryGetValue("Roboto-Bold SDF_UNDERLAY", out var value))
				{
					return null;
				}
				return value;
			}
		}

		public static Dictionary<string, Texture> Textures { get; private set; } = new Dictionary<string, Texture>();


		public static Texture Arrow
		{
			get
			{
				if (!Textures.TryGetValue("Arrow", out var value))
				{
					return null;
				}
				return value;
			}
		}

		public static Texture Circle
		{
			get
			{
				if (!Textures.TryGetValue("Circle", out var value))
				{
					return null;
				}
				return value;
			}
		}

		public static Texture HollowCircle
		{
			get
			{
				if (!Textures.TryGetValue("HollowCircle", out var value))
				{
					return null;
				}
				return value;
			}
		}

		public static Texture GradientBottLong
		{
			get
			{
				if (!Textures.TryGetValue("GradientBottLong", out var value))
				{
					return null;
				}
				return value;
			}
		}

		internal static void Init()
		{
			SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded);
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			if (((Scene)(ref scene)).name != "Menu" || (int)loadSceneMode != 2)
			{
				return;
			}
			SceneManager.sceneLoaded -= UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded);
			foreach (Object item in (Il2CppArrayBase<Object>)(object)Object.FindObjectsOfType(Il2CppType.Of<TextMeshProUGUI>(), true))
			{
				TextMeshProUGUI val = new TextMeshProUGUI(((Il2CppObjectBase)item).Pointer);
				if ((Object)(object)((TMP_Text)val).font != (Object)null)
				{
					Fonts[((Object)((TMP_Text)val).font).name] = ((TMP_Text)val).font;
				}
			}
			foreach (Object item2 in (Il2CppArrayBase<Object>)(object)Object.FindObjectsOfType(Il2CppType.Of<RawImage>(), true))
			{
				RawImage val2 = new RawImage(((Il2CppObjectBase)item2).Pointer);
				if ((Object)(object)val2.texture != (Object)null)
				{
					Textures[((Object)val2.texture).name] = val2.texture;
				}
			}
		}
	}
	public sealed class KeybindComponent : BaseSettingComponent
	{
		private string _displayName = "Some Keybind";

		private KeyCode _initialKey;

		private Vector2 _size = new Vector2(300f, 40f);

		private TMP_FontAsset _font = CommonUi.RobotoBoldFont;

		private Color _textColor = Color.white;

		private ColorBlock _colors;

		private CustomKeybindCallback _callback;

		public KeybindComponent WithDisplayName(string displayName)
		{
			_displayName = displayName;
			return this;
		}

		public KeybindComponent WithInitialKey(KeyCode initialKey)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_initialKey = initialKey;
			return this;
		}

		public KeybindComponent WithSize(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_size = new Vector2(width, height);
			return this;
		}

		public KeybindComponent WithFont(TMP_FontAsset font)
		{
			_font = font;
			return this;
		}

		public KeybindComponent WithTextColor(Color textColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_textColor = textColor;
			return this;
		}

		public KeybindComponent WithNormalColor(Color normalColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).normalColor = normalColor;
			return this;
		}

		public KeybindComponent WithHighlightedColor(Color highlightedColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).highlightedColor = highlightedColor;
			return this;
		}

		public KeybindComponent WithPressedColor(Color pressedColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).pressedColor = pressedColor;
			return this;
		}

		public KeybindComponent WithSelectedColor(Color selectedColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).selectedColor = selectedColor;
			return this;
		}

		public KeybindComponent WithDisabledColor(Color disabledColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ColorBlock)(ref _colors)).disabledColor = disabledColor;
			return this;
		}

		public KeybindComponent WithColorMultiplier(float colorMultiplier)
		{
			((ColorBlock)(ref _colors)).colorMultiplier = colorMultiplier;
			return this;
		}

		public KeybindComponent WithFadeDuration(float fadeDuration)
		{
			((ColorBlock)(ref _colors)).fadeDuration = fadeDuration;
			return this;
		}

		public KeybindComponent WithCallback(CustomKeybindCallback callback)
		{
			_callback = (CustomKeybindCallback)Delegate.Combine(_callback, callback);
			return this;
		}

		public new KeybindComponent WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public override GameObject Build()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected I4, but got Unknown
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(_displayName))
			{
				throw new Exception("displayName cannot be null or empty.");
			}
			if ((int)_initialKey == 0 || (!Enum.IsDefined(typeof(KeyCode), _initialKey) && (int)_initialKey != -1 && (int)_initialKey != -2))
			{
				throw new Exception("initialKey cannot be None or invalid.");
			}
			if ((Object)(object)_font == (Object)null)
			{
				throw new Exception("font cannot be null.");
			}
			if ((Object)(object)_parent == (Object)null)
			{
				throw new Exception("parent cannot be null.");
			}
			GameObject val = new GameObject("Keybind Component");
			val.transform.SetParent(_parent);
			val.transform.localScale = Vector3.one;
			val.AddComponent<RectTransform>().sizeDelta = _size;
			val.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj = val.AddComponent<RawImage>();
			((Behaviour)obj).enabled = false;
			((Graphic)obj).color = Color.red;
			HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)4;
			CustomKeybind customKeybind = val.AddComponent<CustomKeybind>();
			customKeybind.setting = val.AddComponent<MonoBehaviour1PublicTekeIncuStUnique>();
			GameObject val2 = new GameObject("Button");
			val2.transform.SetParent(val.transform);
			val2.transform.localScale = Vector3.one;
			val2.AddComponent<RectTransform>().sizeDelta = _size;
			val2.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			val2.AddComponent<RawImage>();
			Button obj3 = val2.AddComponent<Button>();
			((Selectable)obj3).colors = _colors;
			((UnityEventBase)obj3.onClick).AddListener((Object)(object)customKeybind.setting, ((Object)customKeybind.setting).GetIl2CppType().GetMethod("StartListening"));
			val2.AddComponent<MonoBehaviourPublicIPointerEnterHandlerIEventSystemHandlerIPointerClickHandlerUnique>();
			GameObject val3 = new GameObject("Text (TMP)");
			val3.transform.SetParent(val2.transform);
			val3.transform.localScale = Vector3.one;
			val3.AddComponent<RectTransform>().sizeDelta = _size;
			val3.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			TextMeshProUGUI text = val3.AddComponent<TextMeshProUGUI>();
			((TMP_Text)text).font = _font;
			((Graphic)text).color = _textColor;
			((TMP_Text)text).alignment = (TextAlignmentOptions)514;
			((TMP_Text)text).verticalAlignment = (VerticalAlignmentOptions)512;
			CustomKeybindCallback a = delegate
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Expected I4, but got Unknown
				((TMP_Text)text).text = customKeybind.setting.intToKeyCode((int)customKeybind.key);
			};
			GameObject val4 = new GameObject("Fake Text");
			val4.transform.SetParent(val3.transform);
			val4.transform.localScale = Vector3.one;
			val4.SetActive(false);
			val4.AddComponent<RectTransform>().sizeDelta = _size;
			customKeybind.setting.keyText = val4.AddComponent<TextMeshProUGUI>();
			((Behaviour)customKeybind.setting.keyText).enabled = false;
			customKeybind.setting.set_actionName(_displayName);
			customKeybind.setting.currentKey = (int)_initialKey;
			((UnityEventBase)((MonoBehaviourPublicIncuObm_ObUnique)customKeybind.setting).m_OnClick).AddListener((Object)(object)customKeybind, ((Object)customKeybind).GetIl2CppType().GetMethod("KeybindUpdated"));
			a = (CustomKeybindCallback)Delegate.Combine(a, _callback);
			customKeybind.callback = a;
			customKeybind.SetKeybind(_initialKey);
			return val;
		}

		public KeybindComponent()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = new Color(0f, 0f, 0f, 0.502f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.7075f, 0.7075f, 0.7075f, 0.502f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0f, 0f, 0f, 1f);
			((ColorBlock)(ref colors)).selectedColor = new Color(0f, 0f, 0f, 0.502f);
			((ColorBlock)(ref colors)).disabledColor = new Color(0.7843f, 0.7843f, 0.7843f, 0.502f);
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			_colors = colors;
			base..ctor();
		}
	}
	public sealed class LabelComponent : BaseSettingComponent
	{
		private string _label = "Basic Label";

		private Vector2 _size = new Vector2(0f, 40f);

		private TMP_FontAsset _font = CommonUi.RobotoBoldFont;

		private Color _textColor = Color.white;

		private bool _childControlWidth = true;

		private bool _childControlHeight = true;

		private bool _childForceExpandWidth = true;

		private bool _childForceExpandHeight = true;

		private bool _childScaleWidth;

		private bool _childScaleHeight;

		public LabelComponent WithLabel(string label)
		{
			_label = label;
			return this;
		}

		public LabelComponent WithSize(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_size = new Vector2(width, height);
			return this;
		}

		public LabelComponent WithFont(TMP_FontAsset font)
		{
			_font = font;
			return this;
		}

		public LabelComponent WithTextColor(Color textColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_textColor = textColor;
			return this;
		}

		public LabelComponent WithChildControl(bool width, bool height)
		{
			_childControlWidth = width;
			_childControlHeight = height;
			return this;
		}

		public LabelComponent WithChildForceExpand(bool width, bool height)
		{
			_childForceExpandWidth = width;
			_childForceExpandHeight = height;
			return this;
		}

		public LabelComponent WithScale(bool width, bool height)
		{
			_childScaleWidth = width;
			_childScaleHeight = height;
			return this;
		}

		public new LabelComponent WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public override GameObject Build()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(_label))
			{
				throw new Exception("label cannot be null or empty.");
			}
			if ((Object)(object)_font == (Object)null)
			{
				throw new Exception("font cannot be null.");
			}
			if ((Object)(object)_parent == (Object)null)
			{
				throw new Exception("parent cannot be null.");
			}
			GameObject val = new GameObject("Label Component");
			val.transform.SetParent(_parent);
			val.transform.localScale = Vector3.one;
			val.AddComponent<RectTransform>().sizeDelta = _size;
			val.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj = val.AddComponent<RawImage>();
			((Behaviour)obj).enabled = false;
			((Graphic)obj).color = Color.red;
			HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = _childControlWidth;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = _childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = _childForceExpandWidth;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = _childForceExpandHeight;
			((HorizontalOrVerticalLayoutGroup)obj2).childScaleWidth = _childScaleWidth;
			((HorizontalOrVerticalLayoutGroup)obj2).childScaleHeight = _childScaleHeight;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)3;
			GameObject val2 = new GameObject("Text (TMP)");
			val2.transform.SetParent(val.transform);
			val2.transform.localScale = Vector3.one;
			val2.AddComponent<RectTransform>().sizeDelta = _size;
			val2.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			TextMeshProUGUI obj3 = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj3).text = _label;
			((TMP_Text)obj3).font = _font;
			((Graphic)obj3).color = _textColor;
			((TMP_Text)obj3).alignment = (TextAlignmentOptions)513;
			((TMP_Text)obj3).verticalAlignment = (VerticalAlignmentOptions)512;
			return val;
		}
	}
	public sealed class ScrollComponent : BaseSettingComponent
	{
		private int _initialState;

		private object[] _options;

		private float _size = 40f;

		private float _textWidth = 300f;

		private TMP_FontAsset _font = CommonUi.RobotoBoldFont;

		private Color _textColor = Color.white;

		private Color _buttonColor = Color.white;

		private CustomScrollCallback _callback;

		public ScrollComponent WithInitialState(int initialState)
		{
			_initialState = initialState;
			return this;
		}

		public ScrollComponent WithOptions(object[] options)
		{
			_options = options.ToArray();
			return this;
		}

		public ScrollComponent WithSize(float size)
		{
			_size = size;
			return this;
		}

		public ScrollComponent WithTextWidth(float textWidth)
		{
			_textWidth = textWidth;
			return this;
		}

		public ScrollComponent WithFont(TMP_FontAsset font)
		{
			_font = font;
			return this;
		}

		public ScrollComponent WithTextColor(Color textColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_textColor = textColor;
			return this;
		}

		public ScrollComponent WithButtonColor(Color buttonColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_buttonColor = buttonColor;
			return this;
		}

		public ScrollComponent WithCallback(CustomScrollCallback callback)
		{
			_callback = (CustomScrollCallback)Delegate.Combine(_callback, callback);
			return this;
		}

		public new ScrollComponent WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public override GameObject Build()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Expected O, but got Unknown
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Expected O, but got Unknown
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			if (_options == null || _options.Length == 0)
			{
				throw new Exception("options cannot be null or empty.");
			}
			_initialState = Mathf.Clamp(_initialState, 0, _options.Length - 1);
			if ((Object)(object)_font == (Object)null)
			{
				throw new Exception("font cannot be null.");
			}
			if ((Object)(object)_parent == (Object)null)
			{
				throw new Exception("parent cannot be null.");
			}
			GameObject val = new GameObject("Scroll Component");
			val.transform.SetParent(_parent);
			val.transform.localScale = Vector3.one;
			val.AddComponent<RectTransform>().sizeDelta = new Vector2(_size * 2f + _textWidth, _size);
			val.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj = val.AddComponent<RawImage>();
			((Behaviour)obj).enabled = false;
			((Graphic)obj).color = Color.red;
			HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)4;
			CustomScrollCallback a = null;
			CustomScroll customScroll = val.AddComponent<CustomScroll>();
			GameObject val2 = new GameObject("Left");
			val2.transform.SetParent(val.transform);
			val2.transform.localScale = Vector3.one;
			val2.AddComponent<RectTransform>().sizeDelta = Vector2.one * _size;
			val2.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj3 = val2.AddComponent<RawImage>();
			((Behaviour)obj3).enabled = false;
			((Graphic)obj3).color = Color.red;
			GameObject val3 = new GameObject("Button");
			val3.transform.SetParent(val2.transform);
			val3.transform.localScale = new Vector3(-1f, 1f, 1f);
			val3.AddComponent<RectTransform>().sizeDelta = Vector2.one * _size;
			val3.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			((UnityEventBase)val3.AddComponent<Button>().onClick).AddListener((Object)(object)customScroll, ((Object)customScroll).GetIl2CppType().GetMethod("ScrollLeft"));
			val3.AddComponent<MonoBehaviourPublicIPointerEnterHandlerIEventSystemHandlerIPointerClickHandlerUnique>();
			RawImage leftButtonImg = val3.AddComponent<RawImage>();
			leftButtonImg.texture = CommonUi.Arrow;
			((Graphic)leftButtonImg).color = _buttonColor;
			a = (CustomScrollCallback)Delegate.Combine(a, (CustomScrollCallback)delegate(int state, Action<int> _, Action<object[]> _)
			{
				((Behaviour)leftButtonImg).enabled = state != 0;
			});
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val.transform);
			val4.transform.localScale = Vector3.one;
			val4.AddComponent<RectTransform>().sizeDelta = new Vector2(_textWidth, _size);
			val4.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj4 = val4.AddComponent<RawImage>();
			((Behaviour)obj4).enabled = false;
			((Graphic)obj4).color = Color.red;
			GameObject val5 = new GameObject("Text (TMP)");
			val5.transform.SetParent(val4.transform);
			val5.transform.localScale = Vector3.one;
			val5.AddComponent<RectTransform>().sizeDelta = new Vector2(_textWidth, _size);
			val5.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			TextMeshProUGUI text = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)text).font = _font;
			((Graphic)text).color = _textColor;
			((TMP_Text)text).alignment = (TextAlignmentOptions)514;
			((TMP_Text)text).verticalAlignment = (VerticalAlignmentOptions)512;
			a = (CustomScrollCallback)Delegate.Combine(a, (CustomScrollCallback)delegate(int state, Action<int> _, Action<object[]> _)
			{
				((TMP_Text)text).text = customScroll.options[state].ToString();
			});
			GameObject val6 = new GameObject("Right");
			val6.transform.SetParent(val.transform);
			val6.transform.localScale = Vector3.one;
			val6.AddComponent<RectTransform>().sizeDelta = Vector2.one * _size;
			val6.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj5 = val6.AddComponent<RawImage>();
			((Behaviour)obj5).enabled = false;
			((Graphic)obj5).color = Color.red;
			GameObject val7 = new GameObject("Button");
			val7.transform.SetParent(val6.transform);
			val7.transform.localScale = Vector3.one;
			val7.AddComponent<RectTransform>().sizeDelta = Vector2.one * _size;
			val7.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			((UnityEventBase)val7.AddComponent<Button>().onClick).AddListener((Object)(object)customScroll, ((Object)customScroll).GetIl2CppType().GetMethod("ScrollRight"));
			val7.AddComponent<MonoBehaviourPublicIPointerEnterHandlerIEventSystemHandlerIPointerClickHandlerUnique>();
			RawImage rightButtonImg = val7.AddComponent<RawImage>();
			rightButtonImg.texture = CommonUi.Arrow;
			((Graphic)rightButtonImg).color = _buttonColor;
			a = (CustomScrollCallback)Delegate.Combine(a, (CustomScrollCallback)delegate(int state, Action<int> _, Action<object[]> _)
			{
				((Behaviour)rightButtonImg).enabled = state != customScroll.options.Length - 1;
			});
			a = (CustomScrollCallback)Delegate.Combine(a, _callback);
			customScroll.state = _initialState;
			customScroll.options = _options.ToArray();
			customScroll.callback = a;
			customScroll.UpdateState();
			return val;
		}
	}
	public sealed class SettingBuilder : BaseSettingComponent
	{
		private string _name = "Basic Setting";

		private Vector2 _size = new Vector2(0f, 50f);

		private Color _backgroundColor = new Color(0f, 0f, 0f, 0.298f);

		private bool _childControlWidth = true;

		private bool _childControlHeight = true;

		private bool _childForceExpandWidth;

		private bool _childForceExpandHeight;

		private bool _childScaleWidth;

		private bool _childScaleHeight;

		private bool _reverseArangement;

		private float _spacing = 5f;

		private readonly RectOffset _padding = new RectOffset
		{
			left = 15,
			right = 15,
			top = 5,
			bottom = 5
		};

		public List<GameObject> BuiltComponents;

		private readonly List<BaseSettingComponent> _components = new List<BaseSettingComponent>();

		public SettingBuilder WithName(string name)
		{
			_name = name;
			return this;
		}

		public SettingBuilder WithSize(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_size = new Vector2(width, height);
			return this;
		}

		public SettingBuilder WithBackgroundColor(Color backgroundColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_backgroundColor = backgroundColor;
			return this;
		}

		public SettingBuilder WithChildControl(bool width, bool height)
		{
			_childControlWidth = width;
			_childControlHeight = height;
			return this;
		}

		public SettingBuilder WithChildForceExpand(bool width, bool height)
		{
			_childForceExpandWidth = width;
			_childForceExpandHeight = height;
			return this;
		}

		public SettingBuilder WithScale(bool width, bool height)
		{
			_childScaleWidth = width;
			_childScaleHeight = height;
			return this;
		}

		public SettingBuilder WithReversedArrangement(bool reverseArrangement)
		{
			_reverseArangement = reverseArrangement;
			return this;
		}

		public SettingBuilder WithSpacing(float spacing)
		{
			_spacing = spacing;
			return this;
		}

		public SettingBuilder WithPadding(int left, int right, int top, int bottom)
		{
			_padding.left = left;
			_padding.right = right;
			_padding.top = top;
			_padding.bottom = bottom;
			return this;
		}

		public SettingBuilder WithPadding(int horizontal, int vertical)
		{
			_padding.left = horizontal;
			_padding.right = horizontal;
			_padding.top = vertical;
			_padding.bottom = vertical;
			return this;
		}

		public SettingBuilder WithPadding(int padding)
		{
			_padding.left = padding;
			_padding.right = padding;
			_padding.top = padding;
			_padding.bottom = padding;
			return this;
		}

		public new SettingBuilder WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public SettingBuilder WithComponent(BaseSettingComponent component)
		{
			_components.Add(component);
			return this;
		}

		public SettingBuilder WithComponents([ParamCollection] IEnumerable<BaseSettingComponent> components)
		{
			_components.AddRange(components);
			return this;
		}

		public override GameObject Build()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(_name))
			{
				throw new Exception("name cannot be null or empty.");
			}
			if ((Object)(object)_parent == (Object)null)
			{
				throw new Exception("parent cannot be null.");
			}
			GameObject val = new GameObject(_name);
			val.transform.SetParent(_parent);
			val.transform.localScale = Vector3.one;
			val.AddComponent<RectTransform>().sizeDelta = _size;
			val.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			((Graphic)val.AddComponent<RawImage>()).color = _backgroundColor;
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = _childControlWidth;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = _childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = _childForceExpandWidth;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = _childForceExpandHeight;
			((HorizontalOrVerticalLayoutGroup)obj).childScaleWidth = _childScaleWidth;
			((HorizontalOrVerticalLayoutGroup)obj).childScaleHeight = _childScaleHeight;
			((HorizontalOrVerticalLayoutGroup)obj).reverseArrangement = _reverseArangement;
			((HorizontalOrVerticalLayoutGroup)obj).spacing = _spacing;
			((LayoutGroup)obj).padding.left = _padding.left;
			((LayoutGroup)obj).padding.right = _padding.right;
			((LayoutGroup)obj).padding.top = _padding.top;
			((LayoutGroup)obj).padding.bottom = _padding.bottom;
			BuiltComponents = new List<GameObject>(_components.Count);
			foreach (BaseSettingComponent component in _components)
			{
				try
				{
					BuiltComponents.Add(component.WithParent(val.transform).Build());
				}
				catch (Exception ex)
				{
					BuiltComponents.Add(null);
					((BasePlugin)CrabDevKit.Instance).Log.LogError((object)ex);
				}
			}
			return val;
		}
	}
	public sealed class SliderComponent : BaseSettingComponent
	{
		private int _minState;

		private int _maxState = 10;

		private int _initialState = 5;

		private Vector2 _size = new Vector2(230f, 40f);

		private float _fillHeight = 10f;

		private float _handleWidth = 15f;

		private Vector2 _valueSize = new Vector2(90f, 40f);

		private TMP_FontAsset _font = CommonUi.RobotoBoldFont;

		private Color _textColor = Color.white;

		private Color _backgroundColor = new Color(0f, 0f, 0f, 0.5804f);

		private Color _fillColor = new Color(0.2235f, 0.2745f, 0.8f);

		private Color _valueTextBackgroundColor = new Color(0f, 0f, 0f, 0.502f);

		private CustomSliderCallback _callback;

		public SliderComponent WithMinState(int minState)
		{
			_minState = minState;
			return this;
		}

		public SliderComponent WithMaxState(int maxState)
		{
			_maxState = maxState;
			return this;
		}

		public SliderComponent WithInitialState(int initialState)
		{
			_initialState = initialState;
			return this;
		}

		public SliderComponent WithSize(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_size = new Vector2(width, height);
			return this;
		}

		public SliderComponent WithFillHeight(float fillHeight)
		{
			_fillHeight = fillHeight;
			return this;
		}

		public SliderComponent WithHandleWidth(float handleWidth)
		{
			_handleWidth = handleWidth;
			return this;
		}

		public SliderComponent WithValueSize(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_valueSize = new Vector2(width, height);
			return this;
		}

		public SliderComponent WithFont(TMP_FontAsset font)
		{
			_font = font;
			return this;
		}

		public SliderComponent WithTextColor(Color textColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_textColor = textColor;
			return this;
		}

		public SliderComponent WithBackgroundColor(Color backgroundColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_backgroundColor = backgroundColor;
			return this;
		}

		public SliderComponent WithFillColor(Color fillColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_fillColor = fillColor;
			return this;
		}

		public SliderComponent WithValueTextBackgroundColor(Color valueTextBackgroundColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_valueTextBackgroundColor = valueTextBackgroundColor;
			return this;
		}

		public SliderComponent WithCallback(CustomSliderCallback callback)
		{
			_callback = (CustomSliderCallback)Delegate.Combine(_callback, callback);
			return this;
		}

		public new SliderComponent WithParent(Transform parent)
		{
			_parent = parent;
			return this;
		}

		public override GameObject Build()
		{
			//IL_0073: 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_007a: Expected O, but got Unknown
			//IL_007b: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Expected O, but got Unknown
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Expected O, but got Unknown
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Expected O, but got Unknown
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			if (_minState > _maxState)
			{
				throw new Exception("minState should be less than or equal to maxState.");
			}
			_initialState = Mathf.Clamp(_initialState, _minState, _maxState);
			if ((Object)(object)_font == (Object)null)
			{
				throw new Exception("font cannot be null.");
			}
			if ((Object)(object)_parent == (Object)null)
			{
				throw new Exception("parent cannot be null.");
			}
			GameObject val = new GameObject("Slider Component");
			GameObject val2 = val;
			val2 = val;
			val2.transform.SetParent(_parent);
			val2.transform.localScale = Vector3.one;
			val2.AddComponent<RectTransform>().sizeDelta = new Vector2(_size.x + _valueSize.x + 25f, _size.y);
			val2.AddComponent<CanvasRenderer>().cullTransparentMesh = false;
			RawImage obj = val2.AddComponent<RawImage>();
			((Behaviour)obj).enabled = false;
			((Graphic)obj).color = Color.red;
			HorizontalLayoutGroup obj2 = val2.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 25f;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)4;
			GameObject val3 = new GameObject("Slider");
			val3.transform.SetParent(val2.transform);
			val3.transform.localScale = Vector3.one;
			val3.AddComponent<RectTransform>().sizeDelta = _size;
			CustomSlider customSlider = val3.AddComponent<CustomSlider>();
			Slider val4 = val3.AddComponent<Slider>();
			val4.wholeNumbers = true;
			val4.minValue = _minState;
			val4.maxValue = _maxState;
			val4.value = _initialState;
			((UnityEventBase)val4.onValueChanged).AddListener((Object)(object)customSlider, ((Object)customSlider).GetIl2CppType().GetMethod("SliderUpdated"));
			customSlider.slider = val4;
			GameObject val5 = new GameObject("Background");
			val5.transform.SetParent(val3.transform);
			val5.transform.localScale = Vector3.one;
			RectTransform obj3 = val5.AddComponent<RectTransform>();
			obj3.anchorMax = new Vector2(0.9787f, 0.75f);
			obj3.anchorMin = new Vector2(0.0213f, 0.25f);
			obj3.sizeDelta = new