using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.Store;
using FrooxEngine.UIX;
using HarmonyLib;
using SkyFrost.Base;
[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.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+c5ea9adc93b426016e5ff2757f34ce8fde8211cb")]
[assembly: AssemblyProduct("QuickFolderOpener")]
[assembly: AssemblyTitle("QuickFolderOpener")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/QuickFolderOpener")]
[assembly: AssemblyVersion("2.0.1.0")]
[module: RefSafetyRules(11)]
namespace QuickFolderOpener;
[ResonitePlugin("art0007i.QuickFolderOpener", "QuickFolderOpener", "2.0.1", "art0007i", "https://github.com/art0007i/QuickFolderOpener")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
[HarmonyPatch(typeof(InventoryLink), "GenerateMenuItems")]
private class QuickFolderOpenerPatch
{
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
[StructLayout((LayoutKind)3)]
private struct <<InsertContextMenu>b__0>d : IAsyncStateMachine
{
public int <>1__state;
public AsyncVoidMethodBuilder <>t__builder;
public <>c__DisplayClass1_0 <>4__this;
private <>c__DisplayClass1_1 <>8__1;
private ToBackground <>u__1;
private TaskAwaiter<CloudResult<Record>> <>u__2;
private ToWorld <>u__3;
private void MoveNext()
{
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Expected O, but got Unknown
int num = <>1__state;
<>c__DisplayClass1_0 <>c__DisplayClass1_ = <>4__this;
try
{
ToBackground val3;
TaskAwaiter<CloudResult<Record>> val2;
ToWorld val;
CloudResult<Record> result;
ToWorld val6;
switch (num)
{
default:
{
<>8__1 = new <>c__DisplayClass1_1();
<>8__1.CS$<>8__locals1 = <>c__DisplayClass1_;
<>8__1.dash = Userspace.UserspaceWorld.GetGloballyRegisteredComponent<UserspaceRadiantDash>((Predicate<UserspaceRadiantDash>)null);
SyncRef<LegacyCanvasPanel> val4 = Traverse.Create((object)<>8__1.dash).Field("_legacyInventoryPanel").GetValue() as SyncRef<LegacyCanvasPanel>;
<>8__1.inv = Traverse.Create((object)<>8__1.dash).Field("_legacyInventory").GetValue() as SyncRef<InventoryBrowser>;
if (val4.Target == null || !((Component)val4.Target).Slot.ActiveSelf)
{
Log.LogDebug((object)"Toggling legacy inventory...");
((ComponentBase<Component>)(object)<>8__1.dash).RunSynchronously((Action)delegate
{
<>8__1.dash.ToggleLegacyInventory(true);
}, false);
}
CoroutineManager.Manager.Value = ((Worker)<>c__DisplayClass1_.i).World.Coroutines;
ToBackground val5 = default(ToBackground);
val3 = ((ToBackground)(ref val5)).GetAwaiter();
if (!((ToBackground)(ref val3)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val3;
((AsyncVoidMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToBackground, <<InsertContextMenu>b__0>d>(ref val3, ref this);
return;
}
goto IL_015d;
}
case 0:
val3 = <>u__1;
<>u__1 = default(ToBackground);
num = (<>1__state = -1);
goto IL_015d;
case 1:
val2 = <>u__2;
<>u__2 = default(TaskAwaiter<CloudResult<Record>>);
num = (<>1__state = -1);
goto IL_01d4;
case 2:
{
val = <>u__3;
<>u__3 = default(ToWorld);
num = (<>1__state = -1);
break;
}
IL_015d:
((ToBackground)(ref val3)).GetResult();
val2 = Engine.Current.RecordManager.FetchRecord(<>c__DisplayClass1_.ruri, (TimeSpan?)null).GetAwaiter();
if (!val2.IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val2;
((AsyncVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter<CloudResult<Record>>, <<InsertContextMenu>b__0>d>(ref val2, ref this);
return;
}
goto IL_01d4;
IL_01d4:
result = val2.GetResult();
<>8__1.rec = result.Entity;
val6 = default(ToWorld);
val = ((ToWorld)(ref val6)).GetAwaiter();
if (!((ToWorld)(ref val)).IsCompleted)
{
num = (<>1__state = 2);
<>u__3 = val;
((AsyncVoidMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToWorld, <<InsertContextMenu>b__0>d>(ref val, ref this);
return;
}
break;
}
((ToWorld)(ref val)).GetResult();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val7 = new BepInExDebugLogInterpolatedStringHandler(22, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("opening inventory ");
((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(<>8__1.rec.OwnerId);
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(<>8__1.rec.Path);
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(((SyncField<string>)(object)<>c__DisplayClass1_.i.TargetName).Value);
}
log.LogDebug(val7);
((ComponentBase<Component>)(object)<>8__1.inv?.Target)?.RunSynchronously((Action)delegate
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
SyncRef<InventoryBrowser> obj = <>8__1.inv;
if (obj != null)
{
InventoryBrowser target = obj.Target;
if (target != null)
{
target.Open(new RecordDirectory(<>8__1.rec.OwnerId, <>8__1.rec.Path + "\\" + <>8__1.rec.Name, Engine.Current, ((SyncField<string>)(object)<>8__1.CS$<>8__locals1.i.TargetName).Value), (Slide)1);
}
}
}, false);
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<>8__1 = null;
((AsyncVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
return;
}
<>1__state = -2;
<>8__1 = null;
((AsyncVoidMethodBuilder)(ref <>t__builder)).SetResult();
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
((AsyncVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
}
}
public InventoryLink i;
public Uri ruri;
[AsyncStateMachine(typeof(<<InsertContextMenu>b__0>d))]
internal void <InsertContextMenu>b__0(IButton b, ButtonEventData e)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
<<InsertContextMenu>b__0>d <<InsertContextMenu>b__0>d = default(<<InsertContextMenu>b__0>d);
<<InsertContextMenu>b__0>d.<>t__builder = AsyncVoidMethodBuilder.Create();
<<InsertContextMenu>b__0>d.<>4__this = this;
<<InsertContextMenu>b__0>d.<>1__state = -1;
((AsyncVoidMethodBuilder)(ref <<InsertContextMenu>b__0>d.<>t__builder)).Start<<<InsertContextMenu>b__0>d>(ref <<InsertContextMenu>b__0>d);
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_1
{
public UserspaceRadiantDash dash;
public SyncRef<InventoryBrowser> inv;
public Record rec;
public <>c__DisplayClass1_0 CS$<>8__locals1;
internal void <InsertContextMenu>b__1()
{
dash.ToggleLegacyInventory(true);
}
internal void <InsertContextMenu>b__2()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
SyncRef<InventoryBrowser> obj = inv;
if (obj != null)
{
InventoryBrowser target = obj.Target;
if (target != null)
{
target.Open(new RecordDirectory(rec.OwnerId, rec.Path + "\\" + rec.Name, Engine.Current, ((SyncField<string>)(object)CS$<>8__locals1.i.TargetName).Value), (Slide)1);
}
}
}
}
[CompilerGenerated]
private sealed class <Transpiler>d__0 : global::System.Collections.Generic.IEnumerable<CodeInstruction>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<CodeInstruction>, global::System.Collections.IEnumerator, global::System.IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private global::System.Collections.Generic.IEnumerable<CodeInstruction> codes;
public global::System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;
private CodeInstruction[] <injects>5__2;
private global::System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap2;
private CodeInstruction <code>5__4;
private CodeInstruction[] <>7__wrap4;
private int <>7__wrap5;
CodeInstruction global::System.Collections.Generic.IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object global::System.Collections.IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void global::System.IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<injects>5__2 = null;
<>7__wrap2 = null;
<code>5__4 = null;
<>7__wrap4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<injects>5__2 = (CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldarg_1, (object)null),
new CodeInstruction(OpCodes.Call, (object)typeof(QuickFolderOpenerPatch).GetMethod("InsertContextMenu"))
};
<>7__wrap2 = codes.GetEnumerator();
<>1__state = -3;
break;
case 1:
{
<>1__state = -3;
object operand = <code>5__4.operand;
object obj = ((operand is MethodInfo) ? operand : null);
if (((obj != null) ? ((MemberInfo)obj).Name : null) == "AddItem")
{
<>7__wrap4 = <injects>5__2;
<>7__wrap5 = 0;
goto IL_0134;
}
goto IL_014b;
}
case 2:
{
<>1__state = -3;
<>7__wrap5++;
goto IL_0134;
}
IL_0134:
if (<>7__wrap5 < <>7__wrap4.Length)
{
CodeInstruction val = <>7__wrap4[<>7__wrap5];
<>2__current = val;
<>1__state = 2;
return true;
}
<>7__wrap4 = null;
goto IL_014b;
IL_014b:
<code>5__4 = null;
break;
}
if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext())
{
<code>5__4 = <>7__wrap2.Current;
<>2__current = <code>5__4;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>7__wrap2 = null;
return false;
}
catch
{
//try-fault
((global::System.IDisposable)this).Dispose();
throw;
}
}
bool global::System.Collections.IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap2 != null)
{
((global::System.IDisposable)<>7__wrap2).Dispose();
}
}
[DebuggerHidden]
void global::System.Collections.IEnumerator.Reset()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
[DebuggerHidden]
global::System.Collections.Generic.IEnumerator<CodeInstruction> global::System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.codes = <>3__codes;
return <Transpiler>d__;
}
[DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
public static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
{
CodeInstruction[] injects = (CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldarg_1, (object)null),
new CodeInstruction(OpCodes.Call, (object)typeof(QuickFolderOpenerPatch).GetMethod("InsertContextMenu"))
};
global::System.Collections.Generic.IEnumerator<CodeInstruction> enumerator = codes.GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
CodeInstruction code = enumerator.Current;
yield return code;
object operand = code.operand;
object obj = ((operand is MethodInfo) ? operand : null);
if (((obj != null) ? ((MemberInfo)obj).Name : null) == "AddItem")
{
CodeInstruction[] array = injects;
for (int i = 0; i < array.Length; i++)
{
yield return array[i];
}
}
}
}
finally
{
((global::System.IDisposable)enumerator)?.Dispose();
}
}
public static void InsertContextMenu(InventoryLink i, ContextMenu m)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
<>c__DisplayClass1_0 CS$<>8__locals5 = new <>c__DisplayClass1_0();
CS$<>8__locals5.i = i;
CS$<>8__locals5.ruri = ((SyncField<Uri>)(object)CS$<>8__locals5.i.Target).Value;
if (!(CS$<>8__locals5.ruri.Scheme != "resrec"))
{
LocaleString val = LocaleString.op_Implicit("Open Folder");
Uri folder = Icons.Folder;
colorX? val2 = colorX.Orange;
m.AddItem(ref val, folder, ref val2).Button.LocalPressed += (ButtonEventHandler)([AsyncStateMachine(typeof(<>c__DisplayClass1_0.<<InsertContextMenu>b__0>d))] (IButton b, ButtonEventData e) =>
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
<>c__DisplayClass1_0.<<InsertContextMenu>b__0>d <<InsertContextMenu>b__0>d = default(<>c__DisplayClass1_0.<<InsertContextMenu>b__0>d);
<<InsertContextMenu>b__0>d.<>t__builder = AsyncVoidMethodBuilder.Create();
<<InsertContextMenu>b__0>d.<>4__this = CS$<>8__locals5;
<<InsertContextMenu>b__0>d.<>1__state = -1;
((AsyncVoidMethodBuilder)(ref <<InsertContextMenu>b__0>d.<>t__builder)).Start<<>c__DisplayClass1_0.<<InsertContextMenu>b__0>d>(ref <<InsertContextMenu>b__0>d);
});
}
}
}
internal static ManualLogSource Log;
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("art0007i.QuickFolderOpener");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
((BasePlugin)this).HarmonyInstance.PatchAll();
}
}
public static class PluginMetadata
{
public const string GUID = "art0007i.QuickFolderOpener";
public const string NAME = "QuickFolderOpener";
public const string VERSION = "2.0.1";
public const string AUTHORS = "art0007i";
public const string REPOSITORY_URL = "https://github.com/art0007i/QuickFolderOpener";
}