Decompiled source of Enhanced Prefab Loader v4.0.0

BepInEx/patchers/CollectionWeaver.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using CollectionWeaver.Core;
using CollectionWeaver.Extensions;
using CollectionWeaver.Utility;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
using Mono.Collections.Generic;
using MonoMod.Cil;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CollectionWeaver
{
	public static class ListInterceptor<T>
	{
		private static readonly ConcurrentDictionary<string, ListInterceptorHandler<T>> handlerCache = new ConcurrentDictionary<string, ListInterceptorHandler<T>>();

		public static List<ListInterceptorHandler<T>> Handlers { get; private set; } = new List<ListInterceptorHandler<T>>();


		public static void InvokeInsert(List<T> list, int index, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Insert(list, index, value, fieldName);
				return;
			}
			try
			{
				list.Insert(index, value);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Insert for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeIndexOf(List<T> list, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.IndexOf(list, value, fieldName);
			}
			try
			{
				return list.IndexOf(value);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in IndexOf for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeRemoveAt(List<T> list, int index, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.RemoveAt(list, index, fieldName);
				return;
			}
			try
			{
				list.RemoveAt(index);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in RemoveAt for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static T InvokeGet_Item(List<T> list, int index, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.GetItem(list, index, fieldName);
			}
			try
			{
				return list[index];
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Get_Item for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeSet_Item(List<T> list, int index, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.SetItem(list, index, value, fieldName);
				return;
			}
			try
			{
				list[index] = value;
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Set_Item for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static List<T>.Enumerator InvokeGetEnumerator(List<T> list, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.GetEnumerator(list, fieldName);
			}
			try
			{
				return list.GetEnumerator();
			}
			catch (Exception ex)
			{
				throw new Exception("Error in GetEnumerator for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeAdd(List<T> list, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Add(list, value, fieldName);
				return;
			}
			try
			{
				list.Add(value);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Add for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static bool InvokeRemove(List<T> list, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.Remove(list, value, fieldName);
			}
			try
			{
				return list.Remove(value);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Remove for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeGet_Count(List<T> list, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.Count(list, fieldName);
			}
			try
			{
				return list.Count;
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Get_Count for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeClear(List<T> list, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Clear(list, fieldName);
				return;
			}
			try
			{
				list.Clear();
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Clear for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static bool InvokeContains(List<T> list, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.Contains(list, value, fieldName);
			}
			try
			{
				return list.Contains(value);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Contains for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeCopyTo(List<T> list, T[] array, int arrayIndex, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.CopyTo(list, array, arrayIndex, fieldName);
				return;
			}
			try
			{
				list.CopyTo(array, arrayIndex);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in CopyTo for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeAddRange(List<T> list, IEnumerable<T> values, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.AddRange(list, values, fieldName);
				return;
			}
			try
			{
				list.AddRange(values);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in AddRange for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeInsertRange(List<T> list, int index, IEnumerable<T> values, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.InsertRange(list, index, values, fieldName);
				return;
			}
			try
			{
				list.InsertRange(index, values);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in InsertRange for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeRemoveRange(List<T> list, int index, int count, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.RemoveRange(list, index, count, fieldName);
				return;
			}
			try
			{
				list.RemoveRange(index, count);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in RemoveRange for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeLastIndexOf(List<T> list, T value, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.LastIndexOf(list, value, fieldName);
			}
			try
			{
				return list.LastIndexOf(value);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in LastIndexOf for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeSort(List<T> list, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Sort(list, fieldName);
				return;
			}
			try
			{
				list.Sort();
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Sort for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeSort(List<T> list, Comparison<T> comparison, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Sort(list, comparison, fieldName);
				return;
			}
			try
			{
				list.Sort(comparison);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Sort(Comparison) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeSort(List<T> list, IComparer<T> comparer, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Sort(list, comparer, fieldName);
				return;
			}
			try
			{
				list.Sort(comparer);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Sort(IComparer) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeReverse(List<T> list, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Reverse(list, fieldName);
				return;
			}
			try
			{
				list.Reverse();
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Reverse for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static void InvokeReverse(List<T> list, int index, int count, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				handler.Reverse(list, index, count, fieldName);
				return;
			}
			try
			{
				list.Reverse(index, count);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Reverse(int, int) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static bool InvokeExists(List<T> list, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.Exists(list, predicate, fieldName);
			}
			try
			{
				return list.Exists(predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Exists for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static T InvokeFind(List<T> list, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.Find(list, predicate, fieldName);
			}
			try
			{
				return list.Find(predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in Find for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeFindIndex(List<T> list, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindIndex(list, predicate, fieldName);
			}
			try
			{
				return list.FindIndex(predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindIndex for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeFindIndex(List<T> list, int index, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindIndex(list, index, predicate, fieldName);
			}
			try
			{
				return list.FindIndex(index, predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindIndex(int) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeFindIndex(List<T> list, int index, int count, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindIndex(list, index, count, predicate, fieldName);
			}
			try
			{
				return list.FindIndex(index, count, predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindIndex(int, int) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static T InvokeFindLast(List<T> list, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindLast(list, predicate, fieldName);
			}
			try
			{
				return list.FindLast(predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindLast for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeFindLastIndex(List<T> list, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindLastIndex(list, predicate, fieldName);
			}
			try
			{
				return list.FindLastIndex(predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindLastIndex for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeFindLastIndex(List<T> list, int index, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindLastIndex(list, index, predicate, fieldName);
			}
			try
			{
				return list.FindLastIndex(index, predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindLastIndex(int) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static int InvokeFindLastIndex(List<T> list, int index, int count, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.FindLastIndex(list, index, count, predicate, fieldName);
			}
			try
			{
				return list.FindLastIndex(index, count, predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in FindLastIndex(int, int) for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static bool InvokeTrueForAll(List<T> list, Predicate<T> predicate, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.TrueForAll(list, predicate, fieldName);
			}
			try
			{
				return list.TrueForAll(predicate);
			}
			catch (Exception ex)
			{
				throw new Exception("Error in TrueForAll for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		public static T[] InvokeToArray(List<T> list, string fieldName)
		{
			ListInterceptorHandler<T> handler = GetHandler(fieldName);
			if (handler != null)
			{
				return handler.ToArray(list, fieldName);
			}
			try
			{
				return list.ToArray();
			}
			catch (Exception ex)
			{
				throw new Exception("Error in ToArray for field '" + fieldName + "': " + ex.Message, ex);
			}
		}

		private static ListInterceptorHandler<T>? GetHandler(string fieldName)
		{
			return handlerCache.GetOrAdd(fieldName, delegate(string fn)
			{
				string fn2 = fn;
				return Handlers.FirstOrDefault((ListInterceptorHandler<T> h) => h.ShouldHandleCall(fn2));
			});
		}
	}
}
namespace CollectionWeaver.Utility
{
	internal static class StringParser
	{
		internal static bool AnyMatch(IEnumerable<string> patterns, string input)
		{
			foreach (string pattern in patterns)
			{
				if (IsMatch(pattern, input))
				{
					return true;
				}
			}
			return false;
		}

		internal static bool IsMatch(string pattern, string input)
		{
			if (pattern == "*")
			{
				return true;
			}
			string[] array = pattern.Split('*', StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 1 && !pattern.Contains("*"))
			{
				return input == pattern;
			}
			int startIndex = 0;
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i];
				if (i == 0 && !pattern.StartsWith("*") && !input.StartsWith(text))
				{
					return false;
				}
				if (i == array.Length - 1 && !pattern.EndsWith("*") && !input.EndsWith(text))
				{
					return false;
				}
				int num = input.IndexOf(text, startIndex, StringComparison.Ordinal);
				if (num == -1)
				{
					return false;
				}
				startIndex = num + text.Length;
			}
			return true;
		}
	}
}
namespace CollectionWeaver.IL
{
	public class ILWeaver
	{
		private readonly WeaverOptions weaverOptions;

		private readonly MethodWeaver methodWeaver;

		public ILWeaver(WeaverOptions? weaverOptions = null)
		{
			this.weaverOptions = weaverOptions ?? new WeaverOptions();
			methodWeaver = new MethodWeaver(this.weaverOptions);
		}

		public WeaverResult Weave(AssemblyDefinition assembly)
		{
			ModuleDefinition mainModule = assembly.MainModule;
			WeaverResult weaverResult = new WeaverResult();
			foreach (TypeDefinition item in from t in ModuleDefinitionRocks.GetAllTypes(mainModule)
				where t.IsClassType()
				select t)
			{
				if (StringParser.AnyMatch(weaverOptions.ExcludedNamespaces, ((TypeReference)item).Namespace))
				{
					weaverResult.AddSkipped("", ((TypeReference)item).Namespace, "Excluded by namespace filter");
					continue;
				}
				if (StringParser.AnyMatch(weaverOptions.ExcludedClassNames, ((MemberReference)item).Name))
				{
					weaverResult.AddSkipped(((TypeReference)item).Namespace, ((MemberReference)item).Name, "Excluded by class filter");
					continue;
				}
				foreach (MethodDefinition item2 in ((IEnumerable<MethodDefinition>)item.Methods).Where((MethodDefinition m) => m.HasBody))
				{
					if (StringParser.AnyMatch(weaverOptions.ExcludedMethodNames, ((MemberReference)item2.DeclaringType).Name + "." + ((MemberReference)item2).Name))
					{
						weaverResult.AddSkipped(((MemberReference)item).Name, ((MemberReference)item2).Name, "Excluded by method filter");
					}
					else
					{
						weaverResult.Merge(methodWeaver.Weave(item2));
					}
				}
			}
			return weaverResult;
		}
	}
	internal class MethodVariablePool
	{
		private readonly MethodDefinition method;

		private readonly Dictionary<TypeReference, VariableDefinition> variables = new Dictionary<TypeReference, VariableDefinition>();

		internal MethodVariablePool(MethodDefinition method)
		{
			this.method = method;
		}

		internal VariableDefinition GetVariableDefinition(TypeReference type)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (!variables.TryGetValue(type, out VariableDefinition value))
			{
				value = new VariableDefinition(type);
				method.Body.Variables.Add(value);
				variables[type] = value;
			}
			return value;
		}
	}
	public class MethodWeaver
	{
		private readonly WeaverOptions options = options ?? new WeaverOptions();

		private readonly NameResolver nameResolver = new NameResolver();

		private readonly Dictionary<string, (GenericInstanceType, TypeDefinition)> interceptorTypeCache = new Dictionary<string, (GenericInstanceType, TypeDefinition)>();

		private readonly Dictionary<string, MethodReference> interceptorMethodRefCache = new Dictionary<string, MethodReference>();

		public MethodWeaver(WeaverOptions? options = null)
		{
		}

		public WeaverResult Weave(MethodDefinition method)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			MethodBodyRocks.SimplifyMacros(method.Body);
			ILContext val = new ILContext(method);
			try
			{
				ILCursor val2 = new ILCursor(val);
				WeaverResult weaverResult = new WeaverResult();
				MethodReference targetMethodRef = null;
				while (val2.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref targetMethodRef)
				}))
				{
					if (targetMethodRef == null || !((MemberReference)targetMethodRef).DeclaringType.IsSupportedCollectionType())
					{
						string scope = ((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name;
						MethodReference obj = targetMethodRef;
						object obj2 = ((obj != null) ? ((MemberReference)obj).FullName : null) ?? "[null]";
						if (obj2 == null)
						{
							obj2 = "";
						}
						weaverResult.AddSkipped(scope, (string)obj2, "Excluded by collection type filter");
						continue;
					}
					GenericInstanceType genericInstanceType = ((MemberReference)targetMethodRef).DeclaringType.GetGenericInstanceType();
					if (genericInstanceType == null)
					{
						weaverResult.AddSkipped(((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name, ((MemberReference)targetMethodRef).FullName, "None generic collection type.");
						continue;
					}
					if (!nameResolver.TryResolveName(val2.Clone(), ((IEnumerable<TypeReference>)genericInstanceType.GenericArguments).ToArray(), out string name))
					{
						weaverResult.AddSkipped(((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name, name, "Unresolvable name.");
						continue;
					}
					if (StringParser.AnyMatch(options.ExcludedFieldNames, name))
					{
						weaverResult.AddSkipped(((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name, name, "Excluded by method name filter.");
						continue;
					}
					TypeDefinition interceptorTypeDef = GetInterceptorTypeDef(val2.Module, genericInstanceType);
					if (interceptorTypeDef == null)
					{
						weaverResult.AddSkipped(((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name, ((MemberReference)genericInstanceType).FullName, "No interceptor found.");
						continue;
					}
					MethodReference interceptorMethodRef = GetInterceptorMethodRef(val2.Module, interceptorTypeDef, targetMethodRef, genericInstanceType);
					if (interceptorMethodRef == null)
					{
						weaverResult.AddSkipped(((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name, ((MemberReference)interceptorTypeDef).FullName, "No matching interceptor method found.");
						continue;
					}
					PatchCollectionCall(val2, interceptorMethodRef, name);
					weaverResult.AddPatched(((MemberReference)method.DeclaringType).Name + "." + ((MemberReference)method).Name, name, (MethodReference)(object)method);
				}
				MethodBodyRocks.OptimizeMacros(method.Body);
				return weaverResult;
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}

		private void PatchCollectionCall(ILCursor cursor, MethodReference interceptorMethodRef, string declaredName)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			ILCursor cursor2 = cursor;
			List<Instruction> list = ((IEnumerable<Instruction>)cursor2.Method.Body.Instructions).Where((Instruction instr) => instr.Operand == cursor2.Next).ToList();
			ILLabel val = cursor2.MarkLabel();
			cursor2.Emit(OpCodes.Ldstr, declaredName).Remove().Emit(OpCodes.Call, interceptorMethodRef);
			foreach (Instruction item in list)
			{
				item.Operand = val.Target;
			}
		}

		private TypeDefinition? GetInterceptorTypeDef(ModuleDefinition module, GenericInstanceType collectionType)
		{
			if (!interceptorTypeCache.TryGetValue(((MemberReference)collectionType).FullName, out (GenericInstanceType, TypeDefinition) value))
			{
				Type interceptorRuntimeType = GetInterceptorRuntimeType(collectionType);
				if ((object)interceptorRuntimeType == null)
				{
					return null;
				}
				GenericInstanceType obj = TypeReferenceRocks.MakeGenericInstanceType(module.ImportReference(interceptorRuntimeType), ((IEnumerable<TypeReference>)collectionType.GenericArguments).ToArray());
				TypeDefinition item = ((TypeReference)obj).Resolve();
				value = (obj, item);
				interceptorTypeCache[((MemberReference)collectionType).FullName] = value;
			}
			return value.Item2;
		}

		private MethodReference? GetInterceptorMethodRef(ModuleDefinition module, TypeDefinition? interceptorTypeDef, MethodReference targetMethod, GenericInstanceType collectionType)
		{
			MethodReference targetMethod2 = targetMethod;
			GenericInstanceType collectionType2 = collectionType;
			MethodDefinition val = ((interceptorTypeDef != null) ? ((IEnumerable<MethodDefinition>)interceptorTypeDef.Methods).FirstOrDefault((Func<MethodDefinition, bool>)((MethodDefinition m) => ((MemberReference)m).Name.EndsWith(((MemberReference)targetMethod2).Name, StringComparison.OrdinalIgnoreCase) && ((MethodReference)m).Parameters.Count - 2 == targetMethod2.Parameters.Count && ((IEnumerable<ParameterDefinition>)((MethodReference)m).Parameters).Skip(1).Take(((MethodReference)m).Parameters.Count - 2).Zip((IEnumerable<ParameterDefinition>)targetMethod2.Parameters, (ParameterDefinition interceptorParam, ParameterDefinition methodParam) => ((ParameterReference)interceptorParam).ParameterType.IsEquivalentTo(((ParameterReference)methodParam).ParameterType, collectionType2))
				.All((bool match) => match))) : null);
			if (val == null)
			{
				return null;
			}
			string text = string.Join("|", ((IEnumerable<ParameterDefinition>)targetMethod2.Parameters).Select((ParameterDefinition p) => ((MemberReference)((ParameterReference)p).ParameterType).FullName));
			string key = ((MemberReference)collectionType2).FullName + "::" + ((MemberReference)targetMethod2).Name + "::" + text;
			if (!interceptorMethodRefCache.TryGetValue(key, out MethodReference value))
			{
				value = module.ImportReference((MethodReference)(object)val);
				((MemberReference)value).DeclaringType = (TypeReference)(object)interceptorTypeCache[((MemberReference)collectionType2).FullName].Item1;
				interceptorMethodRefCache[key] = value;
			}
			return value;
		}

		private Type? GetInterceptorRuntimeType(GenericInstanceType? genericInstanceType)
		{
			string text = ((genericInstanceType != null) ? ((MemberReference)((TypeReference)genericInstanceType).GetElementType()).FullName : null);
			if (text == "System.Collections.Generic.List`1" || text == "System.Collections.Generic.IList`1")
			{
				return typeof(ListInterceptor<>);
			}
			return null;
		}
	}
	internal class NameResolver
	{
		internal bool TryResolveName(ILCursor cursor, TypeReference[] targetGenericArguments, out string name)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_01f4: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			ILCursor cursor2 = cursor;
			TypeReference[] targetGenericArguments2 = targetGenericArguments;
			string name2 = ((MemberReference)cursor2.Method).Name;
			Instruction next = cursor2.Next;
			name = $"{name2}_unk_{((next != null) ? next.Offset : 0)}";
			if (cursor2.Next == null)
			{
				return false;
			}
			Instruction next2 = cursor2.Next;
			while (cursor2.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => instr.MatchCollectionLoad(cursor2.Method, targetGenericArguments2)
			}))
			{
				if (cursor2.Next == null)
				{
					return false;
				}
				int stackCount = 1;
				if (!TryTraceToTarget(cursor2.Next, next2, ref stackCount) || stackCount != 0)
				{
					continue;
				}
				if (cursor2.Previous.OpCode.IsFieldLoad())
				{
					FieldReference val = (FieldReference)cursor2.Previous.Operand;
					name = ((MemberReference)((MemberReference)val).DeclaringType).Name + "." + ((MemberReference)val).Name;
					return true;
				}
				if (cursor2.Previous.OpCode.IsLdarg())
				{
					name = $"{((MemberReference)cursor2.Method).Name}_arg{cursor2.Method.GetParameterIndex(cursor2.Previous)}";
					return true;
				}
				while (cursor2.Previous.OpCode.IsLdloc() && cursor2.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction instr) => instr.IsComplimentaryStOf(cursor2.Previous)
				}))
				{
					if (cursor2.SkipNeutralBackward().Previous.OpCode.IsFieldLoad())
					{
						FieldReference val2 = (FieldReference)cursor2.Previous.Operand;
						name = ((MemberReference)((MemberReference)val2).DeclaringType).Name + "." + ((MemberReference)val2).Name;
						return true;
					}
					if (cursor2.Previous.OpCode.IsLdarg())
					{
						name = $"{((MemberReference)cursor2.Method).Name}_arg{cursor2.Method.GetParameterIndex(cursor2.Previous)}";
						return true;
					}
				}
			}
			return false;
		}

		private bool TryTraceToTarget(Instruction current, Instruction target, ref int stackCount)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (current == null || target == null)
			{
				return false;
			}
			Instruction obj;
			for (; current != null; current = obj)
			{
				if (current == target)
				{
					stackCount -= current.GetStackPopCount();
					return true;
				}
				stackCount -= current.GetStackPopCount();
				stackCount += current.GetStackPushCount();
				if (current.OpCode.IsUnconditionalBranch())
				{
					object operand = current.Operand;
					Instruction val = (Instruction)((operand is Instruction) ? operand : null);
					if (val != null)
					{
						obj = val;
						continue;
					}
				}
				obj = current.Next;
			}
			return false;
		}
	}
	public class WeaverOptions
	{
		private readonly HashSet<string> excludedNamespaces = new HashSet<string>();

		private readonly HashSet<string> excludedClassNames = new HashSet<string>();

		private readonly HashSet<string> excludedMethodNames = new HashSet<string>();

		private readonly HashSet<string> excludedFieldNames = new HashSet<string>();

		public CollectionTypes IncludedCollectionTypes { get; private set; }

		public IReadOnlyCollection<string> ExcludedNamespaces => excludedNamespaces;

		public IReadOnlyCollection<string> ExcludedClassNames => excludedClassNames;

		public IReadOnlyCollection<string> ExcludedMethodNames => excludedMethodNames;

		public IReadOnlyCollection<string> ExcludedFieldNames => excludedFieldNames;

		public WeaverOptions IncludeCollectionTypes(CollectionTypes collectionTypes)
		{
			IncludedCollectionTypes |= collectionTypes;
			return this;
		}

		public WeaverOptions ExcludeNamespace(string namespaceName)
		{
			excludedNamespaces.Add(namespaceName);
			return this;
		}

		public WeaverOptions ExcludeClass(string className)
		{
			excludedClassNames.Add(className);
			return this;
		}

		public WeaverOptions ExcludeMethod(string methodName)
		{
			excludedMethodNames.Add(methodName);
			return this;
		}

		public WeaverOptions ExcludeField(string fieldName)
		{
			excludedFieldNames.Add(fieldName);
			return this;
		}
	}
	public class WeaverResult
	{
		private class Entry
		{
			public ResultKind Kind { get; set; }

			public string? Scope { get; set; }

			public string? Name { get; set; }

			public string? Details { get; set; }
		}

		private enum ResultKind
		{
			Patched,
			Skipped
		}

		private readonly List<Entry> entries = new List<Entry>();

		public int PatchedCount => entries.Count((Entry e) => e.Kind == ResultKind.Patched);

		public int SkippedCount => entries.Count((Entry e) => e.Kind == ResultKind.Skipped);

		public void AddPatched(string scope, string name, MethodReference methodReference)
		{
			entries.Add(new Entry
			{
				Kind = ResultKind.Patched,
				Scope = scope,
				Name = name,
				Details = ((MemberReference)methodReference).FullName
			});
		}

		public void AddSkipped(string scope, string name, string reason)
		{
			entries.Add(new Entry
			{
				Kind = ResultKind.Skipped,
				Scope = scope,
				Name = name,
				Details = reason
			});
		}

		public void Merge(WeaverResult other)
		{
			if (other != null)
			{
				entries.AddRange(other.entries);
			}
		}

		public string CompileLog()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("=== Weaver Results ===");
			foreach (Entry entry in entries)
			{
				string text = ((entry.Kind == ResultKind.Patched) ? "✔" : "✘");
				string text2 = (string.IsNullOrEmpty(entry.Details) ? "" : (" -> " + entry.Details));
				stringBuilder.AppendLine(text + " [" + entry.Scope + "] " + entry.Name + text2);
			}
			return stringBuilder.ToString();
		}
	}
}
namespace CollectionWeaver.Extensions
{
	internal static class ArrayTypeExtensions
	{
		internal static bool IsEquivalentTo(this ArrayType source, ArrayType target, GenericInstanceType? genericContext)
		{
			if (((TypeSpecification)source).ElementType.IsEquivalentTo(((TypeSpecification)target).ElementType, genericContext))
			{
				return source.Rank == target.Rank;
			}
			return false;
		}
	}
	internal static class CursorExtensions
	{
		internal static ILCursor SkipNeutralForward(this ILCursor cursor)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			while (cursor.Next != null && cursor.Next.OpCode.IsNeutral())
			{
				cursor.GotoNext(Array.Empty<Func<Instruction, bool>>());
			}
			return cursor;
		}

		internal static ILCursor SkipNeutralBackward(this ILCursor cursor)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			while (cursor.Previous != null && cursor.Previous.OpCode.IsNeutral())
			{
				cursor.GotoPrev(Array.Empty<Func<Instruction, bool>>());
			}
			return cursor;
		}
	}
	internal static class GenericInstanceTypeExtensions
	{
		internal static bool IsEquivalentTo(this GenericInstanceType source, GenericInstanceType target, GenericInstanceType? genericContext)
		{
			if (!((TypeSpecification)source).ElementType.IsEquivalentTo(((TypeSpecification)target).ElementType, genericContext))
			{
				return false;
			}
			Collection<TypeReference> genericArguments = source.GenericArguments;
			Collection<TypeReference> genericArguments2 = target.GenericArguments;
			if (genericArguments.Count != genericArguments2.Count)
			{
				return false;
			}
			for (int i = 0; i < genericArguments.Count; i++)
			{
				if (!genericArguments[i].IsEquivalentTo(genericArguments2[i], genericContext))
				{
					return false;
				}
			}
			return true;
		}
	}
	internal static class GenericParameterExtensions
	{
		internal static bool TryResolveAndMatch(this GenericParameter genericParam, TypeReference target, GenericInstanceType? genericContext)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			GenericParameter val = (GenericParameter)(object)((target is GenericParameter) ? target : null);
			if (val != null)
			{
				if (genericParam.Position == val.Position)
				{
					return genericParam.Type == val.Type;
				}
				return false;
			}
			if (genericContext != null && genericParam.Position < genericContext.GenericArguments.Count)
			{
				return ((MemberReference)genericContext.GenericArguments[genericParam.Position]).FullName == ((MemberReference)target).FullName;
			}
			return false;
		}
	}
	internal static class InstructionExtensions
	{
		internal static bool MatchCollectionLoad(this Instruction instruction, MethodDefinition method, TypeReference[] targetGenericArguments)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected I4, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Invalid comparison between Unknown and I4
			if (!instruction.OpCode.IsLoadCode())
			{
				return false;
			}
			OpCode opCode = instruction.OpCode;
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code <= 120)
			{
				switch (code - 2)
				{
				case 4:
					goto IL_0099;
				case 5:
					goto IL_00ab;
				case 6:
					goto IL_00bd;
				case 7:
					goto IL_00cf;
				case 15:
					goto IL_00e1;
				case 0:
					goto IL_00fe;
				case 1:
					goto IL_011b;
				case 2:
					goto IL_0136;
				case 3:
					goto IL_0151;
				case 13:
					goto IL_016c;
				case 8:
				case 9:
				case 10:
				case 11:
				case 12:
				case 14:
					goto IL_01a0;
				}
				if ((int)code == 120)
				{
					goto IL_0186;
				}
			}
			else
			{
				if ((int)code == 123)
				{
					goto IL_0186;
				}
				if ((int)code == 199)
				{
					goto IL_016c;
				}
				if ((int)code == 202)
				{
					goto IL_00e1;
				}
			}
			goto IL_01a0;
			IL_0186:
			object operand = instruction.Operand;
			object obj = ((operand is FieldReference) ? operand : null);
			TypeReference val = ((obj != null) ? ((FieldReference)obj).FieldType : null);
			goto IL_01a2;
			IL_01a0:
			val = null;
			goto IL_01a2;
			IL_00e1:
			object operand2 = instruction.Operand;
			object obj2 = ((operand2 is VariableReference) ? operand2 : null);
			val = ((obj2 != null) ? ((VariableReference)obj2).VariableType : null);
			goto IL_01a2;
			IL_01a2:
			TypeReference val2 = val;
			if (val2 == null || !val2.IsSupportedCollectionType())
			{
				return false;
			}
			GenericInstanceType genericInstanceType = val2.GetGenericInstanceType();
			if (genericInstanceType != null)
			{
				return targetGenericArguments.Select((TypeReference x) => ((MemberReference)x).FullName).SequenceEqual(((IEnumerable<TypeReference>)genericInstanceType.GenericArguments).Select((TypeReference x) => ((MemberReference)x).FullName));
			}
			return false;
			IL_00cf:
			val = method.Body.GetVariableType(3);
			goto IL_01a2;
			IL_00bd:
			val = method.Body.GetVariableType(2);
			goto IL_01a2;
			IL_00ab:
			val = method.Body.GetVariableType(1);
			goto IL_01a2;
			IL_0099:
			val = method.Body.GetVariableType(0);
			goto IL_01a2;
			IL_0151:
			val = (((MethodReference)method).HasThis ? method.GetParameterType(2) : method.GetParameterType(3));
			goto IL_01a2;
			IL_011b:
			val = (((MethodReference)method).HasThis ? method.GetParameterType(0) : method.GetParameterType(1));
			goto IL_01a2;
			IL_00fe:
			val = (TypeReference)(((MethodReference)method).HasThis ? ((object)method.DeclaringType) : ((object)method.GetParameterType(0)));
			goto IL_01a2;
			IL_016c:
			object operand3 = instruction.Operand;
			object obj3 = ((operand3 is ParameterReference) ? operand3 : null);
			val = ((obj3 != null) ? ((ParameterReference)obj3).ParameterType : null);
			goto IL_01a2;
			IL_0136:
			val = (((MethodReference)method).HasThis ? method.GetParameterType(1) : method.GetParameterType(2));
			goto IL_01a2;
		}

		internal static bool IsComplimentaryStOf(this Instruction stInstruction, Instruction ldInstruction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!stInstruction.OpCode.IsStloc() || !ldInstruction.OpCode.IsLdloc())
			{
				return false;
			}
			int? localCodeIndex = stInstruction.GetLocalCodeIndex();
			int? localCodeIndex2 = ldInstruction.GetLocalCodeIndex();
			if (localCodeIndex.HasValue)
			{
				return localCodeIndex == localCodeIndex2;
			}
			return false;
		}

		internal static int? GetLocalCodeIndex(this Instruction instr)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected I4, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			OpCode opCode = instr.OpCode;
			Code code = ((OpCode)(ref opCode)).Code;
			switch (code - 6)
			{
			default:
				if ((int)code != 202 && (int)code != 204)
				{
					break;
				}
				goto case 11;
			case 0:
			case 4:
				return 0;
			case 1:
			case 5:
				return 1;
			case 2:
			case 6:
				return 2;
			case 3:
			case 7:
				return 3;
			case 11:
			case 13:
			{
				object operand = instr.Operand;
				VariableReference val = (VariableReference)((operand is VariableReference) ? operand : null);
				return (val != null) ? new int?(val.Index) : null;
			}
			case 8:
			case 9:
			case 10:
			case 12:
				break;
			}
			return null;
		}

		internal static int GetStackPopCount(this Instruction inst)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected I4, but got Unknown
			OpCode opCode = inst.OpCode;
			StackBehaviour stackBehaviourPop = ((OpCode)(ref opCode)).StackBehaviourPop;
			return (int)stackBehaviourPop switch
			{
				0 => 0, 
				1 => 1, 
				2 => 2, 
				3 => 1, 
				4 => 2, 
				5 => 2, 
				6 => 2, 
				7 => 3, 
				8 => 2, 
				9 => 2, 
				10 => 1, 
				11 => 2, 
				12 => 2, 
				13 => 3, 
				14 => 3, 
				15 => 3, 
				16 => 3, 
				17 => 3, 
				27 => inst.GetVarPop(), 
				_ => 0, 
			};
		}

		internal static int GetStackPushCount(this Instruction inst)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected I4, but got Unknown
			OpCode opCode = inst.OpCode;
			StackBehaviour stackBehaviourPush = ((OpCode)(ref opCode)).StackBehaviourPush;
			return (stackBehaviourPush - 19) switch
			{
				0 => 0, 
				1 => 1, 
				2 => 2, 
				3 => 1, 
				4 => 1, 
				5 => 1, 
				6 => 1, 
				7 => 1, 
				9 => inst.GetVarPush(), 
				_ => 0, 
			};
		}

		internal static int GetVarPop(this Instruction inst)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			OpCode opCode = inst.OpCode;
			if ((int)((OpCode)(ref opCode)).FlowControl == 2)
			{
				object operand = inst.Operand;
				MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null);
				if (val != null)
				{
					return val.Parameters.Count + (val.HasThis ? 1 : 0);
				}
			}
			opCode = inst.OpCode;
			return ((int)((OpCode)(ref opCode)).Code == 68) ? 1 : 0;
		}

		internal static int GetVarPush(this Instruction inst)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			OpCode opCode = inst.OpCode;
			if ((int)((OpCode)(ref opCode)).FlowControl == 2)
			{
				object operand = inst.Operand;
				MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null);
				if (val != null)
				{
					return ((int)val.ReturnType.MetadataType != 1) ? 1 : 0;
				}
			}
			return 0;
		}
	}
	internal static class MethodBodyExtensions
	{
		internal static TypeReference? GetVariableType(this MethodBody body, int index)
		{
			if (index < 0 || index >= body.Variables.Count)
			{
				return null;
			}
			return ((VariableReference)body.Variables[index]).VariableType;
		}
	}
	internal static class MethodDefinitionExtensions
	{
		internal static TypeReference? GetParameterType(this MethodDefinition method, int index)
		{
			if (index < 0 || index >= ((MethodReference)method).Parameters.Count)
			{
				return null;
			}
			return ((ParameterReference)((MethodReference)method).Parameters[index]).ParameterType;
		}

		internal static int? GetParameterIndex(this MethodDefinition method, Instruction instr)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected I4, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			OpCode opCode = instr.OpCode;
			Code code = ((OpCode)(ref opCode)).Code;
			switch (code - 2)
			{
			default:
				if ((int)code == 14 || (int)code == 199)
				{
					object operand = instr.Operand;
					ParameterReference val = (ParameterReference)((operand is ParameterReference) ? operand : null);
					return (val != null) ? new int?(val.Index) : null;
				}
				return null;
			case 0:
				return (!((MethodReference)method).HasThis) ? 1 : 0;
			case 1:
				return ((MethodReference)method).HasThis ? 1 : 2;
			case 2:
				return ((MethodReference)method).HasThis ? 2 : 3;
			case 3:
				return ((MethodReference)method).HasThis ? 3 : 4;
			}
		}
	}
	internal static class OpCodeExtensions
	{
		internal static bool IsLoadCode(this OpCode opCode)
		{
			//IL_0000: 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)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!opCode.IsLdloc() && !opCode.IsLdarg() && !opCode.IsLdc() && !opCode.IsLdelem() && !opCode.IsFieldLoad() && !opCode.IsLdNullOrStr())
			{
				return opCode.IsLdind();
			}
			return true;
		}

		internal static bool IsFieldLoad(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 120 || (int)code == 123)
			{
				return true;
			}
			return false;
		}

		internal static bool IsLdloc(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000c: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 6 <= 3 || (int)code == 17 || (int)code == 202)
			{
				return true;
			}
			return false;
		}

		internal static bool IsLdarg(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000c: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: 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_001d: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 2 <= 3 || code - 14 <= 1 || code - 199 <= 1)
			{
				return true;
			}
			return false;
		}

		internal static bool IsLdc(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000e: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 21 <= 14)
			{
				return true;
			}
			return false;
		}

		internal static bool IsLdelem(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 145 || (int)code == 151 || (int)code == 160)
			{
				return true;
			}
			return false;
		}

		internal static bool IsLdind(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 69 <= 6 || code - 77 <= 2)
			{
				return true;
			}
			return false;
		}

		internal static bool IsLdNullOrStr(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 20 || (int)code == 113)
			{
				return true;
			}
			return false;
		}

		internal static bool IsStloc(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 10 <= 3 || (int)code == 19 || (int)code == 204)
			{
				return true;
			}
			return false;
		}

		internal static bool IsNeutral(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code <= 209)
			{
				if ((int)code == 0 || code - 207 <= 2)
				{
					goto IL_002f;
				}
			}
			else if ((int)code == 211 || (int)code == 218)
			{
				goto IL_002f;
			}
			return false;
			IL_002f:
			return true;
		}

		internal static bool IsUnconditionalBranch(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 42 || (int)code == 55 || code - 187 <= 1)
			{
				return true;
			}
			return false;
		}

		internal static bool IsConditionalBranch(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 43 <= 1 || code - 56 <= 1)
			{
				return true;
			}
			return false;
		}

		internal static bool IsCompareBranch(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 45 <= 9 || code - 58 <= 9)
			{
				return true;
			}
			return false;
		}

		internal static bool IsSwitchBranch(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			return (int)((OpCode)(ref opCode)).Code == 68;
		}
	}
	internal static class TypeDefinitionExtensions
	{
		internal static bool IsClassType(this TypeDefinition typeDef)
		{
			if (typeDef.IsClass && !typeDef.IsInterface)
			{
				return !((TypeReference)typeDef).IsValueType;
			}
			return false;
		}
	}
	internal static class TypeReferenceExtensions
	{
		private static readonly Dictionary<string, bool> collectionTypeCache = new Dictionary<string, bool>();

		private static readonly Dictionary<string, GenericInstanceType?> genericInstanceCache = new Dictionary<string, GenericInstanceType>();

		internal static bool IsSupportedCollectionType(this TypeReference typeRef)
		{
			return typeRef.IsListType();
		}

		internal static bool IsListType(this TypeReference typeRef)
		{
			if (!collectionTypeCache.TryGetValue(((MemberReference)typeRef).FullName, out var value))
			{
				bool flag = typeRef.Namespace == "System.Collections.Generic";
				if (flag)
				{
					string name = ((MemberReference)typeRef).Name;
					bool flag2 = ((name == "List`1" || name == "IList`1") ? true : false);
					flag = flag2;
				}
				if (flag && typeRef is GenericInstanceType)
				{
					value = true;
				}
				else
				{
					TypeDefinition obj = typeRef.Resolve();
					value = ((obj == null) ? null : obj.BaseType?.IsListType()).GetValueOrDefault();
				}
				collectionTypeCache[((MemberReference)typeRef).FullName] = value;
			}
			return value;
		}

		internal static GenericInstanceType? GetGenericInstanceType(this TypeReference typeRef)
		{
			if (!genericInstanceCache.TryGetValue(((MemberReference)typeRef).FullName, out GenericInstanceType value))
			{
				try
				{
					GenericInstanceType val = (GenericInstanceType)(object)((typeRef is GenericInstanceType) ? typeRef : null);
					value = (GenericInstanceType)((val == null) ? ((object)typeRef.Resolve().BaseType?.GetGenericInstanceType()) : ((object)val));
					genericInstanceCache[((MemberReference)typeRef).FullName] = value;
				}
				catch
				{
					genericInstanceCache[((MemberReference)typeRef).FullName] = null;
				}
			}
			return value;
		}

		internal static bool IsEquivalentTo(this TypeReference source, TypeReference target, GenericInstanceType? genericContext = null)
		{
			if (source == null || target == null)
			{
				return false;
			}
			if (((MemberReference)source).FullName == ((MemberReference)target).FullName)
			{
				return true;
			}
			GenericParameter val = (GenericParameter)(object)((source is GenericParameter) ? source : null);
			if (val != null)
			{
				return val.TryResolveAndMatch(target, genericContext);
			}
			GenericParameter val2 = (GenericParameter)(object)((target is GenericParameter) ? target : null);
			if (val2 != null)
			{
				return val2.TryResolveAndMatch(source, genericContext);
			}
			GenericInstanceType val3 = (GenericInstanceType)(object)((source is GenericInstanceType) ? source : null);
			if (val3 != null)
			{
				GenericInstanceType val4 = (GenericInstanceType)(object)((target is GenericInstanceType) ? target : null);
				if (val4 != null)
				{
					return val3.IsEquivalentTo(val4, genericContext);
				}
			}
			ArrayType val5 = (ArrayType)(object)((source is ArrayType) ? source : null);
			if (val5 != null)
			{
				ArrayType val6 = (ArrayType)(object)((target is ArrayType) ? target : null);
				if (val6 != null)
				{
					return val5.IsEquivalentTo(val6, genericContext);
				}
			}
			return false;
		}
	}
}
namespace CollectionWeaver.Core
{
	[Flags]
	public enum CollectionTypes : byte
	{
		None = 0,
		List = 1,
		Dictionary = 2,
		Array = 4,
		HashSet = 8,
		Queue = 0x10,
		Stack = 0x20,
		All = byte.MaxValue
	}
	public class ConsoleLogger : ILogger
	{
		private readonly object logLock = new object();

		public void Log(LogLevel logLevel, string message)
		{
			lock (logLock)
			{
				ConsoleColor foregroundColor = Console.ForegroundColor;
				try
				{
					Console.ForegroundColor = GetLevelColor(logLevel);
					Console.WriteLine($"[{DateTime.Now:HH:mm:ss.fff}] [{logLevel}] {message}");
				}
				finally
				{
					Console.ForegroundColor = foregroundColor;
				}
			}
		}

		private ConsoleColor GetLevelColor(LogLevel level)
		{
			return level switch
			{
				LogLevel.Debug => ConsoleColor.DarkGray, 
				LogLevel.Info => ConsoleColor.White, 
				LogLevel.Warning => ConsoleColor.Yellow, 
				LogLevel.Error => ConsoleColor.Red, 
				_ => ConsoleColor.Gray, 
			};
		}
	}
	public interface ILogger
	{
		void Log(LogLevel logLevel, string message);
	}
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
	public sealed class InterceptorHandler : Attribute
	{
	}
	public static class InterceptorRegistry
	{
		public static void RegisterFromAssembly(Assembly assembly)
		{
			if (assembly == null)
			{
				throw new ArgumentNullException("assembly");
			}
			foreach (Type item in assembly.GetTypes().Where(IsInterceptorType))
			{
				TryRegisterHandler(item);
			}
		}

		public static void RegisterFromAllAssemblies()
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					RegisterFromAssembly(assembly);
				}
				catch
				{
				}
			}
		}

		private static bool IsInterceptorType(Type type)
		{
			if (type.IsClass && !type.IsAbstract)
			{
				return type.GetCustomAttribute<InterceptorHandler>() != null;
			}
			return false;
		}

		private static void TryRegisterHandler(Type handlerType)
		{
			Type type = FindInterceptorBase(handlerType);
			if (type == null)
			{
				Log.Warning(handlerType.Name + " has [Interceptor] but does not inherit from a valid InterceptorHandler<T>");
				return;
			}
			Type type2 = ResolveInterceptorType(type);
			if (type2 == null)
			{
				Log.Warning("No runtime interceptor found for " + type.Name);
				return;
			}
			IList handlersList = GetHandlersList(type2);
			if (handlersList == null)
			{
				Log.Error("Cannot access Handlers property on " + type2.Name);
			}
			else
			{
				RegisterHandler(handlersList, handlerType, type.GenericTypeArguments);
			}
		}

		private static Type? FindInterceptorBase(Type type)
		{
			Type baseType = type.BaseType;
			while (baseType != null)
			{
				if (baseType.IsGenericType && baseType.Name.EndsWith("InterceptorHandler`1"))
				{
					return baseType;
				}
				baseType = baseType.BaseType;
			}
			return null;
		}

		private static Type? ResolveInterceptorType(Type interceptorBase)
		{
			return ((!(interceptorBase.Name == "ListInterceptorHandler`1")) ? null : typeof(ListInterceptor<>))?.MakeGenericType(interceptorBase.GenericTypeArguments);
		}

		private static IList? GetHandlersList(Type interceptorType)
		{
			return interceptorType.GetProperty("Handlers", BindingFlags.Static | BindingFlags.Public)?.GetValue(null) as IList;
		}

		private static void RegisterHandler(IList handlerList, Type handlerType, Type[] genericArgs)
		{
			try
			{
				object obj = Activator.CreateInstance(handlerType);
				if (obj == null)
				{
					Log.Error("Activator.CreateInstance returned null for " + handlerType.Name);
					return;
				}
				handlerList.Add(obj);
				Log.Info("Registered " + handlerType.Name + " for " + string.Join(", ", genericArgs.Select((Type a) => a.Name)));
			}
			catch (Exception ex)
			{
				Log.Error("Failed to register " + handlerType.Name + ": " + ex.Message);
			}
		}
	}
	public abstract class ListInterceptorHandler<T>
	{
		public abstract bool ShouldHandleCall(string fieldName);

		public virtual T GetItem(List<T> list, int index, string fieldName)
		{
			return list[index];
		}

		public virtual void SetItem(List<T> list, int index, T value, string fieldName)
		{
			list[index] = value;
		}

		public virtual int Count(List<T> list, string fieldName)
		{
			return list.Count;
		}

		public virtual List<T>.Enumerator GetEnumerator(List<T> list, string fieldName)
		{
			return list.GetEnumerator();
		}

		public virtual void Add(List<T> list, T item, string fieldName)
		{
			list.Add(item);
		}

		public virtual void Insert(List<T> list, int index, T value, string fieldName)
		{
			list.Insert(index, value);
		}

		public virtual void AddRange(List<T> list, IEnumerable<T> values, string fieldName)
		{
			list.AddRange(values);
		}

		public virtual bool Remove(List<T> list, T value, string fieldName)
		{
			return list.Remove(value);
		}

		public virtual void RemoveRange(List<T> list, int index, int count, string fieldName)
		{
			list.RemoveRange(index, count);
		}

		public virtual void Clear(List<T> list, string fieldName)
		{
			list.Clear();
		}

		public virtual bool Contains(List<T> list, T value, string fieldName)
		{
			return list.Contains(value);
		}

		public virtual int IndexOf(List<T> list, T value, string fieldName)
		{
			return list.IndexOf(value);
		}

		public virtual void Sort(List<T> list, string fieldName)
		{
			list.Sort();
		}

		public virtual void Sort(List<T> list, Comparison<T> comparison, string fieldName)
		{
			list.Sort(comparison);
		}

		public virtual void Sort(List<T> list, IComparer<T> comparer, string fieldName)
		{
			list.Sort(comparer);
		}

		public virtual void Reverse(List<T> list, string fieldName)
		{
			list.Reverse();
		}

		public virtual void Reverse(List<T> list, int index, int count, string fieldName)
		{
			list.Reverse(index, count);
		}

		public virtual void CopyTo(List<T> list, T[] array, int arrayIndex, string fieldName)
		{
			list.CopyTo(array, arrayIndex);
		}

		public virtual void RemoveAt(List<T> list, int index, string fieldName)
		{
			list.RemoveAt(index);
		}

		public virtual void InsertRange(List<T> list, int index, IEnumerable<T> values, string fieldName)
		{
			list.InsertRange(index, values);
		}

		public virtual int LastIndexOf(List<T> list, T value, string fieldName)
		{
			return list.LastIndexOf(value);
		}

		public virtual bool Exists(List<T> list, Predicate<T> predicate, string fieldName)
		{
			return list.Exists(predicate);
		}

		public virtual T Find(List<T> list, Predicate<T> predicate, string fieldName)
		{
			return list.Find(predicate);
		}

		public virtual int FindIndex(List<T> list, Predicate<T> predicate, string fieldName)
		{
			return list.FindIndex(predicate);
		}

		public virtual int FindIndex(List<T> list, int index, Predicate<T> predicate, string fieldName)
		{
			return list.FindIndex(index, predicate);
		}

		public virtual int FindIndex(List<T> list, int index, int count, Predicate<T> predicate, string fieldName)
		{
			return list.FindIndex(index, count, predicate);
		}

		public virtual T FindLast(List<T> list, Predicate<T> predicate, string fieldName)
		{
			return list.FindLast(predicate);
		}

		public virtual int FindLastIndex(List<T> list, Predicate<T> predicate, string fieldName)
		{
			return list.FindLastIndex(predicate);
		}

		public virtual int FindLastIndex(List<T> list, int index, Predicate<T> predicate, string fieldName)
		{
			return list.FindLastIndex(index, predicate);
		}

		public virtual int FindLastIndex(List<T> list, int index, int count, Predicate<T> predicate, string fieldName)
		{
			return list.FindLastIndex(index, count, predicate);
		}

		public virtual bool TrueForAll(List<T> list, Predicate<T> predicate, string fieldName)
		{
			return list.TrueForAll(predicate);
		}

		public virtual T[] ToArray(List<T> list, string fieldName)
		{
			return list.ToArray();
		}
	}
	public static class Log
	{
		public static ILogger Logger { get; set; } = new ConsoleLogger();


		public static LogLevel LogLevel { get; set; } = LogLevel.Debug;


		internal static void Debug(string message)
		{
			InternalLog(LogLevel.Debug, message);
		}

		internal static void Info(string message)
		{
			InternalLog(LogLevel.Info, message);
		}

		internal static void Warning(string message)
		{
			InternalLog(LogLevel.Warning, message);
		}

		internal static void Error(string message)
		{
			InternalLog(LogLevel.Error, message);
		}

		private static void InternalLog(LogLevel logLevel, string message)
		{
			if (logLevel >= LogLevel)
			{
				Logger.Log(logLevel, message);
			}
		}
	}
	public enum LogLevel
	{
		Debug,
		Info,
		Warning,
		Error,
		None
	}
}

BepInEx/patchers/EnhancedPrefabLoaderPrepatch.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CollectionWeaver.Core;
using CollectionWeaver.IL;
using EnhancedPrefabLoaderPrepatch.Extensions;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Newtonsoft.Json;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnhancedPrefabLoaderPrepatch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.0+ce67eb128bbeaa3b2f79707fdda58b7d70eedf4b")]
[assembly: AssemblyProduct("Enhanced Prefab Loader Prepatch")]
[assembly: AssemblyTitle("EnhancedPrefabLoaderPrepatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.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 EnhancedPrefabLoaderPrepatch
{
	public class BepInExLogger : ILogger
	{
		private readonly ManualLogSource logSource;

		public BepInExLogger(string sourceName)
		{
			logSource = Logger.CreateLogSource(sourceName);
		}

		public void Log(LogLevel logLevel, string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected I4, but got Unknown
			switch ((int)logLevel)
			{
			case 0:
				logSource.LogDebug((object)message);
				break;
			case 1:
				logSource.LogInfo((object)message);
				break;
			case 2:
				logSource.LogWarning((object)message);
				break;
			case 3:
				logSource.LogError((object)message);
				break;
			}
		}
	}
	public class EnumPatcher
	{
		public void PatchEnums(AssemblyDefinition assembly, int startingValue)
		{
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Expected O, but got Unknown
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Expected O, but got Unknown
			foreach (string enumName in PatchDataManager.UserData.Keys)
			{
				int i = startingValue;
				TypeDefinition val = ((IEnumerable<TypeDefinition>)assembly.MainModule.Types).FirstOrDefault((Func<TypeDefinition, bool>)((TypeDefinition t) => ((MemberReference)t).Name == enumName));
				if (val == null || !val.IsEnum)
				{
					Patcher.Log.LogWarning((object)("Enum type " + enumName + " not found in assembly."));
					continue;
				}
				FieldDefinition val2 = ((IEnumerable<FieldDefinition>)val.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition f) => f.HasConstant && f.IsStatic && f.IsLiteral));
				if (val2 == null)
				{
					Patcher.Log.LogWarning((object)("No valid enum fields found in " + enumName + "."));
					continue;
				}
				HashSet<string> hashSet = new HashSet<string>(from f in (IEnumerable<FieldDefinition>)val.Fields
					where f.HasConstant && f.IsStatic && f.IsLiteral
					select ((MemberReference)f).Name);
				HashSet<int> hashSet2 = new HashSet<int>(from f in (IEnumerable<FieldDefinition>)val.Fields
					where f.HasConstant && f.IsStatic && f.IsLiteral
					select (int)f.Constant);
				SortedDictionary<int, FieldDefinition> sortedDictionary = new SortedDictionary<int, FieldDefinition>();
				HashSet<string> hashSet3 = PatchDataManager.UserData[enumName];
				if (PatchDataManager.SavedData.TryGetValue(enumName, out var value))
				{
					List<string> list = new List<string>();
					foreach (KeyValuePair<string, int> item in value)
					{
						if (!hashSet3.Contains(item.Key))
						{
							list.Add(item.Key);
						}
						else if (hashSet.Contains(item.Key))
						{
							Patcher.Log.LogWarning((object)("Field name '" + item.Key + "' already exists in enum " + enumName + ". Skipping."));
							list.Add(item.Key);
						}
						else if (hashSet2.Contains(item.Value))
						{
							Patcher.Log.LogWarning((object)$"Field value {item.Value} already exists in enum {enumName} for saved field '{item.Key}'. Assigning new value.");
							list.Add(item.Key);
						}
						else
						{
							sortedDictionary[item.Value] = new FieldDefinition(item.Key, val2.Attributes, (TypeReference)(object)val)
							{
								Constant = item.Value
							};
							hashSet.Add(item.Key);
							hashSet2.Add(item.Value);
						}
					}
					foreach (string item2 in list)
					{
						value.Remove(item2);
						Patcher.Log.LogDebug((object)("Removed obsolete/conflicting saved field " + item2 + " from enum " + enumName));
					}
				}
				foreach (string fieldName in hashSet3)
				{
					if (sortedDictionary.Values.Any((FieldDefinition f) => ((MemberReference)f).Name == fieldName))
					{
						continue;
					}
					if (hashSet.Contains(fieldName))
					{
						Patcher.Log.LogWarning((object)("Field name '" + fieldName + "' already exists in enum " + enumName + ". Skipping."));
						continue;
					}
					for (; hashSet2.Contains(i) || sortedDictionary.ContainsKey(i); i++)
					{
					}
					sortedDictionary[i] = new FieldDefinition(fieldName, val2.Attributes, (TypeReference)(object)val)
					{
						Constant = i
					};
					PatchDataManager.SavedData.GetOrAdd(enumName, (string _) => new Dictionary<string, int>())[fieldName] = i;
					hashSet.Add(fieldName);
					hashSet2.Add(i);
				}
				foreach (KeyValuePair<int, FieldDefinition> item3 in sortedDictionary)
				{
					val.Fields.Add(item3.Value);
					Patcher.Log.LogDebug((object)$"Added field {((MemberReference)item3.Value).Name} with value {item3.Key} to enum {((MemberReference)val).Name}");
				}
				Patcher.Log.LogInfo((object)$"Patching for enum {enumName} complete. {sortedDictionary.Count} fields added.");
			}
			foreach (string item4 in PatchDataManager.SavedData.Keys.Where((string k) => !PatchDataManager.UserData.ContainsKey(k)).ToList())
			{
				PatchDataManager.SavedData.Remove(item4);
			}
		}
	}
	public static class PatchDataManager
	{
		private static bool initialized = false;

		private static readonly Dictionary<string, string> keyMapping = new Dictionary<string, string>
		{
			{ "FurnitureObjectTypes", "EObjectType" },
			{ "ItemTypes", "EItemType" },
			{ "ItemCategories", "EItemCategory" },
			{ "FurnitureTypes", "EObjectType" },
			{ "DecoTypes", "EDecoObject" },
			{ "DecoObject", "EDecoObject" },
			{ "PackType", "ECollectionPackType" },
			{ "Rarity", "ERarity" },
			{ "CardExpansions", "ECardExpansionType" }
		};

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


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


		private static string SavedDataPath { get; set; } = string.Empty;


		public static void Initialize(string patcherDirectory)
		{
			if (initialized)
			{
				Patcher.Log.LogInfo((object)"Already initialized.");
				return;
			}
			SavedDataPath = Path.Combine(patcherDirectory, "enum_values.json");
			LoadSavedEnumValues();
			LoadNewEnumEntries();
			initialized = true;
		}

		public static void SaveEnumValues()
		{
			if (!initialized)
			{
				Patcher.Log.LogError((object)"Cannot save - not initialized");
				return;
			}
			try
			{
				string contents = JsonConvert.SerializeObject((object)SavedData, (Formatting)1);
				File.WriteAllText(SavedDataPath, contents);
				Patcher.Log.LogInfo((object)$"Saved values for {SavedData.Count} enums");
			}
			catch (Exception ex)
			{
				Patcher.Log.LogError((object)("Error saving values: " + ex.Message));
			}
		}

		private static void LoadSavedEnumValues()
		{
			string text = (File.Exists(SavedDataPath) ? SavedDataPath : Path.Combine(Path.GetDirectoryName(SavedDataPath) ?? string.Empty, "savedTypes"));
			if (!File.Exists(text))
			{
				Patcher.Log.LogInfo((object)("No saved enum values file found at " + text));
				return;
			}
			try
			{
				foreach (KeyValuePair<string, Dictionary<string, int>> item in JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, int>>>(File.ReadAllText(text)) ?? new Dictionary<string, Dictionary<string, int>>())
				{
					SavedData[MapLegacyKey(item.Key)] = item.Value;
				}
				Patcher.Log.LogInfo((object)("Loaded saved enum values from " + text));
			}
			catch (Exception ex)
			{
				Patcher.Log.LogError((object)("Failed to load saved enum values: " + ex.Message));
				SavedData = new Dictionary<string, Dictionary<string, int>>();
			}
		}

		private static void LoadNewEnumEntries()
		{
			UserData = new Dictionary<string, HashSet<string>>();
			foreach (string item in (from x in Directory.GetDirectories(Paths.PatcherPluginPath, "*", SearchOption.AllDirectories)
				where x.ToLower().EndsWith("_prefabloader")
				select x).ToList())
			{
				foreach (string item2 in Directory.EnumerateFiles(item, "*.json", SearchOption.AllDirectories))
				{
					try
					{
						Dictionary<string, List<string>> dictionary = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(File.ReadAllText(item2));
						if (dictionary == null || dictionary.Count == 0)
						{
							Patcher.Log.LogWarning((object)("No valid data found in " + item2));
							continue;
						}
						foreach (KeyValuePair<string, List<string>> item3 in dictionary)
						{
							string key = MapLegacyKey(item3.Key);
							UserData.GetOrAdd(key, (string _) => new HashSet<string>());
							foreach (string item4 in item3.Value.Where((string e) => !string.IsNullOrWhiteSpace(e)))
							{
								UserData[key].Add(item4.Trim());
							}
						}
					}
					catch (Exception ex)
					{
						Patcher.Log.LogError((object)("Error reading file " + item2 + ": " + ex.Message));
					}
				}
			}
		}

		private static string MapLegacyKey(string key)
		{
			if (!keyMapping.TryGetValue(key, out var value))
			{
				return key;
			}
			return value;
		}
	}
	public class Patcher
	{
		public static ManualLogSource Log { get; private set; } = Logger.CreateLogSource("EnhancedPrefabLoader");


		private static ILWeaver Weaver { get; set; } = null;


		private static EnumPatcher EnumPatcher { get; set; } = null;


		public static IEnumerable<string> TargetDLLs { get; } = new <>z__ReadOnlySingleElementList<string>("Assembly-CSharp.dll");


		public static void Initialize()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			Log.Logger = (ILogger)(object)new BepInExLogger("CollectionWeaver");
			Log.LogLevel = (LogLevel)0;
			WeaverOptions val = new WeaverOptions();
			val.ExcludeNamespace("Unity*").ExcludeNamespace("Steam*").ExcludeNamespace("Facepunch*")
				.ExcludeNamespace("System*")
				.ExcludeNamespace("Mono*")
				.ExcludeNamespace("Microsoft*");
			PatchDataManager.Initialize(Path.Combine(Paths.PatcherPluginPath, "EnhancedPrefabLoader"));
			if (Weaver == null)
			{
				Weaver = new ILWeaver(val);
			}
			if (EnumPatcher == null)
			{
				EnumPatcher = new EnumPatcher();
			}
		}

		public static void Patch(AssemblyDefinition assembly)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			BaseAssemblyResolver val = (BaseAssemblyResolver)assembly.MainModule.AssemblyResolver;
			val.AddSearchDirectory(Path.GetDirectoryName(typeof(Patcher).Assembly.Location));
			val.AddSearchDirectory(Paths.PatcherPluginPath);
			Log.LogInfo((object)"Starting Enhanced Prefab Loader PrePatching");
			ILWeaver weaver = Weaver;
			WeaverResult val2 = ((weaver != null) ? weaver.Weave(assembly) : null);
			Log.LogInfo((object)$"Collection weaving complete. Weaved: {((val2 != null) ? new int?(val2.PatchedCount) : null)}, Skipped: {((val2 != null) ? new int?(val2.SkippedCount) : null)}");
			EnumPatcher?.PatchEnums(assembly, 200000);
			PatchDataManager.SaveEnumValues();
			Log.LogInfo((object)"Enhanced Prefab Loader PrePatching complete");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EnhancedPrefabLoaderPrepatch";

		public const string PLUGIN_NAME = "Enhanced Prefab Loader Prepatch";

		public const string PLUGIN_VERSION = "4.0.0";
	}
}
namespace EnhancedPrefabLoaderPrepatch.Extensions
{
	public static class CicelExtensions
	{
		public static bool IsLoadCode(this OpCode opCode)
		{
			//IL_0000: 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)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!opCode.IsLdloc() && !opCode.IsLdarg() && !opCode.IsLdc() && !opCode.IsLdelem() && !opCode.IsFieldLoad() && !opCode.IsLdNullOrStr())
			{
				return opCode.IsLdind();
			}
			return true;
		}

		public static bool IsFieldLoad(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 120 || (int)code == 123)
			{
				return true;
			}
			return false;
		}

		public static bool IsLdloc(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000c: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 6 <= 3 || (int)code == 17 || (int)code == 202)
			{
				return true;
			}
			return false;
		}

		public static bool IsLdarg(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000c: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: 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_001d: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 2 <= 3 || code - 14 <= 1 || code - 199 <= 1)
			{
				return true;
			}
			return false;
		}

		public static bool IsLdc(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000e: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 21 <= 14)
			{
				return true;
			}
			return false;
		}

		public static bool IsLdelem(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 145 || (int)code == 151 || (int)code == 160)
			{
				return true;
			}
			return false;
		}

		public static bool IsLdind(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 69 <= 6 || code - 77 <= 2)
			{
				return true;
			}
			return false;
		}

		public static bool IsLdNullOrStr(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if ((int)code == 20 || (int)code == 113)
			{
				return true;
			}
			return false;
		}

		public static bool IsStloc(this OpCode opCode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			Code code = ((OpCode)(ref opCode)).Code;
			if (code - 10 <= 3 || (int)code == 19 || (int)code == 204)
			{
				return true;
			}
			return false;
		}

		public static bool IsComplimentaryStOf(this Instruction stInstruction, Instruction ldInstruction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (stInstruction.OpCode.IsStloc() && ldInstruction.OpCode.IsLdloc())
			{
				return stInstruction.GetLocalCodeIndex() == ldInstruction.GetLocalCodeIndex();
			}
			return false;
		}

		public static int? GetLocalCodeIndex(this Instruction instr)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected I4, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			OpCode opCode = instr.OpCode;
			Code code = ((OpCode)(ref opCode)).Code;
			switch (code - 6)
			{
			default:
				if ((int)code != 202 && (int)code != 204)
				{
					break;
				}
				goto case 11;
			case 0:
			case 4:
				return 0;
			case 1:
			case 5:
				return 1;
			case 2:
			case 6:
				return 2;
			case 3:
			case 7:
				return 3;
			case 11:
			case 13:
			{
				object operand = instr.Operand;
				object obj = ((operand is VariableReference) ? operand : null);
				return (obj != null) ? new int?(((VariableReference)obj).Index) : null;
			}
			case 8:
			case 9:
			case 10:
			case 12:
				break;
			}
			return null;
		}

		public static bool IsListType(this TypeReference typeRef)
		{
			if (((typeRef != null) ? ((MemberReference)typeRef).Name : null) == "List`1" && ((typeRef != null) ? typeRef.Namespace : null) == "System.Collections.Generic")
			{
				if (!(typeRef is GenericInstanceType))
				{
					TypeDefinition obj = typeRef.Resolve();
					object obj2;
					if (obj == null)
					{
						obj2 = null;
					}
					else
					{
						TypeReference baseType = obj.BaseType;
						obj2 = ((baseType != null) ? ((MemberReference)baseType).Name : null);
					}
					return (string?)obj2 == "List`1";
				}
				return true;
			}
			return false;
		}

		public static bool IsListAccessor(this MethodReference methodRef)
		{
			if (methodRef != null)
			{
				if (!methodRef.IsListGetItemCall() && !methodRef.IsListSetItemCall())
				{
					return methodRef.IsListGetCountCall();
				}
				return true;
			}
			return false;
		}

		public static bool IsListGetItemCall(this MethodReference methodRef)
		{
			if (methodRef != null && ((MemberReference)methodRef).DeclaringType.IsListType())
			{
				return ((MemberReference)methodRef).Name == "get_Item";
			}
			return false;
		}

		public static bool IsListSetItemCall(this MethodReference methodRef)
		{
			if (methodRef != null && ((MemberReference)methodRef).DeclaringType.IsListType())
			{
				return ((MemberReference)methodRef).Name == "set_Item";
			}
			return false;
		}

		public static bool IsListGetCountCall(this MethodReference methodRef)
		{
			if (methodRef != null && ((MemberReference)methodRef).DeclaringType.IsListType())
			{
				return ((MemberReference)methodRef).Name == "get_Count";
			}
			return false;
		}

		public static bool MatchListLoad(this Instruction instr, MethodBody methodBody, out TypeReference elementType)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected I4, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Invalid comparison between Unknown and I4
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			elementType = null;
			if (instr != null)
			{
				_ = instr.OpCode;
				if (0 == 0 && ((methodBody != null) ? methodBody.Method : null) != null && instr.OpCode.IsLoadCode())
				{
					try
					{
						OpCode opCode = instr.OpCode;
						Code code = ((OpCode)(ref opCode)).Code;
						if ((int)code <= 120)
						{
							switch (code - 2)
							{
							case 4:
								goto IL_00bb;
							case 5:
								goto IL_00d2;
							case 6:
								goto IL_00e9;
							case 7:
								goto IL_0100;
							case 15:
								goto IL_0117;
							case 0:
								goto IL_0134;
							case 1:
								goto IL_0171;
							case 2:
								goto IL_019a;
							case 3:
								goto IL_01c3;
							case 12:
								goto IL_01ec;
							case 8:
							case 9:
							case 10:
							case 11:
							case 13:
							case 14:
								goto IL_0220;
							}
							if ((int)code == 120)
							{
								goto IL_0206;
							}
						}
						else
						{
							if ((int)code == 123)
							{
								goto IL_0206;
							}
							if ((int)code == 199)
							{
								goto IL_01ec;
							}
							if ((int)code == 202)
							{
								goto IL_0117;
							}
						}
						goto IL_0220;
						IL_0220:
						TypeReference val = null;
						goto IL_0222;
						IL_0134:
						object obj2;
						if (!((MethodReference)methodBody.Method).HasThis)
						{
							ParameterDefinition obj = ((MethodReference)methodBody.Method).Parameters[0];
							obj2 = ((obj != null) ? ((ParameterReference)obj).ParameterType : null);
						}
						else
						{
							obj2 = methodBody.Method.DeclaringType;
						}
						val = (TypeReference)obj2;
						goto IL_0222;
						IL_0100:
						val = ((VariableReference)methodBody.Variables[3]).VariableType;
						goto IL_0222;
						IL_00e9:
						val = ((VariableReference)methodBody.Variables[2]).VariableType;
						goto IL_0222;
						IL_00d2:
						val = ((VariableReference)methodBody.Variables[1]).VariableType;
						goto IL_0222;
						IL_00bb:
						val = ((VariableReference)methodBody.Variables[0]).VariableType;
						goto IL_0222;
						IL_01c3:
						val = ((ParameterReference)((MethodReference)methodBody.Method).Parameters[((MethodReference)methodBody.Method).HasThis ? 2 : 3]).ParameterType;
						goto IL_0222;
						IL_0117:
						object operand = instr.Operand;
						object obj3 = ((operand is VariableReference) ? operand : null);
						val = ((obj3 != null) ? ((VariableReference)obj3).VariableType : null);
						goto IL_0222;
						IL_0206:
						object operand2 = instr.Operand;
						object obj4 = ((operand2 is FieldReference) ? operand2 : null);
						val = ((obj4 != null) ? ((FieldReference)obj4).FieldType : null);
						goto IL_0222;
						IL_01ec:
						object operand3 = instr.Operand;
						object obj5 = ((operand3 is ParameterReference) ? operand3 : null);
						val = ((obj5 != null) ? ((ParameterReference)obj5).ParameterType : null);
						goto IL_0222;
						IL_019a:
						val = ((ParameterReference)((MethodReference)methodBody.Method).Parameters[((MethodReference)methodBody.Method).HasThis ? 1 : 2]).ParameterType;
						goto IL_0222;
						IL_0222:
						TypeReference val2 = val;
						GenericInstanceType val3 = (GenericInstanceType)(object)((val2 is GenericInstanceType) ? val2 : null);
						if (val3 != null && val2.IsListType() && val3.GenericArguments.Count > 0)
						{
							elementType = val3.GenericArguments[0];
							return true;
						}
						return false;
						IL_0171:
						val = ((ParameterReference)((MethodReference)methodBody.Method).Parameters[(!((MethodReference)methodBody.Method).HasThis) ? 1 : 0]).ParameterType;
						goto IL_0222;
					}
					catch (Exception ex) when (((ex is ArgumentOutOfRangeException || ex is NullReferenceException) ? 1 : 0) != 0)
					{
						elementType = null;
						return false;
					}
				}
			}
			return false;
		}
	}
	public static class DictionaryExtensions
	{
		public static TValue GetOrAdd<TKey, TValue>(this Dictionary<TKey, TValue> dict, TKey key, Func<TKey, TValue> factory)
		{
			if (!dict.TryGetValue(key, out var value))
			{
				value = (dict[key] = factory(key));
			}
			return value;
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}

BepInEx/plugins/EnhancedPrefabLoader.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CollectionWeaver.Core;
using EnhancedPrefabLoader;
using EnhancedPrefabLoader.Assets;
using EnhancedPrefabLoader.Cards;
using EnhancedPrefabLoader.Cards.PackGenerators;
using EnhancedPrefabLoader.Extensions;
using EnhancedPrefabLoader.Helpers;
using EnhancedPrefabLoader.IntercepterHandlers;
using EnhancedPrefabLoader.Items;
using EnhancedPrefabLoader.Models;
using EnhancedPrefabLoader.Models.Json;
using EnhancedPrefabLoader.Models.RunTime;
using EnhancedPrefabLoader.Models.SaveData;
using EnhancedPrefabLoader.Saves;
using EnhancedPrefabLoader.UI.CollectionBinder;
using HarmonyLib;
using I2.Loc;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UIElements;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("EnhancedPrefabLoader")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.0+ce67eb128bbeaa3b2f79707fdda58b7d70eedf4b")]
[assembly: AssemblyProduct("Enhanced Prefab Loader")]
[assembly: AssemblyTitle("EnhancedPrefabLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.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;
		}
	}
}
public sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
[HarmonyPatch(typeof(CGameManager))]
public class CGameManagerPatch
{
	[CompilerGenerated]
	private sealed class <LoadLobbySceneAsyncPostfix>d__1 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public IEnumerator __result;

		public string sceneName;

		private int <percentComplete>5__2;

		private AsyncOperation <asyncLoad>5__3;

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

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

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

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

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				__result.MoveNext();
				<>2__current = __result.Current;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				ModLoadManager.Instance.Load(Paths.PluginPath);
				goto IL_00b8;
			case 2:
				<>1__state = -1;
				goto IL_00b8;
			case 3:
				{
					<>1__state = -1;
					break;
				}
				IL_00b8:
				if (!ModLoadManager.Instance.IsLoadingComplete)
				{
					int percentDone = (int)(ModLoadManager.Instance.LoadingProgress * 50f);
					LoadingScreen.SetPercentDone(percentDone);
					ModLogger.Debug("Game loading: EnhancedPrefabLoader assets " + percentDone + "%", "LoadLobbySceneAsyncPostfix", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\Patches\\CGameManagerPatches.cs");
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				<percentComplete>5__2 = (int)(ModLoadManager.Instance.LoadingProgress * 50f);
				<asyncLoad>5__3 = SceneManager.LoadSceneAsync(sceneName);
				break;
			}
			if (!<asyncLoad>5__3.isDone)
			{
				float num = <asyncLoad>5__3.progress / 0.9f;
				int percentDone2 = <percentComplete>5__2 + (int)(num * 50f);
				LoadingScreen.SetPercentDone(percentDone2);
				ModLogger.Debug("Game loading: " + percentDone2 + "%", "LoadLobbySceneAsyncPostfix", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\Patches\\CGameManagerPatches.cs");
				<>2__current = null;
				<>1__state = 3;
				return true;
			}
			return false;
		}

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

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

	[HarmonyPatch("SaveGameData")]
	[HarmonyPrefix]
	private static void SaveGameDataPrefix(int saveSlotIndex)
	{
		if (!Directory.Exists(Plugin.ModDirectory + "/Saves"))
		{
			Directory.CreateDirectory(Plugin.ModDirectory + "/Saves");
		}
		ModSaveManager.Instance.SaveToFile(string.Format("{0}/Saves/{1}_{2}", Plugin.ModDirectory, "EnhancedPrefabLoader", saveSlotIndex));
	}

	[IteratorStateMachine(typeof(<LoadLobbySceneAsyncPostfix>d__1))]
	[HarmonyPatch("LoadLobbySceneAsync")]
	[HarmonyPostfix]
	public static IEnumerator LoadLobbySceneAsyncPostfix(IEnumerator __result, string sceneName)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LoadLobbySceneAsyncPostfix>d__1(0)
		{
			__result = __result,
			sceneName = sceneName
		};
	}
}
public class FlowLayoutGroup : LayoutGroup
{
	public float SpacingX = 30f;

	public float SpacingY = -45f;

	public float ChildWidth = 325f;

	public float ChildHeight = 184.5f;

	public bool CenterContent = true;

	public override void CalculateLayoutInputHorizontal()
	{
		((LayoutGroup)this).CalculateLayoutInputHorizontal();
		ArrangeChildren();
	}

	public override void CalculateLayoutInputVertical()
	{
		ArrangeChildren();
	}

	public static GameObject Create(Transform parent, bool isScrollable)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Expected O, but got Unknown
		GameObject val = new GameObject("FlowLayoutGroup", new Type[4]
		{
			typeof(RectTransform),
			typeof(ScrollRect),
			typeof(ScrollRectAutoScroller),
			typeof(Image)
		});
		RectTransform component = val.GetComponent<RectTransform>();
		((Transform)component).SetParent(parent, false);
		Image component2 = ((Component)component).GetComponent<Image>();
		((Graphic)component2).color = new Color(0f, 0f, 0f, 0f);
		((Graphic)component2).raycastTarget = true;
		GameObject val2 = new GameObject("FlowContent", new Type[2]
		{
			typeof(RectTransform),
			typeof(FlowLayoutGroup)
		});
		RectTransform component3 = val2.GetComponent<RectTransform>();
		((Transform)component3).SetParent((Transform)(object)component, false);
		component3.anchorMin = new Vector2(0f, 1f);
		component3.anchorMax = new Vector2(1f, 1f);
		component3.pivot = new Vector2(0.5f, 1f);
		component3.anchoredPosition = Vector2.zero;
		component3.sizeDelta = new Vector2(0f, 0f);
		((LayoutGroup)val2.GetComponent<FlowLayoutGroup>()).padding = new RectOffset(10, 10, 0, 0);
		ScrollRect component4 = val.GetComponent<ScrollRect>();
		component4.content = component3;
		component4.viewport = component;
		component4.horizontal = false;
		component4.vertical = true;
		component4.movementType = (MovementType)2;
		component4.scrollSensitivity = 20f;
		component4.inertia = true;
		component4.decelerationRate = 0.135f;
		return val;
	}

	public Transform AddButtonFromTemplate(Transform template)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		if (template == null)
		{
			return null;
		}
		Transform obj = Object.Instantiate<Transform>(template, ((Component)this).transform);
		((Component)obj).gameObject.SetActive(true);
		((Object)obj).name = ((Object)template).name + "_CLONE";
		obj.localPosition = Vector3.zero;
		obj.localScale = Vector3.one;
		RectTransform component = ((Component)obj).GetComponent<RectTransform>();
		if (component != null)
		{
			component.sizeDelta = new Vector2(ChildWidth, ChildHeight);
			component.pivot = new Vector2(0f, 1f);
			component.anchoredPosition = new Vector2(0f, 1f);
		}
		return ((Component)obj).transform;
	}

	public override void SetLayoutHorizontal()
	{
	}

	public override void SetLayoutVertical()
	{
	}

	private void ArrangeChildren()
	{
		//IL_0006: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		Rect rect = ((LayoutGroup)this).rectTransform.rect;
		float num = ((Rect)(ref rect)).width - (float)((LayoutGroup)this).padding.left - (float)((LayoutGroup)this).padding.right;
		float num2 = ((LayoutGroup)this).padding.top;
		List<List<RectTransform>> list = new List<List<RectTransform>>();
		List<RectTransform> list2 = new List<RectTransform>();
		float num3 = 0f;
		foreach (RectTransform rectChild in ((LayoutGroup)this).rectChildren)
		{
			if (((Component)rectChild).gameObject.activeSelf)
			{
				if (num3 + ChildWidth > num && list2.Count > 0)
				{
					list.Add(list2);
					list2 = new List<RectTransform>();
					num3 = 0f;
				}
				list2.Add(rectChild);
				num3 += ChildWidth + SpacingX;
			}
		}
		if (list2.Count > 0)
		{
			list.Add(list2);
		}
		foreach (List<RectTransform> item in list)
		{
			float num4 = (float)item.Count * ChildWidth + (float)(item.Count - 1) * SpacingX;
			float num5 = ((LayoutGroup)this).padding.left;
			if (CenterContent)
			{
				num5 = (float)((LayoutGroup)this).padding.left + (num - num4) / 2f;
			}
			float num6 = num5;
			foreach (RectTransform item2 in item)
			{
				((LayoutGroup)this).SetChildAlongAxis(item2, 0, num6, ChildWidth);
				((LayoutGroup)this).SetChildAlongAxis(item2, 1, num2, ChildHeight);
				num6 += ChildWidth + SpacingX;
			}
			num2 += ChildHeight + SpacingY;
		}
		float num7 = num2 - SpacingY + (float)((LayoutGroup)this).padding.bottom;
		Vector2 sizeDelta = ((LayoutGroup)this).rectTransform.sizeDelta;
		((LayoutGroup)this).rectTransform.sizeDelta = new Vector2(sizeDelta.x, num7);
		((LayoutGroup)this).SetLayoutInputForAxis(num7, num7, -1f, 1);
	}
}
public class ScrollRectAutoScroller : MonoBehaviour
{
	private ScrollRect scrollRect;

	private RectTransform viewportRect;

	private RectTransform contentRect;

	private void Start()
	{
		scrollRect = ((Component)this).GetComponent<ScrollRect>();
		viewportRect = scrollRect.viewport;
		contentRect = scrollRect.content;
	}

	private void Update()
	{
		EventSystem current = EventSystem.current;
		GameObject val = ((current != null) ? current.currentSelectedGameObject : null);
		if (!((Object)(object)val == (Object)null))
		{
			RectTransform component = val.GetComponent<RectTransform>();
			if (!((Object)(object)component == (Object)null) && ((Transform)component).IsChildOf((Transform)(object)contentRect))
			{
				ScrollToRect(component);
			}
		}
	}

	private void ScrollToRect(RectTransform target)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] array = (Vector3[])(object)new Vector3[4];
		viewportRect.GetWorldCorners(array);
		Vector3[] array2 = (Vector3[])(object)new Vector3[4];
		target.GetWorldCorners(array2);
		if (array2[0].y < array[0].y)
		{
			float num = array[0].y - array2[0].y;
			RectTransform obj = contentRect;
			obj.anchoredPosition += new Vector2(0f, num);
		}
		else if (array2[1].y > array[1].y)
		{
			float num2 = array2[1].y - array[1].y;
			RectTransform obj2 = contentRect;
			obj2.anchoredPosition -= new Vector2(0f, num2);
		}
	}
}
namespace EnhancedPrefabLoader
{
	public static class AssetData
	{
		public static List<Assembly> Assemblies { get; private set; } = new List<Assembly>();


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


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


		public static List<Tuple<FurniturePurchaseData, ObjectData>> FurnitureData { get; private set; } = new List<Tuple<FurniturePurchaseData, ObjectData>>();


		public static List<Tuple<RestockData, ItemFlags>> RestockData { get; private set; } = new List<Tuple<RestockData, ItemFlags>>();


		public static Dictionary<EItemType, ItemData> ItemData { get; private set; } = new Dictionary<EItemType, ItemData>();


		public static Dictionary<EItemType, ItemMeshData> ItemMeshData { get; private set; } = new Dictionary<EItemType, ItemMeshData>();


		public static Dictionary<EItemType, CardPackData> CardPackData { get; private set; } = new Dictionary<EItemType, CardPackData>();


		public static Dictionary<ECollectionPackType, ECardExpansionType> CollectionPackToExpansion { get; private set; } = new Dictionary<ECollectionPackType, ECardExpansionType>();


		public static Dictionary<ECardExpansionType, CardExpansion> CardExpanions { get; private set; } = new Dictionary<ECardExpansionType, CardExpansion>();


		public static Dictionary<EItemType, EItemType> CardBoxData { get; private set; } = new Dictionary<EItemType, EItemType>();


		public static Dictionary<EDecoObject, Tuple<DecoPurchaseData, DecoData>> DecoObjectData { get; private set; } = new Dictionary<EDecoObject, Tuple<DecoPurchaseData, DecoData>>();


		public static List<ShopDecoData> DecoWallTextureData { get; private set; } = new List<ShopDecoData>();


		public static List<ShopDecoData> DecoFloorTextureData { get; private set; } = new List<ShopDecoData>();


		public static List<ShopDecoData> DecoCeilingTextureData { get; private set; } = new List<ShopDecoData>();


		public static int? FirstInsertedWallTexture { get; set; } = null;


		public static int? FirstInsertedCeilingTexture { get; set; } = null;


		public static int? FirstInsertedFloorTexture { get; set; } = null;


		public static Dictionary<ECardExpansionType, int> CurrentExpansionToCurrentSort { get; private set; } = new Dictionary<ECardExpansionType, int>();

	}
	public static class CustomCardUIGroups
	{
		private class TransformState
		{
			public bool Active { get; set; }

			public Vector2 OffsetMax { get; set; }

			public Vector2 OffsetMin { get; set; }

			public Transform Parent { get; set; }

			public int SiblingIndex { get; set; }

			public Sprite FoilMask { get; set; }
		}

		private static ConditionalWeakTable<object, Dictionary<int, TransformState>> cachedStates = new ConditionalWeakTable<object, Dictionary<int, TransformState>>();

		private static ConditionalWeakTable<object, Material> cachedMaterials = new ConditionalWeakTable<object, Material>();

		public static void ApplyCardUIChanges(CardUI cardUI, CardData cardData, GameObject targetGroup, CardExpansion expansion, bool isFullArt)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			if (targetGroup == null)
			{
				return;
			}
			if (!cachedStates.TryGetValue(cardUI, out var value))
			{
				value = new Dictionary<int, TransformState>();
				cachedStates.Add(cardUI, value);
			}
			if (!cachedMaterials.TryGetValue(cardUI, out var value2))
			{
				Card3dUIGroup card3dUIGroup = cardUI.m_Card3dUIGroup;
				Renderer val = ((card3dUIGroup != null) ? card3dUIGroup.m_CardBackMesh.GetComponent<Renderer>() : null);
				if (val != null)
				{
					value2 = val.material;
					cachedMaterials.Add(cardUI, value2);
				}
			}
			Card3dUIGroup card3dUIGroup2 = cardUI.m_Card3dUIGroup;
			Renderer val2 = ((card3dUIGroup2 != null) ? card3dUIGroup2.m_CardBackMesh.GetComponent<Renderer>() : null);
			if (val2 != null)
			{
				Material material = new Material(Shader.Find("Toony Colors Pro 2/Hybrid Shader 2"))
				{
					mainTexture = expansion.CardBack
				};
				val2.material = material;
			}
			Transform[] componentsInChildren = targetGroup.GetComponentsInChildren<Transform>(true);
			foreach (Transform val3 in componentsInChildren)
			{
				if (!value.ContainsKey(((Object)val3).GetInstanceID()))
				{
					value[((Object)val3).GetInstanceID()] = new TransformState
					{
						Active = ((Component)val3).gameObject.activeSelf,
						Parent = val3.parent,
						SiblingIndex = val3.GetSiblingIndex()
					};
					if (((Object)val3).name == "MonsterMask")
					{
						Image component = ((Component)val3).GetComponent<Image>();
						if (component != null)
						{
							value[((Object)val3).GetInstanceID()].FoilMask = component.sprite;
						}
					}
					RectTransform val4 = (RectTransform)(object)((val3 is RectTransform) ? val3 : null);
					if (val4 != null)
					{
						value[((Object)val4).GetInstanceID()].OffsetMin = val4.offsetMin;
						value[((Object)val4).GetInstanceID()].OffsetMax = val4.offsetMax;
					}
				}
				bool flag;
				switch (((Object)val3).name)
				{
				case "EvoBorder":
				case "TitleText":
				case "EvoBasicIcon":
				case "EvoBasicText":
				case "CompanyText":
				case "EvoNameText":
				case "RarityImage":
				case "EvoText":
				case "TitleBG":
				case "ArtistText":
				case "NumberText":
				case "RarityText":
				case "StatText_1":
				case "StatText_2":
				case "StatText_3":
				case "StatText_4":
				case "EvoBG":
				case "EvoPreviousStageIcon":
				case "DescriptionText":
				case "NameText":
				case "FirstEditionText":
					flag = true;
					break;
				default:
					flag = false;
					break;
				}
				if (flag)
				{
					((Component)val3).gameObject.SetActive(false);
				}
				RectTransform val5 = (RectTransform)(object)((val3 is RectTransform) ? val3 : null);
				if (val5 != null)
				{
					if (isFullArt)
					{
						ApplyFullArtCardUIChanges(val5);
					}
					else
					{
						ApplyNormalArtCardUIChanges(val5, cardData, cardUI);
					}
				}
			}
		}

		public static void RestoreOriginalState(CardUI cardUI, GameObject targetGroup)
		{
			//IL_00ea: 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)
			if (!cachedStates.TryGetValue(cardUI, out var value))
			{
				return;
			}
			if (cachedMaterials.TryGetValue(cardUI, out var value2))
			{
				cardUI.m_Card3dUIGroup.m_CardBackMesh.GetComponent<Renderer>().material = value2;
			}
			Transform[] componentsInChildren = targetGroup.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!value.TryGetValue(((Object)val).GetInstanceID(), out var value3))
				{
					continue;
				}
				((Component)val).gameObject.SetActive(value3.Active);
				if ((Object)(object)val.parent != (Object)(object)value3.Parent && value3.Parent != null)
				{
					val.SetParent(value3.Parent, true);
					val.SetSiblingIndex(value3.SiblingIndex);
				}
				if (((Object)val).name == "MonsterMask")
				{
					Image component = ((Component)val).GetComponent<Image>();
					if (component != null)
					{
						component.sprite = value3.FoilMask;
					}
				}
				RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null);
				if (val2 != null)
				{
					val2.offsetMax = value3.OffsetMax;
					val2.offsetMin = value3.OffsetMin;
				}
			}
		}

		private static void ApplyFullArtCardUIChanges(RectTransform rectTransform)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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 (((Object)rectTransform).name == "ElementBGMask")
			{
				rectTransform.offsetMax = new Vector2(36f, 40f);
				rectTransform.offsetMin = new Vector2(-36f, -40f);
			}
			if (((Object)rectTransform).name == "ElementBGImage")
			{
				rectTransform.offsetMax = new Vector2(0f, 0f);
				rectTransform.offsetMin = new Vector2(0f, 0f);
			}
			if (((Object)rectTransform).name == "MonsterMask")
			{
				rectTransform.offsetMax = new Vector2(40f, 4f);
				rectTransform.offsetMin = new Vector2(-40f, -4f);
			}
			if (((Object)rectTransform).name == "Image")
			{
				rectTransform.offsetMax = new Vector2(-67f, 142f);
				rectTransform.offsetMin = new Vector2(60f, -142.5f);
			}
		}

		private static void ApplyNormalArtCardUIChanges(RectTransform rectTransform, CardData cardData, CardUI cardUI)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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_01f4: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)rectTransform).name == "CameraFoilShine" && ((Object)((Transform)rectTransform).parent).name == "CardBorder")
			{
				Transform obj = ((Transform)rectTransform).parent.parent.Find("FoilGrp");
				Transform val = ((obj != null) ? obj.Find("GlowMask") : null);
				if (val != null)
				{
					((Transform)rectTransform).SetParent(val, true);
				}
			}
			if (((Object)rectTransform).name == "CameraFoilShine" && ((Object)((Transform)rectTransform).parent).name == "GlowMask")
			{
				rectTransform.offsetMax = new Vector2(-165f, -45f);
				rectTransform.offsetMin = new Vector2(158f, 45f);
			}
			if (((Object)rectTransform).name == "GlowMaskMonsterGrp")
			{
				((Component)rectTransform).gameObject.SetActive(false);
			}
			if (((Object)rectTransform).name == "MonsterMaskGrp")
			{
				rectTransform.offsetMax = new Vector2(0f, 0f);
				rectTransform.offsetMin = new Vector2(0f, 0f);
			}
			if (((Object)rectTransform).name == "MonsterMask")
			{
				Image component = ((Component)rectTransform).GetComponent<Image>();
				if (component != null && component.sprite != null && component.sprite.texture != null && ((Object)component.sprite.texture).name == "WhiteTile")
				{
					Sprite foilMask = AssetData.CardExpanions[cardData.expansionType].FoilMask;
					if (foilMask != null)
					{
						((Object)foilMask).name = "WhiteTile";
						component.sprite = foilMask;
					}
				}
			}
			string name = ((Object)rectTransform).name;
			if ((name == "CameraFoilShine" || name == "CameraFoilShine (1)") ? true : false)
			{
				rectTransform.offsetMax = new Vector2(-172f, -57f);
				rectTransform.offsetMin = new Vector2(165f, 57f);
			}
			if (((Object)rectTransform).name == "Image")
			{
				rectTransform.offsetMax = new Vector2(-172f, -57f);
				rectTransform.offsetMin = new Vector2(165f, 57f);
			}
		}
	}
	public static class DeferredActions
	{
		private static Dictionary<string, List<Action>> deferredActions = new Dictionary<string, List<Action>>();

		public static void AfterAwake<T>(Action action) where T : MonoBehaviour
		{
			RegisterAction("Awake_" + typeof(T).Name, action);
		}

		public static void ExecuteAfterAwake<T>() where T : MonoBehaviour
		{
			Execute("Awake_" + typeof(T).Name);
		}

		public static void ClearAwakeActions<T>() where T : MonoBehaviour
		{
			deferredActions.Remove("Awake_" + typeof(T).Name);
		}

		private static void Execute(string lifeCycleKey)
		{
			if (!deferredActions.TryGetValue(lifeCycleKey, out var value))
			{
				return;
			}
			foreach (Action item in value)
			{
				try
				{
					item();
				}
				catch (Exception ex)
				{
					ModLogger.Error("Error executing deferred action for '" + lifeCycleKey + "': " + ex.Message + "\n" + ex.StackTrace, "Execute", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\DeferredActions.cs");
				}
			}
			value.Clear();
		}

		private static void RegisterAction(string key, Action action)
		{
			deferredActions.GetOrAdd(key, (string _) => new List<Action>()).Add(action);
		}
	}
	public class ModConfigManager
	{
		private static ModConfigManager instance;

		private ConfigFile config;

		private readonly Dictionary<string, ConfigEntryBase> entries = new Dictionary<string, ConfigEntryBase>();

		public static ModConfigManager Instance => instance ?? (instance = new ModConfigManager());

		private ModConfigManager()
		{
		}

		public void Initialize(ConfigFile config)
		{
			this.config = config;
		}

		public ConfigEntry<T> BindSetting<T>(string category, string key, T value, string description = "", AcceptableValueBase acceptableValueBase = null, ConfigurationManagerAttributes configurationManagerAttributes = null)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description, acceptableValueBase, new object[1] { configurationManagerAttributes });
			ConfigEntry<T> val2 = config.Bind<T>(category, key, value, val);
			string key2 = category + "." + key;
			entries[key2] = (ConfigEntryBase)(object)val2;
			return val2;
		}

		public T GetValue<T>(string category, string key)
		{
			string key2 = category + "." + key;
			if (!entries.TryGetValue(key2, out var value) || !(value is ConfigEntry<T> val))
			{
				return default(T);
			}
			return val.Value;
		}

		public void SetValue<T>(string category, string key, T value)
		{
			string key2 = category + "." + key;
			if (entries.TryGetValue(key2, out var value2) && value2 is ConfigEntry<T> val)
			{
				val.Value = value;
			}
		}

		public ConfigEntry<T> GetEntry<T>(string category, string key)
		{
			string key2 = category + "." + key;
			if (!entries.TryGetValue(key2, out var value) || !(value is ConfigEntry<T> result))
			{
				return null;
			}
			return result;
		}

		public void OnSettingChanged<T>(string category, string key, Action<T> callback)
		{
			ConfigEntry<T> entry = GetEntry<T>(category, key);
			if (entry != null)
			{
				entry.SettingChanged += delegate
				{
					callback(entry.Value);
				};
			}
		}

		private void Entry_SettingChanged(object sender, EventArgs e)
		{
			throw new NotImplementedException();
		}
	}
	public static class ModIdGenerator
	{
		public static string GenerateFromDirectory(string directory)
		{
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(directory));
			string fullName = directoryInfo.FullName;
			string name = directoryInfo.Name;
			using SHA1 sHA = SHA1.Create();
			string text = BitConverter.ToString(sHA.ComputeHash(Encoding.UTF8.GetBytes(fullName.ToLowerInvariant()))).Replace("-", "").Substring(0, 8);
			ModLogger.Debug("Generated MOD_ID: " + name + "_" + text, "GenerateFromDirectory", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\ModIdGenerator.cs");
			return name + "_" + text;
		}
	}
	public class ModLoadManager
	{
		[CompilerGenerated]
		private sealed class <LoadModsAsync>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string basePath;

			public ModLoadManager <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				ModLoadManager CS$<>8__locals0 = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					List<BundleConfig> list = new BundleConfigLoader().LoadBundleConfigs(basePath);
					if (list == null || list.Count == 0)
					{
						CS$<>8__locals0.IsLoadingComplete = true;
						CS$<>8__locals0.LoadingProgress = 1f;
						return false;
					}
					BundleProcessor bundleProcessor = new BundleProcessor(delegate(float percent)
					{
						CS$<>8__locals0.LoadingProgress = percent;
					});
					<>2__current = bundleProcessor.ProcessBundles(list);
					<>1__state = 1;
					return true;
				}
				case 1:
					<>1__state = -1;
					CS$<>8__locals0.IsLoadingComplete = true;
					return false;
				}
			}

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

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

		private static ModLoadManager instance;

		private MonoBehaviour runner;

		private Coroutine loadingCoroutine;

		public static ModLoadManager Instance => instance ?? (instance = new ModLoadManager());

		public bool IsLoadingComplete { get; private set; }

		public float LoadingProgress { get; private set; }

		public void Initialize(MonoBehaviour runner)
		{
			this.runner = runner;
		}

		public void Load(string basePath)
		{
			if (loadingCoroutine != null)
			{
				ModLogger.Warning("Loading already in progress.", "Load", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\ModLoadManager.cs");
				return;
			}
			IsLoadingComplete = false;
			LoadingProgress = 0f;
			ModLogger.Info("Mod loading started", "Load", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\ModLoadManager.cs");
			loadingCoroutine = runner.StartCoroutine(LoadModsAsync(basePath));
		}

		[IteratorStateMachine(typeof(<LoadModsAsync>d__15))]
		private IEnumerator LoadModsAsync(string basePath)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadModsAsync>d__15(0)
			{
				<>4__this = this,
				basePath = basePath
			};
		}
	}
	public static class ModLogger
	{
		private static ManualLogSource logger;

		private static bool isEnabled = true;

		public static void Initialize(ManualLogSource logger)
		{
			ModLogger.logger = logger;
			isEnabled = ModConfigManager.Instance.BindSetting("Logs", "Enabled", value: true).Value;
			ModConfigManager.Instance.OnSettingChanged("Logs", "Enabled", delegate(bool value)
			{
				isEnabled = value;
			});
		}

		public static void Debug(string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "")
		{
			if (isEnabled)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
				logger.LogDebug((object)("[" + fileNameWithoutExtension + "." + memberName + "]: " + message));
			}
		}

		public static void Info(string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "")
		{
			if (isEnabled)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
				logger.LogInfo((object)("[" + fileNameWithoutExtension + "." + memberName + "]: " + message));
			}
		}

		public static void Warning(string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "")
		{
			if (isEnabled)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
				logger.LogWarning((object)("[" + fileNameWithoutExtension + "." + memberName + "]: " + message));
			}
		}

		public static void Error(string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "")
		{
			if (isEnabled)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
				logger.LogError((object)("[" + fileNameWithoutExtension + "." + memberName + "]: " + message));
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("EnhancedPrefabLoader", "Enhanced Prefab Loader", "4.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("EnhancedPrefabLoader");

		private bool isLoaded;

		internal static ManualLogSource Logger { get; private set; }

		public static string ModDirectory { get; private set; }

		public static ShopInventoryManager ShopInventoryManager { get; private set; } = new ShopInventoryManager();


		public static ShopUIManager ShopUIManager { get; private set; } = new ShopUIManager();


		public static CollectionBinderUIManager CollectionBinderUIManager { get; set; } = new CollectionBinderUIManager();


		private void Awake()
		{
			ModDirectory = Path.Combine(Paths.PluginPath, "EnhancedPrefabLoader");
			Logger = ((BaseUnityPlugin)this).Logger;
			ModConfigManager.Instance.Initialize(((BaseUnityPlugin)this).Config);
			ModLoadManager.Instance.Initialize((MonoBehaviour)(object)this);
			ModLogger.Initialize(Logger);
			InterceptorRegistry.RegisterFromAssembly(Assembly.GetExecutingAssembly());
			SceneManager.sceneLoaded += OnSceneLoad;
			CollectionBinderUIManager.RegisterConfigs();
			harmony.PatchAll();
			ModLogger.Info("Plugin Enhanced Prefab Loader v:4.0.0 by GhostNarwhal is loaded!", "Awake", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\Plugin.cs");
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
			ModLogger.Info("Plugin Enhanced Prefab Loader is unloaded!", "OnDestroy", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\Plugin.cs");
		}

		private void OnSceneLoad(Scene scene, LoadSceneMode _)
		{
			if (((Scene)(ref scene)).name == "Title")
			{
				ModSaveManager.Instance.SetAllToDefaults();
				CollectionBinderUIManager.IsLoaded = false;
				if (!isLoaded)
				{
					ModLogger.Debug("Loading precompiled scripts.", "OnSceneLoad", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\Plugin.cs");
					Assembly.LoadFrom(Paths.PluginPath + "/EnhancedPrefabLoader/Scripts.dll");
					isLoaded = true;
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EnhancedPrefabLoader";

		public const string PLUGIN_NAME = "Enhanced Prefab Loader";

		public const string PLUGIN_VERSION = "4.0.0";
	}
}
namespace EnhancedPrefabLoader.UI.CollectionBinder
{
	public class CollectionBinderUIManager
	{
		private CollectionBinderUI collectionBinderUI;

		private FlowLayoutGroup flowLayoutGroup;

		private Transform cloneableButton;

		public List<ECardExpansionType> Buttons { get; set; } = new List<ECardExpansionType>();


		public bool IsLoaded { get; set; }

		public void RegisterConfigs()
		{
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			ModConfigManager.Instance.BindSetting("UI", $"Enable{(object)(ECardExpansionType)4}", value: false);
			ModConfigManager.Instance.OnSettingChanged("UI", $"Enable{(object)(ECardExpansionType)4}", delegate(bool value)
			{
				((Component)collectionBinderUI.m_ExpansionBtnList[Buttons.IndexOf((ECardExpansionType)4)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.BindSetting("UI", $"Enable{(object)(ECardExpansionType)3}", value: false);
			ModConfigManager.Instance.OnSettingChanged("UI", $"Enable{(object)(ECardExpansionType)3}", delegate(bool value)
			{
				((Component)collectionBinderUI.m_ExpansionBtnList[Buttons.IndexOf((ECardExpansionType)3)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.BindSetting("UI", $"Enable{(object)(ECardExpansionType)5}", value: false);
			ModConfigManager.Instance.OnSettingChanged("UI", $"Enable{(object)(ECardExpansionType)5}", delegate(bool value)
			{
				((Component)collectionBinderUI.m_ExpansionBtnList[Buttons.IndexOf((ECardExpansionType)5)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.BindSetting("UI", "ExpansionSpacingX", 30f);
			ModConfigManager.Instance.OnSettingChanged("UI", "ExpansionSpacingX", delegate(float value)
			{
				if (flowLayoutGroup != null)
				{
					flowLayoutGroup.SpacingX = value;
				}
			});
			ModConfigManager.Instance.BindSetting("UI", "ExpansionSpacingY", -45f);
			ModConfigManager.Instance.OnSettingChanged("UI", "ExpansionSpacingY", delegate(float value)
			{
				if (flowLayoutGroup != null)
				{
					flowLayoutGroup.SpacingY = value;
				}
			});
			ModConfigManager.Instance.BindSetting<Vector2>("UI", "ExpansionButtonSize", new Vector2(325f, 184.5f));
			ModConfigManager.Instance.OnSettingChanged("UI", "ExpansionButtonSize", delegate(Vector2 value)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				foreach (Transform expansionBtn in collectionBinderUI.m_ExpansionBtnList)
				{
					RectTransform val = (RectTransform)(object)((expansionBtn is RectTransform) ? expansionBtn : null);
					if (val != null)
					{
						val.sizeDelta = value;
					}
				}
			});
		}

		public void InitCustomUI(CollectionBinderUI collectionBinderUI)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			if (!IsLoaded)
			{
				if (this.collectionBinderUI == null)
				{
					this.collectionBinderUI = collectionBinderUI;
				}
				this.collectionBinderUI.m_ExpansionBtnList.Clear();
				Transform obj = this.collectionBinderUI.m_ExpansionSelectScreen.transform.Find("Mask/UIGroup");
				Transform obj2 = ((obj is RectTransform) ? obj : null);
				Transform parent = obj2.parent;
				int siblingIndex = obj2.GetSiblingIndex();
				Vector2 anchorMin = ((RectTransform)obj2).anchorMin;
				Vector2 anchorMax = ((RectTransform)obj2).anchorMax;
				Vector2 pivot = ((RectTransform)obj2).pivot;
				Vector2 anchoredPosition = ((RectTransform)obj2).anchoredPosition;
				Vector2 sizeDelta = ((RectTransform)obj2).sizeDelta;
				Vector3 localScale = obj2.localScale;
				Vector2 offsetMin = ((RectTransform)obj2).offsetMin;
				Vector2 offsetMax = ((RectTransform)obj2).offsetMax;
				GameObject val = null;
				Transform val2 = obj2.Find("BtnHighlightGrp");
				if (val2 != null)
				{
					val = ((Component)val2).gameObject;
					val.transform.SetParent((Transform)null);
				}
				Transform val3 = obj2.Find("Tetramon_Button");
				if (val3 != null)
				{
					((Component)val3).transform.SetParent((Transform)null);
					((Component)val3).gameObject.SetActive(false);
					cloneableButton = val3;
				}
				GameObject val4 = FlowLayoutGroup.Create(parent, isScrollable: true);
				flowLayoutGroup = val4.GetComponentInChildren<FlowLayoutGroup>(true);
				Vector2 value = ModConfigManager.Instance.GetValue<Vector2>("UI", "ExpansionButtonSize");
				flowLayoutGroup.ChildHeight = value.y;
				flowLayoutGroup.ChildWidth = value.x;
				flowLayoutGroup.SpacingX = ModConfigManager.Instance.GetValue<float>("UI", "ExpansionSpacingX");
				flowLayoutGroup.SpacingY = ModConfigManager.Instance.GetValue<float>("UI", "ExpansionSpacingY");
				RectTransform component = val4.GetComponent<RectTransform>();
				((Transform)component).SetSiblingIndex(siblingIndex);
				component.anchorMin = anchorMin;
				component.anchorMax = anchorMax;
				component.pivot = pivot;
				component.anchoredPosition = anchoredPosition;
				component.sizeDelta = sizeDelta;
				((Transform)component).localScale = localScale;
				component.offsetMin = offsetMin;
				component.offsetMax = offsetMax;
				if (val != null)
				{
					val.transform.SetParent(val4.transform, true);
					val.transform.SetAsFirstSibling();
					this.collectionBinderUI.m_ExpansionSelectHighlightBtn = val;
					val.SetActive(false);
				}
				Object.Destroy((Object)(object)((Component)obj2).gameObject);
			}
			IsLoaded = true;
		}

		public void AddNewExpansionButton(string text, ECardExpansionType expansionType, bool enabled, UnityAction onClick = null)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!IsLoaded)
			{
				return;
			}
			Transform val = flowLayoutGroup?.AddButtonFromTemplate(cloneableButton);
			Localize componentInChildren = ((Component)val).GetComponentInChildren<Localize>(true);
			if (componentInChildren != null)
			{
				componentInChildren.SetTerm(text);
			}
			Button componentInChildren2 = ((Component)val).GetComponentInChildren<Button>(true);
			if (componentInChildren2 != null)
			{
				((UnityEventBase)componentInChildren2.onClick).RemoveAllListeners();
				if (onClick != null)
				{
					((UnityEvent)componentInChildren2.onClick).AddListener(onClick);
				}
				((Selectable)componentInChildren2).navigation = Navigation.defaultNavigation;
			}
			((Component)val).gameObject.SetActive(enabled);
			collectionBinderUI.m_ExpansionBtnList.Add(val);
			Buttons.Add(expansionType);
			ModLogger.Debug($"Button added for {expansionType}", "AddNewExpansionButton", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\UI\\CollectionBinder\\CollectionBinderUIManager.cs");
		}
	}
}
namespace EnhancedPrefabLoader.Saves
{
	public class ModAssetTracker
	{
		private readonly ManualLogSource log = Logger.CreateLogSource(typeof(ModAssetTracker).FullName);

		private readonly Dictionary<Type, Dictionary<object, string>> enumTrackers = new Dictionary<Type, Dictionary<object, string>>();

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

		public void Register<TEnum>(TEnum enumValue, string modId) where TEnum : Enum
		{
			Type typeFromHandle = typeof(TEnum);
			enumTrackers.GetOrAdd(typeFromHandle, (Type _) => new Dictionary<object, string>())[enumValue] = modId;
		}

		public void Register(string category, string assetName, string modId)
		{
			nameTrackers.GetOrAdd(category, (string _) => new Dictionary<string, string>())[assetName] = modId;
		}

		public string GetModId<TEnum>(TEnum enumValue) where TEnum : Enum
		{
			Type typeFromHandle = typeof(TEnum);
			if (!enumTrackers.TryGetValue(typeFromHandle, out var value) || !value.TryGetValue(enumValue, out var value2))
			{
				return null;
			}
			return value2;
		}

		public string GetModId(string category, string assetName)
		{
			if (!nameTrackers.TryGetValue(category, out var value) || !value.TryGetValue(assetName, out var value2))
			{
				return null;
			}
			return value2;
		}
	}
	[Serializable]
	public class ModSaveData
	{
		[JsonProperty]
		public Dictionary<string, object> Data { get; private set; } = new Dictionary<string, object>();


		public T GetData<T>(string key) where T : class
		{
			if (!Data.TryGetValue(key, out var value))
			{
				return null;
			}
			return value as T;
		}

		public void SetData<T>(string key, T value) where T : class
		{
			Data[key] = value;
		}

		public void MergeFrom(ModSaveData other)
		{
			foreach (KeyValuePair<string, object> datum in other.Data)
			{
				Data[datum.Key] = datum.Value;
			}
		}

		public void SetAllDataDefaults()
		{
			foreach (KeyValuePair<string, object> datum in Data)
			{
				if (Data[datum.Key] is IResettable resettable)
				{
					resettable.Reset();
				}
			}
		}
	}
	public class ModSaveManager
	{
		private readonly ManualLogSource log = Logger.CreateLogSource(typeof(ModSaveManager).FullName);

		private static ModSaveManager instance;

		private readonly ModAssetTracker assetTracker = new ModAssetTracker();

		private readonly Dictionary<string, ModSaveData> modSaveData = new Dictionary<string, ModSaveData>();

		public static ModSaveManager Instance => instance ?? (instance = new ModSaveManager());

		private ModSaveManager()
		{
		}

		public void RegisterAsset<TEnum, TSaveData>(TEnum enumValue, string modId, TSaveData defaultData) where TEnum : Enum where TSaveData : class
		{
			assetTracker.Register(enumValue, modId);
			SetSaveData(enumValue, defaultData);
		}

		public void RegisterAsset<TSaveData>(string category, string assetName, string modId, TSaveData defaultData) where TSaveData : class
		{
			assetTracker.Register(category, assetName, modId);
			SetSaveData(category, assetName, defaultData);
		}

		public TSaveData GetSaveData<TEnum, TSaveData>(TEnum enumValue) where TEnum : Enum where TSaveData : class
		{
			string modId = assetTracker.GetModId(enumValue);
			if (modId == null)
			{
				return null;
			}
			string key = $"{typeof(TEnum).Name}:{enumValue}";
			if (!modSaveData.TryGetValue(modId, out var value))
			{
				return null;
			}
			return value.GetData<TSaveData>(key);
		}

		public TSaveData GetSaveData<TSaveData>(string category, string assetName) where TSaveData : class, new()
		{
			string modId = assetTracker.GetModId(category, assetName);
			if (modId == null)
			{
				return null;
			}
			string key = category + ":" + assetName;
			if (!modSaveData.TryGetValue(modId, out var value))
			{
				return null;
			}
			return value.GetData<TSaveData>(key);
		}

		public void SaveToFile(string filePath)
		{
			//IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			string contents = JsonConvert.SerializeObject((object)modSaveData, new JsonSerializerSettings
			{
				TypeNameHandling = (TypeNameHandling)1,
				Formatting = (Formatting)1
			});
			File.WriteAllText(filePath, contents);
		}

		public void LoadFromFile(string filePath)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if (!File.Exists(filePath))
			{
				ModLogger.Debug("Unable to find save file " + filePath, "LoadFromFile", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\Saves\\ModSaveManager.cs");
				return;
			}
			Dictionary<string, ModSaveData> dictionary = JsonConvert.DeserializeObject<Dictionary<string, ModSaveData>>(File.ReadAllText(filePath), new JsonSerializerSettings
			{
				TypeNameHandling = (TypeNameHandling)1
			});
			if (dictionary == null)
			{
				return;
			}
			foreach (KeyValuePair<string, ModSaveData> item in dictionary)
			{
				if (modSaveData.ContainsKey(item.Key))
				{
					modSaveData[item.Key].MergeFrom(item.Value);
				}
			}
			foreach (ModSaveData value in modSaveData.Values)
			{
				foreach (KeyValuePair<string, object> datum in value.Data)
				{
					if (datum.Value is IHandleLoad handleLoad)
					{
						handleLoad.OnLoad(datum.Key);
					}
				}
			}
		}

		public void SetAllToDefaults()
		{
			foreach (KeyValuePair<string, ModSaveData> modSaveDatum in modSaveData)
			{
				modSaveData[modSaveDatum.Key].SetAllDataDefaults();
			}
		}

		private void SetSaveData<TEnum, TSaveData>(TEnum enumValue, TSaveData data) where TEnum : Enum where TSaveData : class
		{
			string modId = assetTracker.GetModId(enumValue);
			if (modId != null)
			{
				string key = $"{typeof(TEnum).Name}:{enumValue}";
				if (!this.modSaveData.TryGetValue(modId, out var value))
				{
					value = (this.modSaveData[modId] = new ModSaveData());
				}
				value.SetData(key, data);
			}
		}

		private void SetSaveData<TSaveData>(string category, string assetName, TSaveData data) where TSaveData : class
		{
			string modId = assetTracker.GetModId(category, assetName);
			if (modId != null)
			{
				string key = category + ":" + assetName;
				if (!this.modSaveData.TryGetValue(modId, out var value))
				{
					value = (this.modSaveData[modId] = new ModSaveData());
				}
				value.SetData(key, data);
			}
		}
	}
}
namespace EnhancedPrefabLoader.Patches
{
	[HarmonyPatch(typeof(CardOpeningSequence))]
	public class CardOpeningSequencePatches
	{
		[HarmonyPatch("OpenScreen")]
		[HarmonyPrefix]
		public static bool OpenScreenPrefix(CardOpeningSequence __instance, ECollectionPackType collectionPackType, bool isMultiPack, bool isPremiumPack)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CollectionPackToExpansion.ContainsKey(collectionPackType))
			{
				return true;
			}
			__instance.m_IsScreenActive = true;
			__instance.m_CollectionPackType = collectionPackType;
			__instance.m_IsNewlList.Clear();
			__instance.m_TotalExpGained = 0;
			__instance.m_TotalCardValue = 0f;
			__instance.m_HasFoilCard = false;
			__instance.m_StateIndex = 0;
			__instance.m_ManualOpenCardDataList.Clear();
			__instance.m_CardValueList.Clear();
			__instance.m_CurrentOpenedCardIndex = 0;
			if (AssetData.CardPackData.TryGetValue(__instance.m_CurrentItem.GetItemType(), out var value))
			{
				foreach (Card3dUIGroup card3dUI in __instance.m_Card3dUIList)
				{
					((Component)card3dUI).gameObject.SetActive(false);
				}
				int num = 0;
				foreach (CardData item in PatchHelpers.GetPackContent(collectionPackType, value))
				{
					__instance.m_HasFoilCard = __instance.m_HasFoilCard || item.isFoil;
					__instance.m_ManualOpenCardDataList.Add(item);
					__instance.m_CardValueList.Add(CPlayerData.GetCardMarketPrice(item));
					__instance.m_Card3dUIList[num].m_CardUI.SetCardUI(item);
					__instance.m_IsNewlList.Add(CSingleton<CGameManager>.Instance.m_OpenPackShowNewCard && item.isNew);
					CPlayerData.AddCard(item, 1);
					num++;
				}
				CSingleton<InteractionPlayerController>.Instance.m_CollectionBinderFlipAnimCtrl.SetCanUpdateSort(true);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CardUI))]
	public class CardUIPatches
	{
		[HarmonyPatch("SetCardUI")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo operandAndAdvance = AccessTools.Method(typeof(PatchHelpers), "GetMonsterData", new Type[1] { typeof(CardData) }, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CardData), "monsterType");
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
			});
			if (val.IsValid)
			{
				val.Advance(1).RemoveInstruction().SetOperandAndAdvance((object)operandAndAdvance);
			}
			return val.InstructionEnumeration();
		}

		[HarmonyPatch("SetCardUI")]
		[HarmonyPostfix]
		public static void SetCardUIPostfix(CardUI __instance, CardData cardData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			GameObject targetGroup = (((int)cardData.borderType == 5) ? __instance.m_FullArtGrp : __instance.m_NormalGrp);
			if (!AssetData.CardExpanions.TryGetValue(cardData.expansionType, out var value))
			{
				if (!Chainloader.PluginInfos.ContainsKey("shaklin.TextureReplacer"))
				{
					CustomCardUIGroups.RestoreOriginalState(__instance, targetGroup);
				}
			}
			else
			{
				CustomCardUIGroups.ApplyCardUIChanges(__instance, cardData, targetGroup, value, (int)cardData.borderType == 5);
			}
		}
	}
	[HarmonyPatch(typeof(CheckPricePanelUI))]
	public class CheckPricePanelUIPatches
	{
		[HarmonyPatch("InitCard")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo operandAndAdvance = AccessTools.Method(typeof(PatchHelpers), "GetMonsterData", new Type[1] { typeof(CardData) }, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CardData), "monsterType");
			while (val.IsValid)
			{
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
				});
				if (val.IsValid)
				{
					val.Advance(1).RemoveInstruction().SetOperandAndAdvance((object)operandAndAdvance);
				}
			}
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(CollectionBinderFlipAnimCtrl))]
	public class CollectionBinderFlipAnimCtrlPatches
	{
		[HarmonyPatch("EnterViewUpCloseState")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> EnterViewUpCloseStateTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo operandAndAdvance = AccessTools.Method(typeof(PatchHelpers), "GetMonsterData", new Type[1] { typeof(CardData) }, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CardData), "monsterType");
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
			});
			if (val.IsValid)
			{
				val.Advance(1).RemoveInstruction().SetOperandAndAdvance((object)operandAndAdvance);
			}
			return val.InstructionEnumeration();
		}

		[HarmonyPatch("SortByCardRarity")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> SortByCardRarityTranspilier(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo replacement = AccessTools.Method(typeof(PatchHelpers), "GetMonsterData", new Type[2]
			{
				typeof(EMonsterType),
				typeof(ECardExpansionType)
			}, (Type[])null);
			FieldInfo expansionTypeField = AccessTools.Field(typeof(CollectionBinderFlipAnimCtrl), "m_ExpansionType");
			val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
			}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher matchAction)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				if (matchAction.IsValid)
				{
					matchAction.Insert((CodeInstruction[])(object)new CodeInstruction[2]
					{
						new CodeInstruction(OpCodes.Ldarg_0, (object)null),
						new CodeInstruction(OpCodes.Ldfld, (object)expansionTypeField)
					}).Advance(2).SetOperandAndAdvance((object)replacement);
				}
			}, (Action<string>)null);
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(CollectionBinderUI))]
	public class CollectionBinderUIPatches
	{
		[HarmonyPatch("OpenSortAlbumScreen")]
		[HarmonyPrefix]
		public static void OpenSortAlbumScreenPrefix(int sortingMethodIndex, ref int currentExpansionIndex, bool isGradedCardAlbum)
		{
			currentExpansionIndex = Plugin.CollectionBinderUIManager.Buttons.IndexOf((ECardExpansionType)currentExpansionIndex);
		}

		[HarmonyPatch("OpenSortAlbumScreen")]
		[HarmonyPostfix]
		public static void OpenSortAlbumSceenPostfix(int sortingMethodIndex, int currentExpansionIndex, bool isGradedCardAlbum)
		{
			Canvas.ForceUpdateCanvases();
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void AwakePostfix(CollectionBinderUI __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			Plugin.CollectionBinderUIManager.InitCustomUI(__instance);
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Tetramon", (ECardExpansionType)0, enabled: true, (UnityAction)delegate
			{
				__instance.OnPressSwitchExpansion(0);
			});
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Destiny", (ECardExpansionType)1, enabled: true, (UnityAction)delegate
			{
				__instance.OnPressSwitchExpansion(1);
			});
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Ghost", (ECardExpansionType)2, enabled: true, (UnityAction)delegate
			{
				__instance.OnPressSwitchExpansion(2);
			});
			bool value = ModConfigManager.Instance.GetValue<bool>("UI", $"Enable{(object)(ECardExpansionType)4}");
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Fantasy", (ECardExpansionType)4, value, (UnityAction)delegate
			{
				__instance.OnPressSwitchExpansion(4);
			});
			bool value2 = ModConfigManager.Instance.GetValue<bool>("UI", $"Enable{(object)(ECardExpansionType)3}");
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Megabot", (ECardExpansionType)3, value2, (UnityAction)delegate
			{
				__instance.OnPressSwitchExpansion(3);
			});
			bool value3 = ModConfigManager.Instance.GetValue<bool>("UI", $"Enable{(object)(ECardExpansionType)5}");
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Catjob", (ECardExpansionType)5, value3, (UnityAction)delegate
			{
				__instance.OnPressSwitchExpansion(5);
			});
			foreach (KeyValuePair<ECardExpansionType, CardExpansion> kvp2 in AssetData.CardExpanions.OrderBy((KeyValuePair<ECardExpansionType, CardExpansion> kvp) => (int)kvp.Key))
			{
				Plugin.CollectionBinderUIManager.AddNewExpansionButton(kvp2.Value.Name, kvp2.Key, enabled: true, (UnityAction)delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Expected I4, but got Unknown
					__instance.OnPressSwitchExpansion((int)kvp2.Key);
				});
			}
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Graded Card", (ECardExpansionType)(-1), enabled: true, (UnityAction)delegate
			{
				__instance.OnPressSwitchToGradedAlbum();
			});
			__instance.m_GradedCardBtn = __instance.m_ExpansionBtnList[__instance.m_ExpansionBtnList.Count - 1];
		}
	}
	[HarmonyPatch(typeof(CPlayerData))]
	public class CPlayerDataPatches
	{
		[HarmonyPatch("GetCardCollectedList")]
		[HarmonyPrefix]
		public static bool GetCardCollectedListPrefix(ECardExpansionType expansionType, bool isDimension, ref List<int> __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			__result = saveData.CardCountList;
			return false;
		}

		[HarmonyPatch("GetIsCardCollectedList")]
		[HarmonyPrefix]
		public static bool GetIsCardCollectedListPrefix(ECardExpansionType expansionType, bool isDimension, ref List<bool> __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			__result = saveData.IsCardCollectedList;
			return false;
		}

		[HarmonyPatch("GetCardMarketPrice", new Type[]
		{
			typeof(int),
			typeof(ECardExpansionType),
			typeof(bool),
			typeof(int)
		})]
		[HarmonyPrefix]
		public static bool GetCardMarketPricePrefix(int index, ECardExpansionType expansionType, bool isDestiny, int cardGrade, ref float __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			__result = saveData.CardMarketPriceList[index].GetMarketPrice(index, cardGrade);
			return false;
		}

		[HarmonyPatch("GetCardMarketPrice", new Type[] { typeof(CardData) })]
		[HarmonyPrefix]
		public static bool GetCardMarketPricePrefix(CardData cardData, ref float __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(cardData.expansionType);
			if (saveData == null)
			{
				return true;
			}
			int cardSaveIndex = CPlayerData.GetCardSaveIndex(cardData);
			__result = saveData.CardMarketPriceList[cardSaveIndex].GetMarketPrice(cardSaveIndex, cardData.cardGrade);
			return false;
		}

		[HarmonyPatch("GetCardAmountPerMonsterType")]
		[HarmonyPrefix]
		public static bool GetCardAmountPerMonsterTypePrefix(ECardExpansionType expansionType, bool includeFoilCount, ref int __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(expansionType, out var value))
			{
				return true;
			}
			__result = ((!(value.HasFoils && includeFoilCount)) ? 1 : 2);
			return false;
		}

		[HarmonyPatch("GetCardBorderType")]
		[HarmonyPrefix]
		public static bool GetCardBorderTypePrefix(int borderTypeIndex, ECardExpansionType expansionType, ref ECardBorderType __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(expansionType, out var _))
			{
				return true;
			}
			__result = (ECardBorderType)borderTypeIndex;
			return false;
		}

		[HarmonyPatch("GetCardSaveIndex")]
		[HarmonyPrefix]
		public static bool GetCardSaveIndex(CardData cardData, ref int __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(cardData.expansionType, out var value))
			{
				return true;
			}
			__result = value.Cards.Keys.OrderBy((EMonsterType key) => (int)key).ToList().IndexOf(cardData.monsterType);
			if (value.HasFoils)
			{
				__result = __result * 2 + (cardData.isFoil ? 1 : 0);
			}
			return false;
		}

		[HarmonyPatch("GetCardPrice")]
		[HarmonyPrefix]
		public static bool GetCardPricePrefix(CardData cardData, ref float __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(cardData.expansionType);
			if (saveData == null)
			{
				return true;
			}
			int cardSaveIndex = CPlayerData.GetCardSaveIndex(cardData);
			double num = ((GameInstance.GetCurrencyConversionRate() > 1f) ? Math.Round(saveData.CardPriceList[cardSaveIndex], 3, MidpointRounding.AwayFromZero) : Math.Round(saveData.CardPriceList[cardSaveIndex], 2, MidpointRounding.AwayFromZero));
			__result = (float)num;
			return false;
		}

		[HarmonyPatch("GetCardPriceUsingIndex")]
		[HarmonyPrefix]
		public static bool GetCardPriceUsingIndexPrefix(int index, ECardExpansionType expansionType, bool isDestiny, int cardGrade, ref float __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			double num = ((GameInstance.GetCurrencyConversionRate() > 1f) ? Math.Round(saveData.CardPriceList[index], 3, MidpointRounding.AwayFromZero) : Math.Round(saveData.CardPriceList[index], 2, MidpointRounding.AwayFromZero));
			__result = (float)num;
			return false;
		}

		[HarmonyPatch("SetCardPrice")]
		[HarmonyPrefix]
		public static bool SetCardPricePrefix(CardData cardData, float priceSet)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(cardData.expansionType);
			if (saveData == null)
			{
				return true;
			}
			int cardSaveIndex = CPlayerData.GetCardSaveIndex(cardData);
			if (cardData.cardGrade > 0)
			{
				saveData.GradedCardPriceList[cardSaveIndex][cardData.cardGrade] = priceSet;
			}
			else
			{
				saveData.CardPriceList[cardSaveIndex] = priceSet;
			}
			CEventManager.QueueEvent((CEvent)new CEventPlayer_CardPriceChanged(cardData, priceSet));
			return false;
		}

		[HarmonyPatch("SetCardGeneratedMarketPrice")]
		[HarmonyPrefix]
		public static bool SetCardGeneratedMarketPricePrefix(int cardIndex, ECardExpansionType expansionType, bool isDestiny, float price)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			saveData.CardMarketPriceList[cardIndex].generatedMarketPrice = price;
			return false;
		}

		[HarmonyPatch("AddCardPricePercentChange")]
		[HarmonyPrefix]
		public static bool AddCardPricePercentChangePrefix(int cardIndex, ECardExpansionType expansionType, bool isDestiny, float percentChange)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			MarketPrice obj = saveData.CardMarketPriceList[cardIndex];
			float num = (obj.pricePercentChangeList += percentChange);
			if (num < -80f)
			{
				saveData.CardMarketPriceList[cardIndex].pricePercentChangeList = -80f;
			}
			if (num > 200f)
			{
				saveData.CardMarketPriceList[cardIndex].pricePercentChangeList = 200f;
			}
			return false;
		}

		[HarmonyPatch("GetCardPricePercentChange")]
		[HarmonyPrefix]
		public static bool GetCardPricePercentChangePrefix(int cardIndex, ECardExpansionType expansionType, bool isDestiny, ref float __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			__result = saveData.CardMarketPriceList[cardIndex].pricePercentChangeList;
			return false;
		}

		[HarmonyPatch("UpdatePastCardPricePercentChange")]
		[HarmonyPostfix]
		public static void UpdatePastCardPricePercentChangePostfix()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			foreach (ECardExpansionType key in AssetData.CardExpanions.Keys)
			{
				CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(key);
				if (saveData == null)
				{
					continue;
				}
				foreach (MarketPrice cardMarketPrice in saveData.CardMarketPriceList)
				{
					MarketPrice val = cardMarketPrice;
					if (val.pastPricePercentChangeList == null)
					{
						val.pastPricePercentChangeList = new List<float>();
					}
					cardMarketPrice.pastPricePercentChangeList.Add(cardMarketPrice.pricePercentChangeList);
					if (cardMarketPrice.pastPricePercentChangeList.Count > 30)
					{
						cardMarketPrice.pastPricePercentChangeList.RemoveAt(0);
					}
				}
			}
		}

		[HarmonyPatch("GetPastCardPricePercentChange")]
		[HarmonyPrefix]
		public static bool GetPastCardPricePercentChangePrefix(int cardIndex, ECardExpansionType expansionType, bool isDestiny, ref List<float> __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			__result = saveData.CardMarketPriceList[cardIndex].pastPricePercentChangeList;
			return false;
		}

		[HarmonyPatch("GetCardMarketPriceCustomPercent")]
		[HarmonyPrefix]
		public static bool GetCardMarketPriceCustomPercentPrefix(int index, ECardExpansionType expansionType, bool isDestiny, float percent, int cardGrade, ref float __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			__result = saveData.CardMarketPriceList[index].GetMarketPriceCustomPercent(percent, index, cardGrade);
			return false;
		}

		[HarmonyPatch("AddCard")]
		[HarmonyPrefix]
		public static bool AddCardPrefix(CardData cardData, int addAmount)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(cardData.expansionType);
			if (saveData == null)
			{
				return true;
			}
			int cardSaveIndex = CPlayerData.GetCardSaveIndex(cardData);
			if (cardData.cardGrade > 0)
			{
				CPlayerData.m_GradedCardInventoryList.Add(new CompactCardDataAmount
				{
					cardSaveIndex = cardSaveIndex,
					amount = cardData.cardGrade,
					expansionType = cardData.expansionType,
					isDestiny = cardData.isDestiny,
					gradedCardIndex = CPlayerData.m_GradedCardInventoryList.Count + 1
				});
				return false;
			}
			saveData.CardCountList[cardSaveIndex] += addAmount;
			saveData.IsCardCollectedList[cardSaveIndex] = true;
			return false;
		}

		[HarmonyPatch("ReduceCard")]
		[HarmonyPrefix]
		public static bool ReduceCardPrefix(CardData cardData, int reduceAmount)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(cardData.expansionType);
			if (saveData == null)
			{
				return true;
			}
			int cardSaveIndex = CPlayerData.GetCardSaveIndex(cardData);
			saveData.CardCountList[cardSaveIndex] -= reduceAmount;
			return false;
		}

		[HarmonyPatch("ReduceCardUsingIndex")]
		[HarmonyPrefix]
		public static bool ReduceCardUsingIndexPrefix(int index, ECardExpansionType expansionType, bool isDestiny, int reduceAmount)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(expansionType);
			if (saveData == null)
			{
				return true;
			}
			saveData.CardCountList[index] -= reduceAmount;
			return false;
		}

		[HarmonyPatch("SetCard")]
		[HarmonyPrefix]
		public static bool SetCardPrefix(CardData cardData, int amount)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(cardData.expansionType);
			if (saveData == null)
			{
				return true;
			}
			int cardSaveIndex = CPlayerData.GetCardSaveIndex(cardData);
			saveData.CardCountList[cardSaveIndex] = amount;
			return false;
		}

		[HarmonyPatch("GetCardData")]
		[HarmonyPrefix]
		public static bool GetCardDataPrefix(int cardIndex, ECardExpansionType expansionType, bool isDestiny, ref CardData __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			if (!AssetData.CardExpanions.TryGetValue(expansionType, out var value))
			{
				return true;
			}
			int num = cardIndex;
			if (value.HasFoils)
			{
				num >>= 1;
			}
			__result = new CardData
			{
				monsterType = value.Cards.Keys.OrderBy((EMonsterType key) => (int)key).ToList()[num],
				isFoil = (value.HasFoils && cardIndex % 2 == 1),
				borderType = CPlayerData.GetCardBorderType(num, expansionType),
				isDestiny = isDestiny,
				expansionType = expansionType
			};
			return false;
		}

		[HarmonyPatch("GetGradedCardData")]
		[HarmonyPrefix]
		public static bool GetGradedCardDataPrefix(CompactCardDataAmount compactCardData, ref CardData __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			if (!AssetData.CardExpanions.TryGetValue(compactCardData.expansionType, out var value))
			{
				return true;
			}
			EMonsterType monsterTypeFromCardSaveIndex = CPlayerData.GetMonsterTypeFromCardSaveIndex(compactCardData.cardSaveIndex, compactCardData.expansionType);
			__result = new CardData
			{
				monsterType = monsterTypeFromCardSaveIndex,
				isFoil = (value.HasFoils && compactCardData.cardSaveIndex % 2 == 1),
				borderType = value.CardBorderMap[monsterTypeFromCardSaveIndex],
				isDestiny = compactCardData.isDestiny,
				expansionType = compactCardData.expansionType,
				cardGrade = compactCardData.amount,
				gradedCardIndex = compactCardData.cardSaveIndex
			};
			return false;
		}

		[HarmonyPatch("HasGradedCardInAlbum")]
		[HarmonyPrefix]
		public static bool HasGradedCardInAlbumPrefix(CardData cardData, ref bool __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.ContainsKey(cardData.expansionType))
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPatch("GetTotalCardCollectedAmount")]
		[HarmonyPostfix]
		public static int GetTotalCardCollectedAmountPostfix(int __result)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			foreach (ECardExpansionType key in AssetData.CardExpanions.Keys)
			{
				CardExpansionSaveData saveData = ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(key);
				if (saveData == null)
				{
					continue;
				}
				foreach (int cardCount in saveData.CardCountList)
				{
					__result += cardCount;
				}
			}
			return __result;
		}

		[HarmonyPatch("GetFullCardTypeName")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> GetFullCardTypeNameTranspilier(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo operandAndAdvance = AccessTools.Method(typeof(PatchHelpers), "GetMonsterData", new Type[1] { typeof(CardData) }, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CardData), "monsterType");
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
			});
			if (val.IsValid)
			{
				val.Advance(1).RemoveInstruction().SetOperandAndAdvance((object)operandAndAdvance);
			}
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(CustomerManager))]
	public class CustomerManagerPatches
	{
		[HarmonyPatch("EvaluateMaxCustomerCount")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(CustomerManagerPatches), "GetCombinedDecoCount", (Type[])null, (Type[])null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)129, (string)null)
			});
			if (val.IsValid)
			{
				val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)methodInfo));
			}
			return val.InstructionEnumeration();
		}

		public static int GetCombinedDecoCount()
		{
			if (AssetData.DecoObjectData.Count <= 0)
			{
				return 129;
			}
			return 200000 + AssetData.DecoObjectData.Max((KeyValuePair<EDecoObject, Tuple<DecoPurchaseData, DecoData>> data) => (int)data.Key);
		}
	}
	[HarmonyPatch(typeof(CustomerManager), "EvaluateMaxCustomerCount")]
	public class EvaluateMaxCustomerCountPatches
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0019: 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_0042: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			MethodInfo method = typeof(EvaluateMaxCustomerCountPatches).GetMethod("GetCombinedDecoCount", BindingFlags.Static | BindingFlags.Public);
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)129, (string)null)
			});
			if (val.IsValid)
			{
				val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)method));
			}
			return val.InstructionEnumeration();
		}

		public static int GetCombinedDecoCount()
		{
			if (AssetData.DecoObjectData.Count <= 0)
			{
				return 129;
			}
			return 200000 + AssetData.DecoObjectData.Max((KeyValuePair<EDecoObject, Tuple<DecoPurchaseData, DecoData>> data) => (int)data.Key);
		}
	}
	[HarmonyPatch(typeof(FurnitureShopUIScreen))]
	public class FurnitureShopUIScreenPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPrefix]
		private static void InitPrefix(FurnitureShopUIScreen __instance)
		{
			Plugin.ShopUIManager.SetupFurnitureShopUI(__instance);
		}
	}
	[HarmonyPatch(typeof(InteractableAutoPackOpener))]
	public class InteractableAutoPackOpenerPatches
	{
		[HarmonyPatch("OpenPack")]
		[HarmonyPrefix]
		public static bool OpenPackPrefix(InteractableAutoPackOpener __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			if (!AssetData.CardPackData.TryGetValue(__instance.m_StoredItemList[0].GetItemType(), out var value))
			{
				return true;
			}
			__instance.m_PackOpenedCount++;
			foreach (CardData item2 in PatchHelpers.GetPackContent(value.PackType, value))
			{
				int cardSaveIndex = CPlayerData.GetCardSaveIndex(item2);
				bool flag = false;
				for (int i = 0; i < __instance.m_CompactCardDataAmountList.Count; i++)
				{
					if (__instance.m_CompactCardDataAmountList[i].cardSaveIndex == cardSaveIndex && __instance.m_CompactCardDataAmountList[i].expansionType == item2.expansionType)
					{
						flag = true;
						CompactCardDataAmount obj = __instance.m_CompactCardDataAmountList[i];
						obj.amount++;
						break;
					}
				}
				if (!flag)
				{
					CompactCardDataAmount item = new CompactCardDataAmount
					{
						expansionType = item2.expansionType,
						isDestiny = false,
						cardSaveIndex = cardSaveIndex,
						amount = 1
					};
					__instance.m_CompactCardDataAmountList.Add(item);
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(InteractionPlayerController))]
	public class InteractionPlayerControllerPatches
	{
		[HarmonyPatch("IsCardPackType")]
		[HarmonyPrefix]
		public static bool IsCardPackTypePrefix(EItemType itemType, ref bool __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.ItemData.TryGetValue(itemType, out var value))
			{
				return true;
			}
			__result = !value.isNotBoosterPack;
			return false;
		}

		[HarmonyPatch("CanOpenCardBox")]
		[HarmonyPrefix]
		public static bool CanOpenCardBoxPrefix(InteractionPlayerController __instance, ref bool __result)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_HoldItemList.Count == 0)
			{
				return true;
			}
			if (!AssetData.CardBoxData.ContainsKey(__instance.m_HoldItemList[0].GetItemType()))
			{
				return true;
			}
			__result = true;
			return false;
		}

		[HarmonyPatch("CardBoxToCardPack")]
		[HarmonyPrefix]
		public static bool CardBoxToCardPackPrefix(EItemType cardBoxItemType, ref EItemType __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected I4, but got Unknown
			if (!AssetData.CardBoxData.TryGetValue(cardBoxItemType, out var value))
			{
				return true;
			}
			__result = (EItemType)(int)value;
			return false;
		}
	}
	[HarmonyPatch(typeof(InventoryBase))]
	public class InventoryBasePatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void AwakePostfix()
		{
			DeferredActions.ExecuteAfterAwake<InventoryBase>();
			DeferredActions.ClearAwakeActions<InventoryBase>();
			Plugin.ShopInventoryManager.PopulateAllShopInventories();
		}

		[HarmonyPatch("GetCardExpansionType")]
		[HarmonyPrefix]
		public static bool GetCardExpansionTypePrefix(ECollectionPackType collectionPackType, ref ECardExpansionType __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected I4, but got Unknown
			if (!AssetData.CollectionPackToExpansion.TryGetValue(collectionPackType, out var value))
			{
				return true;
			}
			__result = (ECardExpansionType)(int)value;
			return false;
		}

		[HarmonyPatch("ItemTypeToCollectionPackType")]
		[HarmonyPrefix]
		public static bool ItemTypeToCollectionPackTypePrefix(EItemType itemType, ref ECollectionPackType __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected I4, but got Unknown
			if (!AssetData.CardPackData.TryGetValue(itemType, out var value))
			{
				return true;
			}
			__result = (ECollectionPackType)(int)value.PackType;
			return false;
		}

		[HarmonyPatch("GetShownMonsterList")]
		[HarmonyPrefix]
		public static bool GetShownMonsterListPrefix(ECardExpansionType expansionType, ref List<EMonsterType> __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(expansionType, out var value))
			{
				return true;
			}
			__result = value.Cards.Select((KeyValuePair<EMonsterType, MonsterData> kvp) => kvp.Key).ToList();
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemPriceGraphScreen))]
	public class ItemPriceGraphScreenPatches
	{
		[HarmonyPatch("ShowCardPriceChart")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> ShowCardPriceChartTranspilier(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo operandAndAdvance = AccessTools.Method(typeof(PatchHelpers), "GetMonsterData", new Type[1] { typeof(CardData) }, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CardData), "monsterType");
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
			});
			if (val.IsValid)
			{
				val.Advance(1).RemoveInstruction().SetOperandAndAdvance((object)operandAndAdvance);
			}
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(PriceChangeManager))]
	public class PriceChangeManagerPatches
	{
		[HarmonyPatch("UpdateCardMarketPrice")]
		[HarmonyPrefix]
		public static bool UpdateCardMarketPricePrefix(ECardExpansionType expansionType, EPriceChangeType priceChangeType, bool isIncrease)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CardExpansion value;
			return !AssetData.CardExpanions.TryGetValue(expansionType, out value);
		}
	}
	[HarmonyPatch(typeof(RestockItemBoardGameScreen))]
	public class RestockItemBoardGameScreenPatches
	{
		[HarmonyPatch("EvaluateRestockItemPanelUI")]
		[HarmonyPrefix]
		public static void EvaluateRestockItemPanelUIPrefix(RestockItemBoardGameScreen __instance)
		{
			Plugin.ShopUIManager.SetupBoardgameShopUI(__instance);
		}
	}
	[HarmonyPatch(typeof(RestockItemScreen))]
	public class RestockItemScreenPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPrefix]
		public static void EvaluateRestockItemPanelUIPrefix(RestockItemScreen __instance)
		{
			Plugin.ShopUIManager.SetupItemShopUI(__instance);
		}
	}
	[HarmonyPatch(typeof(RestockManager))]
	public class RestockManagerPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPostfix]
		public static void InitPostfix(RestockManager __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			foreach (ECardExpansionType value in AssetData.CollectionPackToExpansion.Values)
			{
				__instance.GenerateCardMarketPrice(value);
				foreach (MarketPrice cardMarketPrice in ModSaveManager.Instance.GetSaveData<ECardExpansionType, CardExpansionSaveData>(value).CardMarketPriceList)
				{
					MarketPrice val = cardMarketPrice;
					if (val.pastPricePercentChangeList == null)
					{
						val.pastPricePercentChangeList = new List<float>();
					}
					cardMarketPrice.pastPricePercentChangeList.Add(cardMarketPrice.pricePercentChangeList);
				}
			}
		}

		[HarmonyPatch("GenerateCardMarketPrice")]
		[HarmonyPrefix]
		public static bool GenerateCardMarketPricePrefix(ECardExpansionType expansionType)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(expansionType, out var value))
			{
				return true;
			}
			List<MonsterData> list = value.Cards.Values.OrderB

BepInEx/plugins/Scripts.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Scripts")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+ce67eb128bbeaa3b2f79707fdda58b7d70eedf4b")]
[assembly: AssemblyProduct("Scripts")]
[assembly: AssemblyTitle("Scripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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;
		}
	}
}
public class CeilingHangingInteractableObject : InteractableObject
{
	public override void Update()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: 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_00ec: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		if (!base.m_IsMovingObject)
		{
			return;
		}
		((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, base.m_TargetMoveObjectPosition, Time.deltaTime * 7.5f);
		bool flag = false;
		int mask = LayerMask.GetMask(new string[2] { "MoveStateBlockedArea", "Customer" });
		if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, mask).Length == 0)
		{
			if (base.m_PlaceObjectInShopOnly)
			{
				if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidArea" })).Length != 0)
				{
					flag = true;
				}
			}
			else if (base.m_PlaceObjectInShopOnly && Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidWarehouseArea" })).Length != 0)
			{
				flag = true;
			}
		}
		base.m_IsMovingObjectValidState = flag;
		ShelfManager.SetMoveObjectPreviewModelValidState(flag);
	}

	public override void OnPlacedMovedObject()
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		CSingleton<InteractionPlayerController>.Instance.OnExitMoveObjectMode();
		base.m_IsMovingObject = false;
		((Component)this).gameObject.layer = base.m_OriginalLayer;
		((Collider)base.m_BoxCollider).enabled = true;
		for (int i = 0; i < base.m_BoxColliderList.Count; i++)
		{
			((Collider)base.m_BoxColliderList[i]).enabled = true;
		}
		int mask = LayerMask.GetMask(new string[1] { "ShopModel" });
		Vector3 position = ((Component)base.m_PickupObjectMesh).transform.position;
		position.y += 0.2f;
		RaycastHit val = default(RaycastHit);
		if (Physics.Raycast(position, Vector3.up, ref val, 50f, mask))
		{
			((Component)this).transform.position = ((RaycastHit)(ref val)).point;
		}
		((Component)base.m_MoveStateValidArea).gameObject.SetActive(true);
		ShelfManager.DisableMoveObjectPreviewMode();
		if (Object.op_Implicit((Object)(object)base.m_BoxCollider))
		{
			((Component)CSingleton<ShelfManager>.Instance.m_MoveObjectCustomerBlocker).gameObject.SetActive(false);
		}
		if (!base.m_IsBoxedUp && Object.op_Implicit((Object)(object)base.m_InteractablePackagingBox_Shelf))
		{
			if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp))
			{
				((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position;
			}
			base.m_InteractablePackagingBox_Shelf.EmptyBoxShelf();
			((InteractableObject)base.m_InteractablePackagingBox_Shelf).OnDestroyed();
		}
		if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp) && !base.m_IsBoxedUp)
		{
			((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position;
			((Component)base.m_Shelf_WorldUIGrp).transform.rotation = ((Component)this).transform.rotation;
		}
		if (Object.op_Implicit((Object)(object)base.m_NavMeshCut))
		{
			base.m_NavMeshCut.SetActive(false);
			base.m_NavMeshCut.SetActive(true);
		}
	}
}
namespace Scripts
{
	public class CustomInteractableDeco : InteractableDecoration
	{
		public bool m_CanBePlacedOnFurniture;

		public bool m_IsDecorationCeiling;

		public override void Update()
		{
			if (((InteractableObject)this).m_IsMovingObject)
			{
				UpdatePosition();
				bool isMovingObjectValidState = (((InteractableObject)this).m_IsDecorationVertical ? IsValidWallPlacement() : (m_IsDecorationCeiling ? IsValidCeilingPlacement() : IsValidFloorOrFurniturePlacement()));
				((InteractableObject)this).m_IsMovingObjectValidState = isMovingObjectValidState;
				ShelfManager.SetMoveObjectPreviewModelValidState(((InteractableObject)this).m_IsMovingObjectValidState);
			}
		}

		public override void OnPlacedMovedObject()
		{
			//IL_00df: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			CSingleton<InteractionPlayerController>.Instance.OnExitMoveObjectMode();
			((Component)((InteractableObject)this).m_MoveStateValidArea).gameObject.SetActive(true);
			((Component)this).gameObject.layer = ((InteractableObject)this).m_OriginalLayer;
			((InteractableObject)this).m_IsMovingObject = false;
			if (((InteractableObject)this).m_BoxCollider != null)
			{
				((Component)CSingleton<ShelfManager>.Instance.m_MoveObjectCustomerBlocker).gameObject.SetActive(false);
				((Collider)((InteractableObject)this).m_BoxCollider).enabled = true;
			}
			foreach (BoxCollider boxCollider in ((InteractableObject)this).m_BoxColliderList)
			{
				((Collider)boxCollider).enabled = true;
			}
			if (!m_CanBePlacedOnFurniture && !m_IsDecorationCeiling && !((InteractableObject)this).m_IsDecorationVertical)
			{
				Vector3 position = ((Component)this).transform.position;
				position.y = 0f;
				((Component)this).transform.position = position;
			}
			else if (m_IsDecorationCeiling)
			{
				Vector3 position2 = ((Component)this).transform.position;
				Bounds bounds = ((Collider)((InteractableObject)this).m_BoxCollider).bounds;
				position2.y = 3f - (((Bounds)(ref bounds)).max.y - ((Component)this).transform.position.y);
				((Component)this).transform.position = position2;
			}
			else if (((InteractableObject)this).m_IsDecorationVertical && ((InteractableObject)this).m_LastHitTransform != null)
			{
				((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker = null;
				DecoBlocker component = ((Component)((InteractableObject)this).m_LastHitTransform).GetComponent<DecoBlocker>();
				if (component != null)
				{
					((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker = component.m_LockedRoomBlocker;
					((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker.AddToVerticalDecoObjectList((InteractableObject)(object)this);
					if (((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker.m_MainRoomIndex != -1)
					{
						((InteractableObject)this).m_IsVerticalSnapToWarehouseWall = false;
						((InteractableObject)this).m_VerticalSnapWallIndex = ((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker.m_MainRoomIndex;
					}
					else if (((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker.m_StoreRoomIndex != -1)
					{
						((InteractableObject)this).m_IsVerticalSnapToWarehouseWall = true;
						((InteractableObject)this).m_VerticalSnapWallIndex = ((InteractableObject)this).m_DecoPlaccedLockedRoomBlocker.m_StoreRoomIndex;
					}
				}
			}
			ShelfManager.DisableMoveObjectPreviewMode();
			if (!((InteractableObject)this).m_IsBoxedUp && ((InteractableObject)this).m_InteractablePackagingBox_Shelf != null)
			{
				if (((InteractableObject)this).m_Shelf_WorldUIGrp != null)
				{
					((Component)((InteractableObject)this).m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position;
				}
				((InteractableObject)this).m_InteractablePackagingBox_Shelf.EmptyBoxShelf();
				((InteractableObject)((InteractableObject)this).m_InteractablePackagingBox_Shelf).OnDestroyed();
			}
			if (((InteractableObject)this).m_Shelf_WorldUIGrp != null && !((InteractableObject)this).m_IsBoxedUp)
			{
				((Component)((InteractableObject)this).m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position;
				((Component)((InteractableObject)this).m_Shelf_WorldUIGrp).transform.rotation = ((Component)this).transform.rotation;
			}
			if (((InteractableObject)this).m_NavMeshCut != null)
			{
				((InteractableObject)this).m_NavMeshCut.SetActive(false);
				((InteractableObject)this).m_NavMeshCut.SetActive(true);
			}
		}

		private void UpdatePosition()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, ((InteractableObject)this).m_TargetMoveObjectPosition, Time.deltaTime * 7.5f);
			if (m_IsDecorationCeiling)
			{
				float y = ((Component)this).transform.position.y;
				Bounds bounds = ((Collider)((InteractableObject)this).m_BoxCollider).bounds;
				if (y + (((Bounds)(ref bounds)).max.y - ((Component)this).transform.position.y) > 3f)
				{
					Vector3 position = ((Component)this).transform.position;
					bounds = ((Collider)((InteractableObject)this).m_BoxCollider).bounds;
					position.y = 3f - (((Bounds)(ref bounds)).max.y - ((Component)this).transform.position.y);
					((Component)this).transform.position = position;
				}
			}
			else if (((InteractableObject)this).m_IsDecorationVertical && ((InteractableObject)this).m_LastHitTransform != null)
			{
				Quaternion rotation = Quaternion.FromToRotation(Vector3.forward, ((InteractableObject)this).m_HitNormal);
				Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
				eulerAngles.x = 0f;
				Quaternion rotation2 = ((Component)this).transform.rotation;
				eulerAngles.z = ((Quaternion)(ref rotation2)).eulerAngles.z;
				if (((InteractableObject)this).m_IsFlipped)
				{
					eulerAngles.y += 180f;
				}
				((Quaternion)(ref rotation)).eulerAngles = eulerAngles;
				((Component)this).transform.rotation = rotation;
			}
		}

		private bool IsValidFloorOrFurniturePlacement()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (GetCollisions("MoveStateBlockedArea", "Customer").Length != 0)
			{
				return false;
			}
			if (((InteractableObject)this).m_PlaceObjectInShopOnly && GetCollisions("MoveStateValidArea").Length == 0)
			{
				return false;
			}
			if (((InteractableObject)this).m_PlaceObjectInWarehouseOnly && GetCollisions("MoveStateValidWarehouseArea").Length == 0)
			{
				return false;
			}
			if (m_CanBePlacedOnFurniture)
			{
				Bounds bounds = ((Collider)((InteractableObject)this).m_BoxCollider).bounds;
				Vector3 center = ((Bounds)(ref bounds)).center;
				bounds = ((Collider)((InteractableObject)this).m_BoxCollider).bounds;
				center.y = ((Bounds)(ref bounds)).min.y;
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(center, Vector3.down, ref val, 0.1f) && ((RaycastHit)(ref val)).normal.y > 0.9f)
				{
					return true;
				}
			}
			return ((Component)this).transform.position.y <= 0.1f;
		}

		private bool IsValidCeilingPlacement()
		{
			//IL_0006: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			Bounds bounds = ((Collider)((InteractableObject)this).m_BoxCollider).bounds;
			float num = ((Bounds)(ref bounds)).max.y - ((Component)this).transform.position.y;
			float num2 = 3.1f - num;
			if (((Component)this).transform.position.y < num2 && ((Component)this).transform.position.y > num2 - 0.2f)
			{
				return GetCollisions("MoveStateValidArea", "MoveStateValidWarehouseArea").Length != 0;
			}
			return false;
		}

		private bool IsValidWallPlacement()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((InteractableObject)this).m_TargetMoveObjectPosition - ((Component)this).transform.position;
			if (((Vector3)(ref val)).magnitude <= 0.02f && ((Component)this).transform.position.y >= 0.1f)
			{
				Collider[] collisions = GetCollisions("DecorationBlocker");
				if (collisions.Length != 0 && GetCollisions("DecorationMoveStateBlockedArea").Length == 0)
				{
					((InteractableObject)this).m_LastHitTransform = ((Component)collisions[0]).transform;
					return true;
				}
			}
			((InteractableObject)this).m_LastHitTransform = null;
			return false;
		}

		private Collider[] GetCollisions(params string[] layers)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			int mask = LayerMask.GetMask(layers);
			return Physics.OverlapBox(((InteractableObject)this).m_MoveStateValidArea.position, ((InteractableObject)this).m_MoveStateValidArea.lossyScale / 2f, ((InteractableObject)this).m_MoveStateValidArea.rotation, mask);
		}
	}
	public class CustomInteractableObject : InteractableObject
	{
		public override void Awake()
		{
		}

		public override void Update()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00ec: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (!base.m_IsMovingObject)
			{
				return;
			}
			((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, base.m_TargetMoveObjectPosition, Time.deltaTime * 7.5f);
			bool flag = false;
			int mask = LayerMask.GetMask(new string[2] { "MoveStateBlockedArea", "Customer" });
			if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, mask).Length == 0)
			{
				if (base.m_PlaceObjectInShopOnly)
				{
					if (Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidArea" })).Length != 0)
					{
						flag = true;
					}
				}
				else if (base.m_PlaceObjectInWarehouseOnly && Physics.OverlapBox(base.m_MoveStateValidArea.position, base.m_MoveStateValidArea.lossyScale / 2f, base.m_MoveStateValidArea.rotation, LayerMask.GetMask(new string[1] { "MoveStateValidWarehouseArea" })).Length != 0)
				{
					flag = true;
				}
			}
			base.m_IsMovingObjectValidState = flag;
			ShelfManager.SetMoveObjectPreviewModelValidState(flag);
		}

		public override void OnPlacedMovedObject()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			CSingleton<InteractionPlayerController>.Instance.OnExitMoveObjectMode();
			base.m_IsMovingObject = false;
			((Component)this).gameObject.layer = base.m_OriginalLayer;
			((Collider)base.m_BoxCollider).enabled = true;
			for (int i = 0; i < base.m_BoxColliderList.Count; i++)
			{
				((Collider)base.m_BoxColliderList[i]).enabled = true;
			}
			int mask = LayerMask.GetMask(new string[1] { "ShopModel" });
			Vector3 position = ((Component)base.m_PickupObjectMesh).transform.position;
			position.y += 0.2f;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(position, Vector3.down, ref val, 100f, mask))
			{
				((Component)this).transform.position = ((RaycastHit)(ref val)).point;
			}
			((Component)base.m_MoveStateValidArea).gameObject.SetActive(true);
			ShelfManager.DisableMoveObjectPreviewMode();
			if (Object.op_Implicit((Object)(object)base.m_BoxCollider))
			{
				((Component)CSingleton<ShelfManager>.Instance.m_MoveObjectCustomerBlocker).gameObject.SetActive(false);
			}
			if (!base.m_IsBoxedUp && Object.op_Implicit((Object)(object)base.m_InteractablePackagingBox_Shelf))
			{
				if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp))
				{
					((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position;
				}
				base.m_InteractablePackagingBox_Shelf.EmptyBoxShelf();
				((InteractableObject)base.m_InteractablePackagingBox_Shelf).OnDestroyed();
			}
			if (Object.op_Implicit((Object)(object)base.m_Shelf_WorldUIGrp) && !base.m_IsBoxedUp)
			{
				((Component)base.m_Shelf_WorldUIGrp).transform.position = ((Component)this).transform.position;
				((Component)base.m_Shelf_WorldUIGrp).transform.rotation = ((Component)this).transform.rotation;
			}
			if (Object.op_Implicit((Object)(object)base.m_NavMeshCut))
			{
				base.m_NavMeshCut.SetActive(false);
				base.m_NavMeshCut.SetActive(true);
			}
		}
	}
	public class VideoPlayerController : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ErrorEventHandler <>9__9_1;

			internal void <Start>b__9_1(VideoPlayer source, string error)
			{
				Debug.Log((object)error);
			}
		}

		public bool m_StopOnPickupObject;

		public AudioSource m_AudioSource;

		public VideoPlayer m_VideoPlayer;

		public InteractableObject m_InteractableObject;

		private bool isPrepared;

		private InteractableObject InteractableObject
		{
			get
			{
				if (m_InteractableObject == null)
				{
					m_InteractableObject = ((Component)this).GetComponentInParent<InteractableObject>();
				}
				return m_InteractableObject;
			}
		}

		private VideoPlayer VideoPlayer
		{
			get
			{
				if (m_VideoPlayer == null)
				{
					m_VideoPlayer = ((Component)this).gameObject.GetComponent<VideoPlayer>();
				}
				return m_VideoPlayer;
			}
		}

		public void Start()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			if (m_AudioSource != null)
			{
				VideoPlayer.audioOutputMode = (VideoAudioOutputMode)1;
			}
			VideoPlayer.prepareCompleted += (EventHandler)delegate(VideoPlayer player)
			{
				if (player.audioTrackCount > 0)
				{
					player.SetTargetAudioSource((ushort)0, m_AudioSource);
				}
				else
				{
					Debug.LogWarning((object)"Video has no audio tracks!");
				}
				isPrepared = true;
			};
			VideoPlayer videoPlayer = VideoPlayer;
			object obj = <>c.<>9__9_1;
			if (obj == null)
			{
				ErrorEventHandler val = delegate(VideoPlayer source, string error)
				{
					Debug.Log((object)error);
				};
				<>c.<>9__9_1 = val;
				obj = (object)val;
			}
			videoPlayer.errorReceived += (ErrorEventHandler)obj;
			VideoPlayer.Prepare();
		}

		public void Update()
		{
			if (isPrepared)
			{
				if (InteractableObject.GetIsBoxedUp() && VideoPlayer.isPlaying)
				{
					VideoPlayer.Stop();
				}
				if (InteractableObject.GetIsMovingObject() && m_StopOnPickupObject && VideoPlayer.isPlaying)
				{
					VideoPlayer.Stop();
				}
				if (!InteractableObject.GetIsMovingObject() && !InteractableObject.GetIsBoxedUp() && !VideoPlayer.isPlaying)
				{
					VideoPlayer.Play();
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Scripts";

		public const string PLUGIN_NAME = "Scripts";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}