Decompiled source of LocalMenu v1.0.5

plugins/LocalMenu/LocalMenu.dll

Decompiled 3 months 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 HarmonyLib;

[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.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+052bfdbb2f4df957b3adc12528a64557319dd6db")]
[assembly: AssemblyProduct("LocalMenu")]
[assembly: AssemblyTitle("LocalMenu")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LeCloutPanda/LocalMenu")]
[assembly: AssemblyVersion("1.0.5.0")]
[module: RefSafetyRules(11)]
namespace LocalMenu;

[ResonitePlugin("dev.lecloutpanda.LocalMenu", "LocalMenu", "1.0.5", "LeCloutPanda", "https://github.com/LeCloutPanda/LocalMenu")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Patch : BasePlugin
{
	[HarmonyPatch(typeof(ContextMenu))]
	private class PatchContextMenu
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnAwake")]
		private static void Postfix(ContextMenu __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			ContextMenu __instance2 = __instance;
			if (!HIDE_CONTEXTMENU.Value)
			{
				return;
			}
			((ComponentBase<Component>)(object)__instance2).RunInUpdates(3, (Action)delegate
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				if (((Component)__instance2).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance2).LocalUser)
				{
					Slot slot = ((Component)__instance2).Slot;
					ValueUserOverride<bool> obj = ((ContainerWorker<Component>)(object)slot).AttachComponent<ValueUserOverride<bool>>(true, (Action<ValueUserOverride<bool>>)null);
					((SyncField<RefID>)(object)obj.Target).Value = ((SyncElement)slot.ActiveSelf_Field).ReferenceID;
					((SyncField<bool>)(object)((ValueOverrideBase<bool>)(object)obj).PersistentOverrides).Value = false;
					((SyncField<bool>)(object)((ValueOverrideBase<bool>)(object)obj).Default).Value = false;
					((ValueOverrideBase<bool>)(object)obj).SetOverride(((Worker)__instance2).LocalUser, true);
				}
			});
		}
	}

	[HarmonyPatch(typeof(InteractionLaser))]
	private class PatchInteractionLaser
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnAwake")]
		private static void Postfix(InteractionLaser __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			InteractionLaser __instance2 = __instance;
			if (!HIDE_LASERS.Value)
			{
				return;
			}
			((ComponentBase<Component>)(object)__instance2).RunInUpdates(3, (Action)delegate
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				if (((Component)__instance2).Slot.ActiveUserRoot.ActiveUser == ((Worker)__instance2).LocalUser)
				{
					Slot slot = ((Component)__instance2).Slot;
					ValueUserOverride<bool> obj = ((ContainerWorker<Component>)(object)slot).AttachComponent<ValueUserOverride<bool>>(true, (Action<ValueUserOverride<bool>>)null);
					((SyncField<RefID>)(object)obj.Target).Value = ((SyncElement)slot.ActiveSelf_Field).ReferenceID;
					((SyncField<bool>)(object)((ValueOverrideBase<bool>)(object)obj).PersistentOverrides).Value = false;
					((SyncField<bool>)(object)((ValueOverrideBase<bool>)(object)obj).Default).Value = false;
					((ValueOverrideBase<bool>)(object)obj).SetOverride(((Worker)__instance2).LocalUser, true);
				}
			});
		}
	}

	private static ConfigEntry<bool> HIDE_LASERS;

	private static ConfigEntry<bool> HIDE_CONTEXTMENU;

	public override void Load()
	{
		HIDE_LASERS = ((BasePlugin)this).Config.Bind<bool>("General", "Hide Lasers", false, "Locally hide your lasers for everyone else");
		HIDE_CONTEXTMENU = ((BasePlugin)this).Config.Bind<bool>("General", "Hide Context Menu", false, "Locally hide your context menu for everyone else.");
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}
}
public static class PluginMetadata
{
	public const string GUID = "dev.lecloutpanda.LocalMenu";

	public const string NAME = "LocalMenu";

	public const string VERSION = "1.0.5";

	public const string AUTHORS = "LeCloutPanda";

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