Decompiled source of ResoniteWorldClick v1.0.0

plugins/ResoniteWorldClick/ResoniteWorldClick.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using FrooxEngine;
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("NepuShiro")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+37c6fa77b850ea5912433022d10a6520e3313316")]
[assembly: AssemblyProduct("ResoniteWorldClick")]
[assembly: AssemblyTitle("ResoniteWorldClick")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NepuShiro/ResoniteWorldClick")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace ResoniteWorldClick;

[ResonitePlugin("NepuShiro.ResoniteWorldClick", "ResoniteWorldClick", "1.0.0", "NepuShiro", "https://github.com/NepuShiro/ResoniteWorldClick")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(InteractionHandler), "OnCommonUpdate")]
	public static class Inteaction
	{
		private static bool _locked;

		private static bool _lastKeyPressed;

		public static void Postfix(InteractionHandler __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (((Component)__instance).Slot.ActiveUser != ((Worker)__instance).LocalUser)
				{
					return;
				}
				bool key = Userspace.UserspaceWorld.InputInterface.GetKey(Key.Value);
				if (Toggle.Value)
				{
					if (key && !_lastKeyPressed)
					{
						_locked = !_locked;
						if (_locked)
						{
							((Worker)__instance).Input.RegisterCursorUnlock((IWorldElement)(object)((Worker)__instance).LocalUser.Root);
						}
						else
						{
							((Worker)__instance).Input.UnregisterCursorUnlock((IWorldElement)(object)((Worker)__instance).LocalUser.Root);
						}
					}
				}
				else if (key && !_locked)
				{
					_locked = true;
					((Worker)__instance).Input.RegisterCursorUnlock((IWorldElement)(object)((Worker)__instance).LocalUser.Root);
				}
				else if (!key && _locked)
				{
					_locked = false;
					((Worker)__instance).Input.UnregisterCursorUnlock((IWorldElement)(object)((Worker)__instance).LocalUser.Root);
				}
				_lastKeyPressed = key;
			}
			catch
			{
			}
		}
	}

	internal static ManualLogSource Log;

	public static ConfigEntry<Key> Key;

	public static ConfigEntry<bool> Toggle;

	public override void Load()
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		Log = ((BasePlugin)this).Log;
		Key = ((BasePlugin)this).Config.Bind<Key>("General", "Key", (Key)514, (ConfigDescription)null);
		Toggle = ((BasePlugin)this).Config.Bind<bool>("General", "Toggle", false, (ConfigDescription)null);
		((BasePlugin)this).HarmonyInstance.PatchAll();
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("NepuShiro.ResoniteWorldClick");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
		}
		log.LogInfo(val);
	}
}
public static class PluginMetadata
{
	public const string GUID = "NepuShiro.ResoniteWorldClick";

	public const string NAME = "ResoniteWorldClick";

	public const string VERSION = "1.0.0";

	public const string AUTHORS = "NepuShiro";

	public const string REPOSITORY_URL = "https://github.com/NepuShiro/ResoniteWorldClick";
}