Decompiled source of ResoTabbed v2.1.2

plugins/ResoTabbed/ResoTabbed.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using BepisResoniteWrapper;
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("2.1.2.0")]
[assembly: AssemblyInformationalVersion("2.1.2")]
[assembly: AssemblyProduct("ResoTabbed")]
[assembly: AssemblyTitle("ResoTabbed")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NepuShiro/ResoTabbed")]
[assembly: AssemblyVersion("2.1.2.0")]
[module: RefSafetyRules(11)]
namespace ResoTabbed;

[ResonitePlugin("NepuShiro.ResoTabbed", "ResoTabbed", "2.1.2", "NepuShiro", "https://github.com/NepuShiro/ResoTabbed")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(UserRoot))]
	private static class UserRootPatch
	{
		[field: CompilerGenerated]
		private static DynamicValueVariable<bool> Variable
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			set;
		}

		[HarmonyPatch("OnStart")]
		[HarmonyPostfix]
		private static void OnStart(UserRoot __instance)
		{
			if (__instance != null && __instance.ActiveUser == ((Worker)__instance).LocalUser && !WorldExtensions.IsUserspace(((Worker)__instance).World))
			{
				Variable = ((ContainerWorker<Component>)(object)((Component)__instance).Slot).GetComponentOrAttach<DynamicValueVariable<bool>>((Predicate<DynamicValueVariable<bool>>)((DynamicValueVariable<bool> x) => ((SyncField<string>)(object)((DynamicVariableBase<bool>)(object)x).VariableName).Value == Dynvar.Value));
				if (Variable != null)
				{
					((SyncField<string>)(object)((DynamicVariableBase<bool>)(object)Variable).VariableName).Value = Dynvar.Value;
					((SyncField<bool>)(object)Variable.Value).Value = true;
				}
			}
		}

		[HarmonyPatch("OnCommonUpdate")]
		[HarmonyPostfix]
		private static void OnCommonUpdate(UserRoot __instance)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (__instance != null && __instance.ActiveUser == ((Worker)__instance).LocalUser && !WorldExtensions.IsUserspace(((Worker)__instance).World))
			{
				if (_dynVarChanged && Variable != null)
				{
					_dynVarChanged = false;
					((SyncField<string>)(object)((DynamicVariableBase<bool>)(object)Variable).VariableName).Value = Dynvar.Value;
				}
				DynamicVariableHelper.WriteDynamicVariable<bool>(((Component)__instance).Slot, Dynvar.Value, _focused);
			}
		}
	}

	[HarmonyPatch(typeof(InputInterface), "UpdateWindowState")]
	private static class InputInterfacePatch
	{
		[HarmonyPostfix]
		private static void UpdateWindowState(WindowState state)
		{
			Plugin.WindowStateUpdated?.Invoke(state.isWindowFocused);
		}
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Action<bool> <>9__7_1;

		public static EventHandler <>9__7_2;

		public static Action <>9__7_0;

		internal void <Load>b__7_0()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			WindowStateUpdated += delegate(bool focus)
			{
				_focused = focus;
			};
			ConfigEntry<string> dynvar = Dynvar;
			object obj = <>9__7_2;
			if (obj == null)
			{
				EventHandler val = delegate(object? value, EventArgs _)
				{
					_dynVarChanged = DynamicVariableHelper.IsValidName((string)value);
				};
				<>9__7_2 = val;
				obj = (object)val;
			}
			dynvar.SettingChanged += (EventHandler)obj;
		}

		internal void <Load>b__7_1(bool focus)
		{
			_focused = focus;
		}

		internal void <Load>b__7_2(object? value, EventArgs _)
		{
			_dynVarChanged = DynamicVariableHelper.IsValidName((string)value);
		}
	}

	internal static ManualLogSource Log;

	private static ConfigEntry<string> Dynvar;

	private static bool _focused;

	private static bool _dynVarChanged;

	[CompilerGenerated]
	private static Action<bool> m_WindowStateUpdated;

	private static event Action<bool> WindowStateUpdated
	{
		[CompilerGenerated]
		add
		{
			Action<bool> val = Plugin.m_WindowStateUpdated;
			Action<bool> val2;
			do
			{
				val2 = val;
				Action<bool> val3 = (Action<bool>)(object)global::System.Delegate.Combine((global::System.Delegate)(object)val2, (global::System.Delegate)(object)value);
				val = Interlocked.CompareExchange<Action<bool>>(ref Plugin.m_WindowStateUpdated, val3, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			Action<bool> val = Plugin.m_WindowStateUpdated;
			Action<bool> val2;
			do
			{
				val2 = val;
				Action<bool> val3 = (Action<bool>)(object)global::System.Delegate.Remove((global::System.Delegate)(object)val2, (global::System.Delegate)(object)value);
				val = Interlocked.CompareExchange<Action<bool>>(ref Plugin.m_WindowStateUpdated, val3, val2);
			}
			while (val != val2);
		}
	}

	public override void Load()
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		Log = ((BasePlugin)this).Log;
		Dynvar = ((BasePlugin)this).Config.Bind<string>("General", "Dynvar", "User/IsFocused", "The Dynamic Variable to have the expose the focus state as");
		((BasePlugin)this).HarmonyInstance.PatchAll();
		object obj = <>c.<>9__7_0;
		if (obj == null)
		{
			Action val = delegate
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Expected O, but got Unknown
				WindowStateUpdated += delegate(bool focus)
				{
					_focused = focus;
				};
				ConfigEntry<string> dynvar = Dynvar;
				object obj2 = <>c.<>9__7_2;
				if (obj2 == null)
				{
					EventHandler val3 = delegate(object? value, EventArgs _)
					{
						_dynVarChanged = DynamicVariableHelper.IsValidName((string)value);
					};
					<>c.<>9__7_2 = val3;
					obj2 = (object)val3;
				}
				dynvar.SettingChanged += (EventHandler)obj2;
			};
			<>c.<>9__7_0 = val;
			obj = (object)val;
		}
		ResoniteHooks.OnEngineReady += (Action)obj;
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Plugin ");
			((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("NepuShiro.ResoTabbed");
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" is loaded!");
		}
		log.LogInfo(val2);
	}
}
public static class PluginMetadata
{
	public const string GUID = "NepuShiro.ResoTabbed";

	public const string NAME = "ResoTabbed";

	public const string VERSION = "2.1.2";

	public const string AUTHORS = "NepuShiro";

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