using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using HarmonyLib;
using SkyFrost.Base;
using SpecialItemsLib;
[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.2.1.0")]
[assembly: AssemblyInformationalVersion("2.2.1+bdfe73a922425f5450d8399012dd7eeedf9abf64")]
[assembly: AssemblyProduct("CustomInspectors")]
[assembly: AssemblyTitle("CustomInspectors")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/CustomInspectors")]
[assembly: AssemblyVersion("2.2.1.0")]
[module: RefSafetyRules(11)]
namespace CustomInspectors;
[ResonitePlugin("art0007i.CustomInspectors", "CustomInspectors", "2.2.1", "art0007i", "https://github.com/art0007i/CustomInspectors")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
[HarmonyPatch(typeof(SlotHelper), "GenerateTags", new global::System.Type[]
{
typeof(Slot),
typeof(HashSet<string>)
})]
private class SlotHelper_GenerateTags_Patch
{
public static void Postfix(Slot slot, HashSet<string> tags)
{
if (((ContainerWorker<Component>)(object)slot).GetComponent<SceneInspector>((Predicate<SceneInspector>)null, false) != null)
{
tags.Add("custom_inspector_panel");
}
}
}
[HarmonyPatch(typeof(SceneInspector), "OnAttach")]
private class SceneInspector_OnAttach_Patch
{
[CompilerGenerated]
private sealed class <>c__DisplayClass0_0
{
[StructLayout((LayoutKind)3)]
private struct <<Prefix>b__0>d : IAsyncStateMachine
{
public int <>1__state;
public AsyncTaskMethodBuilder <>t__builder;
public <>c__DisplayClass0_0 <>4__this;
private Updates <>u__1;
private TaskAwaiter<bool> <>u__2;
private ToWorld <>u__3;
private void MoveNext()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
<>c__DisplayClass0_0 <>c__DisplayClass0_ = <>4__this;
try
{
Updates val3;
TaskAwaiter<bool> val2;
ToWorld val;
switch (num)
{
default:
{
Updates val4 = new Updates(0);
val3 = ((Updates)(ref val4)).GetAwaiter();
if (!((Updates)(ref val3)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val3;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<Updates, <<Prefix>b__0>d>(ref val3, ref this);
return;
}
goto IL_0077;
}
case 0:
val3 = <>u__1;
<>u__1 = default(Updates);
num = (<>1__state = -1);
goto IL_0077;
case 1:
val2 = <>u__2;
<>u__2 = default(TaskAwaiter<bool>);
num = (<>1__state = -1);
goto IL_00da;
case 2:
{
val = <>u__3;
<>u__3 = default(ToWorld);
num = (<>1__state = -1);
break;
}
IL_00da:
if (val2.GetResult())
{
Log.LogWarning((object)"Custom Inspector failed to generate, using fallback behaviour.");
ToWorld val5 = default(ToWorld);
val = ((ToWorld)(ref val5)).GetAwaiter();
if (!((ToWorld)(ref val)).IsCompleted)
{
num = (<>1__state = 2);
<>u__3 = val;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToWorld, <<Prefix>b__0>d>(ref val, ref this);
return;
}
break;
}
goto end_IL_000e;
IL_0077:
((Updates)(ref val3)).GetResult();
val2 = SpawnCustomInspector(<>c__DisplayClass0_.__instance).GetAwaiter();
if (!val2.IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val2;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter<bool>, <<Prefix>b__0>d>(ref val2, ref this);
return;
}
goto IL_00da;
}
((ToWorld)(ref val)).GetResult();
Slot slot = ((Component)<>c__DisplayClass0_.__instance).Slot;
float3 localScale = slot.LocalScale;
slot.LocalScale = (ref localScale) / <>c__DisplayClass0_.configuredScale;
if (((MethodBase)reentrantMethod).IsStatic)
{
((MethodBase)reentrantMethod).Invoke((object)null, new object[1] { <>c__DisplayClass0_.__instance });
}
else
{
((MethodBase)reentrantMethod).Invoke((object)<>c__DisplayClass0_.__instance, global::System.Array.Empty<object>());
}
end_IL_000e:;
}
catch (global::System.Exception exception)
{
<>1__state = -2;
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
return;
}
<>1__state = -2;
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult();
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
}
}
public SceneInspector __instance;
public float configuredScale;
[AsyncStateMachine(typeof(<<Prefix>b__0>d))]
internal global::System.Threading.Tasks.Task <Prefix>b__0()
{
//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)
<<Prefix>b__0>d <<Prefix>b__0>d = default(<<Prefix>b__0>d);
<<Prefix>b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create();
<<Prefix>b__0>d.<>4__this = this;
<<Prefix>b__0>d.<>1__state = -1;
((AsyncTaskMethodBuilder)(ref <<Prefix>b__0>d.<>t__builder)).Start<<<Prefix>b__0>d>(ref <<Prefix>b__0>d);
return ((AsyncTaskMethodBuilder)(ref <<Prefix>b__0>d.<>t__builder)).Task;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public SceneInspector __instance;
internal bool <SpawnCustomInspector>b__1(SceneInspector insp)
{
return insp != __instance;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_1
{
public ReferenceTranslator translator;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_2
{
public DataTreeDictionary dataDict;
public <>c__DisplayClass1_1 CS$<>8__locals1;
internal void <SpawnCustomInspector>b__0(IWorldElement member)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
DataTreeDictionary obj = dataDict.TryGetDictionary(member.Name);
string text = ((obj != null) ? LoadSaveHelper.LoadString(obj.TryGetNode("ID")) : null);
if (text != null)
{
CS$<>8__locals1.translator.Associate(member.ReferenceID, new Guid(text), false);
dataDict.TryGetDictionary(member.Name).Children["ID"] = (DataTreeNode)new DataTreeValue(((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString());
}
}
}
[StructLayout((LayoutKind)3)]
[CompilerGenerated]
private struct <SpawnCustomInspector>d__1 : IAsyncStateMachine
{
public int <>1__state;
public AsyncTaskMethodBuilder<bool> <>t__builder;
public SceneInspector __instance;
private <>c__DisplayClass1_1 <>8__1;
private <>c__DisplayClass1_0 <>8__2;
private float3? <restorePos>5__2;
private floatQ? <restoreRot>5__3;
private float3? <restoreScl>5__4;
private Uri <uri>5__5;
private DataTreeDictionary <node>5__6;
private ToBackground <>u__1;
private TaskAwaiter<CloudResult<Record>> <>u__2;
private ValueTaskAwaiter<string> <>u__3;
private ToWorld <>u__4;
private void MoveNext()
{
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: 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_04dc: Unknown result type (might be due to invalid IL or missing references)
//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_0529: Unknown result type (might be due to invalid IL or missing references)
//IL_052e: Unknown result type (might be due to invalid IL or missing references)
//IL_0540: Unknown result type (might be due to invalid IL or missing references)
//IL_0545: Unknown result type (might be due to invalid IL or missing references)
//IL_0557: Unknown result type (might be due to invalid IL or missing references)
//IL_055c: Unknown result type (might be due to invalid IL or missing references)
//IL_055f: Unknown result type (might be due to invalid IL or missing references)
//IL_056c: Unknown result type (might be due to invalid IL or missing references)
//IL_0579: Unknown result type (might be due to invalid IL or missing references)
//IL_0715: Unknown result type (might be due to invalid IL or missing references)
//IL_072c: Unknown result type (might be due to invalid IL or missing references)
//IL_0743: Unknown result type (might be due to invalid IL or missing references)
//IL_07f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0821: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Expected O, but got Unknown
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
//IL_0440: Unknown result type (might be due to invalid IL or missing references)
//IL_0445: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Expected O, but got Unknown
int num = <>1__state;
bool result2;
try
{
if ((uint)num > 3u)
{
<>8__2 = new <>c__DisplayClass1_0();
<>8__2.__instance = __instance;
<restorePos>5__2 = null;
<restoreRot>5__3 = null;
<restoreScl>5__4 = null;
}
try
{
ToBackground val4;
TaskAwaiter<CloudResult<Record>> val3;
ValueTaskAwaiter<string> val2;
ToWorld val;
Uri obj;
string result;
CloudResult<Record> result3;
switch (num)
{
default:
{
<>8__1 = new <>c__DisplayClass1_1();
ToBackground val5 = default(ToBackground);
val4 = ((ToBackground)(ref val5)).GetAwaiter();
if (!((ToBackground)(ref val4)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val4;
<>t__builder.AwaitOnCompleted<ToBackground, <SpawnCustomInspector>d__1>(ref val4, ref this);
return;
}
goto IL_00c7;
}
case 0:
val4 = <>u__1;
<>u__1 = default(ToBackground);
num = (<>1__state = -1);
goto IL_00c7;
case 1:
val3 = <>u__2;
<>u__2 = default(TaskAwaiter<CloudResult<Record>>);
num = (<>1__state = -1);
goto IL_017a;
case 2:
val2 = <>u__3;
<>u__3 = default(ValueTaskAwaiter<string>);
num = (<>1__state = -1);
goto IL_0223;
case 3:
{
val = <>u__4;
<>u__4 = default(ToWorld);
num = (<>1__state = -1);
break;
}
IL_01aa:
val2 = Engine.Current.AssetManager.GatherAssetFile(<uri>5__5, 20f, (DB_Endpoint?)null).GetAwaiter();
if (!val2.IsCompleted)
{
num = (<>1__state = 2);
<>u__3 = val2;
<>t__builder.AwaitUnsafeOnCompleted<ValueTaskAwaiter<string>, <SpawnCustomInspector>d__1>(ref val2, ref this);
return;
}
goto IL_0223;
IL_00c7:
((ToBackground)(ref val4)).GetResult();
<uri>5__5 = OurItem.ItemUri;
obj = <uri>5__5;
if (((obj != null) ? obj.Scheme : null) == ((SkyFrostInterface)Engine.Current.Cloud).Platform.RecordScheme)
{
val3 = ((SkyFrostInterface)Engine.Current.Cloud).Records.GetRecordCached<Record>(<uri>5__5, (string)null).GetAwaiter();
if (!val3.IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val3;
<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter<CloudResult<Record>>, <SpawnCustomInspector>d__1>(ref val3, ref this);
return;
}
goto IL_017a;
}
goto IL_01aa;
IL_0223:
result = val2.GetResult();
if (result != null && File.Exists(result))
{
<node>5__6 = DataTreeConverter.Load(result, <uri>5__5);
DataTreeDictionary obj2 = <node>5__6;
object obj3;
if (obj2 == null)
{
obj3 = null;
}
else
{
DataTreeDictionary obj4 = obj2.TryGetDictionary("FeatureFlags");
obj3 = ((obj4 != null) ? obj4.TryGetNode("TypeManagement") : null);
}
bool flag = obj3 != null;
DataTreeDictionary val6 = <node>5__6.TryGetDictionary("Object");
if (LoadSaveHelper.LoadString(val6.TryGetDictionary("Name").TryGetNode("Data")) == "Holder")
{
DataTreeNode obj5 = val6.TryGetList("Children").Children[0];
val6 = (DataTreeDictionary)(object)((obj5 is DataTreeDictionary) ? obj5 : null);
<node>5__6.Children["Object"] = (DataTreeNode)(object)val6;
}
DataTreeList obj6 = val6.TryGetDictionary("Components").TryGetList("Data");
<>8__1.translator = new ReferenceTranslator();
Enumerator<DataTreeNode> enumerator = obj6.Children.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
DataTreeNode current = enumerator.Current;
DataTreeDictionary val7 = (DataTreeDictionary)(object)((current is DataTreeDictionary) ? current : null);
DataTreeNode val8 = val7.TryGetNode("Type");
bool flag2 = false;
if (flag)
{
int num2 = LoadSaveHelper.LoadInt(val8);
DataTreeList val9 = <node>5__6.TryGetList("Types");
if (val9 != null && val9.Count > num2)
{
flag2 = ((Worker)<>8__2.__instance).World.Types.DecodeType(LoadSaveHelper.LoadString(val9[num2])) == typeof(SceneInspector);
}
}
else
{
flag2 = LoadSaveHelper.LoadString(val8) == ((object)typeof(SceneInspector)).ToString();
}
if (!flag2)
{
continue;
}
<>c__DisplayClass1_2 CS$<>8__locals6 = new <>c__DisplayClass1_2
{
CS$<>8__locals1 = <>8__1,
dataDict = val7.TryGetDictionary("Data")
};
CS$<>8__locals6.CS$<>8__locals1.translator.Associate(((Worker)<>8__2.__instance).ReferenceID, new Guid(LoadSaveHelper.LoadString(CS$<>8__locals6.dataDict.TryGetNode("ID"))), false);
CS$<>8__locals6.dataDict.Children["ID"] = (DataTreeNode)new DataTreeValue(((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString());
((Worker)<>8__2.__instance).ForeachSyncMember<IWorldElement>((Action<IWorldElement>)delegate(IWorldElement member)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
DataTreeDictionary obj7 = CS$<>8__locals6.dataDict.TryGetDictionary(member.Name);
string text = ((obj7 != null) ? LoadSaveHelper.LoadString(obj7.TryGetNode("ID")) : null);
if (text != null)
{
CS$<>8__locals6.CS$<>8__locals1.translator.Associate(member.ReferenceID, new Guid(text), false);
CS$<>8__locals6.dataDict.TryGetDictionary(member.Name).Children["ID"] = (DataTreeNode)new DataTreeValue(((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString());
}
});
break;
}
}
finally
{
if (num < 0)
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
ToWorld val10 = default(ToWorld);
val = ((ToWorld)(ref val10)).GetAwaiter();
if (!((ToWorld)(ref val)).IsCompleted)
{
num = (<>1__state = 3);
<>u__4 = val;
<>t__builder.AwaitOnCompleted<ToWorld, <SpawnCustomInspector>d__1>(ref val, ref this);
return;
}
break;
}
result2 = true;
goto end_IL_004c;
IL_017a:
result3 = val3.GetResult();
if (!((CloudResult)result3).IsError)
{
<uri>5__5 = new Uri(result3.Entity.AssetURI);
goto IL_01aa;
}
result2 = true;
goto end_IL_004c;
}
((ToWorld)(ref val)).GetResult();
if (!((ContainerWorker<Component>)(object)((Component)<>8__2.__instance).Slot).IsDestroyed)
{
float3 globalPosition = ((Component)<>8__2.__instance).Slot.GlobalPosition;
floatQ globalRotation = ((Component)<>8__2.__instance).Slot.GlobalRotation;
float3 globalScale = ((Component)<>8__2.__instance).Slot.GlobalScale;
<restorePos>5__2 = globalPosition;
<restoreRot>5__3 = globalRotation;
<restoreScl>5__4 = globalScale;
((Component)<>8__2.__instance).Slot.LoadObject(<node>5__6, (IRecord)null, (Slot)null, (Predicate<global::System.Type>)null, <>8__1.translator, (Func<DataTreeNode, DataTreeNode>)null);
SceneInspector component = ((ContainerWorker<Component>)(object)((Component)<>8__2.__instance).Slot).GetComponent<SceneInspector>((Predicate<SceneInspector>)((SceneInspector insp) => insp != <>8__2.__instance), false);
FieldInfo val11 = AccessTools.Field(typeof(SceneInspector), "_rootText");
FieldInfo val12 = AccessTools.Field(typeof(SceneInspector), "_componentText");
FieldInfo val13 = AccessTools.Field(typeof(SceneInspector), "_hierarchyContentRoot");
FieldInfo val14 = AccessTools.Field(typeof(SceneInspector), "_componentsContentRoot");
(val11.GetValue((object)<>8__2.__instance) as SyncRef<Sync<string>>).Target = (val11.GetValue((object)component) as SyncRef<Sync<string>>).Target;
(val12.GetValue((object)<>8__2.__instance) as SyncRef<Sync<string>>).Target = (val12.GetValue((object)component) as SyncRef<Sync<string>>).Target;
(val13.GetValue((object)<>8__2.__instance) as SyncRef<Slot>).Target = (val13.GetValue((object)component) as SyncRef<Slot>).Target;
(val14.GetValue((object)<>8__2.__instance) as SyncRef<Slot>).Target = (val14.GetValue((object)component) as SyncRef<Slot>).Target;
((ComponentBase<Component>)(object)component).Destroy(false);
((ComponentBase<Component>)(object)<>8__2.__instance).Enabled = true;
((Component)<>8__2.__instance).Slot.GlobalPosition = globalPosition;
((Component)<>8__2.__instance).Slot.GlobalRotation = globalRotation;
((Component)<>8__2.__instance).Slot.GlobalScale = globalScale;
}
result2 = false;
end_IL_004c:;
}
catch (global::System.Exception ex)
{
Log.LogError((object)("Failed to spawn custom inspector: " + (object)ex));
if (!((Worker)<>8__2.__instance).IsRemoved && !((Worker)((Component)<>8__2.__instance).Slot).IsRemoved)
{
if (<restorePos>5__2.HasValue)
{
((Component)<>8__2.__instance).Slot.GlobalPosition = <restorePos>5__2.Value;
}
if (<restoreRot>5__3.HasValue)
{
((Component)<>8__2.__instance).Slot.GlobalRotation = <restoreRot>5__3.Value;
}
if (<restoreScl>5__4.HasValue)
{
((Component)<>8__2.__instance).Slot.GlobalScale = <restoreScl>5__4.Value;
}
}
goto IL_082d;
}
goto end_IL_0007;
IL_082d:
result2 = true;
end_IL_0007:;
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<>8__2 = null;
<>t__builder.SetException(exception);
return;
}
<>1__state = -2;
<>8__2 = null;
<>t__builder.SetResult(result2);
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
<>t__builder.SetStateMachine(stateMachine);
}
}
public static bool Prefix(SceneInspector __instance)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
<>c__DisplayClass0_0 CS$<>8__locals6 = new <>c__DisplayClass0_0();
CS$<>8__locals6.__instance = __instance;
if (OurItem.ItemUri == (Uri)null)
{
return true;
}
CS$<>8__locals6.configuredScale = InspectorScale.Value;
Slot slot = ((Component)CS$<>8__locals6.__instance).Slot;
float3 localScale = slot.LocalScale;
slot.LocalScale = (ref localScale) * CS$<>8__locals6.configuredScale;
((Worker)CS$<>8__locals6.__instance).StartTask((Func<global::System.Threading.Tasks.Task>)([AsyncStateMachine(typeof(<>c__DisplayClass0_0.<<Prefix>b__0>d))] () =>
{
//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__DisplayClass0_0.<<Prefix>b__0>d <<Prefix>b__0>d = default(<>c__DisplayClass0_0.<<Prefix>b__0>d);
<<Prefix>b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create();
<<Prefix>b__0>d.<>4__this = CS$<>8__locals6;
<<Prefix>b__0>d.<>1__state = -1;
((AsyncTaskMethodBuilder)(ref <<Prefix>b__0>d.<>t__builder)).Start<<>c__DisplayClass0_0.<<Prefix>b__0>d>(ref <<Prefix>b__0>d);
return ((AsyncTaskMethodBuilder)(ref <<Prefix>b__0>d.<>t__builder)).Task;
}));
return false;
}
[AsyncStateMachine(typeof(<SpawnCustomInspector>d__1))]
public static async global::System.Threading.Tasks.Task<bool> SpawnCustomInspector(SceneInspector __instance)
{
//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)
float3? restorePos = null;
floatQ? restoreRot = null;
float3? restoreScl = null;
try
{
await default(ToBackground);
Uri uri = OurItem.ItemUri;
Uri obj = uri;
if (((obj != null) ? obj.Scheme : null) == ((SkyFrostInterface)Engine.Current.Cloud).Platform.RecordScheme)
{
CloudResult<Record> val = await ((SkyFrostInterface)Engine.Current.Cloud).Records.GetRecordCached<Record>(uri, (string)null);
if (((CloudResult)val).IsError)
{
return true;
}
uri = new Uri(val.Entity.AssetURI);
}
string text = await Engine.Current.AssetManager.GatherAssetFile(uri, 20f, (DB_Endpoint?)null);
if (text == null || !File.Exists(text))
{
return true;
}
DataTreeDictionary node = DataTreeConverter.Load(text, uri);
object obj2;
if (node == null)
{
obj2 = null;
}
else
{
DataTreeDictionary obj3 = node.TryGetDictionary("FeatureFlags");
obj2 = ((obj3 != null) ? obj3.TryGetNode("TypeManagement") : null);
}
bool flag = obj2 != null;
DataTreeDictionary val2 = node.TryGetDictionary("Object");
if (LoadSaveHelper.LoadString(val2.TryGetDictionary("Name").TryGetNode("Data")) == "Holder")
{
DataTreeNode obj4 = val2.TryGetList("Children").Children[0];
val2 = (DataTreeDictionary)(object)((obj4 is DataTreeDictionary) ? obj4 : null);
node.Children["Object"] = (DataTreeNode)(object)val2;
}
DataTreeList obj5 = val2.TryGetDictionary("Components").TryGetList("Data");
ReferenceTranslator translator = new ReferenceTranslator();
Enumerator<DataTreeNode> enumerator = obj5.Children.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
DataTreeNode current = enumerator.Current;
DataTreeDictionary val3 = (DataTreeDictionary)(object)((current is DataTreeDictionary) ? current : null);
DataTreeNode val4 = val3.TryGetNode("Type");
bool flag2 = false;
if (flag)
{
int num = LoadSaveHelper.LoadInt(val4);
DataTreeList val5 = node.TryGetList("Types");
if (val5 != null && val5.Count > num)
{
flag2 = ((Worker)__instance).World.Types.DecodeType(LoadSaveHelper.LoadString(val5[num])) == typeof(SceneInspector);
}
}
else
{
flag2 = LoadSaveHelper.LoadString(val4) == ((object)typeof(SceneInspector)).ToString();
}
if (!flag2)
{
continue;
}
DataTreeDictionary dataDict = val3.TryGetDictionary("Data");
translator.Associate(((Worker)__instance).ReferenceID, new Guid(LoadSaveHelper.LoadString(dataDict.TryGetNode("ID"))), false);
dataDict.Children["ID"] = (DataTreeNode)new DataTreeValue(((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString());
((Worker)__instance).ForeachSyncMember<IWorldElement>((Action<IWorldElement>)delegate(IWorldElement member)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
DataTreeDictionary obj6 = dataDict.TryGetDictionary(member.Name);
string text2 = ((obj6 != null) ? LoadSaveHelper.LoadString(obj6.TryGetNode("ID")) : null);
if (text2 != null)
{
translator.Associate(member.ReferenceID, new Guid(text2), false);
dataDict.TryGetDictionary(member.Name).Children["ID"] = (DataTreeNode)new DataTreeValue(((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString());
}
});
break;
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
await default(ToWorld);
if (!((ContainerWorker<Component>)(object)((Component)__instance).Slot).IsDestroyed)
{
float3 globalPosition = ((Component)__instance).Slot.GlobalPosition;
floatQ globalRotation = ((Component)__instance).Slot.GlobalRotation;
float3 globalScale = ((Component)__instance).Slot.GlobalScale;
restorePos = globalPosition;
restoreRot = globalRotation;
restoreScl = globalScale;
((Component)__instance).Slot.LoadObject(node, (IRecord)null, (Slot)null, (Predicate<global::System.Type>)null, translator, (Func<DataTreeNode, DataTreeNode>)null);
SceneInspector component = ((ContainerWorker<Component>)(object)((Component)__instance).Slot).GetComponent<SceneInspector>((Predicate<SceneInspector>)((SceneInspector insp) => insp != __instance), false);
FieldInfo val6 = AccessTools.Field(typeof(SceneInspector), "_rootText");
FieldInfo val7 = AccessTools.Field(typeof(SceneInspector), "_componentText");
FieldInfo val8 = AccessTools.Field(typeof(SceneInspector), "_hierarchyContentRoot");
FieldInfo val9 = AccessTools.Field(typeof(SceneInspector), "_componentsContentRoot");
(val6.GetValue((object)__instance) as SyncRef<Sync<string>>).Target = (val6.GetValue((object)component) as SyncRef<Sync<string>>).Target;
(val7.GetValue((object)__instance) as SyncRef<Sync<string>>).Target = (val7.GetValue((object)component) as SyncRef<Sync<string>>).Target;
(val8.GetValue((object)__instance) as SyncRef<Slot>).Target = (val8.GetValue((object)component) as SyncRef<Slot>).Target;
(val9.GetValue((object)__instance) as SyncRef<Slot>).Target = (val9.GetValue((object)component) as SyncRef<Slot>).Target;
((ComponentBase<Component>)(object)component).Destroy(false);
((ComponentBase<Component>)(object)__instance).Enabled = true;
((Component)__instance).Slot.GlobalPosition = globalPosition;
((Component)__instance).Slot.GlobalRotation = globalRotation;
((Component)__instance).Slot.GlobalScale = globalScale;
}
return false;
}
catch (global::System.Exception ex)
{
Log.LogError((object)("Failed to spawn custom inspector: " + (object)ex));
if (!((Worker)__instance).IsRemoved && !((Worker)((Component)__instance).Slot).IsRemoved)
{
if (restorePos.HasValue)
{
((Component)__instance).Slot.GlobalPosition = restorePos.Value;
}
if (restoreRot.HasValue)
{
((Component)__instance).Slot.GlobalRotation = restoreRot.Value;
}
if (restoreScl.HasValue)
{
((Component)__instance).Slot.GlobalScale = restoreScl.Value;
}
}
}
return true;
}
}
internal static ManualLogSource Log;
internal static ConfigEntry<float> InspectorScale;
private static DynamicMethod reentrantMethod;
private const string INSPECTOR_TAG = "custom_inspector_panel";
private static CustomSpecialItem OurItem;
public override void Load()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
OurItem = SpecialItemsLib.RegisterItem("custom_inspector_panel", "Inspector");
InspectorScale = ((BasePlugin)this).Config.Bind<float>("General", "Inspector Scale", 0.0005f, "Changes the spawned inspector scale to this value.\n0.0005 by default, because that's what the default inspector's scale is.");
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.CustomInspectors");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
((BasePlugin)this).HarmonyInstance.PatchAll();
MethodInfo val2 = AccessTools.Method(typeof(SceneInspector), "OnAttach", (global::System.Type[])null, (global::System.Type[])null);
reentrantMethod = (DynamicMethod)((BasePlugin)this).HarmonyInstance.Patch((MethodBase)(object)val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
public static class PluginMetadata
{
public const string GUID = "art0007i.CustomInspectors";
public const string NAME = "CustomInspectors";
public const string VERSION = "2.2.1";
public const string AUTHORS = "art0007i";
public const string REPOSITORY_URL = "https://github.com/art0007i/CustomInspectors";
}