Decompiled source of Enhanced Prefab Loader v4.2.0

BepInEx/patchers/CollectionWeaver.dll

Decompiled 3 weeks 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 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using 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.2.0.0")]
[assembly: AssemblyInformationalVersion("4.2.0+a930b76e9dd967465fddfad4aa288d6d244774cb")]
[assembly: AssemblyProduct("Enhanced Prefab Loader Prepatch")]
[assembly: AssemblyTitle("EnhancedPrefabLoaderPrepatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.2.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_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: 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 = (from f in PatchDataManager.UserData[enumName]
					select f.Replace(" ", "").Replace("\t", "").Replace("\r", "")
						.Replace("\n", "")
						.Replace(".", "_") into f
					where !string.IsNullOrWhiteSpace(f)
					select f).ToHashSet();
				if (PatchDataManager.SavedData.TryGetValue(enumName, out var value))
				{
					List<string> list = new List<string>();
					foreach (KeyValuePair<string, int> item in value)
					{
						string text = item.Key.Replace(" ", "").Replace("\t", "").Replace("\r", "")
							.Replace("\n", "")
							.Replace(".", "_");
						if (!hashSet3.Contains(text))
						{
							list.Add(item.Key);
						}
						else if (hashSet.Contains(text))
						{
							Patcher.Log.LogWarning((object)("Field name '" + text + "' 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 '{text}'. Assigning new value.");
							list.Add(item.Key);
						}
						else
						{
							sortedDictionary[item.Value] = new FieldDefinition(text, val2.Attributes, (TypeReference)(object)val)
							{
								Constant = item.Value
							};
							hashSet.Add(text);
							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 savedDataPath = SavedDataPath;
			string text = Path.Combine(Path.GetDirectoryName(SavedDataPath) ?? string.Empty, "savedTypes");
			if (File.Exists(text))
			{
				Patcher.Log.LogInfo((object)("Found legacy saved enum values file at " + text + ". Migrating to " + savedDataPath + "."));
				try
				{
					SavedData = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, int>>>(File.ReadAllText(text)) ?? new Dictionary<string, Dictionary<string, int>>();
					File.Delete(text);
					Patcher.Log.LogInfo((object)("Successfully migrated and deleted legacy file " + text + "."));
				}
				catch (Exception ex)
				{
					Patcher.Log.LogError((object)("Failed to load and migrate legacy saved enum values from " + text + ": " + ex.Message + ". Initializing empty data."));
					SavedData = new Dictionary<string, Dictionary<string, int>>();
				}
			}
			else if (File.Exists(savedDataPath))
			{
				Patcher.Log.LogInfo((object)("Loading saved enum values from " + savedDataPath + "."));
				try
				{
					SavedData = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, int>>>(File.ReadAllText(savedDataPath)) ?? new Dictionary<string, Dictionary<string, int>>();
					Patcher.Log.LogInfo((object)("Loaded saved enum values from " + savedDataPath + "."));
				}
				catch (Exception ex2)
				{
					Patcher.Log.LogError((object)("Failed to load saved enum values from " + savedDataPath + ": " + ex2.Message + ". Initializing empty data."));
					SavedData = new Dictionary<string, Dictionary<string, int>>();
				}
			}
			else
			{
				Patcher.Log.LogInfo((object)"No saved enum values file found. Initializing empty data.");
				SavedData = new Dictionary<string, Dictionary<string, int>>();
			}
			Dictionary<string, Dictionary<string, int>> dictionary = new Dictionary<string, Dictionary<string, int>>();
			foreach (KeyValuePair<string, Dictionary<string, int>> savedDatum in SavedData)
			{
				dictionary[MapLegacyKey(savedDatum.Key)] = savedDatum.Value;
			}
			SavedData = dictionary;
		}

		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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			Log.Logger = (ILogger)(object)new BepInExLogger("CollectionWeaver");
			Log.LogLevel = (LogLevel)3;
			WeaverOptions val = new WeaverOptions();
			val.ExcludeNamespace("Unity*").ExcludeNamespace("Steam*").ExcludeNamespace("Facepunch*")
				.ExcludeNamespace("System*")
				.ExcludeNamespace("Mono*")
				.ExcludeNamespace("Microsoft*")
				.ExcludeField("GradeCardSubmitSet.m_CardDataList")
				.ExcludeField("ItemPriceGraphScreen.m_QuickViewGradedCardPriceTextList");
			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.2.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 3 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CollectionWeaver.Core;
using EnhancedPrefabLoader;
using EnhancedPrefabLoader.Assets;
using EnhancedPrefabLoader.Assets.Validation;
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.Properties;
using EnhancedPrefabLoader.Saves;
using EnhancedPrefabLoader.UI;
using EnhancedPrefabLoader.UI.Card;
using EnhancedPrefabLoader.UI.CollectionBinder;
using HarmonyLib;
using I2.Loc;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
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.2.0.0")]
[assembly: AssemblyInformationalVersion("4.2.0+a930b76e9dd967465fddfad4aa288d6d244774cb")]
[assembly: AssemblyProduct("Enhanced Prefab Loader")]
[assembly: AssemblyTitle("EnhancedPrefabLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.2.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__0 : 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__0(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.LoadScene(sceneName);
				goto IL_00b9;
			case 2:
				<>1__state = -1;
				goto IL_00b9;
			case 3:
				{
					<>1__state = -1;
					break;
				}
				IL_00b9:
				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();
		}
	}

	[IteratorStateMachine(typeof(<LoadLobbySceneAsyncPostfix>d__0))]
	[HarmonyPatch("LoadLobbySceneAsync")]
	[HarmonyPostfix]
	private static IEnumerator LoadLobbySceneAsyncPostfix(IEnumerator __result, string sceneName)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LoadLobbySceneAsyncPostfix>d__0(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 class CardSelectionService
	{
		private static readonly (EItemType pack, int foil, int grade)[] PackBonuses = new(EItemType, int, int)[7]
		{
			((EItemType)2, 0, 2),
			((EItemType)4, 0, 2),
			((EItemType)6, 1, 2),
			((EItemType)8, 1, 2),
			((EItemType)10, 1, 2),
			((EItemType)12, 1, 2),
			((EItemType)14, 1, 3)
		};

		public CardData SelectRandomCard()
		{
			//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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			ECardExpansionType val = RandomUtils.Weighted(CalculateExpansionWeights());
			(int foil, int grade) tuple = PackBonuses.Where(((EItemType pack, int foil, int grade) b) => CPlayerData.m_ShopLevel >= InventoryBase.GetUnlockItemLevelRequired(b.pack)).Aggregate((0, 0), ((int foil, int grade) acc, (EItemType pack, int foil, int grade) b) => (acc.foil + b.foil, acc.grade + b.grade));
			int item = tuple.foil;
			int item2 = tuple.grade;
			int num = InventoryBase.GetShownMonsterList(val).Count * CPlayerData.GetCardAmountPerMonsterType(val, true);
			int num2 = Random.Range(0, num);
			bool flag = (int)val == 2 && Random.Range(0, 100) < 50;
			CardData val2 = ((Random.Range(0, 100) < item2) ? CPlayerData.GetGradedCardData(new CompactCardDataAmount
			{
				cardSaveIndex = num2,
				expansionType = val,
				isDestiny = flag,
				amount = Random.Range(1, 11)
			}) : CPlayerData.GetCardData(num2, val, flag));
			if ((int)val == 2)
			{
				val2.isFoil = Random.Range(0, 100) < item;
			}
			return val2;
		}

		public CardData SelectPlayerCard(CardData targetCard, CustomerTradeData customerTradeData)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_002c: 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_0045: Invalid comparison between Unknown and I4
			//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_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_006d: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			int num = 4;
			float cardMarketPrice = CPlayerData.GetCardMarketPrice(targetCard);
			Dictionary<ECardExpansionType, float> dictionary = CalculateExpansionWeights();
			if (dictionary.ContainsKey(targetCard.expansionType))
			{
				dictionary[targetCard.expansionType] *= 3f;
				if ((int)targetCard.expansionType == 2)
				{
					dictionary[targetCard.expansionType] *= 4f;
				}
			}
			for (int i = 0; i < num; i++)
			{
				if (dictionary.Count <= 0)
				{
					break;
				}
				ECardExpansionType val = RandomUtils.Weighted(dictionary);
				CardData val2 = TryFindInExpansion(val, targetCard, cardMarketPrice);
				if (val2 != null)
				{
					return val2;
				}
				dictionary.Remove(val);
			}
			return null;
		}

		private CardData TryFindInExpansion(ECardExpansionType expansion, CardData targetCard, float targetPrice)
		{
			//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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_0034: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			List<int> cardCollectedList = CPlayerData.GetCardCollectedList(expansion, false);
			_ = InventoryBase.GetShownMonsterList(expansion).Count;
			CPlayerData.GetCardAmountPerMonsterType(expansion, true);
			List<CardData> list = new List<CardData>();
			for (int i = 0; i < cardCollectedList.Count; i++)
			{
				if (cardCollectedList[i] > 0)
				{
					float cardMarketPrice = CPlayerData.GetCardMarketPrice(i, expansion, false, 0);
					if (cardMarketPrice >= targetPrice * 0.75f && cardMarketPrice < targetPrice * 1.5f)
					{
						CardData cardData = CPlayerData.GetCardData(i, expansion, false);
						if (!cardData.IsEqual(targetCard))
						{
							list.Add(cardData);
						}
					}
				}
				if ((int)expansion != 2 || CPlayerData.GetCardCollectedList(expansion, true)[i] <= 0)
				{
					continue;
				}
				float cardMarketPrice2 = CPlayerData.GetCardMarketPrice(i, expansion, true, 0);
				if (cardMarketPrice2 >= targetPrice * 0.75f && cardMarketPrice2 < targetPrice * 1.5f)
				{
					CardData cardData2 = CPlayerData.GetCardData(i, expansion, true);
					if (!cardData2.IsEqual(targetCard))
					{
						list.Add(cardData2);
					}
				}
			}
			for (int j = 0; j < CPlayerData.m_GradedCardInventoryList.Count; j++)
			{
				CompactCardDataAmount val = CPlayerData.m_GradedCardInventoryList[j];
				if (val.expansionType != expansion)
				{
					continue;
				}
				float cardMarketPrice3 = CPlayerData.GetCardMarketPrice(val.cardSaveIndex, val.expansionType, val.isDestiny, val.amount);
				if (cardMarketPrice3 >= targetPrice * 0.75f && cardMarketPrice3 < targetPrice * 1.5f)
				{
					CardData gradedCardData = CPlayerData.GetGradedCardData(val);
					if (!gradedCardData.IsEqual(targetCard))
					{
						list.Add(gradedCardData);
					}
				}
			}
			if (list.Count != 0)
			{
				return list[Random.Range(0, list.Count)];
			}
			return null;
		}

		private Dictionary<ECardExpansionType, float> CalculateExpansionWeights()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ECardExpansionType, int> dictionary = (from kvp in AssetData.CardPackData
				group kvp by kvp.Value.Expansion).ToDictionary((IGrouping<ECardExpansionType, KeyValuePair<EItemType, CardPackData>> group) => group.Key, (IGrouping<ECardExpansionType, KeyValuePair<EItemType, CardPackData>> group) => group.Min((KeyValuePair<EItemType, CardPackData> kvp) => InventoryBase.GetUnlockItemLevelRequired(kvp.Key)));
			Dictionary<ECardExpansionType, float> dictionary2 = new Dictionary<ECardExpansionType, float>
			{
				{
					(ECardExpansionType)0,
					48f
				},
				{
					(ECardExpansionType)1,
					CalculateExpansionWeight((ECardExpansionType)1, InventoryBase.GetUnlockItemLevelRequired((EItemType)8), 15, 48)
				}
			};
			foreach (KeyValuePair<ECardExpansionType, int> item in dictionary)
			{
				dictionary2[item.Key] = CalculateExpansionWeight(item.Key, item.Value, 15, 48);
			}
			dictionary2[(ECardExpansionType)2] = CalculateDynamicExpansionWeight((ECardExpansionType)2, InventoryBase.GetUnlockItemLevelRequired((EItemType)2), 0.04f, dictionary2);
			return dictionary2;
		}

		private float CalculateExpansionWeight(ECardExpansionType ghost, int unlockLevel, int minWeight, int maxWeight)
		{
			if (CPlayerData.m_ShopLevel < unlockLevel)
			{
				return 0f;
			}
			if (CPlayerData.m_ShopLevel >= 50)
			{
				return maxWeight;
			}
			int num = CPlayerData.m_ShopLevel - unlockLevel;
			int num2 = 50 - unlockLevel;
			float num3 = (float)num / (float)num2;
			int num4 = maxWeight - minWeight;
			return (float)minWeight + (float)num4 * num3;
		}

		private float CalculateDynamicExpansionWeight(ECardExpansionType expansionType, int unlockLevel, float targetPercentage, Dictionary<ECardExpansionType, float> allWeights)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (CPlayerData.m_ShopLevel < unlockLevel)
			{
				return 0f;
			}
			int maxWeight = Mathf.RoundToInt(allWeights.Values.Sum() * targetPercentage / (1f - targetPercentage));
			return CalculateExpansionWeight(expansionType, unlockLevel, 1, maxWeight);
		}
	}
	public class CardTradeManager
	{
		private readonly CardSelectionService cardSelectionService = new CardSelectionService();

		private readonly CardTradePricingService cardTradePricingService = new CardTradePricingService();

		private readonly CardTradeUIManager cardTradeUIManager = new CardTradeUIManager();

		public void SetCustomer(CustomerTradeCardScreen screen, Customer customer, CustomerTradeData customerTradeData)
		{
			CSingleton<CustomerManager>.Instance.m_IsPlayerTrading = true;
			screen.m_CurrentCustomer = customer;
			screen.m_HasAccepted = false;
			screen.m_IsTrading = customerTradeData?.m_IsTrading ?? (Random.Range(0, 100) < Math.Min(40, CPlayerData.m_ShopLevel));
			screen.m_CardData_L = ((customerTradeData != null) ? customerTradeData.m_CardData_L : cardSelectionService.SelectRandomCard());
			if (screen.m_IsTrading)
			{
				SetupTradeMode(screen, customerTradeData);
			}
			else
			{
				SetupSellMode(screen, customerTradeData);
			}
			cardTradeUIManager.UpdateUI(screen);
		}

		private void SetupTradeMode(CustomerTradeCardScreen screen, CustomerTradeData customerTradeData)
		{
			screen.m_CardData_R = ((customerTradeData != null) ? customerTradeData.m_CardData_R : cardSelectionService.SelectPlayerCard(screen.m_CardData_L, customerTradeData));
			if (screen.m_CardData_R == null)
			{
				screen.m_IsTrading = false;
				SetupSellMode(screen, customerTradeData);
			}
		}

		private void SetupSellMode(CustomerTradeCardScreen screen, CustomerTradeData customerTradeData)
		{
			cardTradePricingService.CalculateAskingPrice(screen, screen.m_CardData_L, customerTradeData);
			if (customerTradeData != null)
			{
				screen.m_PriceSet = customerTradeData.m_PriceSet;
				screen.m_LastPriceSet = customerTradeData.m_LastPriceSet;
			}
			else
			{
				screen.OnInputTextUpdated("0");
			}
		}
	}
	public class CardTradePricingService
	{
		private static readonly (float threshold, float minBonus, float maxBonus)[] PriceTiers = new(float, float, float)[9]
		{
			(10f, 0f, 0.03f),
			(20f, 0f, 0.04f),
			(100f, 0.01f, 0.05f),
			(300f, 0.01f, 0.06f),
			(500f, 0.01f, 0.08f),
			(1000f, 0.01f, 0.1f),
			(2000f, 0.02f, 0.11f),
			(5000f, 0.03f, 0.12f),
			(8000f, 0.03f, 0.12f)
		};

		public void CalculateAskingPrice(CustomerTradeCardScreen screen, CardData customerCard, CustomerTradeData customerTradeData)
		{
			screen.m_SellCardMarketPrice = CPlayerData.GetCardMarketPrice(customerCard);
			if (customerTradeData != null)
			{
				screen.m_SellCardAskPrice = customerTradeData.m_SellCardAskPrice;
				screen.m_MaxDeclineCount = customerTradeData.m_MaxDeclineCount;
				screen.m_DeclineCount = customerTradeData.m_DeclineCount;
			}
			else
			{
				screen.m_SellCardAskPrice = CalculateInitialAskingPrice(screen.m_SellCardMarketPrice);
				screen.m_MaxDeclineCount = Random.Range(0, 5);
				screen.m_DeclineCount = 0;
			}
		}

		private float CalculateInitialAskingPrice(float marketPrice)
		{
			float num = Random.Range(0.7f, 1.2f);
			(float, float, float)[] priceTiers = PriceTiers;
			for (int i = 0; i < priceTiers.Length; i++)
			{
				(float, float, float) tuple = priceTiers[i];
				if (marketPrice > tuple.Item1)
				{
					num += Random.Range(tuple.Item2, tuple.Item3);
				}
			}
			return num * marketPrice;
		}
	}
	public class CardTradeUIManager
	{
		public void UpdateUI(CustomerTradeCardScreen screen)
		{
			SetTradingScreenText(screen);
			UpdateScreenGrpVisibility(screen);
			SetPriceTexts(screen);
			UpdateCardDisplays(screen);
			UpdateButtonVisibility(screen);
		}

		private void SetTradingScreenText(CustomerTradeCardScreen screen)
		{
			List<string> list = (screen.m_IsTrading ? screen.m_CustomerTradeCardTextList : screen.m_CustomerSellCardTextList);
			((TMP_Text)screen.m_CustomerTopText).text = LocalizationManager.GetTranslation("CustomerTrade/" + list[Random.Range(0, list.Count)], true, 0, true, false, (GameObject)null, (string)null, true);
			screen.m_CustomerTopTextAnim.Rewind();
			screen.m_CustomerTopTextAnim.Play();
		}

		private void UpdateScreenGrpVisibility(CustomerTradeCardScreen screen)
		{
			screen.m_CustomerTradingText.SetActive(screen.m_IsTrading);
			screen.m_CustomerSellingText.SetActive(!screen.m_IsTrading);
			screen.m_TradeGrp_R.SetActive(screen.m_IsTrading);
			screen.m_SellGrp_R.SetActive(!screen.m_IsTrading);
		}

		private void SetPriceTexts(CustomerTradeCardScreen screen)
		{
			string translation = LocalizationManager.GetTranslation("Market Price", true, 0, true, false, (GameObject)null, (string)null, true);
			string priceString = GameInstance.GetPriceString(CPlayerData.GetCardMarketPrice(screen.m_CardData_L), false, true, false, "F2");
			string translation2 = LocalizationManager.GetTranslation("Ask Price", true, 0, true, false, (GameObject)null, (string)null, true);
			string priceString2 = GameInstance.GetPriceString(screen.m_SellCardAskPrice, false, true, false, "F2");
			if (screen.m_IsTrading)
			{
				((TMP_Text)screen.m_MarketPrice_L).text = translation + " : " + priceString;
				return;
			}
			((TMP_Text)screen.m_MarketPrice_L).text = translation2 + " : " + priceString2 + "\n" + translation + " : " + priceString;
			screen.m_CardUI_Buying.SetCardUI(screen.m_CardData_L);
		}

		private void UpdateButtonVisibility(CustomerTradeCardScreen screen)
		{
			screen.m_AcceptBtn.SetActive(true);
			screen.m_CancelBtn.SetActive(true);
			screen.m_LetMeThinkBtn.SetActive(true);
			screen.m_DoneBtn.SetActive(false);
		}

		private void UpdateCardDisplays(CustomerTradeCardScreen screen)
		{
			screen.m_IsNewUI.SetActive(CPlayerData.GetCardAmount(screen.m_CardData_L) == 0);
			screen.m_CardUI_L.SetCardUI(screen.m_CardData_L);
			screen.m_CardUI_Album_L.SetCardUI(screen.m_CardData_L);
			((TMP_Text)screen.m_AlbumCardCount_L).text = GetCardCountText(screen.m_CardData_L);
			if (screen.m_IsTrading && screen.m_CardData_R != null)
			{
				screen.m_CardUI_R.SetCardUI(screen.m_CardData_R);
				screen.m_CardUI_Album.SetCardUI(screen.m_CardData_R);
				((TMP_Text)screen.m_AlbumCardCount).text = GetCardCountText(screen.m_CardData_R);
				float cardMarketPrice = CPlayerData.GetCardMarketPrice(screen.m_CardData_R);
				string translation = LocalizationManager.GetTranslation("Market Price", true, 0, true, false, (GameObject)null, (string)null, true);
				((TMP_Text)screen.m_MarketPrice_R).text = translation + " : " + GameInstance.GetPriceString(cardMarketPrice, false, true, false, "F2");
			}
		}

		private string GetCardCountText(CardData card)
		{
			if (card.cardGrade <= 0)
			{
				return "X" + CPlayerData.GetCardAmount(card);
			}
			if (!CPlayerData.HasGradedCardInAlbum(card))
			{
				return "X0";
			}
			return "X1";
		}
	}
	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);
				};
			}
		}
	}
	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;
					CS$<>8__locals0.loadingCoroutine = null;
					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 LoadScene(string scene)
		{
			if (scene == "Title")
			{
				Plugin.CollectionBinderUIManager.IsLoaded = false;
				Plugin.CardExpansionSelectUIManager.IsLoaded = false;
				ModSaveManager.Instance.SetToDefaults();
			}
			if (!IsLoadingComplete)
			{
				if (loadingCoroutine != null)
				{
					ModLogger.Warning("Loading already in progress.", "LoadScene", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\ModLoadManager.cs");
					return;
				}
				LoadingProgress = 0f;
				ModLogger.Info("Mod loading started", "LoadScene", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\ModLoadManager.cs");
				loadingCoroutine = runner.StartCoroutine(LoadModsAsync(Paths.PluginPath));
			}
		}

		[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
			};
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("EnhancedPrefabLoader", "Enhanced Prefab Loader", "4.2.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; private set; } = new CollectionBinderUIManager();


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


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


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


		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();
			CardUIGroupManager.RegisterConfigs();
			CardExpansionSelectUIManager.RegisterConfigs();
			harmony.PatchAll();
			ModLogger.Info("Plugin Enhanced Prefab Loader v:4.2.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 _)
		{
			CacheManager.Instance.ClearAllCaches();
			if (((Scene)(ref scene)).name == "Title" && !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.2.0";
	}
}
namespace EnhancedPrefabLoader.UI
{
	public class CardExpansionSelectUIManager
	{
		private CardExpansionSelectScreen cardExpansionSelectScreen;

		private FlowLayoutGroup flowLayoutGroup;

		private Transform cloneableButton;

		private bool isLoaded;

		public bool IsLoaded
		{
			get
			{
				return isLoaded;
			}
			set
			{
				isLoaded = value;
				if (!value)
				{
					cardExpansionSelectScreen = null;
				}
			}
		}

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


		private List<RectTransform> Buttons { get; set; } = new List<RectTransform>();


		public void RegisterConfigs()
		{
			ModConfigManager.Instance.OnSettingChanged("UI", "ExpansionButtonSize", delegate(Vector2 value)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				foreach (RectTransform button in Buttons)
				{
					if (button != null)
					{
						RectTransform val = button;
						val.sizeDelta = value;
					}
				}
			});
			ModConfigManager.Instance.OnSettingChanged("UI", "EnableFantasyRPG", delegate(bool value)
			{
				((Component)Buttons[ExpansionButtonMap.IndexOf((ECardExpansionType)4)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.OnSettingChanged("UI", "EnableMegabot", delegate(bool value)
			{
				((Component)Buttons[ExpansionButtonMap.IndexOf((ECardExpansionType)3)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.OnSettingChanged("UI", "EnableCatJob", delegate(bool value)
			{
				((Component)Buttons[ExpansionButtonMap.IndexOf((ECardExpansionType)5)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.OnSettingChanged("UI", "ExpansionSpacingX", delegate(float value)
			{
				if (flowLayoutGroup != null)
				{
					flowLayoutGroup.SpacingX = value;
				}
			});
			ModConfigManager.Instance.OnSettingChanged("UI", "ExpansionSpacingY", delegate(float value)
			{
				if (flowLayoutGroup != null)
				{
					flowLayoutGroup.SpacingY = value;
				}
			});
		}

		public void InitCustomUI()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_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_007a: 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_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_0198: 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)
			if (!IsLoaded)
			{
				if (cardExpansionSelectScreen == null)
				{
					cardExpansionSelectScreen = CSingleton<CardExpansionSelectScreen>.Instance;
				}
				cardExpansionSelectScreen.m_BtnHighlightList.Clear();
				Transform obj = cardExpansionSelectScreen.m_ScreenGrp.transform.Find("AnimGrp/Mask/UIGroup");
				Transform obj2 = ((obj is RectTransform) ? obj : null);
				Transform parent = obj2.parent;
				int siblingIndex = obj2.GetSiblingIndex();
				Vector2 anchorMax = ((RectTransform)obj2).anchorMax;
				Vector2 anchorMin = ((RectTransform)obj2).anchorMin;
				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;
				Transform val = obj2.Find("Tetramon_Button");
				if (val != null)
				{
					((Component)val).transform.SetParent((Transform)null);
					((Component)val).gameObject.SetActive(false);
					cloneableButton = val;
				}
				GameObject val2 = FlowLayoutGroup.Create(parent, isScrollable: true);
				flowLayoutGroup = val2.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 = val2.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;
				Object.Destroy((Object)(object)((Component)obj2).gameObject);
			}
			IsLoaded = true;
		}

		public void AddNewExpansionButton(string text, ECardExpansionType expansionType, bool enabled, UnityAction onClick = null)
		{
			//IL_007b: 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_004d: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (!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)
			{
				componentInChildren2.onClick = new ButtonClickedEvent();
				if (onClick != null)
				{
					((UnityEvent)componentInChildren2.onClick).AddListener(onClick);
				}
				((Selectable)componentInChildren2).navigation = Navigation.defaultNavigation;
			}
			((Component)val).gameObject.SetActive(enabled);
			ExpansionButtonMap.Add(expansionType);
			Buttons.Add((RectTransform)(object)((val is RectTransform) ? val : null));
			RectTransform? obj = (from t in ((Component)val).gameObject.GetComponentsInChildren<RectTransform>(true)
				where ((Object)t).name == "BGHighlight"
				select t).FirstOrDefault();
			GameObject item = ((obj != null) ? ((Component)obj).gameObject : null);
			cardExpansionSelectScreen.m_BtnHighlightList.Add(item);
			ModLogger.Debug($"Button added for {expansionType}", "AddNewExpansionButton", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\UI\\CardExpansionSelectUIManager.cs");
		}
	}
}
namespace EnhancedPrefabLoader.UI.CollectionBinder
{
	public class CollectionBinderUIManager
	{
		private bool isLoaded;

		private CollectionBinderUI collectionBinderUI;

		private FlowLayoutGroup flowLayoutGroup;

		private Transform cloneableButton;

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


		public bool IsLoaded
		{
			get
			{
				return isLoaded;
			}
			set
			{
				isLoaded = value;
				if (!value)
				{
					collectionBinderUI = null;
				}
			}
		}

		public void RegisterConfigs()
		{
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			ModConfigManager.Instance.BindSetting("UI", "EnableFantasyRPG", value: false);
			ModConfigManager.Instance.OnSettingChanged("UI", "EnableFantasyRPG", delegate(bool value)
			{
				((Component)collectionBinderUI.m_ExpansionBtnList[Buttons.IndexOf((ECardExpansionType)4)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.BindSetting("UI", "EnableMegabot", value: false);
			ModConfigManager.Instance.OnSettingChanged("UI", "EnableMegabot", delegate(bool value)
			{
				((Component)collectionBinderUI.m_ExpansionBtnList[Buttons.IndexOf((ECardExpansionType)3)]).gameObject.SetActive(value);
			});
			ModConfigManager.Instance.BindSetting("UI", "EnableCatJob", value: false);
			ModConfigManager.Instance.OnSettingChanged("UI", "EnableCatJob", 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.UI.Card
{
	public class CardUIGroupManager
	{
		private ConditionalWeakTable<CardUI, ModdedCardUI> moddedCardUIs;

		private ConditionalWeakTable<CardUI, Dictionary<string, Material>> cardBacks;

		private readonly Sprite cardMask;

		private ConditionalWeakTable<CardUI, ModdedCardUI> ModdedCardUIs => moddedCardUIs ?? (moddedCardUIs = CacheManager.Instance.GetWeakCache<CardUI, ModdedCardUI>("ModdedCardUI"));

		private ConditionalWeakTable<CardUI, Dictionary<string, Material>> CardBacks => cardBacks ?? (cardBacks = CacheManager.Instance.GetWeakCache<CardUI, Dictionary<string, Material>>("CardBacks"));

		public CardUIGroupManager()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			CacheManager.Instance.OnCachesCleared += OnCachesCleared;
			byte[] array = Resources.CardMask;
			if (array != null && array.Length != 0)
			{
				Texture2D val = new Texture2D(2, 2);
				ImageConversion.LoadImage(val, array);
				((Object)val).name = "CardMask";
				cardMask = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
		}

		public void RegisterConfigs()
		{
		}

		public void SetDirty(CardUI cardUI)
		{
			if (ModdedCardUIs.TryGetValue(cardUI, out var value))
			{
				value.IsDirty = true;
			}
		}

		public void SetModdedCardUI(CardUI cardUI)
		{
			if (!ModdedCardUIs.TryGetValue(cardUI, out var value))
			{
				value = ((Component)cardUI).gameObject.AddComponent<ModdedCardUI>();
				value.Initialize(cardUI);
				ModdedCardUIs.Add(cardUI, value);
			}
		}

		public void ApplyCardUIChanges(CardUI cardUI, CardData cardData, CardExpansion expansion)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			SetCardBack(cardUI, cardData, expansion);
			if (ModdedCardUIs.TryGetValue(cardUI, out var value))
			{
				value.ApplyModdedCardSpecs(doApply: true, cardMask, expansion.Cards[cardData.monsterType].CardFoilMask);
				((Component)value).gameObject.SetActive(false);
				((Component)value).gameObject.SetActive(true);
			}
		}

		public void RestoreOriginalState(CardUI cardUI)
		{
			RestoreCardBack(cardUI);
			if (ModdedCardUIs.TryGetValue(cardUI, out var value))
			{
				value.ApplyModdedCardSpecs(doApply: false, null, null);
			}
		}

		private void OnCachesCleared()
		{
			moddedCardUIs = null;
			cardBacks = null;
		}

		private void SetCardBack(CardUI cardUI, CardData cardData, CardExpansion expansion)
		{
			Card3dUIGroup card3dUIGroup = cardUI.m_Card3dUIGroup;
			Renderer renderer = ((card3dUIGroup != null) ? card3dUIGroup.m_CardBackMesh.GetComponent<Renderer>() : null);
			if (renderer != null)
			{
				Dictionary<string, Material> orCreateValue = CardBacks.GetOrCreateValue(cardUI);
				if (!orCreateValue.ContainsKey("OriginalCardBack"))
				{
					orCreateValue["OriginalCardBack"] = renderer.material;
				}
				Material orAdd = orCreateValue.GetOrAdd<string, Material>(expansion.Name, delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0021: 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_004e: Expected O, but got Unknown
					Material val = new Material(renderer.material);
					val.CopyPropertiesFromMaterial(renderer.material);
					val.SetTexture("_BaseMap", expansion.CardBack);
					val.SetTexture("_EmissionMap", expansion.CardBack);
					return val;
				});
				renderer.material = orAdd;
			}
		}

		private void RestoreCardBack(CardUI cardUI)
		{
			Card3dUIGroup card3dUIGroup = cardUI.m_Card3dUIGroup;
			object obj;
			if (card3dUIGroup == null)
			{
				obj = null;
			}
			else
			{
				GameObject cardBackMesh = card3dUIGroup.m_CardBackMesh;
				obj = ((cardBackMesh != null) ? cardBackMesh.GetComponent<Renderer>() : null);
			}
			Renderer val = (Renderer)obj;
			if (val != null && CardBacks.TryGetValue(cardUI, out var value) && value.TryGetValue("OriginalCardBack", out var value2))
			{
				val.material = value2;
			}
		}
	}
	public class ModdedCardUI : MonoBehaviour
	{
		private bool isInitialized;

		private CardUI cardUI;

		private GameObject foilMask;

		private Transform foilGrpParent;

		private Vector2 centerFrameImageAnchorPos;

		private Vector2 centerFrameImageOffsetMin;

		private Vector2 centerFrameImageOffsetMax;

		private Vector2 centerFrameMaskOffsetMin;

		private Vector2 centerFrameMaskOffsetMax;

		public bool IsDirty { get; set; }

		public void Initialize(CardUI cardUI)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			if (!isInitialized)
			{
				this.cardUI = cardUI;
				Transform transform = ((Component)this.cardUI.m_CenterFrameImage).transform;
				RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				centerFrameImageAnchorPos = val.anchoredPosition;
				centerFrameImageOffsetMin = val.offsetMin;
				centerFrameImageOffsetMax = val.offsetMax;
				Transform transform2 = this.cardUI.m_CenterFrameMaskGrp.transform;
				RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
				centerFrameMaskOffsetMin = val2.offsetMin;
				centerFrameMaskOffsetMax = val2.offsetMax;
				foilGrpParent = cardUI.m_FoilGrp.transform.parent;
				CreateFoilMask();
				isInitialized = true;
			}
		}

		public void ApplyModdedCardSpecs(bool doApply, Sprite cardMask, Sprite cardFoilMask)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (doApply)
			{
				if (IsDirty)
				{
					RestoreDefaults();
					IsDirty = false;
				}
				foilMask.GetComponent<Image>().sprite = cardFoilMask;
				cardUI.m_CenterFoilGlitter.transform.SetParent(foilMask.transform, false);
				cardUI.m_FoilGrp.transform.SetParent(foilMask.transform, false);
				cardUI.m_EvoAndArtistNameGrp.SetActive(false);
				cardUI.m_StatGrp.SetActive(false);
				((Component)cardUI.m_RarityImage).gameObject.SetActive(false);
				((Component)cardUI.m_FirstEditionText).gameObject.SetActive(false);
				((Component)cardUI.m_NumberText).gameObject.SetActive(false);
				((Component)cardUI.m_MonsterNameText).gameObject.SetActive(false);
				Transform transform = ((Component)cardUI.m_CenterFrameImage).transform;
				Transform obj = ((transform is RectTransform) ? transform : null);
				((RectTransform)obj).anchoredPosition = Vector2.zero;
				((RectTransform)obj).offsetMax = new Vector2(-22f, 206f);
				((RectTransform)obj).offsetMin = new Vector2(14f, -206f);
				cardUI.m_CenterFrameMaskImage.sprite = cardMask;
			}
			else
			{
				RestoreDefaults();
			}
		}

		private void RestoreDefaults()
		{
			//IL_0059: 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_0085: 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_009c: 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_012b: Invalid comparison between Unknown and I4
			cardUI.m_FoilGrp.transform.SetParent(foilGrpParent, false);
			cardUI.m_CenterFoilGlitter.transform.SetParent(cardUI.m_CenterFrameMaskGrp.transform, false);
			Transform transform = cardUI.m_CenterFrameMaskGrp.transform;
			Transform obj = ((transform is RectTransform) ? transform : null);
			((RectTransform)obj).offsetMin = centerFrameMaskOffsetMin;
			((RectTransform)obj).offsetMax = centerFrameMaskOffsetMax;
			Transform transform2 = ((Component)cardUI.m_CenterFrameImage).transform;
			Transform obj2 = ((transform2 is RectTransform) ? transform2 : null);
			((RectTransform)obj2).anchoredPosition = centerFrameImageAnchorPos;
			((RectTransform)obj2).offsetMax = centerFrameImageOffsetMax;
			((RectTransform)obj2).offsetMin = centerFrameImageOffsetMin;
			cardUI.m_EvoAndArtistNameGrp.SetActive(true);
			cardUI.m_StatGrp.SetActive(true);
			((Component)cardUI.m_RarityImage).gameObject.SetActive(true);
			((Component)cardUI.m_FirstEditionText).gameObject.SetActive(true);
			((Component)cardUI.m_NumberText).gameObject.SetActive(true);
			((Component)cardUI.m_MonsterNameText).gameObject.SetActive((int)cardUI.m_CardData.borderType != 5);
		}

		private void CreateFoilMask()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_006b: 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_0081: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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)
			foilMask = new GameObject("FoilMask", new Type[1] { typeof(RectTransform) });
			Transform transform = foilMask.transform;
			RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			((Transform)val).SetParent(cardUI.m_CenterFrameMaskGrp.transform, false);
			((Transform)val).SetAsLastSibling();
			Transform transform2 = cardUI.m_CenterFrameMaskGrp.transform;
			RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
			if (val2 != null)
			{
				val.anchorMin = Vector2.zero;
				val.anchorMax = Vector2.one;
				val.anchoredPosition = Vector2.zero;
				val.sizeDelta = Vector2.zero;
				((Transform)val).localRotation = Quaternion.identity;
				((Transform)val).localScale = Vector3.one;
				val.pivot = val2.pivot;
			}
			((Component)val).gameObject.AddComponent<Mask>().showMaskGraphic = false;
			Image component = cardUI.m_CenterFrameMaskGrp.GetComponent<Image>();
			if (component != null)
			{
				Image obj = ((Component)val).gameObject.AddComponent<Image>();
				obj.sprite = component.sprite;
				((Graphic)obj).color = ((Graphic)component).color;
				((Graphic)obj).material = ((Graphic)component).material;
				((Graphic)obj).raycastTarget = false;
				obj.type = component.type;
				obj.fillMethod = component.fillMethod;
				obj.fillAmount = component.fillAmount;
			}
			else
			{
				ModLogger.Error("CenterFrameMask has no mask component", "CreateFoilMask", "D:\\Projects\\EnhancedPrefabLoader\\EnhancedPrefabLoader\\UI\\Card\\ModdedCardUI.cs");
				Object.Destroy((Object)(object)foilMask);
				foilMask = null;
			}
		}
	}
}
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 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, modId);
		}

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

		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 = GenerateKey(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 = GenerateKey(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 SetToDefaults()
		{
			foreach (KeyValuePair<string, ModSaveData> modSaveDatum in modSaveData)
			{
				modSaveData[modSaveDatum.Key].SetAllDataDefaults();
			}
		}

		private void SetSaveData<TEnum, TSaveData>(TEnum enumValue, TSaveData data, string modId) where TEnum : Enum where TSaveData : class
		{
			if (modId != null)
			{
				string key = GenerateKey(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, string modId) where TSaveData : class
		{
			if (modId != null)
			{
				string key = GenerateKey(category, assetName);
				if (!this.modSaveData.TryGetValue(modId, out var value))
				{
					value = (this.modSaveData[modId] = new ModSaveData());
				}
				value.SetData(key, data);
			}
		}

		private string GenerateKey<TEnum>(TEnum enumValue) where TEnum : Enum
		{
			return $"{typeof(TEnum).Name}:{enumValue}";
		}

		private string GenerateKey(string category, string assetName)
		{
			return category + ":" + assetName;
		}
	}
}
namespace EnhancedPrefabLoader.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("EnhancedPrefabLoader.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] CardMask => (byte[])ResourceManager.GetObject("CardMask", resourceCulture);

		internal Resources()
		{
		}
	}
}
namespace EnhancedPrefabLoader.Patches
{
	[HarmonyPatch(typeof(Card3dUIGroup))]
	public class Card3dUIGroupPatches
	{
		[HarmonyPatch("EvaluateCardGrade")]
		[HarmonyPostfix]
		private static void EvaluateCardGradePostfix(Card3dUIGroup __instance, CardData cardData)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (AssetData.CardExpanions.TryGetValue(cardData.expansionType, out var value))
			{
				((TMP_Text)__instance.m_GradeExpansionRarityText).text = TranspilerMethods.Prettierize(value.Name) + " " + CPlayerData.GetFullCardTypeName(cardData, false);
			}
		}
	}
	[HarmonyPatch(typeof(CardExpansionSelectScreen))]
	public class CardExpansionSelectScreenPatches
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__1_0;

			public static UnityAction <>9__1_1;

			public static UnityAction <>9__1_2;

			public static UnityAction <>9__1_3;

			public static UnityAction <>9__1_4;

			public static UnityAction <>9__1_5;

			public static Func<KeyValuePair<ECardExpansionType, CardExpansion>, int> <>9__1_6;

			internal void <OpenScreenPrefix>b__1_0()
			{
				CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(0);
			}

			internal void <OpenScreenPrefix>b__1_1()
			{
				CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(1);
			}

			internal void <OpenScreenPrefix>b__1_2()
			{
				CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(2);
			}

			internal void <OpenScreenPrefix>b__1_3()
			{
				CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(4);
			}

			internal void <OpenScreenPrefix>b__1_4()
			{
				CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(3);
			}

			internal void <OpenScreenPrefix>b__1_5()
			{
				CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(5);
			}

			internal int <OpenScreenPrefix>b__1_6(KeyValuePair<ECardExpansionType, CardExpansion> kvp)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected I4, but got Unknown
				return (int)kvp.Key;
			}
		}

		private static bool buttonsAdded;

		[HarmonyPatch("OpenScreen")]
		[HarmonyPrefix]
		private static void OpenScreenPrefix(ref ECardExpansionType initCardExpansion)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//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_009f: Expected O, but got Unknown
			//IL_00e4: 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_00ef: Expected O, but got Unknown
			//IL_0134: 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_013f: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			Plugin.CardExpansionSelectUIManager.InitCustomUI();
			if (!buttonsAdded)
			{
				CardExpansionSelectUIManager cardExpansionSelectUIManager = Plugin.CardExpansionSelectUIManager;
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(0);
					};
					<>c.<>9__1_0 = val;
					obj = (object)val;
				}
				cardExpansionSelectUIManager.AddNewExpansionButton("Tetramon", (ECardExpansionType)0, enabled: true, (UnityAction)obj);
				CardExpansionSelectUIManager cardExpansionSelectUIManager2 = Plugin.CardExpansionSelectUIManager;
				object obj2 = <>c.<>9__1_1;
				if (obj2 == null)
				{
					UnityAction val2 = delegate
					{
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(1);
					};
					<>c.<>9__1_1 = val2;
					obj2 = (object)val2;
				}
				cardExpansionSelectUIManager2.AddNewExpansionButton("Destiny", (ECardExpansionType)1, enabled: true, (UnityAction)obj2);
				CardExpansionSelectUIManager cardExpansionSelectUIManager3 = Plugin.CardExpansionSelectUIManager;
				object obj3 = <>c.<>9__1_2;
				if (obj3 == null)
				{
					UnityAction val3 = delegate
					{
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(2);
					};
					<>c.<>9__1_2 = val3;
					obj3 = (object)val3;
				}
				cardExpansionSelectUIManager3.AddNewExpansionButton("Ghost", (ECardExpansionType)2, enabled: true, (UnityAction)obj3);
				bool value = ModConfigManager.Instance.GetValue<bool>("UI", $"Enable{(object)(ECardExpansionType)4}");
				CardExpansionSelectUIManager cardExpansionSelectUIManager4 = Plugin.CardExpansionSelectUIManager;
				object obj4 = <>c.<>9__1_3;
				if (obj4 == null)
				{
					UnityAction val4 = delegate
					{
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(4);
					};
					<>c.<>9__1_3 = val4;
					obj4 = (object)val4;
				}
				cardExpansionSelectUIManager4.AddNewExpansionButton("Fantasy", (ECardExpansionType)4, value, (UnityAction)obj4);
				bool value2 = ModConfigManager.Instance.GetValue<bool>("UI", $"Enable{(object)(ECardExpansionType)3}");
				CardExpansionSelectUIManager cardExpansionSelectUIManager5 = Plugin.CardExpansionSelectUIManager;
				object obj5 = <>c.<>9__1_4;
				if (obj5 == null)
				{
					UnityAction val5 = delegate
					{
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(3);
					};
					<>c.<>9__1_4 = val5;
					obj5 = (object)val5;
				}
				cardExpansionSelectUIManager5.AddNewExpansionButton("Megabot", (ECardExpansionType)3, value2, (UnityAction)obj5);
				bool value3 = ModConfigManager.Instance.GetValue<bool>("UI", $"Enable{(object)(ECardExpansionType)5}");
				CardExpansionSelectUIManager cardExpansionSelectUIManager6 = Plugin.CardExpansionSelectUIManager;
				object obj6 = <>c.<>9__1_5;
				if (obj6 == null)
				{
					UnityAction val6 = delegate
					{
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton(5);
					};
					<>c.<>9__1_5 = val6;
					obj6 = (object)val6;
				}
				cardExpansionSelectUIManager6.AddNewExpansionButton("Cat Job", (ECardExpansionType)5, value3, (UnityAction)obj6);
				foreach (KeyValuePair<ECardExpansionType, CardExpansion> kvp2 in AssetData.CardExpanions.OrderBy((KeyValuePair<ECardExpansionType, CardExpansion> kvp) => (int)kvp.Key))
				{
					Plugin.CardExpansionSelectUIManager.AddNewExpansionButton(kvp2.Value.Name, kvp2.Key, enabled: true, (UnityAction)delegate
					{
						//IL_000b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0015: Expected I4, but got Unknown
						CSingleton<CardExpansionSelectScreen>.Instance.OnPressButton((int)kvp2.Key);
					});
				}
				buttonsAdded = true;
			}
			initCardExpansion = (ECardExpansionType)Plugin.CardExpansionSelectUIManager.ExpansionButtonMap.IndexOf(initCardExpansion);
		}

		[HarmonyPatch("OpenScreen")]
		[HarmonyPostfix]
		private static void OpenScreenPostfix(ECardExpansionType initCardExpansion)
		{
			Canvas.ForceUpdateCanvases();
		}
	}
	[HarmonyPatch(typeof(CardOpeningSequence))]
	public class CardOpeningSequencePatches
	{
		[HarmonyPatch("OpenScreen")]
		[HarmonyPrefix]
		private 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 TranspilerMethods.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(TranspilerMethods), "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")]
		[HarmonyPriority(800)]
		[HarmonyPrefix]
		private static void SetCardUIPrefix(CardUI __instance, CardData cardData)
		{
			//IL_0011: 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)
			Plugin.CardUIGroupManager.SetModdedCardUI(__instance);
			if (AssetData.CardExpanions.ContainsKey(cardData.expansionType))
			{
				cardData.borderType = (ECardBorderType)5;
			}
		}

		[HarmonyPatch("SetCardUI")]
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		private static void SetCardUIPostfix(CardUI __instance, CardData cardData)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(cardData.expansionType, out var value))
			{
				Plugin.CardUIGroupManager.RestoreOriginalState(__instance);
			}
			else
			{
				Plugin.CardUIGroupManager.ApplyCardUIChanges(__instance, cardData, value);
			}
		}
	}
	[HarmonyPatch(typeof(CheckPricePanelUI))]
	public class CheckPricePanelUIPatches
	{
		[HarmonyPatch("InitCard")]
		private static IEnumerable<CodeInstruction> Transpiler(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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			ConstructorInfo constructorInfo = AccessTools.Constructor(typeof(CardData), (Type[])null, false);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CardData), "expansionType");
			MethodInfo methodInfo = AccessTools.Method(typeof(TranspilerMethods), "InitializeCardData", new Type[4]
			{
				typeof(int),
				typeof(ECardExpansionType),
				typeof(bool),
				typeof(int)
			}, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(InventoryBase), "GetMonsterData", (Type[])null, (Type[])null);
			MethodInfo replacement = AccessTools.Method(typeof(TranspilerMethods), "GetMonsterData", new Type[1] { typeof(CardData) }, (Type[])null);
			FieldInfo fieldInfo2 = AccessTools.Field(typeof(CardData), "monsterType");
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Newobj, (object)constructorInfo, (string)null)
			});
			if (val.IsValid)
			{
				int pos = val.Pos;
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo, (string)null)
				});
				if (val.IsValid)
				{
					int pos2 = val.Pos;
					val.Start().Advance(pos).RemoveInstructions(pos2 - pos + 1)
						.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[6]
						{
							new CodeInstruction(OpCodes.Ldarg_2, (object)null),
							new CodeInstruction(OpCodes.Ldarg_3, (object)null),
							new CodeInstruction(OpCodes.Ldarg, (object)4),
							new CodeInstruction(OpCodes.Ldarg, (object)5),
							new CodeInstruction(OpCodes.Call, (object)methodInfo),
							new CodeInstruction(OpCodes.Stloc_0, (object)null)
						})
						.Start()
						.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
						{
							new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
							new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo2, (string)null),
							new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo2, (string)null)
						})
						.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
						{
							m.Advance(1).RemoveInstruction().SetOperandAndAdvance((object)replacement);
						}, (Action<string>)null);
				}
			}
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(CollectionBinderFlipAnimCtrl))]
	public class CollectionBinderFlipAnimCtrlPatches
	{
		[HarmonyPatch("UpdateBinderAllCardUI")]
		[HarmonyPrefix]
		private static bool UpdateBinderAllCardUIPrefix(CollectionBinderFlipAnimCtrl __instance, int binderIndex, int pageIndex)
		{
			//IL_0006: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			if (!AssetData.CardExpanions.TryGetValue(__instance.m_ExpansionType, out var value))
			{
				return true;
			}
			for (int i = 0; i < __instance.m_BinderPageGrpList[binderIndex].m_CardList.Count; i++)
			{
				if (pageIndex <= 0 || pageIndex > __instance.m_MaxIndex)
				{
					return false;
				}
				__instance.m_BinderPageGrpList[binderIndex].SetSingleCard(i, (CardData)null, 0, __instance.m_SortingType);
				int num = (pageIndex - 1) * 12 + i;
				if (num < __instance.m_SortedIndexList.Count)
				{
					int num2 = __instance.m_SortedIndexList[num];
					ModCardData modCardData = (from kvp in value.Cards
						select kvp.Value into c
						orderby (int)c.BaseMonsterData.MonsterType
						select c).ToList()[value.HasRandomFoils ? (num2 >> 1) : num2];
					if (value.HasRandomFoils)
					{
						modCardData.IsFoil = (num2 & 1) == 1;
					}
					int cardAmountByIndex = CPlayerData.GetCardAmountByIndex(num2, modCardData.ExpansionType, false);
					__instance.m_BinderPageGrpList[binderIndex].SetSingleCard(i, modCardData.CardData, cardAmountByIndex, __instance.m_SortingType);
				}
			}
			return false;
		}

		[HarmonyPatch("EnterViewUpCloseState")]
		[HarmonyTranspiler]
		private 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(TranspilerMethods), "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]
		private 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(TranspilerMethods), "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]
		private static void OpenSortAlbumScreenPrefix(int sortingMethodIndex, ref int currentExpansionIndex, bool isGradedCardAlbum)
		{
			currentExpansionIndex = Plugin.CollectionBinderUIManager.Buttons.IndexOf((ECardExpansionType)currentExpansionIndex);
		}

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

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: 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);
			});
			Plugin.CollectionBinderUIManager.AddNewExpansionButton("Graded Card", (ECardExpansionType)(-1), enabled: 

BepInEx/plugins/Scripts.dll

Decompiled 3 weeks 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+a930b76e9dd967465fddfad4aa288d6d244774cb")]
[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)
		{
		}
	}
}