Decompiled source of JustBoundedUIX v2.0.1

plugins/JustBoundedUIX/JustBoundedUIX.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
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.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+c938ec1397b94c990c028be87374a2173e916bf9")]
[assembly: AssemblyProduct("JustBoundedUIX")]
[assembly: AssemblyTitle("JustBoundedUIX")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/JustBoundedUIX")]
[assembly: AssemblyVersion("2.0.1.0")]
[module: RefSafetyRules(11)]
namespace JustBoundedUIX;

[ResonitePlugin("art0007i.JustBoundedUIX", "JustBoundedUIX", "2.0.1", "art0007i", "https://github.com/art0007i/JustBoundedUIX")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch]
	internal static class SceneInspectorPatches
	{
		[CompilerGenerated]
		private sealed class <TargetMethods>d__0 : global::System.Collections.Generic.IEnumerable<MethodBase>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<MethodBase>, global::System.Collections.IEnumerator, global::System.IDisposable
		{
			private int <>1__state;

			private MethodBase <>2__current;

			private int <>l__initialThreadId;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					MethodInfo val = AccessTools.Method(typeof(SceneInspector), "OnInsertParentPressed", (global::System.Type[])null, (global::System.Type[])null);
					<>2__current = (MethodBase)(object)val;
					<>1__state = 1;
					return true;
				}
				case 1:
				{
					<>1__state = -1;
					MethodInfo val = AccessTools.Method(typeof(SceneInspector), "OnAddChildPressed", (global::System.Type[])null, (global::System.Type[])null);
					<>2__current = (MethodBase)(object)val;
					<>1__state = 2;
					return true;
				}
				case 2:
					<>1__state = -1;
					return false;
				}
			}

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

			[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<MethodBase> global::System.Collections.Generic.IEnumerable<MethodBase>.GetEnumerator()
			{
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					return this;
				}
				return new <TargetMethods>d__0(0);
			}

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

		[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 MethodInfo <lookFor>5__2;

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

			private CodeInstruction <code>5__4;

			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) <= 2u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<lookFor>5__2 = null;
				<>7__wrap2 = null;
				<code>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00ce: 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_00f1: Expected O, but got Unknown
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<lookFor>5__2 = typeof(Slot).GetMethod("AddSlot");
						<>7__wrap2 = codes.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						if (CodeInstructionExtensions.Calls(<code>5__4, <lookFor>5__2))
						{
							<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
							<>1__state = 2;
							return true;
						}
						goto IL_0104;
					case 2:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Call, (object)typeof(SceneInspectorPatches).GetMethod("ProxyFunc"));
						<>1__state = 3;
						return true;
					case 3:
						{
							<>1__state = -3;
							goto IL_0104;
						}
						IL_0104:
						<code>5__4 = null;
						break;
					}
					if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext())
					{
						<code>5__4 = <>7__wrap2.Current;
						<>2__current = <code>5__4;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>7__wrap2 = 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__wrap2 != null)
				{
					((global::System.IDisposable)<>7__wrap2).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();
			}
		}

		[IteratorStateMachine(typeof(<TargetMethods>d__0))]
		private static global::System.Collections.Generic.IEnumerable<MethodBase> TargetMethods()
		{
			yield return (MethodBase)(object)AccessTools.Method(typeof(SceneInspector), "OnInsertParentPressed", (global::System.Type[])null, (global::System.Type[])null);
			yield return (MethodBase)(object)AccessTools.Method(typeof(SceneInspector), "OnAddChildPressed", (global::System.Type[])null, (global::System.Type[])null);
		}

		[IteratorStateMachine(typeof(<Transpiler>d__1))]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			MethodInfo lookFor = typeof(Slot).GetMethod("AddSlot");
			global::System.Collections.Generic.IEnumerator<CodeInstruction> enumerator = codes.GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					CodeInstruction code = enumerator.Current;
					yield return code;
					if (CodeInstructionExtensions.Calls(code, lookFor))
					{
						yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
						yield return new CodeInstruction(OpCodes.Call, (object)typeof(SceneInspectorPatches).GetMethod("ProxyFunc"));
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}

		public static Slot ProxyFunc(Slot sl, SceneInspector i)
		{
			Slot target = i.ComponentView.Target;
			if (target != null)
			{
				RectTransform component = ((ContainerWorker<Component>)(object)target).GetComponent<RectTransform>((Predicate<RectTransform>)null, false);
				if (component != null && component.Canvas != null)
				{
					((ContainerWorker<Component>)(object)sl).AttachComponent<RectTransform>(true, (Action<RectTransform>)null);
				}
			}
			return sl;
		}
	}

	[HarmonyPatch(typeof(SlotGizmo))]
	internal static class SlotGizmoPatches
	{
		[CompilerGenerated]
		private sealed class <OnCommonUpdateTranspiler>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 <OnCommonUpdateTranspiler>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) <= 3u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = null;
				<code>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Expected O, but got Unknown
				//IL_00de: 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_00f2: Expected O, but got Unknown
				//IL_0093: 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_00a3: 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;
						if (CodeInstructionExtensions.Calls(<code>5__3, computeBoundingBoxMethod))
						{
							<>2__current = new CodeInstruction(OpCodes.Ldloc_0, (object)null);
							<>1__state = 2;
							return true;
						}
						goto IL_0105;
					case 2:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Ldloc_3, (object)null);
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Call, (object)boundUIXMethod);
						<>1__state = 4;
						return true;
					case 4:
						{
							<>1__state = -3;
							goto IL_0105;
						}
						IL_0105:
						<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()
			{
				<OnCommonUpdateTranspiler>d__3 <OnCommonUpdateTranspiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<OnCommonUpdateTranspiler>d__ = this;
				}
				else
				{
					<OnCommonUpdateTranspiler>d__ = new <OnCommonUpdateTranspiler>d__3(0);
				}
				<OnCommonUpdateTranspiler>d__.codes = <>3__codes;
				return <OnCommonUpdateTranspiler>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 MethodInfo boundUIXMethod = typeof(SlotGizmoPatches).GetMethod("BoundUIX", AccessTools.allDeclared);

		private static readonly MethodInfo computeBoundingBoxMethod = typeof(BoundsHelper).GetMethod("ComputeBoundingBox", AccessTools.allDeclared);

		private static BoundingBox BoundUIX(BoundingBox bounds, Slot target, Slot space)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//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_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_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)
			//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_0097: 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_00af: 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)
			//IL_00b7: 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)
			//IL_00c0: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((ContainerWorker<Component>)(object)target).GetComponent<RectTransform>((Predicate<RectTransform>)null, false);
			if (component != null && component.Canvas != null && ((Component)component).Slot != ((Component)component.Canvas).Slot)
			{
				Rect val = component.ComputeGlobalComputeRect();
				Slot slot = ((Component)component.Canvas).Slot;
				float2 extentMin = ((Rect)(ref val)).ExtentMin;
				float2 val2 = (ref extentMin) / Sync<float>.op_Implicit(component.Canvas.UnitScale);
				float3 val3 = float2.op_Implicit(ref val2);
				float3 val4 = slot.LocalPointToGlobal(ref val3);
				float3 val5 = space.GlobalPointToLocal(ref val4);
				((BoundingBox)(ref bounds)).Encapsulate(ref val5);
				Slot slot2 = ((Component)component.Canvas).Slot;
				extentMin = ((Rect)(ref val)).ExtentMax;
				val2 = (ref extentMin) / Sync<float>.op_Implicit(component.Canvas.UnitScale);
				val3 = float2.op_Implicit(ref val2);
				val4 = slot2.LocalPointToGlobal(ref val3);
				val5 = space.GlobalPointToLocal(ref val4);
				((BoundingBox)(ref bounds)).Encapsulate(ref val5);
			}
			return bounds;
		}

		[IteratorStateMachine(typeof(<OnCommonUpdateTranspiler>d__3))]
		[HarmonyTranspiler]
		[HarmonyPatch("OnCommonUpdate")]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> OnCommonUpdateTranspiler(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;
					if (CodeInstructionExtensions.Calls(code, computeBoundingBoxMethod))
					{
						yield return new CodeInstruction(OpCodes.Ldloc_0, (object)null);
						yield return new CodeInstruction(OpCodes.Ldloc_3, (object)null);
						yield return new CodeInstruction(OpCodes.Call, (object)boundUIXMethod);
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}
	}

	[HarmonyPatch(typeof(RectTransform), "BuildInspectorUI")]
	internal class RectTransformPatch
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass0_1
		{
			[StructLayout((LayoutKind)3)]
			private struct <<Postfix>b__1>d : IAsyncStateMachine
			{
				public int <>1__state;

				public AsyncTaskMethodBuilder <>t__builder;

				public <>c__DisplayClass0_1 <>4__this;

				private NextUpdate <>u__1;

				private void MoveNext()
				{
					//IL_0165: 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_0172: 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_0030: 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_0046: Unknown result type (might be due to invalid IL or missing references)
					//IL_005a: Unknown result type (might be due to invalid IL or missing references)
					//IL_005f: 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_007d: 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_008b: 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_0094: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ad: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ef: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
					//IL_0102: Unknown result type (might be due to invalid IL or missing references)
					//IL_0116: Unknown result type (might be due to invalid IL or missing references)
					//IL_011b: Unknown result type (might be due to invalid IL or missing references)
					//IL_012d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0133: Unknown result type (might be due to invalid IL or missing references)
					//IL_0138: Unknown result type (might be due to invalid IL or missing references)
					//IL_014d: Unknown result type (might be due to invalid IL or missing references)
					//IL_014f: Unknown result type (might be due to invalid IL or missing references)
					int num = <>1__state;
					<>c__DisplayClass0_1 <>c__DisplayClass0_ = <>4__this;
					try
					{
						if (num != 0)
						{
							goto IL_0188;
						}
						NextUpdate val = <>u__1;
						<>u__1 = default(NextUpdate);
						num = (<>1__state = -1);
						goto IL_0181;
						IL_0181:
						((NextUpdate)(ref val)).GetResult();
						goto IL_0188;
						IL_0188:
						if (!((IWorldElement)<>c__DisplayClass0_.b).IsRemoved)
						{
							float preferred = <>c__DisplayClass0_.rt.GetHorizontalMetrics().preferred;
							float preferred2 = <>c__DisplayClass0_.rt.GetVerticalMetrics().preferred;
							Rect val2 = <>c__DisplayClass0_.rt.ComputeGlobalComputeRect();
							Slot slot = ((Component)<>c__DisplayClass0_.rt.Canvas).Slot;
							float2 center = ((Rect)(ref val2)).Center;
							float2 val3 = (ref center) / Sync<float>.op_Implicit(<>c__DisplayClass0_.rt.Canvas.UnitScale);
							float3 val4 = new float3(float2.op_Implicit(ref val3));
							float3 val5 = slot.LocalPointToGlobal(ref val4);
							Slot slot2 = ((Component)<>c__DisplayClass0_.rt.Canvas).Slot;
							val4 = new float3(preferred, preferred2, 0f);
							float3 val6 = (ref val4) / Sync<float>.op_Implicit(<>c__DisplayClass0_.rt.Canvas.UnitScale);
							float3 val7 = slot2.LocalScaleToGlobal(ref val6);
							DebugManager debug = ((Worker)<>c__DisplayClass0_.rt).World.Debug;
							colorX val8 = colorX.Blue;
							val8 = ((colorX)(ref val8)).SetA(0.25f);
							floatQ globalRotation = ((Component)<>c__DisplayClass0_.rt.Canvas).Slot.GlobalRotation;
							debug.Box(ref val5, ref val7, ref val8, ref globalRotation, 0f, false);
							NextUpdate val9 = default(NextUpdate);
							val = ((NextUpdate)(ref val9)).GetAwaiter();
							if (!((NextUpdate)(ref val)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = val;
								((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<NextUpdate, <<Postfix>b__1>d>(ref val, ref this);
								return;
							}
							goto IL_0181;
						}
					}
					catch (global::System.Exception exception)
					{
						<>1__state = -2;
						((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
						return;
					}
					<>1__state = -2;
					((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult();
				}

				[DebuggerHidden]
				private void SetStateMachine(IAsyncStateMachine stateMachine)
				{
					((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
				}
			}

			public RectTransform rt;

			public IButton b;

			[AsyncStateMachine(typeof(<<Postfix>b__1>d))]
			internal global::System.Threading.Tasks.Task <Postfix>b__1()
			{
				//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)
				<<Postfix>b__1>d <<Postfix>b__1>d = default(<<Postfix>b__1>d);
				<<Postfix>b__1>d.<>t__builder = AsyncTaskMethodBuilder.Create();
				<<Postfix>b__1>d.<>4__this = this;
				<<Postfix>b__1>d.<>1__state = -1;
				((AsyncTaskMethodBuilder)(ref <<Postfix>b__1>d.<>t__builder)).Start<<<Postfix>b__1>d>(ref <<Postfix>b__1>d);
				return ((AsyncTaskMethodBuilder)(ref <<Postfix>b__1>d.<>t__builder)).Task;
			}
		}

		public static void Postfix(RectTransform __instance, UIBuilder ui)
		{
			//IL_0013: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			LocaleString val = LocaleString.op_Implicit("Visualize Preferred Area");
			ui.Button(ref val).LocalPressed += (ButtonEventHandler)delegate(IButton b, ButtonEventData e)
			{
				<>c__DisplayClass0_1 CS$<>8__locals6 = new <>c__DisplayClass0_1();
				CS$<>8__locals6.b = b;
				CS$<>8__locals6.rt = __instance;
				if (CS$<>8__locals6.rt != null && CS$<>8__locals6.rt.Canvas != null)
				{
					((IComponentBase)CS$<>8__locals6.b).Enabled = false;
					((Worker)__instance).StartTask((Func<global::System.Threading.Tasks.Task>)([AsyncStateMachine(typeof(<>c__DisplayClass0_1.<<Postfix>b__1>d))] () =>
					{
						//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)
						<>c__DisplayClass0_1.<<Postfix>b__1>d <<Postfix>b__1>d = default(<>c__DisplayClass0_1.<<Postfix>b__1>d);
						<<Postfix>b__1>d.<>t__builder = AsyncTaskMethodBuilder.Create();
						<<Postfix>b__1>d.<>4__this = CS$<>8__locals6;
						<<Postfix>b__1>d.<>1__state = -1;
						((AsyncTaskMethodBuilder)(ref <<Postfix>b__1>d.<>t__builder)).Start<<>c__DisplayClass0_1.<<Postfix>b__1>d>(ref <<Postfix>b__1>d);
						return ((AsyncTaskMethodBuilder)(ref <<Postfix>b__1>d.<>t__builder)).Task;
					}));
				}
			};
		}
	}

	internal static ManualLogSource Log;

	public override void Load()
	{
		Log = ((BasePlugin)this).Log;
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}

	public static RectTransform GetRectTransform(Slot target)
	{
		if (target == null)
		{
			return null;
		}
		RectTransform component = ((ContainerWorker<Component>)(object)target).GetComponent<RectTransform>((Predicate<RectTransform>)null, false);
		if (component != null && component.Canvas != null && ((Component)component).Slot != ((Component)component.Canvas).Slot)
		{
			return component;
		}
		return null;
	}

	public static BoundingBox GetBoundingBox(RectTransform rt)
	{
		//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_0007: 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_001c: 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_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_003c: 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_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_0062: 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_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_008b: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		Rect val = rt.ComputeGlobalComputeRect();
		BoundingBox result = BoundingBox.Empty();
		Slot slot = ((Component)rt.Canvas).Slot;
		float2 extentMin = ((Rect)(ref val)).ExtentMin;
		float2 val2 = (ref extentMin) / Sync<float>.op_Implicit(rt.Canvas.UnitScale);
		float3 val3 = float2.op_Implicit(ref val2);
		float3 val4 = slot.LocalPointToGlobal(ref val3);
		((BoundingBox)(ref result)).Encapsulate(ref val4);
		Slot slot2 = ((Component)rt.Canvas).Slot;
		extentMin = ((Rect)(ref val)).ExtentMax;
		val2 = (ref extentMin) / Sync<float>.op_Implicit(rt.Canvas.UnitScale);
		val3 = float2.op_Implicit(ref val2);
		val4 = slot2.LocalPointToGlobal(ref val3);
		((BoundingBox)(ref result)).Encapsulate(ref val4);
		return result;
	}
}
public static class PluginMetadata
{
	public const string GUID = "art0007i.JustBoundedUIX";

	public const string NAME = "JustBoundedUIX";

	public const string VERSION = "2.0.1";

	public const string AUTHORS = "art0007i";

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