using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("art0007i")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.3.0")]
[assembly: AssemblyInformationalVersion("2.0.3+aff0963ef2efcd0d98190910b903fb6a7fdc686a")]
[assembly: AssemblyProduct("InspectorScroll")]
[assembly: AssemblyTitle("InspectorScroll")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/InspectorScroll")]
[assembly: AssemblyVersion("2.0.3.0")]
[module: RefSafetyRules(11)]
namespace InspectorScroll;
[ResonitePlugin("art0007i.InspectorScroll", "InspectorScroll", "2.0.3", "art0007i", "https://github.com/art0007i/InspectorScroll")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
[HarmonyPatch(typeof(InteractionHandler))]
[HarmonyPatch("OnInputUpdate")]
private class InteractionHandler_OnInputUpdate_Patch
{
public static void Postfix(InteractionHandler __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
if (((Worker)__instance).InputInterface.ScreenActive)
{
return;
}
IStandardController controllerNode = ((Worker)__instance).InputInterface.GetControllerNode(Sync<Chirality>.op_Implicit(__instance.Side));
IndexController val = (IndexController)(object)((controllerNode is IndexController) ? controllerNode : null);
if (ScrollWhileWalking.Value || (val != null && !IndexJoystick.Value) || ((InputAction)__instance.Inputs.Axis).RegisterBlocks)
{
float2 val2 = ((val == null || !IndexJoystick.Value) ? __instance.Inputs.Axis.Value.Value : val.Joystick.Value);
float2 val3 = new float2(-1f, 1f);
val2 = (ref val2) * (ref val3);
ITouchable currentTouchable = __instance.Laser.CurrentTouchable;
ITouchable obj = ((currentTouchable is IAxisActionReceiver) ? currentTouchable : null);
if (obj != null)
{
((IAxisActionReceiver)obj).ProcessAxis((Component)(object)__instance.Laser.TouchSource, (ref val2) * Speed.Value);
}
}
}
}
[HarmonyPatch(typeof(InteractionHandler))]
[HarmonyPatch("BeforeInputUpdate")]
[HarmonyAfter(new string[] { "U-xyla.XyMod", "owo.Nytra.NoTankControls" })]
private class InputBlockPatch
{
private static InteractionHandler? userSpaceHandlerLeft;
private static InteractionHandler? userSpaceHandlerRight;
private static void Postfix(InteractionHandler __instance)
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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: Invalid comparison between Unknown and I4
if (!ShouldAttemptInputBlock())
{
return;
}
if (((Worker)__instance).World == Engine.Current.WorldManager.FocusedWorld)
{
bool num = BlockInputWorld.Value && CanScroll(__instance);
bool flag = ((int)Sync<Chirality>.op_Implicit(__instance.Side) == 0 && CanScroll(userSpaceHandlerLeft)) || ((int)Sync<Chirality>.op_Implicit(__instance.Side) == 1 && CanScroll(userSpaceHandlerRight));
if (num || (BlockInputUser.Value && flag))
{
((InputAction)__instance.Inputs.Axis).RegisterBlocks = true;
}
}
else
{
if (((Worker)__instance).World != Userspace.UserspaceWorld)
{
return;
}
if (BlockInputUser.Value)
{
((InputAction)__instance.Inputs.Axis).RegisterBlocks = true;
}
if ((int)Sync<Chirality>.op_Implicit(__instance.Side) == 0)
{
if (WorldElementExtensions.FilterWorldElement<InteractionHandler>(userSpaceHandlerLeft) == null)
{
userSpaceHandlerLeft = __instance;
}
}
else if (WorldElementExtensions.FilterWorldElement<InteractionHandler>(userSpaceHandlerRight) == null)
{
userSpaceHandlerRight = __instance;
}
}
}
}
internal static ManualLogSource Log;
internal static ConfigEntry<bool> ScrollWhileWalking;
internal static ConfigEntry<float> Speed;
internal static ConfigEntry<bool> IndexJoystick;
internal static ConfigEntry<bool> BlockInputWorld;
internal static ConfigEntry<bool> BlockInputUser;
public override void Load()
{
Log = ((BasePlugin)this).Log;
ScrollWhileWalking = ((BasePlugin)this).Config.Bind<bool>("General", "ScrollWhileWalking", true, "Always allows scrolling, even if it means you'd walk and scroll at the same time.");
Speed = ((BasePlugin)this).Config.Bind<float>("General", "Speed", 120f, "How fast you scroll, default is 120.");
IndexJoystick = ((BasePlugin)this).Config.Bind<bool>("General", "IndexJoystick", false, "Use the joystick on index controller.");
BlockInputWorld = ((BasePlugin)this).Config.Bind<bool>("General", "BlockInputWorld", false, "Prevent moving when hovering over a scrollable element in world space.");
BlockInputUser = ((BasePlugin)this).Config.Bind<bool>("General", "BlockInputUser", false, "Prevent moving when hovering over a scrollable element in userspace.");
((BasePlugin)this).HarmonyInstance.PatchAll();
}
private static bool ShouldAttemptInputBlock()
{
if (!BlockInputWorld.Value)
{
return BlockInputUser.Value;
}
return true;
}
private static bool CanScroll(InteractionHandler? __instance)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (__instance == null)
{
return false;
}
ITouchable currentTouchable = __instance.Laser.CurrentTouchable;
IAxisActionReceiver val = (IAxisActionReceiver)(object)((currentTouchable is IAxisActionReceiver) ? currentTouchable : null);
if (val == null)
{
return false;
}
if (ShouldAttemptInputBlock())
{
return val.ProcessAxis((Component)(object)__instance.Laser.TouchSource, float2.Zero);
}
return false;
}
}
public static class PluginMetadata
{
public const string GUID = "art0007i.InspectorScroll";
public const string NAME = "InspectorScroll";
public const string VERSION = "2.0.3";
public const string AUTHORS = "art0007i";
public const string REPOSITORY_URL = "https://github.com/art0007i/InspectorScroll";
}