Decompiled source of Rebind v1.0.4

plugins/Rebind/Rebind.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
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("LeCloutPanda")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+340dd85d8f2eb2242cb371a70da6edf376a74084")]
[assembly: AssemblyProduct("Rebind")]
[assembly: AssemblyTitle("Rebind")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LeCloutPanda/Rebind")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
namespace Rebind;

[ResonitePlugin("dev.lecloutpanda.rebind", "Rebind", "1.0.3", "LeCloutPanda", "https://github.com/LeCloutPanda/Rebind")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Patch : BasePlugin
{
	[HarmonyPatch(typeof(TouchController))]
	private class TouchControllerPatch
	{
		[HarmonyPatch("Bind")]
		[HarmonyPrefix]
		private static bool Prefix(InputGroup group, TouchController __instance, Analog2D ___Joystick, Digital ___TriggerClick, Digital ___GripClick, Digital ___ButtonYB, Analog ___Trigger, Digital ___ButtonXA)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (group.Side != (Chirality?)((ControllerBase)__instance).Side)
			{
				return false;
			}
			InteractionHandlerInputs val = (InteractionHandlerInputs)(object)((group is InteractionHandlerInputs) ? group : null);
			if (val == null)
			{
				LaserHoldInputs val2 = (LaserHoldInputs)(object)((group is LaserHoldInputs) ? group : null);
				if (val2 == null)
				{
					TeleportInputs val3 = (TeleportInputs)(object)((group is TeleportInputs) ? group : null);
					if (val3 == null)
					{
						GrabWorldInputs val4 = (GrabWorldInputs)(object)((group is GrabWorldInputs) ? group : null);
						if (val4 != null)
						{
							((InputAction<bool>)(object)val4.Grab).AddBinding((IInputNode<bool>)(object)InputNode.ToDigital((IInputNode<float>)(object)InputNode.Y((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick)), 0.5f, 0.4f), (IInputDevice)(object)__instance, (string)null, 0);
							((InputAction<float>)(object)val4.TurnDelta).AddBinding((IInputNode<float>)(object)InputNode.LocomotionTurn((IInputNode<float>)(object)InputNode.X((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick))), (IInputDevice)(object)__instance, (string)null, 0);
						}
					}
					else
					{
						((InputAction<bool>)(object)val3.Teleport).AddBinding((IInputNode<bool>)(object)InputNode.ToDigital((IInputNode<float>)(object)InputNode.Y((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick)), 0.8f, 0.4f), (IInputDevice)(object)__instance, (string)null, 0);
						((InputAction<bool>)(object)val3.Backstep).AddBinding((IInputNode<bool>)(object)InputNode.ToDigital((IInputNode<float>)(object)InputNode.Negate<float>((IInputNode<float>)(object)InputNode.Y((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick))), 0.8f, 0.4f), (IInputDevice)(object)__instance, (string)null, 0);
						((InputAction<float>)(object)val3.TurnDelta).AddBinding((IInputNode<float>)(object)InputNode.LocomotionTurn((IInputNode<float>)(object)InputNode.X((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick))), (IInputDevice)(object)__instance, (string)null, 0);
					}
				}
				else
				{
					((InputAction<bool>)(object)val2.Align).AddBinding((IInputNode<bool>)(object)InputNode.Digital(___TriggerClick), (IInputDevice)(object)__instance, (string)null, 0);
					((InputAction<float>)(object)val2.Slide).AddBinding((IInputNode<float>)(object)InputNode.Y((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick)), (IInputDevice)(object)__instance, (string)null, 0);
					((InputAction<float>)(object)val2.Rotate).AddBinding((IInputNode<float>)(object)InputNode.X((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick)), (IInputDevice)(object)__instance, (string)null, 0);
				}
			}
			else
			{
				((InputAction<bool>)(object)val.Interact).AddBinding((IInputNode<bool>)(object)InputNode.Digital(___TriggerClick), (IInputDevice)(object)__instance, (string)null, 0);
				((InputAction<bool>)(object)val.Secondary).AddBinding((IInputNode<bool>)(object)InputNode.Digital(___ButtonXA), (IInputDevice)(object)__instance, (string)null, 0);
				((InputAction<bool>)(object)val.Grab).AddBinding((IInputNode<bool>)(object)InputNode.Digital(___GripClick), (IInputDevice)(object)__instance, (string)null, 0);
				((InputAction<bool>)(object)val.Menu).AddBinding((IInputNode<bool>)(object)InputNode.Digital(___ButtonYB), (IInputDevice)(object)__instance, (string)null, 0);
				((InputAction<float>)(object)val.Strength).AddBinding((IInputNode<float>)(object)InputNode.Analog(___Trigger), (IInputDevice)(object)__instance, (string)null, 0);
				((InputAction<float2>)(object)val.Axis).AddBinding((IInputNode<float2>)(object)InputNode.Analog2D(___Joystick), (IInputDevice)(object)__instance, (string)null, 0);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("BindNodeActions")]
		private static bool PrefixBindActions(TouchController __instance, Digital ___ButtonXA, IInputNode node, string? name = null)
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00f7: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			IDualAxisInputNode val = (IDualAxisInputNode)(object)((node is IDualAxisInputNode) ? node : null);
			if (val == null)
			{
				AnyInput val2 = (AnyInput)(object)((node is AnyInput) ? node : null);
				if (val2 == null)
				{
					if (!(node is LeftRightSelector<bool> val3))
					{
						if (!(node is LeftRightSelector<float2> val4))
						{
							if (node is SumInputs<float> val5 && name == "ReleaseStrength")
							{
								val5.Inputs.Add((IInputNode<float>)(object)InputNode.Magnitude((IInputNode<float2>)(object)InputNode.Analog2D(((ControllerBase)__instance).Side, "Joystick", false)));
							}
						}
						else if (name == "AnchorAxis")
						{
							val4.SetNode(((ControllerBase)__instance).Side, (IInputNode<float2>)(object)InputNode.Analog2D(((ControllerBase)__instance).Side, "Joystick", false));
						}
					}
					else if (!(name == "Jump") && !(name == "Align"))
					{
						if (name == "AnchorAction")
						{
							val3.SetNode(((ControllerBase)__instance).Side, (IInputNode<bool>)(object)InputNode.Digital(((ControllerBase)__instance).Side, ((ControllerProperty)___ButtonXA).Name, false));
						}
					}
					else
					{
						val3.SetNode(((ControllerBase)__instance).Side, (IInputNode<bool>)(object)InputNode.Digital(((ControllerBase)__instance).Side, ((ControllerProperty)___ButtonXA).Name, false));
					}
				}
				else if (name == "Jump")
				{
					val2.Inputs.Add((IInputNode<bool>)(object)InputNode.Digital(((ControllerBase)__instance).Side, ((ControllerProperty)___ButtonXA).Name, false));
				}
			}
			else
			{
				val.SetInput(((ControllerBase)__instance).Side, (IInputNode<float2>)(object)InputNode.Analog2D(((ControllerBase)__instance).Side, "Joystick", false));
			}
			return false;
		}
	}

	public override void Load()
	{
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}
}
public static class PluginMetadata
{
	public const string GUID = "dev.lecloutpanda.rebind";

	public const string NAME = "Rebind";

	public const string VERSION = "1.0.3";

	public const string AUTHORS = "LeCloutPanda";

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