using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.UIX;
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("eia485")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3+6ca826b1062ab7bf9c348b443e1ac46ba7203e0b")]
[assembly: AssemblyProduct("InspectorKeybinds")]
[assembly: AssemblyTitle("InspectorKeybinds")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EIA485/NeosInspectorKeybinds")]
[assembly: AssemblyVersion("1.1.3.0")]
[module: RefSafetyRules(11)]
namespace InspectorKeybinds;
[ResonitePlugin("net.eia485.InspectorKeybinds", "InspectorKeybinds", "1.1.3", "eia485", "https://github.com/EIA485/NeosInspectorKeybinds")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class InspectorKeybinds : BasePlugin
{
[HarmonyPatch(typeof(Userspace), "OnCommonUpdate")]
private class InspectorKeybindsPatch
{
private static void Postfix(Userspace __instance)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Expected O, but got Unknown
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
try
{
InputInterface inputInterface = ((Worker)__instance).InputInterface;
if (inputInterface == null || !inputInterface.GetAnyKey() || Userspace.HasFocus)
{
return;
}
World focusedWorld = ((Worker)__instance).Engine.WorldManager.FocusedWorld;
if (focusedWorld != null && FocusManagerExtensions.HasActiveFocus(focusedWorld.LocalUser))
{
return;
}
ControllerData controllerData = Userspace.GetControllerData(inputInterface.PrimaryHand);
if (controllerData == null)
{
return;
}
InteractionHandler val = controllerData.userspaceController;
if (val == null)
{
return;
}
bool flag = controllerData.userspaceLaserHitTarget;
if (!flag && inputInterface.VR_Active)
{
ControllerData controllerData2 = Userspace.GetControllerData(GetOther(inputInterface.PrimaryHand));
if (controllerData2 == null)
{
return;
}
if (controllerData2.userspaceLaserHitTarget)
{
val = controllerData2.userspaceController;
flag = true;
}
}
if (!flag)
{
World focusedWorld2 = ((Worker)__instance).Engine.WorldManager.FocusedWorld;
UserRoot val2 = ((focusedWorld2 != null) ? focusedWorld2.LocalUser.Root : null);
if (val2 == null)
{
return;
}
InteractionHandler commonTool = GetCommonTool(val2, inputInterface.PrimaryHand);
if (commonTool == null || commonTool.Laser == null || commonTool.Laser.CurrentInteractionTarget == null)
{
return;
}
if (commonTool.Laser.CurrentInteractionTarget != null && typeof(Canvas).IsAssignableFrom(((object)commonTool.Laser.CurrentInteractionTarget).GetType()))
{
val = commonTool;
}
else
{
if (!inputInterface.VR_Active)
{
return;
}
InteractionHandler commonTool2 = GetCommonTool(val2, GetOther(inputInterface.PrimaryHand));
if (commonTool2 == null || commonTool2.Laser == null || commonTool2.Laser.CurrentInteractionTarget == null || commonTool2.Laser.CurrentInteractionTarget == null || !typeof(Canvas).IsAssignableFrom(((object)commonTool2.Laser.CurrentInteractionTarget).GetType()))
{
return;
}
val = commonTool2;
}
}
IInteractionTarget currentInteractionTarget = val.Laser.CurrentInteractionTarget;
object obj;
if (currentInteractionTarget == null)
{
obj = null;
}
else
{
Slot slot = ((IComponent)currentInteractionTarget).Slot;
obj = ((slot != null) ? slot.GetComponentInChildrenOrParents<SceneInspector>((Predicate<SceneInspector>)null, false) : null);
}
SceneInspector inspector = (SceneInspector)obj;
if (inspector == null)
{
return;
}
List<MethodInfo> runOnMain = new List<MethodInfo>();
Keybind[] binds = InspectorKeybinds.binds;
for (int i = 0; i < binds.Length; i++)
{
Keybind keybind = binds[i];
Enumerator<Dictionary<Key, bool>> enumerator = keybind.configKey.Value.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Dictionary<Key, bool> current = enumerator.Current;
if (current.Count == 0)
{
continue;
}
Enumerator<Key, bool> enumerator2 = current.GetEnumerator();
enumerator2.MoveNext();
if (inputInterface.GetKeyDown(enumerator2.Current.Key) != enumerator2.Current.Value)
{
continue;
}
bool flag2 = false;
while (enumerator2.MoveNext())
{
if (inputInterface.GetKey(enumerator2.Current.Key) != enumerator2.Current.Value)
{
flag2 = true;
break;
}
}
if (!flag2)
{
runOnMain.Add(keybind.target);
break;
}
}
}
finally
{
((global::System.IDisposable)enumerator).Dispose();
}
}
((Worker)inspector).World.RunSynchronously((Action)delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Enumerator<MethodInfo> enumerator3 = runOnMain.GetEnumerator();
try
{
while (enumerator3.MoveNext())
{
MethodInfo current2 = enumerator3.Current;
if (!(((current2 != null) ? ((MemberInfo)current2).DeclaringType : null) == (global::System.Type)null))
{
if (((MemberInfo)current2).DeclaringType == typeof(SceneInspector))
{
((MethodBase)current2).Invoke((object)inspector, nullargs);
}
else if (((MemberInfo)current2).DeclaringType == typeof(ExtraBinds))
{
((MethodBase)current2).Invoke((object)null, new object[1] { inspector });
}
else if (((MemberInfo)current2).DeclaringType == typeof(Slot) && inspector.ComponentView.Target != null)
{
((MethodBase)current2).Invoke((object)inspector.ComponentView.Target, nullargs);
}
}
}
}
finally
{
((global::System.IDisposable)enumerator3).Dispose();
}
}, false, (IUpdatable)null, false);
}
catch (global::System.Exception ex)
{
log.LogError((object)ex);
}
}
}
private static class ExtraBinds
{
private static MethodInfo OnAttachComponentPressed = AccessTools.Method(typeof(SceneInspector), "OnAttachComponentPressed", (global::System.Type[])null, (global::System.Type[])null);
internal static void OpenAttacher(SceneInspector instance)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
MethodInfo onAttachComponentPressed = OnAttachComponentPressed;
object[] array = new object[2];
float3 globalPosition = ((Component)instance).Slot.GlobalPosition;
float2 zero = float2.Zero;
float2 zero2 = float2.Zero;
array[1] = (object)new ButtonEventData((Component)null, ref globalPosition, ref zero, ref zero2);
((MethodBase)onAttachComponentPressed).Invoke((object)instance, array);
}
internal static void CreateObjUnderViewRoot(SceneInspector instance)
{
Slot target = ((SyncRef<Slot>)(object)instance.Root).Target;
if (target != null)
{
target.AddSlot(((SyncRef<Slot>)(object)instance.Root).Target.Name + " - Child", true);
}
}
}
private struct Keybind
{
public MethodInfo target;
public ConfigEntry<List<Dictionary<Key, bool>>> configKey;
internal Keybind(ConfigEntry<List<Dictionary<Key, bool>>> configKey, MethodInfo target)
{
this.configKey = configKey;
this.target = target;
}
}
private static ConfigFile config;
private static ManualLogSource log;
private static Keybind[] binds;
private static object[] nullargs = new object[2];
public override void Load()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
config = ((BasePlugin)this).Config;
log = ((BasePlugin)this).Log;
TypeConverter val = new TypeConverter();
val.ConvertToString = (object obj, global::System.Type type) => JsonSerializer.Serialize<object>(obj, (JsonSerializerOptions)null);
val.ConvertToObject = (string str, global::System.Type type) => (!Utility.IsNullOrWhiteSpace(str)) ? JsonSerializer.Deserialize(str, type, (JsonSerializerOptions)null) : Activator.CreateInstance(type);
TomlTypeConverter.AddConverter(typeof(List<Dictionary<Key, bool>>), val);
Keybind[] array = new Keybind[18];
ConfigFile obj2 = config;
List<Dictionary<Key, bool>> obj3 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj4 = new Dictionary<Key, bool>();
obj4.Add((Key)99, true);
obj4.Add((Key)514, false);
obj3.Add(obj4);
array[0] = new Keybind(obj2.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "create child", obj3, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnAddChildPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj5 = config;
List<Dictionary<Key, bool>> obj6 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj7 = new Dictionary<Key, bool>();
obj7.Add((Key)99, true);
obj7.Add((Key)514, true);
obj6.Add(obj7);
array[1] = new Keybind(obj5.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "create child under view root", obj6, (ConfigDescription)null), AccessTools.Method(typeof(ExtraBinds), "CreateObjUnderViewRoot", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj8 = config;
List<Dictionary<Key, bool>> obj9 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj10 = new Dictionary<Key, bool>();
obj10.Add((Key)106, true);
obj10.Add((Key)513, false);
obj10.Add((Key)514, false);
obj9.Add(obj10);
array[2] = new Keybind(obj8.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "create parent", obj9, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnInsertParentPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj11 = config;
List<Dictionary<Key, bool>> obj12 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj13 = new Dictionary<Key, bool>();
obj13.Add((Key)103, true);
obj12.Add(obj13);
array[3] = new Keybind(obj11.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "duplicate", obj12, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnDuplicatePressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj14 = config;
List<Dictionary<Key, bool>> obj15 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj16 = new Dictionary<Key, bool>();
obj16.Add((Key)121, true);
obj15.Add(obj16);
array[4] = new Keybind(obj14.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "object root", obj15, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnObjectRootPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj17 = config;
List<Dictionary<Key, bool>> obj18 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj19 = new Dictionary<Key, bool>();
obj19.Add((Key)117, true);
obj18.Add(obj19);
array[5] = new Keybind(obj17.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "up one root", obj18, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnRootUpPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj20 = config;
List<Dictionary<Key, bool>> obj21 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj22 = new Dictionary<Key, bool>();
obj22.Add((Key)104, true);
obj21.Add(obj22);
array[6] = new Keybind(obj20.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "focus", obj21, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnSetRootPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj23 = config;
List<Dictionary<Key, bool>> obj24 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj25 = new Dictionary<Key, bool>();
obj25.Add((Key)8, true);
obj25.Add((Key)514, false);
obj24.Add(obj25);
array[7] = new Keybind(obj23.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "destroy", obj24, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnDestroyPreservingAssetsPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj26 = config;
List<Dictionary<Key, bool>> obj27 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj28 = new Dictionary<Key, bool>();
obj28.Add((Key)8, true);
obj28.Add((Key)514, true);
obj27.Add(obj28);
array[8] = new Keybind(obj26.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "destroy No Preserve Assets", obj27, (ConfigDescription)null), AccessTools.Method(typeof(SceneInspector), "OnDestroyPressed", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj29 = config;
List<Dictionary<Key, bool>> obj30 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj31 = new Dictionary<Key, bool>();
obj31.Add((Key)118, true);
obj30.Add(obj31);
array[9] = new Keybind(obj29.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "open component attacher", obj30, (ConfigDescription)null), AccessTools.Method(typeof(ExtraBinds), "OpenAttacher", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj32 = config;
List<Dictionary<Key, bool>> obj33 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj34 = new Dictionary<Key, bool>();
obj34.Add((Key)98, true);
obj34.Add((Key)513, false);
obj33.Add(obj34);
array[10] = new Keybind(obj32.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "bring to", obj33, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "BringTo", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj35 = config;
List<Dictionary<Key, bool>> obj36 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj37 = new Dictionary<Key, bool>();
obj37.Add((Key)98, true);
obj37.Add((Key)513, true);
obj36.Add(obj37);
array[11] = new Keybind(obj35.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "jump to", obj36, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "JumpTo", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj38 = config;
List<Dictionary<Key, bool>> obj39 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj40 = new Dictionary<Key, bool>();
obj40.Add((Key)114, true);
obj40.Add((Key)513, true);
obj40.Add((Key)514, false);
obj39.Add(obj40);
array[12] = new Keybind(obj38.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "reset position", obj39, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "ResetPosition", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj41 = config;
List<Dictionary<Key, bool>> obj42 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj43 = new Dictionary<Key, bool>();
obj43.Add((Key)114, true);
obj43.Add((Key)513, true);
obj43.Add((Key)514, true);
obj42.Add(obj43);
array[13] = new Keybind(obj41.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "reset rotation", obj42, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "ResetRotation", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj44 = config;
List<Dictionary<Key, bool>> obj45 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj46 = new Dictionary<Key, bool>();
obj46.Add((Key)114, true);
obj46.Add((Key)513, false);
obj46.Add((Key)514, true);
obj45.Add(obj46);
array[14] = new Keybind(obj44.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "reset scale", obj45, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "ResetScale", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj47 = config;
List<Dictionary<Key, bool>> obj48 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj49 = new Dictionary<Key, bool>();
obj49.Add((Key)106, true);
obj49.Add((Key)513, true);
obj48.Add(obj49);
array[15] = new Keybind(obj47.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "parent under world root", obj48, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "ParentUnderWorldRoot", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj50 = config;
List<Dictionary<Key, bool>> obj51 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj52 = new Dictionary<Key, bool>();
obj52.Add((Key)106, true);
obj52.Add((Key)514, true);
obj51.Add(obj52);
array[16] = new Keybind(obj50.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "parent under local user space", obj51, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "ParentUnderLocalUserSpace", (global::System.Type[])null, (global::System.Type[])null));
ConfigFile obj53 = config;
List<Dictionary<Key, bool>> obj54 = new List<Dictionary<Key, bool>>();
Dictionary<Key, bool> obj55 = new Dictionary<Key, bool>();
obj55.Add((Key)112, true);
obj54.Add(obj55);
array[17] = new Keybind(obj53.Bind<List<Dictionary<Key, bool>>>("InspectorKeybinds", "create pivot", obj54, (ConfigDescription)null), AccessTools.Method(typeof(Slot), "OnCreatePivotAtCenter", (global::System.Type[])null, (global::System.Type[])null));
binds = array;
((BasePlugin)this).HarmonyInstance.PatchAll();
}
private static InteractionHandler? GetCommonTool(UserRoot userRoot, Chirality side)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
try
{
return userRoot.GetRegisteredComponent<InteractionHandler>((Predicate<InteractionHandler>)((InteractionHandler t) => ((SyncField<Chirality>)(object)t.Side).Value == side));
}
catch
{
return null;
}
}
private static Chirality GetOther(Chirality cur)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
if ((int)cur == 1)
{
return (Chirality)0;
}
return (Chirality)1;
}
}
public static class PluginMetadata
{
public const string GUID = "net.eia485.InspectorKeybinds";
public const string NAME = "InspectorKeybinds";
public const string VERSION = "1.1.3";
public const string AUTHORS = "eia485";
public const string REPOSITORY_URL = "https://github.com/EIA485/NeosInspectorKeybinds";
}