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.2.0")]
[assembly: AssemblyInformationalVersion("2.0.2+0660c684ee881e6b409a9ce93a06dff874941805")]
[assembly: AssemblyProduct("InspectorScroll")]
[assembly: AssemblyTitle("InspectorScroll")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/InspectorScroll")]
[assembly: AssemblyVersion("2.0.2.0")]
[module: RefSafetyRules(11)]
namespace InspectorScroll;
[ResonitePlugin("art0007i.InspectorScroll", "InspectorScroll", "2.0.2", "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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if (((Worker)__instance).InputInterface.ScreenActive || !((InputAction)__instance.Inputs.Axis).RegisterBlocks)
{
return;
}
float2 value;
if (IndexJoystick.Value)
{
IStandardController controllerNode = ((Worker)__instance).InputInterface.GetControllerNode(Sync<Chirality>.op_Implicit(__instance.Side));
IndexController val = (IndexController)(object)((controllerNode is IndexController) ? controllerNode : null);
if (val != null)
{
value = val.Joystick.Value;
goto IL_0072;
}
}
value = __instance.Inputs.Axis.Value.Value;
goto IL_0072;
IL_0072:
float2 val2 = new float2(-1f, 1f);
value = (ref value) * (ref val2);
ITouchable currentTouchable = __instance.Laser.CurrentTouchable;
ITouchable obj = ((currentTouchable is IAxisActionReceiver) ? currentTouchable : null);
if (obj != null)
{
((IAxisActionReceiver)obj).ProcessAxis((Component)(object)__instance.Laser.TouchSource, (ref value) * 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_00a1: 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 ((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<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;
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.2";
public const string AUTHORS = "art0007i";
public const string REPOSITORY_URL = "https://github.com/art0007i/InspectorScroll";
}