Decompiled source of ContextMenuFunnies v1.2.4

plugins/ContextMenuFunnies/ContextMenuFunnies.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.UIX;
using HarmonyLib;
using Renderite.Shared;

[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("LeCloutPanda")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.3.0")]
[assembly: AssemblyInformationalVersion("1.2.3+09be6c0bb12ccf56294f95fa3d8858f08fe6333d")]
[assembly: AssemblyProduct("Context Menu Funnies")]
[assembly: AssemblyTitle("ContextMenuFunnies")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LeCloutPanda/ContextMenuFunnies")]
[assembly: AssemblyVersion("1.2.3.0")]
[module: RefSafetyRules(11)]
namespace ContextMenuFunnies;

[ResonitePlugin("dev.lecloutpanda.contextmenufunnies", "Context Menu Funnies", "1.2.3", "LeCloutPanda", "https://github.com/LeCloutPanda/ContextMenuFunnies")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Patch : BasePlugin
{
	[HarmonyPatch(typeof(ContextMenu))]
	private class ContextMenuPatch
	{
		[HarmonyPatch(typeof(ContextMenuItem))]
		private class ContextMenuItemPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("Initialize")]
			public static void InitializePostfix(ContextMenuItem __instance, OutlinedArc arc)
			{
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				if (WorldExtensions.IsUserspace(((Worker)__instance).World) || !MASTER_ENABLED.Value || __instance == null || ((Component)__instance).Slot == null || arc == null)
				{
					return;
				}
				UserRoot activeUserRoot = ((Component)__instance).Slot.ActiveUserRoot;
				User val = ((activeUserRoot != null) ? activeUserRoot.ActiveUser : null);
				if (val == null || val != ((Worker)__instance).LocalUser)
				{
					return;
				}
				Slot slot = ((Component)__instance).Slot;
				ContextMenu val2 = ((slot != null) ? slot.GetComponentInParents<ContextMenu>((Predicate<ContextMenu>)null, true, false) : null);
				Chirality? obj;
				if (val2 == null)
				{
					obj = null;
				}
				else
				{
					SyncRef<Slot> pointer = val2.Pointer;
					if (pointer == null)
					{
						obj = null;
					}
					else
					{
						Slot target = pointer.Target;
						if (target == null)
						{
							obj = null;
						}
						else
						{
							InteractionLaser component = ((ContainerWorker<Component>)(object)target).GetComponent<InteractionLaser>((Predicate<InteractionLaser>)null, false);
							obj = ((component != null) ? new Chirality?(component.Side) : null);
						}
					}
				}
				Chirality? val3 = obj;
				if (val2 != null && val3.HasValue && ((Component)val2).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance).LocalUser)
				{
					((SyncField<float>)(object)arc.RoundedCornerRadius).Value = ((val3 == (Chirality?)1) ? RIGHT_ROUNDED_CORNER_RADIUS.Value : LEFT_ROUNDED_CORNER_RADIUS.Value);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpdateColor", new global::System.Type[] { })]
			public static void UpdateColorPostfix(ContextMenuItem __instance, SyncRef<Button> ____button)
			{
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: 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_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				if (WorldExtensions.IsUserspace(((Worker)__instance).World) || !MASTER_ENABLED.Value || __instance == null || ((Component)__instance).Slot == null || ____button == null)
				{
					return;
				}
				UserRoot activeUserRoot = ((Component)__instance).Slot.ActiveUserRoot;
				User val = ((activeUserRoot != null) ? activeUserRoot.ActiveUser : null);
				if (val == null || val != ((Worker)__instance).LocalUser)
				{
					return;
				}
				Slot slot = ((Component)__instance).Slot;
				ContextMenu val2 = ((slot != null) ? slot.GetComponentInParents<ContextMenu>((Predicate<ContextMenu>)null, true, false) : null);
				Chirality? obj;
				if (val2 == null)
				{
					obj = null;
				}
				else
				{
					SyncRef<Slot> pointer = val2.Pointer;
					if (pointer == null)
					{
						obj = null;
					}
					else
					{
						Slot target = pointer.Target;
						if (target == null)
						{
							obj = null;
						}
						else
						{
							InteractionLaser component = ((ContainerWorker<Component>)(object)target).GetComponent<InteractionLaser>((Predicate<InteractionLaser>)null, false);
							obj = ((component != null) ? new Chirality?(component.Side) : null);
						}
					}
				}
				Chirality? val3 = obj;
				if (val2 != null && val3.HasValue && ((Component)val2).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance).LocalUser)
				{
					ColorDriver val4 = ((SyncElementList<ColorDriver>)(object)((InteractionElement)(____button?.Target?)).ColorDrivers)[0];
					if (val4 != null)
					{
						float num = ((val3 == (Chirality?)1) ? RIGHT_FILL_COLOR_ALPHA.Value : LEFT_FILL_COLOR_ALPHA.Value);
						colorX value = ((SyncField<colorX>)(object)val4.NormalColor).Value;
						colorX value2 = ((SyncField<colorX>)(object)val4.HighlightColor).Value;
						colorX value3 = ((SyncField<colorX>)(object)val4.PressColor).Value;
						((SyncField<colorX>)(object)val4.NormalColor).Value = new colorX(((colorX)(ref value)).r, ((colorX)(ref value)).g, ((colorX)(ref value)).b, num, (ColorProfile)1);
						((SyncField<colorX>)(object)val4.HighlightColor).Value = new colorX(((colorX)(ref value2)).r, ((colorX)(ref value2)).g, ((colorX)(ref value2)).b, num, (ColorProfile)1);
						((SyncField<colorX>)(object)val4.PressColor).Value = new colorX(((colorX)(ref value3)).r, ((colorX)(ref value3)).g, ((colorX)(ref value3)).b, num, (ColorProfile)1);
					}
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ContextMenu), "OpenMenu")]
		private static void PrefixOpenMenu(ContextMenu __instance, Sync<float> ___Separation, Sync<float> ___RadiusRatio, SyncRef<ArcLayout> ____arcLayout, SyncRef<OutlinedArc> ____innerCircle, SyncRef<Image> ____iconImage, SyncRef ____currentSummoner)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			ContextMenu __instance2 = __instance;
			Sync<float> ___Separation2 = ___Separation;
			Sync<float> ___RadiusRatio2 = ___RadiusRatio;
			SyncRef<ArcLayout> ____arcLayout2 = ____arcLayout;
			SyncRef<OutlinedArc> ____innerCircle2 = ____innerCircle;
			if (WorldExtensions.IsUserspace(((Worker)__instance2).World) || !MASTER_ENABLED.Value)
			{
				return;
			}
			((ComponentBase<Component>)(object)__instance2).RunInUpdates(1, (Action)delegate
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Invalid comparison between Unknown and I4
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Invalid comparison between Unknown and I4
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Invalid comparison between Unknown and I4
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Invalid comparison between Unknown and I4
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Invalid comparison between Unknown and I4
				//IL_00c0: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Invalid comparison between Unknown and I4
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Invalid comparison between Unknown and I4
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Invalid comparison between Unknown and I4
				//IL_0142: 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)
				if (((Component)__instance2).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance2).LocalUser)
				{
					Chirality side = ((ContainerWorker<Component>)(object)__instance2.Pointer.Target).GetComponent<InteractionLaser>((Predicate<InteractionLaser>)null, false).Side;
					float value = (((int)side == 1) ? RIGHT_SEPERATION.Value : LEFT_SEPERATION.Value);
					float value2 = (((int)side == 1) ? RIGHT_RADIUS_RATIO.Value : LEFT_RADIUS_RATIO.Value);
					float num = (((int)side == 1) ? RIGHT_ARCLAYOUT_ARC.Value : LEFT_ARCLAYOUT_ARC.Value);
					float value3 = (((int)side == 1) ? RIGHT_ARCLAYOUT_OFFSET.Value : LEFT_ARCLAYOUT_OFFSET.Value);
					Direction value4 = (((int)side == 1) ? RIGHT_ITEM_DIRECTION.Value : LEFT_ITEM_DIRECTION.Value);
					bool enabled = (((int)side == 1) ? RIGHT_INNER_CIRCLE_ENABLED.Value : LEFT_INNER_CIRCLE_ENABLED.Value);
					CurvePreset val = (((int)side == 1) ? RIGHT_ANIMATION_CURVE.Value : LEFT_ANIMATION_CURVE.Value);
					float num2 = (((int)side == 1) ? RIGHT_ANIMATION_TIME.Value : LEFT_ANIMATION_TIME.Value);
					((SyncField<float>)(object)___Separation2).Value = value;
					((SyncField<float>)(object)___RadiusRatio2).Value = value2;
					((SyncField<Direction>)(object)____arcLayout2.Target.ItemDirection).Value = value4;
					((SyncField<float>)(object)____arcLayout2.Target.Offset).Value = value3;
					((ComponentBase<Component>)(object)____innerCircle2.Target).Enabled = enabled;
					if (num2 > 0f)
					{
						TweenExtensions.TweenFromTo<float>((IField<float>)(object)____arcLayout2.Target.Arc, 0f, num, num2, val, (Action)null, (Action)null);
					}
					else
					{
						((SyncField<float>)(object)____arcLayout2.Target.Arc).Value = num;
					}
				}
			});
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ContextMenu), "OpenMenu")]
		private static void PostfixOpenMenu(ContextMenu __instance, Sync<float> ___RadiusRatio)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			if (!WorldExtensions.IsUserspace(((Worker)__instance).World) && MASTER_ENABLED.Value && ((Component)__instance).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance).LocalUser)
			{
				((SyncField<float>)(object)___RadiusRatio).Value = (((int)((ContainerWorker<Component>)(object)__instance.Pointer.Target).GetComponent<InteractionLaser>((Predicate<InteractionLaser>)null, false).Side == 1) ? RIGHT_RADIUS_RATIO.Value : LEFT_RADIUS_RATIO.Value);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ContextMenu), "Close")]
		private static void PrefixClose(ContextMenu __instance, SyncRef<ArcLayout> ____arcLayout)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			ContextMenu __instance2 = __instance;
			SyncRef<ArcLayout> ____arcLayout2 = ____arcLayout;
			if (WorldExtensions.IsUserspace(((Worker)__instance2).World) || !MASTER_ENABLED.Value)
			{
				return;
			}
			((ComponentBase<Component>)(object)__instance2).RunInUpdates(3, (Action)delegate
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Invalid comparison between Unknown and I4
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Invalid comparison between Unknown and I4
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Invalid comparison between Unknown and I4
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				if (((Component)__instance2).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance2).LocalUser)
				{
					Chirality side = ((ContainerWorker<Component>)(object)__instance2.Pointer.Target).GetComponent<InteractionLaser>((Predicate<InteractionLaser>)null, false).Side;
					float value = (((int)side == 1) ? RIGHT_ARCLAYOUT_ARC.Value : LEFT_ARCLAYOUT_ARC.Value);
					CurvePreset val = (((int)side == 1) ? RIGHT_ANIMATION_CURVE.Value : LEFT_ANIMATION_CURVE.Value);
					float num = (((int)side == 1) ? RIGHT_ANIMATION_TIME.Value : LEFT_ANIMATION_TIME.Value);
					if (num > 0f)
					{
						TweenExtensions.TweenFromTo<float>((IField<float>)(object)____arcLayout2.Target.Arc, ((SyncField<float>)(object)____arcLayout2.Target.Arc).Value, 0f, num, val, (Action)null, (Action)null);
					}
					else
					{
						((SyncField<float>)(object)____arcLayout2.Target.Arc).Value = value;
					}
				}
			});
		}
	}

	private static ConfigEntry<bool> MASTER_ENABLED;

	private static ConfigEntry<float> LEFT_SEPERATION;

	private static ConfigEntry<float> LEFT_RADIUS_RATIO;

	private static ConfigEntry<float> LEFT_ARCLAYOUT_ARC;

	private static ConfigEntry<float> LEFT_ARCLAYOUT_OFFSET;

	private static ConfigEntry<Direction> LEFT_ITEM_DIRECTION;

	private static ConfigEntry<bool> LEFT_INNER_CIRCLE_ENABLED;

	private static ConfigEntry<float> LEFT_ROUNDED_CORNER_RADIUS;

	private static ConfigEntry<float> LEFT_FILL_COLOR_ALPHA;

	private static ConfigEntry<CurvePreset> LEFT_ANIMATION_CURVE;

	private static ConfigEntry<float> LEFT_ANIMATION_TIME;

	private static ConfigEntry<float> RIGHT_SEPERATION;

	private static ConfigEntry<float> RIGHT_RADIUS_RATIO;

	private static ConfigEntry<float> RIGHT_ARCLAYOUT_ARC;

	private static ConfigEntry<float> RIGHT_ARCLAYOUT_OFFSET;

	private static ConfigEntry<Direction> RIGHT_ITEM_DIRECTION;

	private static ConfigEntry<bool> RIGHT_INNER_CIRCLE_ENABLED;

	private static ConfigEntry<float> RIGHT_ROUNDED_CORNER_RADIUS;

	private static ConfigEntry<float> RIGHT_FILL_COLOR_ALPHA;

	private static ConfigEntry<CurvePreset> RIGHT_ANIMATION_CURVE;

	private static ConfigEntry<float> RIGHT_ANIMATION_TIME;

	public override void Load()
	{
		MASTER_ENABLED = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable/disable the mod");
		LEFT_SEPERATION = ((BasePlugin)this).Config.Bind<float>("Left", "ItemSeparation", 6f, "Left menu item separation");
		LEFT_RADIUS_RATIO = ((BasePlugin)this).Config.Bind<float>("Left", "RadiusRatio", 0.5f, "Left menu distance from center");
		LEFT_ARCLAYOUT_ARC = ((BasePlugin)this).Config.Bind<float>("Left", "ArcAmount", 360f, "Left menu arc amount");
		LEFT_ARCLAYOUT_OFFSET = ((BasePlugin)this).Config.Bind<float>("Left", "ArcOffset", 0f, "Left menu rotation offset");
		LEFT_ITEM_DIRECTION = ((BasePlugin)this).Config.Bind<Direction>("Left", "ItemDirection", (Direction)0, "Left menu layout direction");
		LEFT_INNER_CIRCLE_ENABLED = ((BasePlugin)this).Config.Bind<bool>("Left", "InnerCircleEnabled", true, "Left menu inner circle enabled");
		LEFT_ROUNDED_CORNER_RADIUS = ((BasePlugin)this).Config.Bind<float>("Left", "RoundedCornerRadius", 16f, "Left Rounded Corner Radius");
		LEFT_FILL_COLOR_ALPHA = ((BasePlugin)this).Config.Bind<float>("Left", "FillColorAlpha", 1f, "Left Fill Color Alpha");
		LEFT_ANIMATION_CURVE = ((BasePlugin)this).Config.Bind<CurvePreset>("Left", "AnimationCurve", (CurvePreset)0, "Left Animation Curve");
		LEFT_ANIMATION_TIME = ((BasePlugin)this).Config.Bind<float>("Left", "AnimationTime", 0f, "Left Animation Time (Disabled when 0.0)");
		RIGHT_SEPERATION = ((BasePlugin)this).Config.Bind<float>("Right", "ItemSeparation", 6f, "Right menu item separation");
		RIGHT_RADIUS_RATIO = ((BasePlugin)this).Config.Bind<float>("Right", "RadiusRatio", 0.5f, "Right menu distance from center");
		RIGHT_ARCLAYOUT_ARC = ((BasePlugin)this).Config.Bind<float>("Right", "ArcAmount", 360f, "Right menu arc amount");
		RIGHT_ARCLAYOUT_OFFSET = ((BasePlugin)this).Config.Bind<float>("Right", "ArcOffset", 0f, "Right menu rotation offset");
		RIGHT_ITEM_DIRECTION = ((BasePlugin)this).Config.Bind<Direction>("Right", "ItemDirection", (Direction)0, "Right menu layout direction");
		RIGHT_INNER_CIRCLE_ENABLED = ((BasePlugin)this).Config.Bind<bool>("Right", "InnerCircleEnabled", true, "Right menu inner circle enabled");
		RIGHT_ROUNDED_CORNER_RADIUS = ((BasePlugin)this).Config.Bind<float>("Right", "RoundedCornerRadius", 16f, "Right Rounded Corner Radius");
		RIGHT_FILL_COLOR_ALPHA = ((BasePlugin)this).Config.Bind<float>("Right", "FillColorAlpha", 1f, "Right Fill Color Alpha");
		RIGHT_ANIMATION_CURVE = ((BasePlugin)this).Config.Bind<CurvePreset>("Right", "AnimationCurve", (CurvePreset)0, "Right Animation Curve");
		RIGHT_ANIMATION_TIME = ((BasePlugin)this).Config.Bind<float>("Right", "AnimationTime", 0f, "Right Animation Time (Disabled when 0.0)");
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}
}
public static class PluginMetadata
{
	public const string GUID = "dev.lecloutpanda.contextmenufunnies";

	public const string NAME = "Context Menu Funnies";

	public const string VERSION = "1.2.3";

	public const string AUTHORS = "LeCloutPanda";

	public const string REPOSITORY_URL = "https://github.com/LeCloutPanda/ContextMenuFunnies";
}