Decompiled source of ShowDelegates v2.2.11

plugins/ShowDelegates/ShowDelegates.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.ProtoFlux;
using FrooxEngine.UIX;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("art0007i")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.2.11.0")]
[assembly: AssemblyInformationalVersion("2.2.11+2c04bdeba39e815ab33a0ce93cbaafb432a95e0c")]
[assembly: AssemblyProduct("ShowDelegates")]
[assembly: AssemblyTitle("ShowDelegates")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/ShowDelegates")]
[assembly: AssemblyVersion("2.2.11.0")]
[module: RefSafetyRules(11)]
namespace ShowDelegates;

public struct MethodArgs
{
	public global::System.Type returnType;

	public global::System.Type[] argumentTypes;

	public MethodArgs(global::System.Type returnType, global::System.Type[] argumentTypes)
	{
		this.returnType = returnType;
		this.argumentTypes = argumentTypes;
	}

	public MethodArgs(params global::System.Type[] argumentTypes)
	{
		returnType = typeof(void);
		this.argumentTypes = argumentTypes;
	}

	public MethodArgs(MethodInfo source)
	{
		returnType = source.ReturnType;
		argumentTypes = Enumerable.ToArray<global::System.Type>(Enumerable.Select<ParameterInfo, global::System.Type>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)((MethodBase)source).GetParameters(), (Func<ParameterInfo, global::System.Type>)((ParameterInfo f) => f.ParameterType)));
	}

	public string ToString()
	{
		string obj = ((returnType == (global::System.Type)null) ? "void" : ((MemberInfo)returnType).Name);
		string text = string.Join(", ", Enumerable.Select<global::System.Type, string>((global::System.Collections.Generic.IEnumerable<global::System.Type>)argumentTypes, (Func<global::System.Type, string>)((global::System.Type t) => ((MemberInfo)t).Name)));
		return obj + " (" + text + ")";
	}

	public bool Equals(object obj)
	{
		if (obj is MethodArgs methodArgs)
		{
			MethodArgs methodArgs2 = this;
			if (methodArgs2.returnType != methodArgs.returnType)
			{
				return false;
			}
			if (methodArgs2.argumentTypes.Length != methodArgs.argumentTypes.Length)
			{
				return false;
			}
			for (int i = 0; i < methodArgs2.argumentTypes.Length; i++)
			{
				if (methodArgs2.argumentTypes[i] != methodArgs.argumentTypes[i])
				{
					return false;
				}
			}
			return true;
		}
		return base.Equals(obj);
	}

	public static bool operator ==(MethodArgs lhs, MethodArgs rhs)
	{
		return ((object)lhs/*cast due to .constrained prefix*/).Equals((object)rhs);
	}

	public static bool operator !=(MethodArgs lhs, MethodArgs rhs)
	{
		return !((object)lhs/*cast due to .constrained prefix*/).Equals((object)rhs);
	}

	public int GetHashCode()
	{
		int num = 17;
		num = num * 23 + ((returnType != (global::System.Type)null) ? ((object)returnType).GetHashCode() : 0);
		if (argumentTypes != null)
		{
			global::System.Type[] array = argumentTypes;
			foreach (global::System.Type type in array)
			{
				num = num * 23 + ((type != (global::System.Type)null) ? ((object)type).GetHashCode() : 0);
			}
		}
		return num;
	}
}
internal class Helper
{
	public static Dictionary<MethodArgs, global::System.Type> argumentLookup;

	public static global::System.Type ClassifyDelegate(MethodInfo m)
	{
		global::System.Type result = default(global::System.Type);
		if (argumentLookup.TryGetValue(new MethodArgs(m), ref result))
		{
			return result;
		}
		global::System.Type[] array = Enumerable.ToArray<global::System.Type>(Enumerable.Select<ParameterInfo, global::System.Type>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)((MethodBase)m).GetParameters(), (Func<ParameterInfo, global::System.Type>)((ParameterInfo para) => para.ParameterType)));
		if (array.Length == 3 && array[0] == typeof(IButton) && array[1] == typeof(ButtonEventData))
		{
			return typeof(ButtonEventHandler<>).MakeGenericType(new global::System.Type[1] { array[2] });
		}
		return GetFuncOrAction(m, array);
	}

	public static global::System.Type GetFuncOrAction(MethodInfo m)
	{
		global::System.Type[] p = Enumerable.ToArray<global::System.Type>(Enumerable.Select<ParameterInfo, global::System.Type>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)((MethodBase)m).GetParameters(), (Func<ParameterInfo, global::System.Type>)((ParameterInfo para) => para.ParameterType)));
		return GetFuncOrAction(m, p);
	}

	public static global::System.Type GetFuncOrAction(MethodInfo m, global::System.Type[] p)
	{
		if (m.ReturnType == typeof(void))
		{
			return Expression.GetActionType(p);
		}
		p = Enumerable.ToArray<global::System.Type>(Enumerable.Concat<global::System.Type>((global::System.Collections.Generic.IEnumerable<global::System.Type>)p, (global::System.Collections.Generic.IEnumerable<global::System.Type>)new global::System.Type[1] { m.ReturnType }));
		return Expression.GetFuncType(p);
	}

	static Helper()
	{
		Dictionary<MethodArgs, global::System.Type> val = new Dictionary<MethodArgs, global::System.Type>();
		val.Add(new MethodArgs(typeof(IButton), typeof(ButtonEventData)), typeof(ButtonEventHandler));
		val.Add(new MethodArgs(typeof(bool), new global::System.Type[2]
		{
			typeof(IGrabbable),
			typeof(Grabber)
		}), typeof(GrabCheck));
		val.Add(new MethodArgs(typeof(ITouchable), typeof(TouchEventInfo).MakeByRefType()), typeof(TouchEvent));
		val.Add(new MethodArgs(typeof(ITouchable), new global::System.Type[5]
		{
			typeof(RelayTouchSource),
			typeof(float3).MakeByRefType(),
			typeof(float3).MakeByRefType(),
			typeof(float3).MakeByRefType(),
			typeof(bool).MakeByRefType()
		}), typeof(TouchableGetter));
		val.Add(new MethodArgs(typeof(SlotGizmo), typeof(SlotGizmo)), typeof(SlotGizmoReplacement));
		val.Add(new MethodArgs(typeof(LegacyWorldItem)), typeof(LegacyWorldItemAction));
		val.Add(new MethodArgs(typeof(Display), typeof(Slot)), typeof(DisplayItemHandler));
		val.Add(new MethodArgs(typeof(bool), new global::System.Type[2]
		{
			typeof(Snapper),
			typeof(SnapTarget)
		}), typeof(SnapperFilter));
		val.Add(new MethodArgs(typeof(DevCreateNewForm), typeof(Slot)), typeof(ItemCreated));
		val.Add(new MethodArgs(typeof(ModalOverlay), new global::System.Type[1] { typeof(Slot) }), typeof(ModalOverlayConstructor));
		argumentLookup = val;
	}
}
[ResonitePlugin("art0007i.ShowDelegates", "ShowDelegates", "2.2.11", "art0007i", "https://github.com/art0007i/ShowDelegates")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(WorkerInitializer), "Initialize", new global::System.Type[] { typeof(global::System.Type) })]
	public static class InitializeAllDelegatesPatch
	{
		public static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> instructions)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			List<CodeInstruction> val = Enumerable.ToList<CodeInstruction>(instructions);
			for (int i = 0; i < val.Count; i++)
			{
				object operand = val[i].operand;
				MethodInfo val2 = (MethodInfo)((operand is MethodInfo) ? operand : null);
				if (val2 != null && ((MemberInfo)val2).Name == "GetMethods")
				{
					MethodInfo method = typeof(InitializeAllDelegatesPatch).GetMethod("GetAllMethodsForRealThisTime");
					val[i] = new CodeInstruction(OpCodes.Call, (object)method);
				}
			}
			return Enumerable.AsEnumerable<CodeInstruction>((global::System.Collections.Generic.IEnumerable<CodeInstruction>)val);
		}

		public static MethodInfo[] GetAllMethodsForRealThisTime(global::System.Type t, BindingFlags _flags)
		{
			//IL_000b: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<RuntimeMethodHandle, MethodInfo> val = Pool.BorrowDictionary<RuntimeMethodHandle, MethodInfo>();
			global::System.Type type = t;
			while (type != (global::System.Type)null)
			{
				MethodInfo[] methods = type.GetMethods(AccessTools.all);
				foreach (MethodInfo val2 in methods)
				{
					if (!val.ContainsKey(((MethodBase)val2).MethodHandle))
					{
						val.Add(((MethodBase)val2).MethodHandle, val2);
					}
				}
				type = type.BaseType;
			}
			MethodInfo[] result = Enumerable.ToArray<MethodInfo>((global::System.Collections.Generic.IEnumerable<MethodInfo>)val.Values);
			Pool.Return<RuntimeMethodHandle, MethodInfo>(ref val);
			return result;
		}
	}

	[HarmonyPatch(typeof(ProtoFluxTool), "OnCreateDelegateProxy")]
	private class FixProtoFluxDeleagtes
	{
		[CompilerGenerated]
		private sealed class <Transpiler>d__1 : global::System.Collections.Generic.IEnumerable<CodeInstruction>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<CodeInstruction>, global::System.Collections.IEnumerator, global::System.IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private global::System.Collections.Generic.IEnumerable<CodeInstruction> codes;

			public global::System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

			private global::System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap1;

			CodeInstruction global::System.Collections.Generic.IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

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

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

			[DebuggerHidden]
			void global::System.IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 1u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>7__wrap1 = codes.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						break;
					case 2:
						<>1__state = -3;
						break;
					}
					if (((global::System.Collections.IEnumerator)<>7__wrap1).MoveNext())
					{
						CodeInstruction current = <>7__wrap1.Current;
						object operand = current.operand;
						MethodInfo val = (MethodInfo)((operand is MethodInfo) ? operand : null);
						if (val != null && ((MemberInfo)val).Name == "GetType")
						{
							MethodInfo method = typeof(FixProtoFluxDeleagtes).GetMethod("GetTypeFixed");
							<>2__current = new CodeInstruction(OpCodes.Call, (object)method);
							<>1__state = 1;
							return true;
						}
						<>2__current = current;
						<>1__state = 2;
						return true;
					}
					<>m__Finally1();
					<>7__wrap1 = null;
					return false;
				}
				catch
				{
					//try-fault
					((global::System.IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap1 != null)
				{
					((global::System.IDisposable)<>7__wrap1).Dispose();
				}
			}

			[DebuggerHidden]
			void global::System.Collections.IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			global::System.Collections.Generic.IEnumerator<CodeInstruction> global::System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<Transpiler>d__1 <Transpiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Transpiler>d__ = this;
				}
				else
				{
					<Transpiler>d__ = new <Transpiler>d__1(0);
				}
				<Transpiler>d__.codes = <>3__codes;
				return <Transpiler>d__;
			}

			[DebuggerHidden]
			global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
			{
				return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		public static void Prefix(IButton button, ButtonEventData eventData, ref global::System.Delegate target)
		{
			try
			{
				global::System.Type funcOrAction = Helper.GetFuncOrAction(target.Method);
				target = target.Method.CreateDelegate(funcOrAction, target.Target);
			}
			catch (global::System.Exception ex)
			{
				Log.LogDebug((object)("Exception in FixProtoFluxDeleagtes.Prefix: " + (object)ex));
			}
		}

		[IteratorStateMachine(typeof(<Transpiler>d__1))]
		public static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			global::System.Collections.Generic.IEnumerator<CodeInstruction> enumerator = codes.GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					CodeInstruction current = enumerator.Current;
					object operand = current.operand;
					MethodInfo val = (MethodInfo)((operand is MethodInfo) ? operand : null);
					if (val != null && ((MemberInfo)val).Name == "GetType")
					{
						MethodInfo method = typeof(FixProtoFluxDeleagtes).GetMethod("GetTypeFixed");
						yield return new CodeInstruction(OpCodes.Call, (object)method);
					}
					else
					{
						yield return current;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}

		public static global::System.Type? GetTypeFixed(string typeName)
		{
			return typeof(ProtoFluxTool).Assembly.GetType(typeName);
		}
	}

	[HarmonyPatch(typeof(WorkerInspector))]
	[HarmonyPatch("BuildInspectorUI")]
	private class WorkerInspector_BuildInspectorUI_Patch
	{
		[CompilerGenerated]
		private sealed class <Transpiler>d__3 : global::System.Collections.Generic.IEnumerable<CodeInstruction>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<CodeInstruction>, global::System.Collections.IEnumerator, global::System.IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private global::System.Collections.Generic.IEnumerable<CodeInstruction> codes;

			public global::System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

			private global::System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap1;

			private CodeInstruction <code>5__3;

			CodeInstruction global::System.Collections.Generic.IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

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

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

			[DebuggerHidden]
			void global::System.IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 6u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = null;
				<code>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Expected O, but got Unknown
				//IL_0107: 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_0117: Expected O, but got Unknown
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Expected O, but got Unknown
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Expected O, but got Unknown
				//IL_0179: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Expected O, but got Unknown
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>7__wrap1 = codes.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
					{
						<>1__state = -3;
						object operand = <code>5__3.operand;
						MethodBase val = (MethodBase)((operand is MethodBase) ? operand : null);
						if (val != null && ((MemberInfo)val).Name == "get_SyncMethodCount")
						{
							<>2__current = new CodeInstruction(OpCodes.Pop, (object)null);
							<>1__state = 2;
							return true;
						}
						goto IL_01af;
					}
					case 2:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
						<>1__state = 4;
						return true;
					case 4:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Ldarg_1, (object)null);
						<>1__state = 5;
						return true;
					case 5:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Ldarg_2, (object)null);
						<>1__state = 6;
						return true;
					case 6:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Call, (object)typeof(WorkerInspector_BuildInspectorUI_Patch).GetMethod("GenerateDelegates"));
						<>1__state = 7;
						return true;
					case 7:
						{
							<>1__state = -3;
							goto IL_01af;
						}
						IL_01af:
						<code>5__3 = null;
						break;
					}
					if (((global::System.Collections.IEnumerator)<>7__wrap1).MoveNext())
					{
						<code>5__3 = <>7__wrap1.Current;
						<>2__current = <code>5__3;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>7__wrap1 = null;
					return false;
				}
				catch
				{
					//try-fault
					((global::System.IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap1 != null)
				{
					((global::System.IDisposable)<>7__wrap1).Dispose();
				}
			}

			[DebuggerHidden]
			void global::System.Collections.IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			global::System.Collections.Generic.IEnumerator<CodeInstruction> global::System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<Transpiler>d__3 <Transpiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Transpiler>d__ = this;
				}
				else
				{
					<Transpiler>d__ = new <Transpiler>d__3(0);
				}
				<Transpiler>d__.codes = <>3__codes;
				return <Transpiler>d__;
			}

			[DebuggerHidden]
			global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
			{
				return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		public static MethodInfo delegateFunc = typeof(Plugin).GetMethod("GenerateDelegateProxy", (BindingFlags)40);

		public static bool ProcessHidden(bool orig)
		{
			if (ShowHidden.Value)
			{
				return false;
			}
			return orig;
		}

		public static void GenerateDelegates(Worker worker, UIBuilder ui, Predicate<ISyncMember> memberFilter)
		{
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_01e5: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			if (ShowHidden.Value)
			{
				for (int i = 0; i < worker.SyncMemberCount; i++)
				{
					ISyncMember syncMember = worker.GetSyncMember(i);
					if ((memberFilter == null || memberFilter.Invoke(syncMember)) && CustomAttributeExtensions.GetCustomAttribute<HideInInspectorAttribute>((MemberInfo)(object)worker.GetSyncMemberFieldInfo(i)) != null)
					{
						GenerateReferenceProxy(ui, worker.GetSyncMemberName(syncMember), (IWorldElement)(object)syncMember);
					}
				}
			}
			if (!ShowDelegates.Value || worker.SyncMethodCount <= 0)
			{
				return;
			}
			WorkerInitInfo value = Traverse.Create((object)worker).Field<WorkerInitInfo>("InitInfo").Value;
			global::System.Collections.Generic.IEnumerable<SyncMethodInfo> enumerable = (ShowNonDefault.Value ? Enumerable.AsEnumerable<SyncMethodInfo>((global::System.Collections.Generic.IEnumerable<SyncMethodInfo>)value.syncMethods) : Enumerable.Where<SyncMethodInfo>((global::System.Collections.Generic.IEnumerable<SyncMethodInfo>)value.syncMethods, (Func<SyncMethodInfo, bool>)((SyncMethodInfo m) => m.methodType != typeof(global::System.Delegate) && ((MethodBase)m.method).IsPublic)));
			if (!Enumerable.Any<SyncMethodInfo>(enumerable))
			{
				return;
			}
			LocaleString val = LocaleString.op_Implicit("---- SYNC METHODS HERE ----");
			Text val2 = ui.Text(ref val, true, (Alignment?)(Alignment)4, true, (string)null);
			VerticalLayout val3 = ui.VerticalLayout(0f, 0f, (Alignment?)null, (bool?)null, (bool?)null);
			((Component)val3).Slot.ActiveSelf = false;
			((ContainerWorker<Component>)(object)((Component)val3).Slot).RemoveComponent((Component)(object)((ContainerWorker<Component>)(object)((Component)val3).Slot).GetComponent<LayoutElement>((Predicate<LayoutElement>)null, false));
			Expander obj = ((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<Expander>(true, (Action<Expander>)null);
			obj.SectionRoot.Target = ((Component)val3).Slot;
			obj.IsExpanded = DefaultOpen.Value;
			Button obj2 = ((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<Button>(true, (Action<Button>)null);
			ColorDriver obj3 = ((SyncElementList<ColorDriver>)(object)((InteractionElement)obj2).ColorDrivers).Add();
			((SyncRef<IField<colorX>>)(object)obj3.ColorDrive).Target = (IField<colorX>)(object)val2.Color;
			RadiantUI_Constants.SetupLabelDriverColors(obj3);
			((SyncField<bool>)(object)obj2.RequireLockInToPress).Value = true;
			global::System.Collections.Generic.IEnumerator<SyncMethodInfo> enumerator = enumerable.GetEnumerator();
			try
			{
				bool flag = default(bool);
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					SyncMethodInfo current = enumerator.Current;
					global::System.Type type = current.methodType;
					global::System.Delegate obj4 = null;
					if (typeof(global::System.MulticastDelegate).IsAssignableFrom(type))
					{
						try
						{
							obj4 = (((MethodBase)current.method).IsStatic ? current.method.CreateDelegate(type) : current.method.CreateDelegate(type, (object)worker));
						}
						catch (global::System.Exception ex)
						{
							ManualLogSource log = Log;
							BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(122, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Error when trying to create a delegate for ");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(GeneralExtensions.FullDescription((MethodBase)(object)current.method));
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" with sync method type ");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ReflectionExtensions.GetNiceName(type, "<", ">", "+"));
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(". This is most likely a bug with Resonite, not the mod.\n");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<global::System.Exception>(ex);
							}
							log.LogError(val4);
						}
					}
					if (obj4 == null)
					{
						try
						{
							type = Helper.ClassifyDelegate(current.method);
							obj4 = (((MethodBase)current.method).IsStatic ? current.method.CreateDelegate(type) : current.method.CreateDelegate(type, (object)worker));
						}
						catch (global::System.Exception ex2)
						{
							Log.LogError((object)("Error while classifying function " + ((object)current.method)?.ToString() + "\n" + (object)ex2));
						}
					}
					if (obj4 == null)
					{
						Log.LogError((object)("Unmapped type. Please report this message to the mod author: Could not identify " + ((object)current.method)?.ToString() + " on type " + (object)((MemberInfo)current.method).DeclaringType));
						val = LocaleString.op_Implicit("<color=orange>" + funName("<i>unknown</i>", current.method));
						ui.Text(ref val, true, (Alignment?)(Alignment)3, true, (string)null);
						continue;
					}
					((MethodBase)delegateFunc.MakeGenericMethod(new global::System.Type[1] { type })).Invoke((object)null, new object[3]
					{
						ui,
						funName(((object)type).ToString(), current.method),
						obj4
					});
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
			ui.NestOut();
		}

		[IteratorStateMachine(typeof(<Transpiler>d__3))]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			global::System.Collections.Generic.IEnumerator<CodeInstruction> enumerator = codes.GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					CodeInstruction code = enumerator.Current;
					yield return code;
					object operand = code.operand;
					MethodBase val = (MethodBase)((operand is MethodBase) ? operand : null);
					if (val != null && ((MemberInfo)val).Name == "get_SyncMethodCount")
					{
						yield return new CodeInstruction(OpCodes.Pop, (object)null);
						yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
						yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
						yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null);
						yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null);
						yield return new CodeInstruction(OpCodes.Call, (object)typeof(WorkerInspector_BuildInspectorUI_Patch).GetMethod("GenerateDelegates"));
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}
	}

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> DefaultOpen;

	internal static ConfigEntry<bool> ShowDelegates;

	internal static ConfigEntry<bool> ShortNames;

	internal static ConfigEntry<bool> ShowNonDefault;

	internal static ConfigEntry<bool> ShowHidden;

	public override void Load()
	{
		Log = ((BasePlugin)this).Log;
		DefaultOpen = ((BasePlugin)this).Config.Bind<bool>("General", "DefaultOpen", false, "If true delegates will be expanded by default.");
		ShowDelegates = ((BasePlugin)this).Config.Bind<bool>("General", "ShowDelegates", true, "If false delegates will not be shown.");
		ShortNames = ((BasePlugin)this).Config.Bind<bool>("General", "ShortNames", true, "Show short delegate names.");
		ShowNonDefault = ((BasePlugin)this).Config.Bind<bool>("General", "ShowNonDefault", true, "If false only delegates that appear in vanilla will be shown.");
		ShowHidden = ((BasePlugin)this).Config.Bind<bool>("General", "ShowHidden", true, "If true items hidden with the HideInInspector attribute will be shown");
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}

	private static void GenerateDelegateProxy<T>(UIBuilder ui, string name, T target) where T : global::System.Delegate
	{
		//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_0035: Unknown result type (might be due to invalid IL or missing references)
		LocaleString val = LocaleString.op_Implicit(name);
		Text val2 = ui.Text(ref val, true, (Alignment?)(Alignment)3, true, (string)null);
		((SyncField<float2>)(object)((ContainerWorker<Component>)(object)((Component)val2).Slot).GetComponent<RectTransform>((Predicate<RectTransform>)null, false).AnchorMax).Value = new float2(0.25f, 1f);
		ColorDriver obj = ((SyncElementList<ColorDriver>)(object)((InteractionElement)((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<Button>(true, (Action<Button>)null)).ColorDrivers).Add();
		((SyncRef<IField<colorX>>)(object)obj.ColorDrive).Target = (IField<colorX>)(object)val2.Color;
		RadiantUI_Constants.SetupLabelDriverColors(obj);
		((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<DelegateProxySource<T>>(true, (Action<DelegateProxySource<T>>)null).Delegate.Target = target;
	}

	private static void GenerateReferenceProxy(UIBuilder ui, string name, IWorldElement target)
	{
		//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_003f: Unknown result type (might be due to invalid IL or missing references)
		LocaleString val = LocaleString.op_Implicit(name + ":");
		Text val2 = ui.Text(ref val, true, (Alignment?)(Alignment)3, true, (string)null);
		((SyncField<float2>)(object)((ContainerWorker<Component>)(object)((Component)val2).Slot).GetComponent<RectTransform>((Predicate<RectTransform>)null, false).AnchorMax).Value = new float2(0.25f, 1f);
		ColorDriver obj = ((SyncElementList<ColorDriver>)(object)((InteractionElement)((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<Button>(true, (Action<Button>)null)).ColorDrivers).Add();
		((SyncRef<IField<colorX>>)(object)obj.ColorDrive).Target = (IField<colorX>)(object)val2.Color;
		RadiantUI_Constants.SetupLabelDriverColors(obj);
		((SyncRef<IWorldElement>)(object)((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<ReferenceProxySource>(true, (Action<ReferenceProxySource>)null).Reference).Target = target;
	}

	private static string funName(string prefix, MethodInfo info)
	{
		if (ShortNames.Value)
		{
			string text = string.Join(", ", Enumerable.Select<ParameterInfo, string>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)((MethodBase)info).GetParameters(), (Func<ParameterInfo, string>)((ParameterInfo p) => ReflectionExtensions.GetNiceName(p.ParameterType, "<", ">", "+") + " " + p.Name)));
			return string.Concat(new string[6]
			{
				ReflectionExtensions.GetNiceName(info.ReturnType, "<", ">", "+"),
				" ",
				((MemberInfo)info).Name,
				"(",
				text,
				")"
			});
		}
		return string.Concat(new string[6]
		{
			((MethodBase)info).IsStatic ? "Static " : "",
			prefix,
			" ",
			((object)info).ToString().Substring(((object)info).ToString().IndexOf(" ")).Replace("FrooxEngine.", ""),
			" -> ",
			((MemberInfo)info.ReturnType).Name
		});
	}
}
public static class PluginMetadata
{
	public const string GUID = "art0007i.ShowDelegates";

	public const string NAME = "ShowDelegates";

	public const string VERSION = "2.2.11";

	public const string AUTHORS = "art0007i";

	public const string REPOSITORY_URL = "https://github.com/art0007i/ShowDelegates";
}