using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Sources;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using BepisModSettings.ConfigAttributes;
using BepisResoniteWrapper;
using Elements.Core;
using FrooxEngine;
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("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+eb6a76c9327eb2eafe3332f73806c532b93162e4")]
[assembly: AssemblyProduct("LocalStuff")]
[assembly: AssemblyTitle("LocalStuff")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/LocalStuff")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace LocalStuff;
public static class ModSettings
{
private enum SaveState
{
NotSaved,
Saved,
Saving,
NotSavable
}
[CompilerGenerated]
private sealed class <>c__DisplayClass2_0
{
public Workspace space;
public string txt;
public IField<string> label;
public IField<bool> enabled;
public Action <>9__4;
public ButtonEventHandler <>9__3;
internal void <EnumerateWorskpaceDataFeed>b__0(IField<string> field)
{
((IValue<string>)(object)field).Value = txt;
label = field;
}
internal void <EnumerateWorskpaceDataFeed>b__1(IField<bool> x)
{
enabled = x;
}
internal void <EnumerateWorskpaceDataFeed>b__2(SyncDelegate<Action> x)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_002b: Expected O, but got Unknown
Button component = ((ContainerWorker<Component>)(object)((SyncElement)x).Slot).GetComponent<Button>((Predicate<Button>)null, false);
ButtonEventHandler obj = <>9__3;
if (obj == null)
{
ButtonEventHandler val = delegate
{
//IL_0035: 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_003c: Expected O, but got Unknown
//IL_0041: Expected O, but got Unknown
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saving);
((IValue<bool>)(object)enabled).Value = false;
Workspace obj2 = space;
Action obj3 = <>9__4;
if (obj3 == null)
{
Action val3 = delegate
{
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)enabled).Value = true;
};
Action val4 = val3;
<>9__4 = val3;
obj3 = val4;
}
Plugin.SaveWorkspaceLocally(obj2, obj3);
};
ButtonEventHandler val2 = val;
<>9__3 = val;
obj = val2;
}
component.LocalPressed += obj;
}
internal void <EnumerateWorskpaceDataFeed>b__3(IButton _, ButtonEventData _)
{
//IL_0035: 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_003c: Expected O, but got Unknown
//IL_0041: Expected O, but got Unknown
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saving);
((IValue<bool>)(object)enabled).Value = false;
Workspace obj = space;
Action obj2 = <>9__4;
if (obj2 == null)
{
Action val = delegate
{
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)enabled).Value = true;
};
Action val2 = val;
<>9__4 = val;
obj2 = val2;
}
Plugin.SaveWorkspaceLocally(obj, obj2);
}
internal void <EnumerateWorskpaceDataFeed>b__4()
{
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)enabled).Value = true;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass3_0
{
public string txt;
public IField<string> label;
public SaveState status;
public IField<bool> enabled;
public FavoriteEntity entity;
public Action <>9__4;
public ButtonEventHandler <>9__3;
internal void <EnumerateEntityInterfaceDataFeed>b__0(IField<string> field)
{
((IValue<string>)(object)field).Value = txt;
label = field;
}
internal void <EnumerateEntityInterfaceDataFeed>b__1(IField<bool> x)
{
((IValue<bool>)(object)x).Value = status != SaveState.NotSavable;
enabled = x;
}
internal void <EnumerateEntityInterfaceDataFeed>b__2(SyncDelegate<Action> x)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_002b: Expected O, but got Unknown
Button component = ((ContainerWorker<Component>)(object)((SyncElement)x).Slot).GetComponent<Button>((Predicate<Button>)null, false);
ButtonEventHandler obj = <>9__3;
if (obj == null)
{
ButtonEventHandler val = delegate
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_003c: Expected O, but got Unknown
//IL_0041: Expected O, but got Unknown
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saving);
((IValue<bool>)(object)enabled).Value = false;
FavoriteEntity val3 = entity;
Action obj2 = <>9__4;
if (obj2 == null)
{
Action val4 = delegate
{
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)enabled).Value = true;
};
Action val5 = val4;
<>9__4 = val4;
obj2 = val5;
}
Plugin.SaveFavoriteEntityLocally(val3, obj2);
};
ButtonEventHandler val2 = val;
<>9__3 = val;
obj = val2;
}
component.LocalPressed += obj;
}
internal void <EnumerateEntityInterfaceDataFeed>b__3(IButton _, ButtonEventData _)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_003c: Expected O, but got Unknown
//IL_0041: Expected O, but got Unknown
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saving);
((IValue<bool>)(object)enabled).Value = false;
FavoriteEntity val = entity;
Action obj = <>9__4;
if (obj == null)
{
Action val2 = delegate
{
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)enabled).Value = true;
};
Action val3 = val2;
<>9__4 = val2;
obj = val3;
}
Plugin.SaveFavoriteEntityLocally(val, obj);
}
internal void <EnumerateEntityInterfaceDataFeed>b__4()
{
((IValue<string>)(object)label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)enabled).Value = true;
}
}
[CompilerGenerated]
private sealed class <EnumerateEntityInterfaceDataFeed>d__3 : global::System.Collections.Generic.IAsyncEnumerable<DataFeedItem>, global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem>, global::System.IAsyncDisposable, IValueTaskSource<bool>, IValueTaskSource, IAsyncStateMachine
{
public int <>1__state;
public AsyncIteratorMethodBuilder <>t__builder;
public ManualResetValueTaskSourceCore<bool> <>v__promiseOfValueOrEnd;
private DataFeedItem <>2__current;
private bool <>w__disposeMode;
private int <>l__initialThreadId;
private global::System.Collections.Generic.IReadOnlyList<string> path;
public global::System.Collections.Generic.IReadOnlyList<string> <>3__path;
private global::System.Collections.Generic.IReadOnlyList<string> groupingKeys;
public global::System.Collections.Generic.IReadOnlyList<string> <>3__groupingKeys;
private <>c__DisplayClass3_0 <>8__1;
private global::System.Collections.IEnumerator <>7__wrap1;
private string <spacePath>5__3;
DataFeedItem global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnumerateEntityInterfaceDataFeed>d__3(int <>1__state)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
<>t__builder = AsyncIteratorMethodBuilder.Create();
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
private void MoveNext()
{
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Expected O, but got Unknown
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Invalid comparison between Unknown and I4
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Invalid comparison between Unknown and I4
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
try
{
if ((uint)(num - -5) <= 1u)
{
goto IL_0044;
}
_ = -3;
if (!<>w__disposeMode)
{
num = (<>1__state = -1);
<>7__wrap1 = global::System.Enum.GetValues(typeof(FavoriteEntity)).GetEnumerator();
goto IL_0044;
}
goto end_IL_0007;
IL_0044:
try
{
switch (num)
{
case -4:
num = (<>1__state = -1);
if (!<>w__disposeMode)
{
DataFeedAction val = new DataFeedAction();
<>8__1.enabled = null;
((DataFeedItem)val).InitBase(<spacePath>5__3 + "_Button", path, groupingKeys, LocaleString.op_Implicit("Save '" + <spacePath>5__3 + "'"), (Uri)null, (Action<IField<bool>>)null, (Action<IField<bool>>)null, (global::System.Collections.Generic.IReadOnlyList<DataFeedItem>)null, (object)null);
((DataFeedItem)val).InitEnabled((Action<IField<bool>>)delegate(IField<bool> x)
{
((IValue<bool>)(object)x).Value = <>8__1.status != SaveState.NotSavable;
<>8__1.enabled = x;
});
val.InitAction((Action<SyncDelegate<Action>>)delegate(SyncDelegate<Action> x)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_002b: Expected O, but got Unknown
Button component = ((ContainerWorker<Component>)(object)((SyncElement)x).Slot).GetComponent<Button>((Predicate<Button>)null, false);
ButtonEventHandler obj = <>8__1.<>9__3;
if (obj == null)
{
ButtonEventHandler val3 = delegate
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_003c: Expected O, but got Unknown
//IL_0041: Expected O, but got Unknown
((IValue<string>)(object)<>8__1.label).Value = GetStatusText(SaveState.Saving);
((IValue<bool>)(object)<>8__1.enabled).Value = false;
FavoriteEntity entity = <>8__1.entity;
Action obj2 = <>8__1.<>9__4;
if (obj2 == null)
{
Action val5 = delegate
{
((IValue<string>)(object)<>8__1.label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)<>8__1.enabled).Value = true;
};
Action val6 = val5;
<>8__1.<>9__4 = val5;
obj2 = val6;
}
Plugin.SaveFavoriteEntityLocally(entity, obj2);
};
ButtonEventHandler val4 = val3;
<>8__1.<>9__3 = val3;
obj = val4;
}
component.LocalPressed += obj;
});
<>2__current = (DataFeedItem)(object)val;
num = (<>1__state = -5);
goto IL_0352;
}
goto end_IL_0044;
case -5:
num = (<>1__state = -1);
if (!<>w__disposeMode)
{
<>8__1 = null;
<spacePath>5__3 = null;
break;
}
goto end_IL_0044;
}
while (<>7__wrap1.MoveNext())
{
object current = <>7__wrap1.Current;
<>8__1 = new <>c__DisplayClass3_0();
<>8__1.entity = (FavoriteEntity)current;
if ((int)<>8__1.entity == 0 || (int)<>8__1.entity == 3 || (int)<>8__1.entity == 12)
{
continue;
}
<spacePath>5__3 = ((object)global::System.Runtime.CompilerServices.Unsafe.As<FavoriteEntity, FavoriteEntity>(ref <>8__1.entity)/*cast due to .constrained prefix*/).ToString();
string entityFilePath = Plugin.GetEntityFilePath(<>8__1.entity);
<>8__1.status = SaveState.Saved;
if (!File.Exists(entityFilePath))
{
if (((SkyFrostInterface)Engine.Current.Cloud).Profile.GetCurrentFavorite(<>8__1.entity) == (Uri)null)
{
<>8__1.status = SaveState.NotSavable;
}
else
{
<>8__1.status = SaveState.NotSaved;
}
}
<>8__1.txt = GetStatusText(<>8__1.status);
DataFeedIndicator<string> val2 = new DataFeedIndicator<string>();
<>8__1.label = null;
((DataFeedItem)val2).InitBase(<spacePath>5__3 + "_Label", path, groupingKeys, LocaleString.op_Implicit(<spacePath>5__3 ?? ""), (Uri)null, (Action<IField<bool>>)null, (Action<IField<bool>>)null, (global::System.Collections.Generic.IReadOnlyList<DataFeedItem>)null, (object)null);
val2.InitSetupValue((Action<IField<string>>)delegate(IField<string> field)
{
((IValue<string>)(object)field).Value = <>8__1.txt;
<>8__1.label = field;
}, (string)null);
<>2__current = (DataFeedItem)(object)val2;
num = (<>1__state = -4);
goto IL_0352;
}
end_IL_0044:;
}
finally
{
if (num == -1 && <>7__wrap1 is global::System.IDisposable disposable)
{
disposable.Dispose();
}
}
if (!<>w__disposeMode)
{
<>7__wrap1 = null;
}
end_IL_0007:;
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<>8__1 = null;
<>7__wrap1 = null;
<spacePath>5__3 = null;
<>2__current = null;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).Complete();
<>v__promiseOfValueOrEnd.SetException(exception);
return;
}
<>1__state = -2;
<>8__1 = null;
<>7__wrap1 = null;
<spacePath>5__3 = null;
<>2__current = null;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).Complete();
<>v__promiseOfValueOrEnd.SetResult(false);
return;
IL_0352:
<>v__promiseOfValueOrEnd.SetResult(true);
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
}
[DebuggerHidden]
global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem> global::System.Collections.Generic.IAsyncEnumerable<DataFeedItem>.GetAsyncEnumerator(CancellationToken cancellationToken = default(CancellationToken))
{
//IL_0020: 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)
<EnumerateEntityInterfaceDataFeed>d__3 <EnumerateEntityInterfaceDataFeed>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = -3;
<>t__builder = AsyncIteratorMethodBuilder.Create();
<>w__disposeMode = false;
<EnumerateEntityInterfaceDataFeed>d__ = this;
}
else
{
<EnumerateEntityInterfaceDataFeed>d__ = new <EnumerateEntityInterfaceDataFeed>d__3(-3);
}
<EnumerateEntityInterfaceDataFeed>d__.path = <>3__path;
<EnumerateEntityInterfaceDataFeed>d__.groupingKeys = <>3__groupingKeys;
return <EnumerateEntityInterfaceDataFeed>d__;
}
[DebuggerHidden]
global::System.Threading.Tasks.ValueTask<bool> global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem>.MoveNextAsync()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
if (<>1__state == -2)
{
return default(global::System.Threading.Tasks.ValueTask<bool>);
}
<>v__promiseOfValueOrEnd.Reset();
<EnumerateEntityInterfaceDataFeed>d__3 <EnumerateEntityInterfaceDataFeed>d__ = this;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).MoveNext<<EnumerateEntityInterfaceDataFeed>d__3>(ref <EnumerateEntityInterfaceDataFeed>d__);
short version = <>v__promiseOfValueOrEnd.Version;
if ((int)<>v__promiseOfValueOrEnd.GetStatus(version) == 1)
{
return new global::System.Threading.Tasks.ValueTask<bool>(<>v__promiseOfValueOrEnd.GetResult(version));
}
return new global::System.Threading.Tasks.ValueTask<bool>((IValueTaskSource<bool>)this, version);
}
[DebuggerHidden]
bool IValueTaskSource<bool>.GetResult(short token)
{
return <>v__promiseOfValueOrEnd.GetResult(token);
}
[DebuggerHidden]
ValueTaskSourceStatus IValueTaskSource<bool>.GetStatus(short token)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return <>v__promiseOfValueOrEnd.GetStatus(token);
}
[DebuggerHidden]
void IValueTaskSource<bool>.OnCompleted(Action<object?> continuation, object? state, short token, ValueTaskSourceOnCompletedFlags flags)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
<>v__promiseOfValueOrEnd.OnCompleted(continuation, state, token, flags);
}
[DebuggerHidden]
void IValueTaskSource.GetResult(short token)
{
<>v__promiseOfValueOrEnd.GetResult(token);
}
[DebuggerHidden]
ValueTaskSourceStatus IValueTaskSource.GetStatus(short token)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return <>v__promiseOfValueOrEnd.GetStatus(token);
}
[DebuggerHidden]
void IValueTaskSource.OnCompleted(Action<object?> continuation, object? state, short token, ValueTaskSourceOnCompletedFlags flags)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
<>v__promiseOfValueOrEnd.OnCompleted(continuation, state, token, flags);
}
[DebuggerHidden]
global::System.Threading.Tasks.ValueTask global::System.IAsyncDisposable.DisposeAsync()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (<>1__state >= -1)
{
throw new NotSupportedException();
}
if (<>1__state == -2)
{
return default(global::System.Threading.Tasks.ValueTask);
}
<>w__disposeMode = true;
<>v__promiseOfValueOrEnd.Reset();
<EnumerateEntityInterfaceDataFeed>d__3 <EnumerateEntityInterfaceDataFeed>d__ = this;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).MoveNext<<EnumerateEntityInterfaceDataFeed>d__3>(ref <EnumerateEntityInterfaceDataFeed>d__);
return new global::System.Threading.Tasks.ValueTask((IValueTaskSource)(object)this, <>v__promiseOfValueOrEnd.Version);
}
}
[CompilerGenerated]
private sealed class <EnumerateWorskpaceDataFeed>d__2 : global::System.Collections.Generic.IAsyncEnumerable<DataFeedItem>, global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem>, global::System.IAsyncDisposable, IValueTaskSource<bool>, IValueTaskSource, IAsyncStateMachine
{
public int <>1__state;
public AsyncIteratorMethodBuilder <>t__builder;
public ManualResetValueTaskSourceCore<bool> <>v__promiseOfValueOrEnd;
private DataFeedItem <>2__current;
private bool <>w__disposeMode;
private int <>l__initialThreadId;
private global::System.Collections.Generic.IReadOnlyList<string> path;
public global::System.Collections.Generic.IReadOnlyList<string> <>3__path;
private global::System.Collections.Generic.IReadOnlyList<string> groupingKeys;
public global::System.Collections.Generic.IReadOnlyList<string> <>3__groupingKeys;
private <>c__DisplayClass2_0 <>8__1;
private Enumerator<Workspace> <>7__wrap1;
private string <spacePath>5__3;
DataFeedItem global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnumerateWorskpaceDataFeed>d__2(int <>1__state)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
<>t__builder = AsyncIteratorMethodBuilder.Create();
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
private void MoveNext()
{
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
try
{
if ((uint)(num - -5) <= 1u)
{
goto IL_004a;
}
_ = -3;
if (!<>w__disposeMode)
{
num = (<>1__state = -1);
List<Workspace> componentsInChildren = Userspace.UserspaceWorld.RootSlot.GetComponentsInChildren<Workspace>((Predicate<Workspace>)null, false, false, (Predicate<Slot>)null);
<>7__wrap1 = componentsInChildren.GetEnumerator();
goto IL_004a;
}
goto end_IL_0007;
IL_004a:
try
{
switch (num)
{
case -4:
num = (<>1__state = -1);
if (!<>w__disposeMode)
{
DataFeedAction val = new DataFeedAction();
<>8__1.enabled = null;
((DataFeedItem)val).InitBase(<spacePath>5__3 + "_Button", path, groupingKeys, LocaleString.op_Implicit("Save '" + <spacePath>5__3 + "'"), (Uri)null, (Action<IField<bool>>)null, (Action<IField<bool>>)null, (global::System.Collections.Generic.IReadOnlyList<DataFeedItem>)null, (object)null);
((DataFeedItem)val).InitEnabled((Action<IField<bool>>)delegate(IField<bool> x)
{
<>8__1.enabled = x;
});
val.InitAction((Action<SyncDelegate<Action>>)delegate(SyncDelegate<Action> x)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_002b: Expected O, but got Unknown
Button component = ((ContainerWorker<Component>)(object)((SyncElement)x).Slot).GetComponent<Button>((Predicate<Button>)null, false);
ButtonEventHandler obj = <>8__1.<>9__3;
if (obj == null)
{
ButtonEventHandler val3 = delegate
{
//IL_0035: 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_003c: Expected O, but got Unknown
//IL_0041: Expected O, but got Unknown
((IValue<string>)(object)<>8__1.label).Value = GetStatusText(SaveState.Saving);
((IValue<bool>)(object)<>8__1.enabled).Value = false;
Workspace space = <>8__1.space;
Action obj2 = <>8__1.<>9__4;
if (obj2 == null)
{
Action val5 = delegate
{
((IValue<string>)(object)<>8__1.label).Value = GetStatusText(SaveState.Saved);
((IValue<bool>)(object)<>8__1.enabled).Value = true;
};
Action val6 = val5;
<>8__1.<>9__4 = val5;
obj2 = val6;
}
Plugin.SaveWorkspaceLocally(space, obj2);
};
ButtonEventHandler val4 = val3;
<>8__1.<>9__3 = val3;
obj = val4;
}
component.LocalPressed += obj;
});
<>2__current = (DataFeedItem)(object)val;
num = (<>1__state = -5);
goto IL_02e2;
}
goto end_IL_004a;
case -5:
num = (<>1__state = -1);
if (!<>w__disposeMode)
{
<spacePath>5__3 = null;
<>8__1 = null;
break;
}
goto end_IL_004a;
}
if (<>7__wrap1.MoveNext())
{
<>8__1 = new <>c__DisplayClass2_0();
<>8__1.space = <>7__wrap1.Current;
<spacePath>5__3 = ((SyncField<string>)(object)<>8__1.space.WorkspacePath).Value;
string workspaceFilePath = Plugin.GetWorkspaceFilePath(((SyncField<string>)(object)<>8__1.space.WorkspacePath).Value);
<>8__1.txt = GetStatusText(File.Exists(workspaceFilePath) ? SaveState.Saved : SaveState.NotSaved);
DataFeedIndicator<string> val2 = new DataFeedIndicator<string>();
<>8__1.label = null;
((DataFeedItem)val2).InitBase(<spacePath>5__3 + "_Label", path, groupingKeys, LocaleString.op_Implicit(<spacePath>5__3 ?? ""), (Uri)null, (Action<IField<bool>>)null, (Action<IField<bool>>)null, (global::System.Collections.Generic.IReadOnlyList<DataFeedItem>)null, (object)null);
val2.InitSetupValue((Action<IField<string>>)delegate(IField<string> field)
{
((IValue<string>)(object)field).Value = <>8__1.txt;
<>8__1.label = field;
}, (string)null);
<>2__current = (DataFeedItem)(object)val2;
num = (<>1__state = -4);
goto IL_02e2;
}
end_IL_004a:;
}
finally
{
if (num == -1)
{
((global::System.IDisposable)<>7__wrap1/*cast due to .constrained prefix*/).Dispose();
}
}
if (!<>w__disposeMode)
{
<>7__wrap1 = default(Enumerator<Workspace>);
}
end_IL_0007:;
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<>8__1 = null;
<>7__wrap1 = default(Enumerator<Workspace>);
<spacePath>5__3 = null;
<>2__current = null;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).Complete();
<>v__promiseOfValueOrEnd.SetException(exception);
return;
}
<>1__state = -2;
<>8__1 = null;
<>7__wrap1 = default(Enumerator<Workspace>);
<spacePath>5__3 = null;
<>2__current = null;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).Complete();
<>v__promiseOfValueOrEnd.SetResult(false);
return;
IL_02e2:
<>v__promiseOfValueOrEnd.SetResult(true);
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
}
[DebuggerHidden]
global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem> global::System.Collections.Generic.IAsyncEnumerable<DataFeedItem>.GetAsyncEnumerator(CancellationToken cancellationToken = default(CancellationToken))
{
//IL_0020: 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)
<EnumerateWorskpaceDataFeed>d__2 <EnumerateWorskpaceDataFeed>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = -3;
<>t__builder = AsyncIteratorMethodBuilder.Create();
<>w__disposeMode = false;
<EnumerateWorskpaceDataFeed>d__ = this;
}
else
{
<EnumerateWorskpaceDataFeed>d__ = new <EnumerateWorskpaceDataFeed>d__2(-3);
}
<EnumerateWorskpaceDataFeed>d__.path = <>3__path;
<EnumerateWorskpaceDataFeed>d__.groupingKeys = <>3__groupingKeys;
return <EnumerateWorskpaceDataFeed>d__;
}
[DebuggerHidden]
global::System.Threading.Tasks.ValueTask<bool> global::System.Collections.Generic.IAsyncEnumerator<DataFeedItem>.MoveNextAsync()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
if (<>1__state == -2)
{
return default(global::System.Threading.Tasks.ValueTask<bool>);
}
<>v__promiseOfValueOrEnd.Reset();
<EnumerateWorskpaceDataFeed>d__2 <EnumerateWorskpaceDataFeed>d__ = this;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).MoveNext<<EnumerateWorskpaceDataFeed>d__2>(ref <EnumerateWorskpaceDataFeed>d__);
short version = <>v__promiseOfValueOrEnd.Version;
if ((int)<>v__promiseOfValueOrEnd.GetStatus(version) == 1)
{
return new global::System.Threading.Tasks.ValueTask<bool>(<>v__promiseOfValueOrEnd.GetResult(version));
}
return new global::System.Threading.Tasks.ValueTask<bool>((IValueTaskSource<bool>)this, version);
}
[DebuggerHidden]
bool IValueTaskSource<bool>.GetResult(short token)
{
return <>v__promiseOfValueOrEnd.GetResult(token);
}
[DebuggerHidden]
ValueTaskSourceStatus IValueTaskSource<bool>.GetStatus(short token)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return <>v__promiseOfValueOrEnd.GetStatus(token);
}
[DebuggerHidden]
void IValueTaskSource<bool>.OnCompleted(Action<object?> continuation, object? state, short token, ValueTaskSourceOnCompletedFlags flags)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
<>v__promiseOfValueOrEnd.OnCompleted(continuation, state, token, flags);
}
[DebuggerHidden]
void IValueTaskSource.GetResult(short token)
{
<>v__promiseOfValueOrEnd.GetResult(token);
}
[DebuggerHidden]
ValueTaskSourceStatus IValueTaskSource.GetStatus(short token)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return <>v__promiseOfValueOrEnd.GetStatus(token);
}
[DebuggerHidden]
void IValueTaskSource.OnCompleted(Action<object?> continuation, object? state, short token, ValueTaskSourceOnCompletedFlags flags)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
<>v__promiseOfValueOrEnd.OnCompleted(continuation, state, token, flags);
}
[DebuggerHidden]
global::System.Threading.Tasks.ValueTask global::System.IAsyncDisposable.DisposeAsync()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (<>1__state >= -1)
{
throw new NotSupportedException();
}
if (<>1__state == -2)
{
return default(global::System.Threading.Tasks.ValueTask);
}
<>w__disposeMode = true;
<>v__promiseOfValueOrEnd.Reset();
<EnumerateWorskpaceDataFeed>d__2 <EnumerateWorskpaceDataFeed>d__ = this;
((AsyncIteratorMethodBuilder)(ref <>t__builder)).MoveNext<<EnumerateWorskpaceDataFeed>d__2>(ref <EnumerateWorskpaceDataFeed>d__);
return new global::System.Threading.Tasks.ValueTask((IValueTaskSource)(object)this, <>v__promiseOfValueOrEnd.Version);
}
}
private static string GetStatusText(SaveState state)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
string text = "<align=right>";
return string.Concat(text + state switch
{
SaveState.NotSaved => "<alpha=hero.red>Not saved.",
SaveState.Saved => "<alpha=hero.green>Saved!",
SaveState.Saving => "<alpha=hero.orange>Saving...",
SaveState.NotSavable => "<alpha=hero.yellow>Not favorited.",
_ => throw new ArgumentOutOfRangeException("state", (object)state, (string)null),
}, "</align></alpha>");
}
[AsyncIteratorStateMachine(typeof(<EnumerateWorskpaceDataFeed>d__2))]
public static global::System.Collections.Generic.IAsyncEnumerable<DataFeedItem> EnumerateWorskpaceDataFeed(global::System.Collections.Generic.IReadOnlyList<string> path, global::System.Collections.Generic.IReadOnlyList<string> groupingKeys)
{
return new <EnumerateWorskpaceDataFeed>d__2(-2)
{
<>3__path = path,
<>3__groupingKeys = groupingKeys
};
}
[AsyncIteratorStateMachine(typeof(<EnumerateEntityInterfaceDataFeed>d__3))]
public static global::System.Collections.Generic.IAsyncEnumerable<DataFeedItem> EnumerateEntityInterfaceDataFeed(global::System.Collections.Generic.IReadOnlyList<string> path, global::System.Collections.Generic.IReadOnlyList<string> groupingKeys)
{
return new <EnumerateEntityInterfaceDataFeed>d__3(-2)
{
<>3__path = path,
<>3__groupingKeys = groupingKeys
};
}
}
[ResonitePlugin("art0007i.LocalStuff", "LocalStuff", "1.0.1", "art0007i", "https://github.com/art0007i/LocalStuff")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
[HarmonyPatch(typeof(Workspace), "SaveChanges")]
private class DisableAutosavePatch
{
public static bool Prefix(ref global::System.Threading.Tasks.Task __result)
{
__result = global::System.Threading.Tasks.Task.CompletedTask;
return !BlockWorkspaceSave.Value;
}
}
[HarmonyPatch(typeof(Workspace), "OnChanges")]
private class LocalWorkspacePatch
{
[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 FileStream <stream>5__2;
private DataTreeDictionary <node>5__3;
private ToBackground <>u__1;
private ToWorld <>u__2;
private void MoveNext()
{
//IL_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
<>c__DisplayClass0_0 <>c__DisplayClass0_ = <>4__this;
try
{
ToBackground val2;
if (num != 0)
{
if (num == 1)
{
goto IL_00bf;
}
<>c__DisplayClass0_.traverse.Field("_loadingWorkspace").SetValue((object)true);
<>c__DisplayClass0_.traverse.Method("Clear", global::System.Array.Empty<object>()).GetValue();
ToBackground val = default(ToBackground);
val2 = ((ToBackground)(ref val)).GetAwaiter();
if (!((ToBackground)(ref val2)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val2;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToBackground, <<Prefix>b__0>d>(ref val2, ref this);
return;
}
}
else
{
val2 = <>u__1;
<>u__1 = default(ToBackground);
num = (<>1__state = -1);
}
((ToBackground)(ref val2)).GetResult();
<stream>5__2 = File.OpenRead(<>c__DisplayClass0_.filePath);
goto IL_00bf;
IL_00bf:
try
{
ToWorld val4;
if (num != 1)
{
<node>5__3 = DataTreeConverter.LoadAuto((Stream)(object)<stream>5__2);
ToWorld val3 = default(ToWorld);
val4 = ((ToWorld)(ref val3)).GetAwaiter();
if (!((ToWorld)(ref val4)).IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val4;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToWorld, <<Prefix>b__0>d>(ref val4, ref this);
return;
}
}
else
{
val4 = <>u__2;
<>u__2 = default(ToWorld);
num = (<>1__state = -1);
}
((ToWorld)(ref val4)).GetResult();
((Component)<>c__DisplayClass0_.__instance).Slot.LoadObject(<node>5__3, (IRecord)null, (Slot)null, (Predicate<global::System.Type>)null, (ReferenceTranslator)null, (Func<DataTreeNode, DataTreeNode>)null);
<>c__DisplayClass0_.traverse.Field("_currentPath").SetValue((object)<>c__DisplayClass0_.path);
<>c__DisplayClass0_.traverse.Field("_currentRecord").SetValue((object)null);
<>c__DisplayClass0_.traverse.Field("_currentOwnerId").SetValue((object)((SkyFrostInterface)((Worker)<>c__DisplayClass0_.__instance).Cloud).CurrentUserID);
<>c__DisplayClass0_.traverse.Field("_loadingWorkspace").SetValue((object)false);
((ComponentBase<Component>)(object)<>c__DisplayClass0_.__instance).MarkChangeDirty();
}
finally
{
if (num < 0 && <stream>5__2 != null)
{
((global::System.IDisposable)<stream>5__2).Dispose();
}
}
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<stream>5__2 = null;
<node>5__3 = null;
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
return;
}
<>1__state = -2;
<stream>5__2 = null;
<node>5__3 = null;
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult();
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
}
}
public Traverse traverse;
public string filePath;
public Workspace __instance;
public string path;
[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;
}
}
public static bool Prefix(Workspace __instance)
{
<>c__DisplayClass0_0 CS$<>8__locals22 = new <>c__DisplayClass0_0();
CS$<>8__locals22.__instance = __instance;
CS$<>8__locals22.filePath = GetWorkspaceFilePath(((SyncField<string>)(object)CS$<>8__locals22.__instance.WorkspacePath).Value);
if (!File.Exists(CS$<>8__locals22.filePath))
{
return true;
}
CS$<>8__locals22.traverse = Traverse.Create((object)CS$<>8__locals22.__instance);
if (((Worker)CS$<>8__locals22.__instance).World != Userspace.UserspaceWorld || CS$<>8__locals22.__instance.User.Target != ((Worker)CS$<>8__locals22.__instance).LocalUser || CS$<>8__locals22.__instance.IsLoadingWorkspace || ((SyncField<bool>)(object)CS$<>8__locals22.__instance.SuspendUpdates).Value)
{
return false;
}
if (!string.IsNullOrEmpty(CS$<>8__locals22.__instance.CurrentWorkspacePath) && CS$<>8__locals22.__instance.CurrentWorkspaceOwnerId != ((SkyFrostInterface)((Worker)CS$<>8__locals22.__instance).Cloud).CurrentUserID)
{
CS$<>8__locals22.traverse.Field("_currentOwnerId").SetValue((object)((SkyFrostInterface)((Worker)CS$<>8__locals22.__instance).Cloud).CurrentUserID);
}
CS$<>8__locals22.path = ((SyncField<string>)(object)CS$<>8__locals22.__instance.WorkspacePath).Value;
if (CS$<>8__locals22.path == CS$<>8__locals22.__instance.CurrentWorkspacePath)
{
return false;
}
((Worker)CS$<>8__locals22.__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__locals22;
<<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;
}
}
[HarmonyPatch]
private class LocalEntityPatch
{
private delegate global::System.Threading.Tasks.Task<I> EntitySpawner<I>(Slot slot, FavoriteEntity favorite);
[StructLayout((LayoutKind)3)]
[CompilerGenerated]
private struct <SpawnEntity>d__9<I> : IAsyncStateMachine where I : class
{
public int <>1__state;
public AsyncTaskMethodBuilder<I> <>t__builder;
public Slot slot;
public FavoriteEntity favorite;
public Func<Slot, I> fallback;
private EntitySpawner<I>[] <array2>5__2;
private int <i>5__3;
private TaskAwaiter<I> <>u__1;
private void MoveNext()
{
//IL_017e: 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_018b: 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_002b: 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_0056: Expected I4, but got Unknown
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
I result;
try
{
I val;
if (num != 0)
{
_ = ((Worker)slot).Engine;
val = null;
EntityInterfacePreference universeEntityPreference = Engine.Config.UniverseEntityPreference;
EntitySpawner<I>[] array = null;
if (((Worker)slot).Engine.InUniverse)
{
switch ((int)universeEntityPreference)
{
case 2:
array = new EntitySpawner<I>[2]
{
MkDelegate<I>(SpawnUniverseEntity),
MkDelegate<I>(SpawnPlatformEntity)
};
break;
case 1:
array = new EntitySpawner<I>[3]
{
MkDelegate<I>(SpawnUniverseEntity),
MkDelegate<I>(SpawnEntityFromFavorite),
MkDelegate<I>(SpawnPlatformEntity)
};
break;
case 0:
array = new EntitySpawner<I>[3]
{
MkDelegate<I>(SpawnEntityFromFavorite),
MkDelegate<I>(SpawnUniverseEntity),
MkDelegate<I>(SpawnPlatformEntity)
};
break;
}
}
if (!((Worker)slot).Engine.InUniverse || array == null)
{
array = new EntitySpawner<I>[2]
{
MkDelegate<I>(SpawnEntityFromFavorite),
MkDelegate<I>(SpawnPlatformEntity)
};
}
<array2>5__2 = array;
<i>5__3 = 0;
goto IL_01bc;
}
TaskAwaiter<I> val2 = <>u__1;
<>u__1 = default(TaskAwaiter<I>);
num = (<>1__state = -1);
goto IL_019a;
IL_019a:
val = val2.GetResult();
if (val == null)
{
<i>5__3++;
goto IL_01bc;
}
goto IL_01cf;
IL_01cf:
if (val == null)
{
val = ((Func<Slot, Slot>)(object)fallback).Invoke(slot);
}
EntityInterface val3 = (EntityInterface)(object)((val is EntityInterface) ? val : null);
if (val3 != null)
{
val3.MarkInstance();
}
result = val;
goto end_IL_0007;
IL_01bc:
if (<i>5__3 < <array2>5__2.Length)
{
val2 = <array2>5__2[<i>5__3](slot, favorite).GetAwaiter();
if (!val2.IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val2;
<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter<I>, <SpawnEntity>d__9<I>>(ref val2, ref this);
return;
}
goto IL_019a;
}
goto IL_01cf;
end_IL_0007:;
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<array2>5__2 = null;
<>t__builder.SetException(exception);
return;
}
<>1__state = -2;
<array2>5__2 = null;
<>t__builder.SetResult(result);
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
<>t__builder.SetStateMachine(stateMachine);
}
}
[StructLayout((LayoutKind)3)]
[CompilerGenerated]
private struct <SpawnEntityPatched>d__3<T> : IAsyncStateMachine where T : class
{
public int <>1__state;
public AsyncTaskMethodBuilder<T> <>t__builder;
public string filePath;
public Slot slot;
private FileStream <stream>5__2;
private DataTreeDictionary <node>5__3;
private ToBackground <>u__1;
private ToWorld <>u__2;
private void MoveNext()
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: 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_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
T result;
try
{
ToBackground val2;
if (num != 0)
{
if (num == 1)
{
goto IL_0081;
}
ToBackground val = default(ToBackground);
val2 = ((ToBackground)(ref val)).GetAwaiter();
if (!((ToBackground)(ref val2)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val2;
<>t__builder.AwaitOnCompleted<ToBackground, <SpawnEntityPatched>d__3<T>>(ref val2, ref this);
return;
}
}
else
{
val2 = <>u__1;
<>u__1 = default(ToBackground);
num = (<>1__state = -1);
}
((ToBackground)(ref val2)).GetResult();
<stream>5__2 = File.OpenRead(filePath);
goto IL_0081;
IL_0081:
try
{
ToWorld val4;
if (num != 1)
{
<node>5__3 = DataTreeConverter.LoadAuto((Stream)(object)<stream>5__2);
ToWorld val3 = default(ToWorld);
val4 = ((ToWorld)(ref val3)).GetAwaiter();
if (!((ToWorld)(ref val4)).IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val4;
<>t__builder.AwaitOnCompleted<ToWorld, <SpawnEntityPatched>d__3<T>>(ref val4, ref this);
return;
}
}
else
{
val4 = <>u__2;
<>u__2 = default(ToWorld);
num = (<>1__state = -1);
}
((ToWorld)(ref val4)).GetResult();
float3 localPosition = slot.LocalPosition;
floatQ localRotation = slot.LocalRotation;
float3 localScale = slot.LocalScale;
slot.LoadObject(<node>5__3, (IRecord)null, (Slot)null, (Predicate<global::System.Type>)null, (ReferenceTranslator)null, (Func<DataTreeNode, DataTreeNode>)null);
slot.LocalPosition = localPosition;
slot.LocalRotation = localRotation;
slot.LocalScale = localScale;
slot = InventoryItemExtensions.UnpackInventoryItem(slot, true);
T componentInChildren = slot.GetComponentInChildren<T>((Predicate<T>)null, false, false);
EntityInterface val5 = (EntityInterface)(object)((componentInChildren is EntityInterface) ? componentInChildren : null);
if (val5 != null)
{
val5.MarkInstance();
}
result = componentInChildren;
}
finally
{
if (num < 0 && <stream>5__2 != null)
{
((global::System.IDisposable)<stream>5__2).Dispose();
}
}
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<stream>5__2 = null;
<node>5__3 = null;
<>t__builder.SetException(exception);
return;
}
<>1__state = -2;
<stream>5__2 = null;
<node>5__3 = null;
<>t__builder.SetResult(result);
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
<>t__builder.SetStateMachine(stateMachine);
}
}
private static readonly Dictionary<FavoriteEntity, global::System.Type> _favoriteEntityTypes;
internal static MethodInfo SpawnUniverseEntity;
internal static MethodInfo SpawnPlatformEntity;
internal static MethodInfo SpawnEntityFromFavorite;
public static MethodInfo TargetMethod()
{
return AccessTools.FirstMethod(typeof(EntityHelper), (Func<MethodInfo, bool>)((MethodInfo mi) => ((MemberInfo)mi).Name == "SpawnEntity" && ((MethodBase)mi).ContainsGenericParameters && ((MethodBase)mi).GetGenericArguments().Length == 1)).MakeGenericMethod(new global::System.Type[1] { typeof(Component) });
}
public static bool Prefix(ref global::System.Threading.Tasks.Task __result, Slot slot, FavoriteEntity favorite, global::System.Delegate fallback)
{
//IL_0022: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
global::System.Type type = ((fallback != null) ? ((object)fallback).GetType().GetGenericArguments()[1] : null);
if (type == (global::System.Type)null)
{
_favoriteEntityTypes.TryGetValue(favorite, ref type);
}
if (type == (global::System.Type)null)
{
ManualLogSource log = Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(89, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not determine favorite entity type for ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<FavoriteEntity>(favorite);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". This should be reported to the mod author.");
}
log.LogError(val);
throw new global::System.Exception("param cannot be null");
}
string entityFilePath = GetEntityFilePath(favorite);
bool flag2 = File.Exists(entityFilePath);
string text = (flag2 ? "SpawnEntityPatched" : "SpawnEntity");
__result = (global::System.Threading.Tasks.Task)((MethodBase)typeof(LocalEntityPatch).GetMethod(text).MakeGenericMethod(new global::System.Type[1] { type })).Invoke((object)null, new object[3]
{
slot,
flag2 ? entityFilePath : ((object)favorite),
fallback
});
return false;
}
[AsyncStateMachine(typeof(<SpawnEntityPatched>d__3<>))]
public static async global::System.Threading.Tasks.Task<T> SpawnEntityPatched<T>(Slot slot, string filePath, global::System.Delegate _fallback) where T : class
{
//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)
await default(ToBackground);
FileStream stream = File.OpenRead(filePath);
try
{
DataTreeDictionary node = DataTreeConverter.LoadAuto((Stream)(object)stream);
await default(ToWorld);
float3 localPosition = slot.LocalPosition;
floatQ localRotation = slot.LocalRotation;
float3 localScale = slot.LocalScale;
slot.LoadObject(node, (IRecord)null, (Slot)null, (Predicate<global::System.Type>)null, (ReferenceTranslator)null, (Func<DataTreeNode, DataTreeNode>)null);
slot.LocalPosition = localPosition;
slot.LocalRotation = localRotation;
slot.LocalScale = localScale;
slot = InventoryItemExtensions.UnpackInventoryItem(slot, true);
T componentInChildren = slot.GetComponentInChildren<T>((Predicate<T>)null, false, false);
EntityInterface val = (EntityInterface)(object)((componentInChildren is EntityInterface) ? componentInChildren : null);
if (val != null)
{
val.MarkInstance();
}
return componentInChildren;
}
finally
{
((global::System.IDisposable)stream)?.Dispose();
}
}
private static EntitySpawner<I> MkDelegate<I>(MethodInfo mi)
{
return AccessTools.MethodDelegate<EntitySpawner<I>>(mi.MakeGenericMethod(new global::System.Type[1] { typeof(I) }), (object)null, true, (global::System.Type[])null);
}
[AsyncStateMachine(typeof(<SpawnEntity>d__9<>))]
public static async global::System.Threading.Tasks.Task<I> SpawnEntity<I>(Slot slot, FavoriteEntity favorite, Func<Slot, I> fallback) where I : class
{
//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)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
_ = ((Worker)slot).Engine;
I val = null;
EntityInterfacePreference universeEntityPreference = Engine.Config.UniverseEntityPreference;
EntitySpawner<I>[] array = null;
if (((Worker)slot).Engine.InUniverse)
{
switch ((int)universeEntityPreference)
{
case 2:
array = new EntitySpawner<I>[2]
{
MkDelegate<I>(SpawnUniverseEntity),
MkDelegate<I>(SpawnPlatformEntity)
};
break;
case 1:
array = new EntitySpawner<I>[3]
{
MkDelegate<I>(SpawnUniverseEntity),
MkDelegate<I>(SpawnEntityFromFavorite),
MkDelegate<I>(SpawnPlatformEntity)
};
break;
case 0:
array = new EntitySpawner<I>[3]
{
MkDelegate<I>(SpawnEntityFromFavorite),
MkDelegate<I>(SpawnUniverseEntity),
MkDelegate<I>(SpawnPlatformEntity)
};
break;
}
}
if (!((Worker)slot).Engine.InUniverse || array == null)
{
array = new EntitySpawner<I>[2]
{
MkDelegate<I>(SpawnEntityFromFavorite),
MkDelegate<I>(SpawnPlatformEntity)
};
}
EntitySpawner<I>[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
val = await array2[i](slot, favorite);
if (val != null)
{
break;
}
}
if (val == null)
{
val = fallback.Invoke(slot);
}
EntityInterface val2 = (EntityInterface)(object)((val is EntityInterface) ? val : null);
if (val2 != null)
{
val2.MarkInstance();
}
return val;
}
static LocalEntityPatch()
{
Dictionary<FavoriteEntity, global::System.Type> obj = new Dictionary<FavoriteEntity, global::System.Type>();
obj.Add((FavoriteEntity)14, typeof(ColorDialogInterface));
_favoriteEntityTypes = obj;
}
}
[CompilerGenerated]
private static class <>O
{
public static DataFeedMethod <0>__EnumerateWorskpaceDataFeed;
public static DataFeedMethod <1>__EnumerateEntityInterfaceDataFeed;
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Action <>9__9_0;
internal void <Load>b__9_0()
{
if (!Directory.Exists(ModDir))
{
Directory.CreateDirectory(ModDir);
}
if (!Directory.Exists(WorkspaceDir))
{
Directory.CreateDirectory(WorkspaceDir);
}
if (!Directory.Exists(EntityDir))
{
Directory.CreateDirectory(EntityDir);
}
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass14_0
{
[StructLayout((LayoutKind)3)]
private struct <<SaveWorkspaceLocally>b__0>d : IAsyncStateMachine
{
public int <>1__state;
public AsyncTaskMethodBuilder <>t__builder;
public <>c__DisplayClass14_0 <>4__this;
private string <filePath>5__2;
private SavedGraph <graph>5__3;
private FileStream <f>5__4;
private ToBackground <>u__1;
private object <>7__wrap4;
private int <>7__wrap5;
private ToWorld <>u__2;
private ValueTaskAwaiter <>u__3;
private void MoveNext()
{
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
<>c__DisplayClass14_0 <>c__DisplayClass14_ = <>4__this;
try
{
ToBackground val2;
ValueTaskAwaiter val;
switch (num)
{
default:
{
<filePath>5__2 = GetWorkspaceFilePath(((SyncField<string>)(object)<>c__DisplayClass14_.space.WorkspacePath).Value);
bool persistent = ((ComponentBase<Component>)(object)<>c__DisplayClass14_.space).Persistent;
((ComponentBase<Component>)(object)<>c__DisplayClass14_.space).Persistent = false;
<graph>5__3 = ((Component)<>c__DisplayClass14_.space).Slot.SaveObject((DependencyHandling)1, false, (ReferenceTranslator)null);
((ComponentBase<Component>)(object)<>c__DisplayClass14_.space).Persistent = persistent;
ToBackground val3 = default(ToBackground);
val2 = ((ToBackground)(ref val3)).GetAwaiter();
if (!((ToBackground)(ref val2)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val2;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToBackground, <<SaveWorkspaceLocally>b__0>d>(ref val2, ref this);
return;
}
goto IL_00cf;
}
case 0:
val2 = <>u__1;
<>u__1 = default(ToBackground);
num = (<>1__state = -1);
goto IL_00cf;
case 1:
try
{
ToWorld val5;
if (num != 1)
{
DataTreeConverter.ToBRSON(<graph>5__3.Root, (Stream)(object)<f>5__4, 9);
ToWorld val4 = default(ToWorld);
val5 = ((ToWorld)(ref val4)).GetAwaiter();
if (!((ToWorld)(ref val5)).IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val5;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToWorld, <<SaveWorkspaceLocally>b__0>d>(ref val5, ref this);
return;
}
}
else
{
val5 = <>u__2;
<>u__2 = default(ToWorld);
num = (<>1__state = -1);
}
((ToWorld)(ref val5)).GetResult();
<>c__DisplayClass14_.onDone.Invoke();
<>7__wrap5 = 1;
}
catch (object obj)
{
<>7__wrap4 = obj;
}
if (<f>5__4 == null)
{
break;
}
val = ((Stream)<f>5__4).DisposeAsync().GetAwaiter();
if (!((ValueTaskAwaiter)(ref val)).IsCompleted)
{
num = (<>1__state = 2);
<>u__3 = val;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<ValueTaskAwaiter, <<SaveWorkspaceLocally>b__0>d>(ref val, ref this);
return;
}
goto IL_01fb;
case 2:
{
val = <>u__3;
<>u__3 = default(ValueTaskAwaiter);
num = (<>1__state = -1);
goto IL_01fb;
}
IL_01fb:
((ValueTaskAwaiter)(ref val)).GetResult();
break;
IL_00cf:
((ToBackground)(ref val2)).GetResult();
<f>5__4 = File.OpenWrite(<filePath>5__2);
<>7__wrap4 = null;
<>7__wrap5 = 0;
goto case 1;
}
object obj2 = <>7__wrap4;
if (obj2 != null)
{
ExceptionDispatchInfo.Capture((obj2 as global::System.Exception) ?? throw obj2).Throw();
}
int num2 = <>7__wrap5;
if (num2 != 1)
{
<>7__wrap4 = null;
<filePath>5__2 = null;
<graph>5__3 = null;
<f>5__4 = null;
throw null;
}
}
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 Workspace space;
public Action onDone;
[AsyncStateMachine(typeof(<<SaveWorkspaceLocally>b__0>d))]
internal global::System.Threading.Tasks.Task <SaveWorkspaceLocally>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)
<<SaveWorkspaceLocally>b__0>d <<SaveWorkspaceLocally>b__0>d = default(<<SaveWorkspaceLocally>b__0>d);
<<SaveWorkspaceLocally>b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create();
<<SaveWorkspaceLocally>b__0>d.<>4__this = this;
<<SaveWorkspaceLocally>b__0>d.<>1__state = -1;
((AsyncTaskMethodBuilder)(ref <<SaveWorkspaceLocally>b__0>d.<>t__builder)).Start<<<SaveWorkspaceLocally>b__0>d>(ref <<SaveWorkspaceLocally>b__0>d);
return ((AsyncTaskMethodBuilder)(ref <<SaveWorkspaceLocally>b__0>d.<>t__builder)).Task;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass15_0
{
[StructLayout((LayoutKind)3)]
private struct <<SaveFavoriteEntityLocally>b__0>d : IAsyncStateMachine
{
public int <>1__state;
public AsyncTaskMethodBuilder <>t__builder;
public <>c__DisplayClass15_0 <>4__this;
private string <filePath>5__2;
private Uri <uri>5__3;
private ToBackground <>u__1;
private ConfiguredTaskAwaiter<CloudResult<Record>> <>u__2;
private ValueTaskAwaiter<string> <>u__3;
private ToWorld <>u__4;
private void MoveNext()
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: 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_0298: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0076: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: 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_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
<>c__DisplayClass15_0 <>c__DisplayClass15_ = <>4__this;
try
{
ToBackground val4;
ConfiguredTaskAwaiter<CloudResult<Record>> val3;
ValueTaskAwaiter<string> val2;
ToWorld val;
string result;
Record val7;
CloudResult<Record> result2;
switch (num)
{
default:
<filePath>5__2 = GetEntityFilePath(<>c__DisplayClass15_.entity);
<uri>5__3 = ((SkyFrostInterface)Engine.Current.Cloud).Profile.GetCurrentFavorite(<>c__DisplayClass15_.entity);
if (!(<uri>5__3 == (Uri)null))
{
ToBackground val5 = default(ToBackground);
val4 = ((ToBackground)(ref val5)).GetAwaiter();
if (!((ToBackground)(ref val4)).IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = val4;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToBackground, <<SaveFavoriteEntityLocally>b__0>d>(ref val4, ref this);
return;
}
goto IL_00c2;
}
goto end_IL_000e;
case 0:
val4 = <>u__1;
<>u__1 = default(ToBackground);
num = (<>1__state = -1);
goto IL_00c2;
case 1:
val3 = <>u__2;
<>u__2 = default(ConfiguredTaskAwaiter<CloudResult<Record>>);
num = (<>1__state = -1);
goto IL_017b;
case 2:
val2 = <>u__3;
<>u__3 = default(ValueTaskAwaiter<string>);
num = (<>1__state = -1);
goto IL_0227;
case 3:
{
val = <>u__4;
<>u__4 = default(ToWorld);
num = (<>1__state = -1);
break;
}
IL_0227:
result = val2.GetResult();
if (result != null && File.Exists(result))
{
File.WriteAllBytes(<filePath>5__2, File.ReadAllBytes(result));
ToWorld val6 = default(ToWorld);
val = ((ToWorld)(ref val6)).GetAwaiter();
if (!((ToWorld)(ref val)).IsCompleted)
{
num = (<>1__state = 3);
<>u__4 = val;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitOnCompleted<ToWorld, <<SaveFavoriteEntityLocally>b__0>d>(ref val, ref this);
return;
}
break;
}
goto end_IL_000e;
IL_019a:
if (val7 != null)
{
<uri>5__3 = new Uri(val7.AssetURI);
}
val2 = Engine.Current.AssetManager.GatherAssetFile(<uri>5__3, 0f, (DB_Endpoint?)null).GetAwaiter();
if (!val2.IsCompleted)
{
num = (<>1__state = 2);
<>u__3 = val2;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<ValueTaskAwaiter<string>, <<SaveFavoriteEntityLocally>b__0>d>(ref val2, ref this);
return;
}
goto IL_0227;
IL_00c2:
((ToBackground)(ref val4)).GetResult();
val7 = null;
if (<uri>5__3 != (Uri)null && <uri>5__3.Scheme == ((SkyFrostInterface)Engine.Current.Cloud).Platform.RecordScheme)
{
val3 = ((SkyFrostInterface)Engine.Current.Cloud).Records.GetRecordCached<Record>(<uri>5__3, (string)null).ConfigureAwait(false).GetAwaiter();
if (!val3.IsCompleted)
{
num = (<>1__state = 1);
<>u__2 = val3;
((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<ConfiguredTaskAwaiter<CloudResult<Record>>, <<SaveFavoriteEntityLocally>b__0>d>(ref val3, ref this);
return;
}
goto IL_017b;
}
goto IL_019a;
IL_017b:
result2 = val3.GetResult();
if (!((CloudResult)result2).IsError)
{
val7 = result2.Entity;
goto IL_019a;
}
goto end_IL_000e;
}
((ToWorld)(ref val)).GetResult();
<>c__DisplayClass15_.onDone.Invoke();
end_IL_000e:;
}
catch (global::System.Exception exception)
{
<>1__state = -2;
<filePath>5__2 = null;
<uri>5__3 = null;
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
return;
}
<>1__state = -2;
<filePath>5__2 = null;
<uri>5__3 = null;
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult();
}
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine stateMachine)
{
((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
}
}
public FavoriteEntity entity;
public Action onDone;
[AsyncStateMachine(typeof(<<SaveFavoriteEntityLocally>b__0>d))]
internal global::System.Threading.Tasks.Task <SaveFavoriteEntityLocally>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)
<<SaveFavoriteEntityLocally>b__0>d <<SaveFavoriteEntityLocally>b__0>d = default(<<SaveFavoriteEntityLocally>b__0>d);
<<SaveFavoriteEntityLocally>b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create();
<<SaveFavoriteEntityLocally>b__0>d.<>4__this = this;
<<SaveFavoriteEntityLocally>b__0>d.<>1__state = -1;
((AsyncTaskMethodBuilder)(ref <<SaveFavoriteEntityLocally>b__0>d.<>t__builder)).Start<<<SaveFavoriteEntityLocally>b__0>d>(ref <<SaveFavoriteEntityLocally>b__0>d);
return ((AsyncTaskMethodBuilder)(ref <<SaveFavoriteEntityLocally>b__0>d.<>t__builder)).Task;
}
}
internal static ManualLogSource Log;
internal static ConfigEntry<bool> BlockWorkspaceSave;
private static DynamicMethod reentrantMethod;
public static string ModDir => Path.Combine(Engine.Current.LocalDB.PermanentPath, "LocalStuff");
public static string WorkspaceDir => Path.Combine(ModDir, "Workspaces");
public static string EntityDir => Path.Combine(ModDir, "Entities");
public override void Load()
{
//IL_003d: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
BlockWorkspaceSave = ((BasePlugin)this).Config.Bind<bool>("General", "BlockWorkspaceSave", true, "Prevents saving of the dashboard and facet anchors.");
ConfigFile config = ((BasePlugin)this).Config;
object[] array = new object[1];
object obj = <>O.<0>__EnumerateWorskpaceDataFeed;
if (obj == null)
{
DataFeedMethod val = ModSettings.EnumerateWorskpaceDataFeed;
<>O.<0>__EnumerateWorskpaceDataFeed = val;
obj = (object)val;
}
array[0] = (object)new CustomDataFeed((DataFeedMethod)obj);
config.Bind<dummy>("Workspaces", "Workspaces", default(dummy), new ConfigDescription("", (AcceptableValueBase)null, array));
ConfigFile config2 = ((BasePlugin)this).Config;
object[] array2 = new object[1];
object obj2 = <>O.<1>__EnumerateEntityInterfaceDataFeed;
if (obj2 == null)
{
DataFeedMethod val2 = ModSettings.EnumerateEntityInterfaceDataFeed;
<>O.<1>__EnumerateEntityInterfaceDataFeed = val2;
obj2 = (object)val2;
}
array2[0] = (object)new CustomDataFeed((DataFeedMethod)obj2);
config2.Bind<dummy>("Entity Interfaces", "Entity Interfaces", default(dummy), new ConfigDescription("", (AcceptableValueBase)null, array2));
LocalEntityPatch.SpawnEntityFromFavorite = AccessTools.Method(typeof(EntityHelper), "SpawnEntityFromFavorite", (global::System.Type[])null, (global::System.Type[])null);
LocalEntityPatch.SpawnPlatformEntity = AccessTools.Method(typeof(EntityHelper), "SpawnPlatformEntity", (global::System.Type[])null, (global::System.Type[])null);
LocalEntityPatch.SpawnUniverseEntity = AccessTools.Method(typeof(EntityHelper), "SpawnUniverseEntity", (global::System.Type[])null, (global::System.Type[])null);
reentrantMethod = (DynamicMethod)((BasePlugin)this).HarmonyInstance.Patch((MethodBase)(object)LocalEntityPatch.TargetMethod(), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BasePlugin)this).HarmonyInstance.PatchAll();
object obj3 = <>c.<>9__9_0;
if (obj3 == null)
{
Action val3 = delegate
{
if (!Directory.Exists(ModDir))
{
Directory.CreateDirectory(ModDir);
}
if (!Directory.Exists(WorkspaceDir))
{
Directory.CreateDirectory(WorkspaceDir);
}
if (!Directory.Exists(EntityDir))
{
Directory.CreateDirectory(EntityDir);
}
};
<>c.<>9__9_0 = val3;
obj3 = (object)val3;
}
ResoniteHooks.OnEngineReady += (Action)obj3;
}
public static string GetWorkspaceFilePath(string workspacePath)
{
return Path.Combine(WorkspaceDir, workspacePath.Replace('/', '_') + ".bin");
}
public unsafe static string GetEntityFilePath(FavoriteEntity entity)
{
return Path.Combine(EntityDir, ((object)(*(FavoriteEntity*)(&entity))/*cast due to .constrained prefix*/).ToString() + ".bin");
}
public static void SaveWorkspaceLocally(Workspace space, Action onDone)
{
<>c__DisplayClass14_0 CS$<>8__locals4 = new <>c__DisplayClass14_0();
CS$<>8__locals4.space = space;
CS$<>8__locals4.onDone = onDone;
((Worker)CS$<>8__locals4.space).StartGlobalTask((Func<global::System.Threading.Tasks.Task>)([AsyncStateMachine(typeof(<>c__DisplayClass14_0.<<SaveWorkspaceLocally>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__DisplayClass14_0.<<SaveWorkspaceLocally>b__0>d <<SaveWorkspaceLocally>b__0>d = default(<>c__DisplayClass14_0.<<SaveWorkspaceLocally>b__0>d);
<<SaveWorkspaceLocally>b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create();
<<SaveWorkspaceLocally>b__0>d.<>4__this = CS$<>8__locals4;
<<SaveWorkspaceLocally>b__0>d.<>1__state = -1;
((AsyncTaskMethodBuilder)(ref <<SaveWorkspaceLocally>b__0>d.<>t__builder)).Start<<>c__DisplayClass14_0.<<SaveWorkspaceLocally>b__0>d>(ref <<SaveWorkspaceLocally>b__0>d);
return ((AsyncTaskMethodBuilder)(ref <<SaveWorkspaceLocally>b__0>d.<>t__builder)).Task;
}));
}
public static void SaveFavoriteEntityLocally(FavoriteEntity entity, Action onDone)
{
//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)
<>c__DisplayClass15_0 CS$<>8__locals3 = new <>c__DisplayClass15_0();
CS$<>8__locals3.entity = entity;
CS$<>8__locals3.onDone = onDone;
((Worker)Userspace.UserspaceWorld.RootSlot).StartGlobalTask((Func<global::System.Threading.Tasks.Task>)([AsyncStateMachine(typeof(<>c__DisplayClass15_0.<<SaveFavoriteEntityLocally>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__DisplayClass15_0.<<SaveFavoriteEntityLocally>b__0>d <<SaveFavoriteEntityLocally>b__0>d = default(<>c__DisplayClass15_0.<<SaveFavoriteEntityLocally>b__0>d);
<<SaveFavoriteEntityLocally>b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create();
<<SaveFavoriteEntityLocally>b__0>d.<>4__this = CS$<>8__locals3;
<<SaveFavoriteEntityLocally>b__0>d.<>1__state = -1;
((AsyncTaskMethodBuilder)(ref <<SaveFavoriteEntityLocally>b__0>d.<>t__builder)).Start<<>c__DisplayClass15_0.<<SaveFavoriteEntityLocally>b__0>d>(ref <<SaveFavoriteEntityLocally>b__0>d);
return ((AsyncTaskMethodBuilder)(ref <<SaveFavoriteEntityLocally>b__0>d.<>t__builder)).Task;
}));
}
}
public static class PluginMetadata
{
public const string GUID = "art0007i.LocalStuff";
public const string NAME = "LocalStuff";
public const string VERSION = "1.0.1";
public const string AUTHORS = "art0007i";
public const string REPOSITORY_URL = "https://github.com/art0007i/LocalStuff";
}