Decompiled source of InspectorDelegateCaller v2.1.0

plugins/InspectorDelegateCaller.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
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.ProtoFlux.CoreNodes;
using FrooxEngine.ProtoFlux.Runtimes.Execution.Nodes;
using FrooxEngine.UIX;
using HarmonyLib;
using ProtoFlux.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("eia485")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyInformationalVersion("2.1.0+2550ad6d47b63ba0aac23f64eb4264f3b6a050b6")]
[assembly: AssemblyProduct("InspectorDelegateCaller")]
[assembly: AssemblyTitle("InspectorDelegateCaller")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EIA485/NeosInspectorDelegateCaller")]
[assembly: AssemblyVersion("2.1.0.0")]
[module: RefSafetyRules(11)]
namespace InspectorDelegateCaller;

[ResonitePlugin("net.eia485.InspectorDelegateCaller", "InspectorDelegateCaller", "2.1.0", "eia485", "https://github.com/EIA485/NeosInspectorDelegateCaller")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class InspectorDelegateCaller : BasePlugin
{
	[HarmonyPatch(typeof(WorkerInspector))]
	private class InspectorDelegateCallerPatch
	{
		[CompilerGenerated]
		private sealed class <ICustomInspectorTranspiler>d__4 : 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 OpCode LoadCode;

			public OpCode <>3__LoadCode;

			private bool <search>5__2;

			private CodeInstruction <last>5__3;

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

			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 <ICustomInspectorTranspiler>d__4(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();
					}
				}
				<last>5__3 = null;
				<>7__wrap3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<search>5__2 = true;
						<last>5__3 = null;
						<>7__wrap3 = codes.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						break;
					case 2:
						<>1__state = -3;
						break;
					}
					if (((global::System.Collections.IEnumerator)<>7__wrap3).MoveNext())
					{
						CodeInstruction current = <>7__wrap3.Current;
						if (<search>5__2)
						{
							if (current.opcode == OpCodes.Isinst && current.operand == typeof(ICustomInspector))
							{
								CodeInstruction obj = <last>5__3;
								if (obj != null && obj.opcode == LoadCode)
								{
									<search>5__2 = false;
									<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(InspectorDelegateCallerPatch), "CallProxy", (global::System.Type[])null, (global::System.Type[])null));
									<>1__state = 1;
									return true;
								}
							}
							<last>5__3 = current;
						}
						<>2__current = current;
						<>1__state = 2;
						return true;
					}
					<>m__Finally1();
					<>7__wrap3 = 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__wrap3 != null)
				{
					((global::System.IDisposable)<>7__wrap3).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()
			{
				//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)
				<ICustomInspectorTranspiler>d__4 <ICustomInspectorTranspiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<ICustomInspectorTranspiler>d__ = this;
				}
				else
				{
					<ICustomInspectorTranspiler>d__ = new <ICustomInspectorTranspiler>d__4(0);
				}
				<ICustomInspectorTranspiler>d__.codes = <>3__codes;
				<ICustomInspectorTranspiler>d__.LoadCode = <>3__LoadCode;
				return <ICustomInspectorTranspiler>d__;
			}

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

		private static readonly Regex NonDigits = new Regex("\\D", (RegexOptions)8);

		private static FieldInfo currentInteractableInfo = AccessTools.Field(typeof(InteractionData), "_currentInteractable");

		private static FieldInfo _laserGrabDistance = AccessTools.Field(typeof(InteractionHandler), "_laserGrabDistance");

		private static FieldInfo _grabHitSlot = AccessTools.Field(typeof(InteractionHandler), "_grabHitSlot");

		private static FieldInfo _grabInteractionTarget = AccessTools.Field(typeof(InteractionHandler), "_grabInteractionTarget");

		private static FieldInfo _isScaling = AccessTools.Field(typeof(InteractionHandler), "_isScaling");

		private static ICustomInspector CallProxy(Worker worker)
		{
			ICustomInspector val = (ICustomInspector)(object)((worker is ICustomInspector) ? worker : null);
			if (val != null && !IsMatch(DisableCustomRegex, custRegex, ReflectionExtensions.GetNiceName(((object)val).GetType(), "<", ">", "+")))
			{
				return val;
			}
			return null;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("BuildUIForComponent")]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> BuildUIForComponentTranspiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ICustomInspectorTranspiler(codes, OpCodes.Ldarg_1);
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(SyncMemberEditorBuilder), "BuildSyncObject")]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> BuildSyncObjectTranspiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ICustomInspectorTranspiler(codes, OpCodes.Ldarg_0);
		}

		[IteratorStateMachine(typeof(<ICustomInspectorTranspiler>d__4))]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> ICustomInspectorTranspiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes, OpCode LoadCode)
		{
			//IL_000f: 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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ICustomInspectorTranspiler>d__4(-2)
			{
				<>3__codes = codes,
				<>3__LoadCode = LoadCode
			};
		}

		[HarmonyPrefix]
		[HarmonyPatch("AddHeaderText")]
		private static bool AddHeaderTextPrefix()
		{
			return !DisableHeaderText.Value;
		}

		[HarmonyPrefix]
		[HarmonyPatch("BuildInspectorUI")]
		private static void BuildInspectorUIPrefix(UIBuilder ui)
		{
			ui.Style.MinHeight = 24f;
		}

		[HarmonyPostfix]
		[HarmonyPatch("BuildInspectorUI")]
		private static void BuildInspectorUIPostfix(Worker worker, UIBuilder ui)
		{
			//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_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Expected O, but got Unknown
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Expected O, but got Unknown
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0766: Unknown result type (might be due to invalid IL or missing references)
			//IL_076b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f1: Expected O, but got Unknown
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_0827: Expected O, but got Unknown
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a16: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a43: Expected O, but got Unknown
			//IL_0a97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_08da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0901: Unknown result type (might be due to invalid IL or missing references)
			//IL_0908: Expected O, but got Unknown
			//IL_093b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0951: Unknown result type (might be due to invalid IL or missing references)
			//IL_0976: Unknown result type (might be due to invalid IL or missing references)
			//IL_098c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<MethodInfo> enumerator = GetAllMethods(((object)worker).GetType()).GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					MethodInfo current = enumerator.Current;
					if (!hasSyncMethod(current))
					{
						continue;
					}
					ParameterInfo[] parameters = ((MethodBase)current).GetParameters();
					if (parameters.Length > 8)
					{
						break;
					}
					string text = (((MethodBase)current).IsStatic ? "static " : "");
					string text2 = "";
					if (((MethodBase)current).IsPublic)
					{
						text2 = "public ";
					}
					else if (((MethodBase)current).IsPrivate)
					{
						text2 = "private ";
					}
					else if (((MethodBase)current).IsFamily)
					{
						text2 = "protected ";
					}
					else if (((MethodBase)current).IsAssembly)
					{
						text2 = "internal ";
					}
					else if (((MethodBase)current).IsFamilyAndAssembly)
					{
						text2 = "private protected ";
					}
					else if (((MethodBase)current).IsFamilyOrAssembly)
					{
						text2 = "protected internal ";
					}
					string text3 = ((parameters.Length != 0) ? ("[" + string.Join(", ", Enumerable.Select<ParameterInfo, string>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)parameters, (Func<ParameterInfo, string>)((ParameterInfo p) => ((MemberInfo)p.ParameterType).Name))) + "]") : "");
					string text4 = ((current.ReturnType != typeof(void)) ? (" : " + ReflectionExtensions.GetNiceName(current.ReturnType, "<", ">", "+")) : "");
					string input = $"{text}{text2}{ReflectionExtensions.GetNiceName(((MemberInfo)current).DeclaringType, "<", ">", "+")}.{((MemberInfo)current).Name}{text3}{text4}";
					if (IsMatch(BlockerRegex, blocRegex, input))
					{
						continue;
					}
					if (current.ReturnType == typeof(void))
					{
						switch (parameters.Length)
						{
						case 0:
							if (Enumerable.Any<CustomAttributeData>(((MemberInfo)current).CustomAttributes, (Func<CustomAttributeData, bool>)((CustomAttributeData a) => a.AttributeType == typeof(SyncMethod))))
							{
								if (Actions.Value)
								{
									actionui(worker, ui, current);
								}
							}
							else if (SubAction.Value)
							{
								actionui(worker, ui, current);
							}
							continue;
						case 1:
							if (ArgAction.Value)
							{
								ParameterInfo val4 = parameters[0];
								global::System.Type parameterType2 = val4.ParameterType;
								if (Enumerable.Contains<global::System.Type>((global::System.Collections.Generic.IEnumerable<global::System.Type>)parameterType2.GetInterfaces(), typeof(IWorldElement)))
								{
									actionCallbackwitharg(isRef: true, worker, ui, current, val4, parameterType2);
								}
								else if (Coder.IsEnginePrimitive(parameterType2))
								{
									actionCallbackwitharg(isRef: false, worker, ui, current, val4, parameterType2);
								}
							}
							continue;
						case 2:
							if (isButtonDelegate(parameters))
							{
								if (Buttons.Value)
								{
									ButtonEventHandler val2 = InspectorDelegateCaller.StaticSafeCreateDelegate<ButtonEventHandler>(current, (object?)worker);
									LocaleString val3 = LocaleString.op_Implicit(((MemberInfo)current).Name);
									Button obj = ui.Button(ref val3);
									obj.Pressed.Target = val2;
									proxySource(obj, (global::System.Delegate)(object)val2, typeof(ButtonEventHandler));
								}
								continue;
							}
							break;
						case 3:
							if (!isButtonDelegate(parameters))
							{
								break;
							}
							if (ArgButtons.Value)
							{
								ParameterInfo val = parameters[2];
								global::System.Type parameterType = val.ParameterType;
								if (Enumerable.Contains<global::System.Type>((global::System.Collections.Generic.IEnumerable<global::System.Type>)parameterType.GetInterfaces(), typeof(IWorldElement)))
								{
									buttonCallbackwitharg(typeof(ButtonRefRelay<>), worker, ui, current, val, parameterType);
								}
								else if (Coder.IsEnginePrimitive(parameterType))
								{
									buttonCallbackwitharg(typeof(ButtonRelay<>), worker, ui, current, val, parameterType);
								}
								else if (typeof(global::System.Delegate).IsAssignableFrom(parameterType))
								{
									buttonCallbackwitharg(typeof(ButtonDelegateRelay<>), worker, ui, current, val, parameterType);
								}
							}
							continue;
						}
					}
					if (!FallBack.Value)
					{
						continue;
					}
					bool isAsync;
					bool isRetRef;
					global::System.Type delegateType;
					global::System.Type returnType;
					global::System.Type delegateNodeType = GetDelegateNodeType(current, out isAsync, out isRetRef, out delegateType, out returnType);
					if (delegateNodeType == (global::System.Type)null || delegateType == (global::System.Type)null)
					{
						continue;
					}
					HorizontalLayout obj2 = ui.HorizontalLayout(0f, 0f, (Alignment?)null);
					((SyncField<float>)(object)((ContainerWorker<Component>)(object)((Component)obj2).Slot).GetComponent<LayoutElement>((Predicate<LayoutElement>)null, false).MinHeight).Value = -1f;
					Slot val5 = ((Component)obj2).Slot.AddSlot("Logix", true);
					ProtoFluxNode val6 = (ProtoFluxNode)((ContainerWorker<Component>)(object)val5).AttachComponent(delegateNodeType, true, (Action<Component>)null);
					global::System.Delegate @delegate = CreateDelegateGlobal(val6, delegateType, current, worker);
					global::System.Type type = (isAsync ? ProtoFluxHelper.AsyncCallInput : ProtoFluxHelper.SyncCallInput);
					ProtoFluxNode val7 = (ProtoFluxNode)((ContainerWorker<Component>)(object)val5).AttachComponent(type, true, (Action<Component>)null);
					val6.TryConnectImpulse(val7.GetImpulse(0), val6.GetOperation(0), false);
					bool flag = returnType != typeof(void);
					bool flag2 = val6.NodeInputCount > 0;
					Button val8 = null;
					if (flag2)
					{
						LocaleString val9 = LocaleString.op_Implicit("|");
						colorX? val10 = colorX.Gray;
						Button obj3 = ui.Button(ref val9, ref val10);
						((SyncField<float>)(object)((ContainerWorker<Component>)(object)((Component)obj3).Slot).GetComponent<LayoutElement>((Predicate<LayoutElement>)null, false).MinWidth).Value = 30f;
						val8 = obj3;
						LayoutElement component = ((ContainerWorker<Component>)(object)((Component)ui.VerticalLayout(0f, 0f, (Alignment?)null, (bool?)null, (bool?)null)).Slot).GetComponent<LayoutElement>((Predicate<LayoutElement>)null, false);
						((SyncField<float>)(object)component.MinHeight).Value = -1f;
						((SyncField<float>)(object)component.FlexibleWidth).Value = 1f;
						VerticalLayout val11 = ui.VerticalLayout(0f, 0f, (Alignment?)null, (bool?)null, (bool?)null);
						((ContainerWorker<Component>)(object)((Component)obj3).Slot).AttachComponent<Expander>(true, (Action<Expander>)null).SectionRoot.Target = ((Component)val11).Slot;
						((Component)val11).Slot.ActiveSelf = DefaultArgState.Value;
						((SyncField<float>)(object)((ContainerWorker<Component>)(object)((Component)val11).Slot).GetComponent<LayoutElement>((Predicate<LayoutElement>)null, false).MinHeight).Value = -1f;
					}
					global::System.Collections.Generic.IEnumerator<ISyncRef> enumerator2 = val6.NodeInputs.GetEnumerator();
					try
					{
						while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
						{
							ISyncRef current2 = enumerator2.Current;
							global::System.Type inputNode = ProtoFluxHelper.GetInputNode(((object)current2).GetType().GetGenericArguments()[0].GetGenericArguments()[0]);
							ProtoFluxNode val12 = (ProtoFluxNode)((ContainerWorker<Component>)(object)val5).AttachComponent(inputNode, true, (Action<Component>)null);
							ISyncMember val13 = ((Worker)val12).GetSyncMember("Value") ?? ((Worker)val12).GetSyncMember("Target");
							if (val13 != null)
							{
								FieldInfo field = inputNode.GetField(((ISyncMember)current2).Name);
								val6.TryConnectInput(current2, val12.GetOutput(0), true, false);
								ParameterInfo val14 = parameters[int.Parse(NonDigits.Replace(((ISyncMember)current2).Name, ""))];
								SyncMemberEditorBuilder.Build(val13, val14.Name, field, ui, 0.3f);
								if (val14.DefaultValue != null && val14.DefaultValue.GetType().IsAssignableTo(((IField)val13).ValueType))
								{
									((IField)val13).BoxedValue = val14.DefaultValue;
								}
							}
						}
					}
					finally
					{
						((global::System.IDisposable)enumerator2)?.Dispose();
					}
					if (flag2)
					{
						ui.NestOut();
					}
					if (flag)
					{
						((ContainerWorker<Component>)(object)((Component)ui.HorizontalLayout(0f, 0f, (Alignment?)null)).Slot).AttachComponent<LayoutElement>(true, (Action<LayoutElement>)null);
					}
					MethodInfo m = AccessTools.Method(type, "OnTrigger", (global::System.Type[])null, (global::System.Type[])null);
					LocaleString val15 = LocaleString.op_Implicit(((MemberInfo)current).Name);
					Button val16 = ui.Button(ref val15);
					val16.Pressed.Target = InspectorDelegateCaller.StaticSafeCreateDelegate<ButtonEventHandler>(m, (object?)val7);
					if (val8 == null)
					{
						val8 = val16;
					}
					proxySource(val8, @delegate, delegateType);
					if (flag)
					{
						global::System.Type type2 = (isRetRef ? typeof(ObjectWrite<, >) : typeof(ValueWrite<, >)).MakeGenericType(new global::System.Type[2]
						{
							typeof(FrooxEngineContext),
							returnType
						});
						ProtoFluxNode val17 = (ProtoFluxNode)((ContainerWorker<Component>)(object)val5).AttachComponent(type2, true, (Action<Component>)null);
						global::System.Type type3 = (isRetRef ? ProtoFluxHelper.ReferenceSource.MakeGenericType(new global::System.Type[1] { returnType }) : ProtoFluxHelper.GetSourceNode(returnType));
						ProtoFluxNode val18 = (ProtoFluxNode)((ContainerWorker<Component>)(object)val5).AttachComponent(type3, true, (Action<Component>)null);
						val17.TryConnectImpulse(val6.GetImpulse(0), val17.GetOperation(0), false);
						val6.TryConnectInput(val17.GetInput(0), val6.GetOutput(0), true, false);
						val17.TryConnectReference(val17.GetReference(0), val18, false);
						Button val19 = ui.Button(ref val15);
						((SyncField<colorX>)(object)((InteractionElement)val19).BaseColor).Value = colorX.Red;
						Text componentInChildren = ((Component)val19).Slot.GetComponentInChildren<Text>((Predicate<Text>)null, false, false);
						if (isRetRef)
						{
							global::System.Type type4 = typeof(ReferenceField<>).MakeGenericType(new global::System.Type[1] { returnType });
							ISyncMember syncMember = ((Worker)((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent(type4, true, (Action<Component>)null)).GetSyncMember("Reference");
							((ISource)val18).TrySetRootSource((IWorldElement)(object)syncMember);
							IField target = (IField)((Worker)((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent(type4, true, (Action<Component>)null)).GetSyncMember("Reference");
							Component obj4 = ((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent(typeof(ReferenceCopy<>).MakeGenericType(new global::System.Type[1] { returnType }), true, (Action<Component>)null);
							((ISyncRef)((Worker)obj4).GetSyncMember("Target")).Target = (IWorldElement)(object)target;
							((ISyncRef)((Worker)obj4).GetSyncMember("Source")).Target = (IWorldElement)(object)syncMember;
							RefEditor obj5 = ((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent<RefEditor>(true, (Action<RefEditor>)null);
							((ISyncRef)((Worker)obj5).GetSyncMember("_targetRef")).Target = (IWorldElement)(object)target;
							((ISyncRef)((Worker)obj5).GetSyncMember("_textDrive")).Target = (IWorldElement)(object)componentInChildren.Content;
							((ISyncRef)((Worker)((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent(typeof(ButtonReferenceSet<>).MakeGenericType(new global::System.Type[1] { returnType }), true, (Action<Component>)null)).GetSyncMember("TargetReference")).Target = (IWorldElement)(object)syncMember;
						}
						else
						{
							ISyncMember syncMember2 = ((Worker)((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent(typeof(ValueProxySource<>).MakeGenericType(new global::System.Type[1] { returnType }), true, (Action<Component>)null)).GetSyncMember("Value");
							((ISource)val18).TrySetRootSource((IWorldElement)(object)syncMember2);
							MultiValueTextFormatDriver obj6 = ((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent<MultiValueTextFormatDriver>(true, (Action<MultiValueTextFormatDriver>)null);
							obj6.Sources.Add((IField)syncMember2);
							((SyncField<string>)(object)obj6.Format).Value = "{0}";
							((SyncRef<IField<string>>)(object)obj6.Text).Target = (IField<string>)(object)componentInChildren.Content;
							Component obj7 = ((ContainerWorker<Component>)(object)((Component)val19).Slot).AttachComponent(typeof(ButtonValueSet<>).MakeGenericType(new global::System.Type[1] { returnType }), true, (Action<Component>)null);
							((ISyncRef)((Worker)obj7).GetSyncMember("TargetValue")).Target = (IWorldElement)(object)syncMember2;
							((IField)((Worker)obj7).GetSyncMember("SetValue")).BoxedValue = Coder.GetDefault(returnType);
						}
					}
					if (flag2)
					{
						ui.NestOut();
					}
					if (flag)
					{
						ui.NestOut();
					}
					ui.NestOut();
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Canvas), "TryGrab")]
		private static bool TryGrabPrefix(ref IGrabbable __result, Component grabber, Canvas __instance, Dictionary<Component, InteractionData> ____currentInteractions, in float3 point)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			Canvas __instance2 = __instance;
			InteractionData val = default(InteractionData);
			____currentInteractions.TryGetValue(grabber, ref val);
			if (val == null)
			{
				return true;
			}
			IUIInteractable val2 = (IUIInteractable)currentInteractableInfo.GetValue((object)val);
			if (val2 == null)
			{
				return true;
			}
			IDelegateProxySource componentInParents = ((IComponent)val2).Slot.GetComponentInParents<IDelegateProxySource>((Predicate<IDelegateProxySource>)((IDelegateProxySource d) => ((Component)d).Slot.Tag == "nodeGrab"), true, false);
			if (componentInParents == null)
			{
				return true;
			}
			global::System.Type delegateType = componentInParents.DelegateType;
			global::System.Type delegateNodeType = GetDelegateNodeType(AccessTools.Method(delegateType, "Invoke", (global::System.Type[])null, (global::System.Type[])null) ?? componentInParents.Delegate.Method, out delegateType);
			if (delegateNodeType == (global::System.Type)null)
			{
				return true;
			}
			Slot nodeSlot = ((Worker)__instance2).LocalUserSpace.AddSlot(((MemberInfo)delegateNodeType).Name, true);
			nodeSlot.GlobalPosition = point;
			nodeSlot.GlobalRotation = ((Component)__instance2).Slot.GlobalRotation;
			Slot obj = nodeSlot;
			float globalScale = ((Worker)__instance2).LocalUserRoot.GlobalScale;
			float3 one = float3.One;
			obj.GlobalScale = globalScale * (ref one);
			ProtoFluxNode val3 = (ProtoFluxNode)((ContainerWorker<Component>)(object)nodeSlot).AttachComponent(delegateNodeType, true, (Action<Component>)null);
			ProtoFluxVisualHelper.EnsureVisual(val3);
			if (componentInParents.Delegate != null)
			{
				CreateDelegateGlobal(val3, delegateType, componentInParents.Delegate.Method, componentInParents.Delegate.Target);
			}
			Grabbable grabbable = ((ContainerWorker<Component>)(object)nodeSlot).GetComponent<Grabbable>((Predicate<Grabbable>)null, false);
			__result = (IGrabbable)(object)grabbable;
			InteractionHandler commonTool = InteractionHandlerExtensions.FindInteractionHandler(grabber.Slot);
			if (commonTool != null)
			{
				((ComponentBase<Component>)(object)__instance2).RunInUpdates(0, (Action)delegate
				{
					//IL_007b: Unknown result type (might be due to invalid IL or missing references)
					//IL_005c: 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_0185: Unknown result type (might be due to invalid IL or missing references)
					//IL_018a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0269: Unknown result type (might be due to invalid IL or missing references)
					//IL_0279: Unknown result type (might be due to invalid IL or missing references)
					((SyncField<GrabType>)(object)(Sync<GrabType>)(object)((Worker)commonTool).GetSyncMember("_currentGrabType")).Value = (GrabType)2;
					commonTool.Grabber.Grab((IGrabbable)(object)grabbable);
					Slot holderSlot = commonTool.Grabber.HolderSlot;
					if (!((SyncElement)holderSlot.Position_Field).IsDriven)
					{
						holderSlot.GlobalPosition = commonTool.Laser.CurrentActualPoint;
					}
					((SyncField<floatQ>)(object)(Sync<floatQ>)(object)((Worker)commonTool).GetSyncMember("_holderRotationOffset")).Value = floatQ.Identity;
					IViewTargettingController val4 = ScreenControllerHelper.GetScreen(((Worker)__instance2).World)?.ActiveTargetting.Target;
					if (((Worker)__instance2).InputInterface.ScreenActive && (val4 is UI_TargettingController || val4 is FreeformTargettingController))
					{
						((SyncField<floatQ?>)(object)(Sync<floatQ?>)(object)((Worker)commonTool).GetSyncMember("_holderRotationReference")).Value = ((Worker)__instance2).World.LocalUserViewRotation;
					}
					else
					{
						((SyncField<floatQ?>)(object)(Sync<floatQ?>)(object)((Worker)commonTool).GetSyncMember("_holderRotationReference")).Value = null;
					}
					((SyncField<LaserRotationType>)(object)(Sync<LaserRotationType>)(object)((Worker)commonTool).GetSyncMember("_laserRotationType")).Value = (LaserRotationType)1;
					((SyncField<float>)(object)(Sync<float>)(object)((Worker)commonTool).GetSyncMember("_originalTwistOffset")).Value = commonTool.TwistAngle;
					float? num = null;
					ScreenController screen = ScreenControllerHelper.GetScreen(((Worker)__instance2).World);
					if (screen != null)
					{
						float3 globalCurrentPoint = commonTool.Laser.GlobalCurrentPoint;
						num = screen.GetPointViewDistance(ref globalCurrentPoint);
					}
					if (num.HasValue)
					{
						_laserGrabDistance.SetValue((object)commonTool, (object)((Component)commonTool.Laser).Slot.GlobalScaleToLocal(num.Value));
					}
					else
					{
						_laserGrabDistance.SetValue((object)commonTool, (object)commonTool.Laser.CurrentPointDistance);
					}
					_grabHitSlot.SetValue((object)commonTool, (object)commonTool.Laser.CurrentHit);
					_grabInteractionTarget.SetValue((object)commonTool, (object)commonTool.Laser.CurrentInteractionTarget);
					_isScaling.SetValue((object)commonTool, (object)true);
					commonTool.Grabber.Grab((IGrabbable)(object)grabbable);
					nodeSlot.LocalPosition = float3.Zero;
					nodeSlot.LocalRotation = floatQ.Identity;
				});
			}
			return false;
		}
	}

	private static ManualLogSource log;

	private static ConfigEntry<bool> Actions;

	private static ConfigEntry<bool> SubAction;

	private static ConfigEntry<bool> ArgAction;

	private static ConfigEntry<bool> Buttons;

	private static ConfigEntry<bool> ArgButtons;

	private static ConfigEntry<bool> FallBack;

	private static ConfigEntry<bool> RegexDebuging;

	private static ConfigEntry<bool> DefaultArgState;

	private static ConfigEntry<bool> DisableHeaderText;

	private static ConfigEntry<string> BlockerRegex;

	private static ConfigEntry<string> DisableCustomRegex;

	private static Regex? blocRegex;

	private static Regex? custRegex;

	private const string GrabNodeTag = "nodeGrab";

	public override void Load()
	{
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Expected O, but got Unknown
		Actions = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "actions", true, "show callable direct actions in inspectors");
		SubAction = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "subActions", true, "show callable non direct actions in inspectors");
		ArgAction = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "argActions", true, "show any action with arguments in inspectors");
		Buttons = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "buttons", true, "show callable buttons in inspectors");
		ArgButtons = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "argButtons", true, "show any button with arguments in inspectors");
		FallBack = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "fallBack", true, "show any other delegate with arguments in inspectors");
		DefaultArgState = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "defaultArgState", true, "default arg inputs visable");
		BlockerRegex = ((BasePlugin)this).Config.Bind<string>("InspectorDelegateCaller", "blockerRegex", "^(static )?(public |private (protected )?|protected (internal )?|internal )?((Slot|StaticGaussianSplat|VideoTextureProvider|MeshRenderer|FingerReferencePoseSource)\\.|((StaticTexture\\dD\\.|StaticTextureProvider.*?\\.)(Invert|Swap|Rotate|Flip|Tile|Adjust|Alpha|Grayscale|ShiftHue|Resize|MakeSquare|ToNearestPOT|InvalidFloats|GenerateBitmapMetadata|ReplaceFromClipboard|Trim[a-zA-Z]|(?!Color).*?Alpha(\\[| )|Normalize[a-zA-Z]|.*?(White|Black).*?\\[))|.+?\\.(((On)?Bake)(.*?(\\[IButton, ButtonEventData\\])|[a-zA-Z]*?$)|OnSetupRenderer)|ProceduralTexture3DBase\\.OnSpawnVisualizer|StaticAudioClip\\.[^A]|ProtoFluxNode\\.OnDumpStructure|SkinnedMeshRenderer\\.(SortBlendshapesBy|Visualize|StripEmpty|ExtendExplicitBoundsFromPose|ComputeExplicitBoundsFromPose|MergeBlendshapes|SeparateOutBlendshapes|ClearBoundsVisuals|ResetBonesToBindPoses))", "regex string that defines what delegates to skip");
		RegexDebuging = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "regexDebug", false, "log each time regex is used and what if anything matched");
		DisableCustomRegex = ((BasePlugin)this).Config.Bind<string>("InspectorDelegateCaller", "customInspectorDisableRegex", "PBS_Slice|AudioZitaReverb|PagingControl|DataPreset|RootSpace|MazeGenerator|HapticManager|PhysicalLocomotion|.*?Collider|DynamicBoneChain|GridContainer|DataFeedItemMapper|RootCategoryView|BreadcrumbManager|Workspace|AmbientLightSH2|Animator|DirectVisemeDriver|MaterialSet|GaussianSplatRenderer|Rig|Skybox|BipedRig|HandPoser|BooleanSwitcher|LookAt|DynamicBlendShapeDriver|ObjectRoot|ScaleObjectManager|CommonAvatarBuilder|SimpleAwayIndicatoCubemapCreator|SettingComponent|ItemTextureThumbnailSource|AvatarExpressionDriver|EyeRotationDriver\\+Eye|SimpleAvatarProtection|PhotonDust\\+.*?Lifetime|VRIKAvatar", "regex string that defines what workers should use the default inspector generation");
		DisableHeaderText = ((BasePlugin)this).Config.Bind<bool>("InspectorDelegateCaller", "disableHeaderText", false, "Disables the warning text some components have after the header");
		log = ((BasePlugin)this).Log;
		BlockerRegex.SettingChanged += new EventHandler(BlockerRegex_SettingChanged);
		BlockerRegex_SettingChanged();
		DisableCustomRegex.SettingChanged += new EventHandler(DisableCustomInspectorsRegex_SettingChanged);
		DisableCustomInspectorsRegex_SettingChanged();
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}

	private void BlockerRegex_SettingChanged(object? sender = null, EventArgs e = null)
	{
		UpdateRegex(ref blocRegex, BlockerRegex);
	}

	private void DisableCustomInspectorsRegex_SettingChanged(object? sender = null, EventArgs e = null)
	{
		UpdateRegex(ref custRegex, DisableCustomRegex);
	}

	private static bool hasSyncMethod(MethodInfo info)
	{
		return Enumerable.Any<CustomAttributeData>(((MemberInfo)info).CustomAttributes, (Func<CustomAttributeData, bool>)((CustomAttributeData a) => a.AttributeType.IsAssignableTo(typeof(SyncMethod))));
	}

	private static bool isButtonDelegate(ParameterInfo[] param)
	{
		if (param[1].ParameterType == typeof(ButtonEventData) || param[1].ParameterType.BaseType == typeof(ButtonEventData))
		{
			return param[0].ParameterType.IsAssignableTo(typeof(IButton));
		}
		return false;
	}

	private static void actionui(Worker worker, UIBuilder ui, MethodInfo m)
	{
		//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)
		LocaleString val = LocaleString.op_Implicit(((MemberInfo)m).Name);
		Button obj = ui.Button(ref val);
		Action val2 = StaticSafeCreateDelegate<Action>(m, (object?)worker);
		((ContainerWorker<Component>)(object)((Component)obj).Slot).AttachComponent<ButtonActionTrigger>(true, (Action<ButtonActionTrigger>)null).OnPressed.Target = val2;
		proxySource(obj, (global::System.Delegate)(object)val2, typeof(Action));
	}

	private static void actionCallbackwitharg(bool isRef, Worker worker, UIBuilder ui, MethodInfo m, ParameterInfo p, global::System.Type pt)
	{
		//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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Expected O, but got Unknown
		ui.HorizontalLayout(0f, 0f, (Alignment?)null);
		LocaleString val = LocaleString.op_Implicit(((MemberInfo)m).Name);
		Button val2 = ui.Button(ref val);
		global::System.Type type = typeof(Action<>).MakeGenericType(new global::System.Type[1] { pt });
		global::System.Type type2 = (isRef ? typeof(CallbackRefArgument<>) : typeof(CallbackValueArgument<>)).MakeGenericType(new global::System.Type[1] { pt });
		Component val3 = ((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent(type2, true, (Action<Component>)null);
		global::System.Type type3 = typeof(SyncDelegate<>).MakeGenericType(new global::System.Type[1] { type });
		global::System.Delegate @delegate = StaticSafeCreateDelegate(m, type, worker);
		type3.GetProperty("Target").SetValue(type2.GetField("Callback").GetValue((object)val3), (object)@delegate);
		proxySource(val2, @delegate, type);
		string text = (isRef ? "Reference" : "Value");
		SyncMemberEditorBuilder.Build(((Worker)val3).GetSyncMember(text), p.Name, type2.GetField(text), ui, 0.3f);
		((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent<ButtonActionTrigger>(true, (Action<ButtonActionTrigger>)null).OnPressed.Target = (Action)type2.GetMethod("Call").CreateDelegate(typeof(Action), (object)val3);
		ui.NestOut();
	}

	private static void buttonCallbackwitharg(global::System.Type genType, Worker worker, UIBuilder ui, MethodInfo m, ParameterInfo p, global::System.Type pt)
	{
		//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)
		ui.HorizontalLayout(0f, 0f, (Alignment?)null);
		LocaleString val = LocaleString.op_Implicit(((MemberInfo)m).Name);
		Button val2 = ui.Button(ref val);
		global::System.Type type = typeof(ButtonEventHandler<>).MakeGenericType(new global::System.Type[1] { pt });
		global::System.Type type2 = genType.MakeGenericType(new global::System.Type[1] { pt });
		Component val3 = ((ContainerWorker<Component>)(object)((Component)val2).Slot).AttachComponent(type2, true, (Action<Component>)null);
		global::System.Type type3 = typeof(SyncDelegate<>).MakeGenericType(new global::System.Type[1] { type });
		global::System.Delegate @delegate = StaticSafeCreateDelegate(m, type, worker);
		type3.GetProperty("Target").SetValue(type2.GetField("ButtonPressed").GetValue((object)val3), (object)@delegate);
		proxySource(val2, @delegate, type);
		SyncMemberEditorBuilder.Build(((Worker)val3).GetSyncMember("Argument"), p.Name, type2.GetField("Argument"), ui, 0.3f);
		ui.NestOut();
	}

	private static void proxySource(Button b, global::System.Delegate Delegate, global::System.Type delegateType)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		global::System.Type type = typeof(DelegateProxySource<>).MakeGenericType(new global::System.Type[1] { delegateType });
		((IDelegateProxySource)((ContainerWorker<Component>)(object)((Component)b).Slot).AttachComponent(type, true, (Action<Component>)null)).Delegate = Delegate;
		((Component)b).Slot.Tag = "nodeGrab";
	}

	private static bool IsMatch(ConfigEntry<string> configEntry, Regex? regex, string input)
	{
		if (RegexDebuging.Value)
		{
			string key = ((ConfigEntryBase)configEntry).Definition.Key;
			log.LogInfo((object)(key + " Regexing: " + input));
			MatchCollection val = ((regex != null) ? regex.Matches(input) : null);
			int num;
			if (val == null)
			{
				num = 0;
			}
			else
			{
				num = ((val.Count > 0) ? 1 : 0);
				if (num != 0)
				{
					log.LogInfo((object)(key + " matched: " + string.Join(" ", Enumerable.Select<Match, string>((global::System.Collections.Generic.IEnumerable<Match>)val, (Func<Match, string>)((Match e) => "[" + string.Join(", ", Enumerable.Select<Group, string>(e.Groups.Values, (Func<Group, string>)((Group g) => g.Name + " : " + ((Capture)g).Value))) + "]")))));
				}
			}
			return (byte)num != 0;
		}
		if (regex == null)
		{
			return false;
		}
		return regex.IsMatch(input);
	}

	private void UpdateRegex(ref Regex? regex, ConfigEntry<string> configEntry)
	{
		//IL_003d: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		if (((object)regex)?.ToString() != configEntry.Value && configEntry.Value != "")
		{
			try
			{
				regex = new Regex(configEntry.Value);
				return;
			}
			catch (RegexParseException val)
			{
				RegexParseException val2 = val;
				ManualLogSource obj = ((BasePlugin)this).Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(57, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("invalid config option ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((ConfigEntryBase)configEntry).Definition.Key);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", cannot parse regular expression: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((global::System.Exception)(object)val2).Message);
				}
				obj.LogWarning(val3);
				return;
			}
		}
		regex = null;
	}

	private static global::System.Type GetDelegateNodeType(MethodInfo m, out global::System.Type delegateType)
	{
		bool isAsync = false;
		bool isRetRef = false;
		global::System.Type returnType = null;
		return GetDelegateNodeType(m, out isAsync, out isRetRef, out delegateType, out returnType);
	}

	private static global::System.Type GetDelegateNodeType(MethodInfo m, out bool isAsync, out bool isRetRef, out global::System.Type delegateType, out global::System.Type returnType)
	{
		isAsync = false;
		isRetRef = false;
		delegateType = null;
		returnType = m.ReturnType;
		ParameterInfo[] parameters = ((MethodBase)m).GetParameters();
		if (Enumerable.Any<ParameterInfo>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)parameters, (Func<ParameterInfo, bool>)((ParameterInfo p) => p.ParameterType.IsByRef)))
		{
			return null;
		}
		global::System.Type type;
		if (returnType == typeof(void))
		{
			type = typeof(SyncMethodProxy);
		}
		else if (returnType == typeof(global::System.Threading.Tasks.Task))
		{
			type = typeof(AsyncMethodProxy);
			returnType = typeof(void);
			isAsync = true;
		}
		else if (!returnType.IsGenericType || !(returnType.GetGenericTypeDefinition() == typeof(global::System.Threading.Tasks.Task<>)))
		{
			isRetRef = !ReflectionHelper.IsUnmanaged(returnType);
			type = (isRetRef ? typeof(SyncObjectFunctionProxy<>) : typeof(SyncValueFunctionProxy<>));
		}
		else
		{
			global::System.Type type2 = returnType.GetGenericArguments()[0];
			isRetRef = !ReflectionHelper.IsUnmanaged(type2);
			type = (isRetRef ? typeof(AsyncObjectFunctionProxy<>) : typeof(AsyncValueFunctionProxy<>));
			returnType = type2;
			isAsync = true;
		}
		if (parameters.Length != 0)
		{
			int num = 0;
			for (int i = 0; i < parameters.Length; i++)
			{
				if (!ReflectionHelper.IsUnmanaged(parameters[i].ParameterType))
				{
					num |= 1 << i;
				}
			}
			List<global::System.Type> val = new List<global::System.Type>(Enumerable.Select<ParameterInfo, global::System.Type>((global::System.Collections.Generic.IEnumerable<ParameterInfo>)parameters, (Func<ParameterInfo, global::System.Type>)((ParameterInfo p) => p.ParameterType)));
			if (returnType != typeof(void))
			{
				val.Add(returnType);
			}
			string text = type.FullName;
			int num2 = text.IndexOf('`');
			if (num2 >= 0)
			{
				text = text.Substring(0, num2);
			}
			type = global::System.Type.GetType(text.Replace("Proxy", $"Proxy_{num:X4}`{val.Count}") + ", FrooxEngine");
			if (type == (global::System.Type)null)
			{
				return null;
			}
			type = type.MakeGenericType(val.ToArray());
		}
		else if (type.IsGenericType)
		{
			type = type.MakeGenericType(new global::System.Type[1] { returnType });
		}
		PropertyInfo obj = AccessTools.Property(type, "DelegateType");
		delegateType = (global::System.Type)((obj != null) ? obj.GetValue((object)null) : null);
		return ProtoFluxHelper.GetBindingForNode(type);
	}

	private static global::System.Delegate CreateDelegateGlobal(ProtoFluxNode proxyNode, global::System.Type delegateType, MethodInfo m, object? target = null)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		global::System.Type type = typeof(GlobalDelegate<>).MakeGenericType(new global::System.Type[1] { delegateType });
		IGlobalValueProxy val = (IGlobalValueProxy)((ContainerWorker<Component>)(object)((Component)proxyNode).Slot).AttachComponent(type, true, (Action<Component>)null);
		global::System.Delegate @delegate = StaticSafeCreateDelegate(m, delegateType, target);
		val.TrySetValue((object)@delegate);
		proxyNode.GetGlobalRef(0).TrySet((IWorldElement)(object)val);
		return @delegate;
	}

	private static global::System.Delegate StaticSafeCreateDelegate(MethodInfo m, global::System.Type delegateType, object? target)
	{
		return m.CreateDelegate(delegateType, ((MethodBase)m).IsStatic ? null : target);
	}

	private static T StaticSafeCreateDelegate<T>(MethodInfo m, object? target) where T : global::System.Delegate
	{
		return (T)StaticSafeCreateDelegate(m, typeof(T), target);
	}

	private static List<MethodInfo> GetAllMethods(global::System.Type type)
	{
		List<MethodInfo> val = new List<MethodInfo>();
		while (type != (global::System.Type)null)
		{
			val.AddRange((global::System.Collections.Generic.IEnumerable<MethodInfo>)AccessTools.GetDeclaredMethods(type));
			type = type.BaseType;
		}
		return val;
	}
}
public static class PluginMetadata
{
	public const string GUID = "net.eia485.InspectorDelegateCaller";

	public const string NAME = "InspectorDelegateCaller";

	public const string VERSION = "2.1.0";

	public const string AUTHORS = "eia485";

	public const string REPOSITORY_URL = "https://github.com/EIA485/NeosInspectorDelegateCaller";
}