using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using Elements.Core; using FrooxEngine; using FrooxEngine.FrooxEngine.ProtoFlux.CoreNodes; using FrooxEngine.ProtoFlux; using FrooxEngine.ProtoFlux.Runtimes.Execution.Nodes; using FrooxEngine.ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Slots; using FrooxEngine.UIX; using HarmonyLib; [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, Gyztor Mizirath")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+2a40ebf1268aafef680c5f020c82e6f134252d9a")] [assembly: AssemblyProduct("MyInspectors")] [assembly: AssemblyTitle("MyInspectors")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Gyztor/BepisMyInspectors")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace MyInspectors; internal class PatchedSyncRef : SyncRef, EditorTargetField where T : class, IWorldElement { private RefID? remoteValue; bool EditorTargetField.ShouldBuild { get { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (remoteValue.HasValue) { if (remoteValue.HasValue) { return IsNullOrDisposed(remoteValue.Value, ((SyncElement)this).World); } return false; } return true; } } protected override void InternalDecodeFull(BinaryReader reader, BinaryMessageBatch inboundMessage) { Decode(reader, inboundMessage); } protected override void InternalDecodeDelta(BinaryReader reader, BinaryMessageBatch inboundMessage) { Decode(reader, inboundMessage); } private void Decode(BinaryReader reader, BinaryMessageBatch inboundMessage) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) RefID val = RefID.op_Implicit(BinaryReaderExtensions.Read7BitEncoded(reader)); remoteValue = val; ((SyncField)(object)this).InternalSetValue(ref val, false, true); } protected override bool InternalSetRefID(in RefID id, T prevTarget) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (!MyInspectors.MyInspectorsEnabled.Value) { return base.InternalSetRefID(ref id, prevTarget); } RefID val = id; bool flag = false; bool flag2 = true; if (remoteValue.HasValue) { global::System.Type type = ((object)((SyncElement)this).Parent).GetType(); if (typeof(SlotInspector).IsAssignableFrom(type) || typeof(UserInspectorItem).IsAssignableFrom(type)) { RefID? val2 = remoteValue; RefID val3 = RefID.Null; if (val2.HasValue && val2.GetValueOrDefault() == val3) { return ((SyncField)(object)this).InternalSetValue(ref val, flag, flag2); } flag = true; RefID current = val; val = RefID.Null; remoteValue = val; flag2 = false; ((SyncElement)this).World.RunInUpdates(1, (Action)delegate { //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) ((SyncField)(object)this)._value = current; ((SyncField)(object)this).ValueChanged(); }); } else { flag = true; } } return ((SyncField)(object)this).InternalSetValue(ref val, flag, flag2); } private static bool IsNullOrDisposed(RefID id, World world) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (id == RefID.Null) { return true; } IWorldElement objectOrNull = world.ReferenceController.GetObjectOrNull(ref id); if (objectOrNull != null) { return objectOrNull.IsRemoved; } return true; } } internal interface EditorTargetField { bool ShouldBuild { get; } } internal class UserInspectorState { internal View View; internal User Target; internal ushort StreamGroup; public UserInspectorState(View view, User target, ushort streamGroup = 0) { //IL_0006: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ushort streamGroup2 = streamGroup; View = view; Target = target; StreamGroup = streamGroup2; } } [ResonitePlugin("MyInspectors", "MyInspectors", "1.0.2", "art0007i, Gyztor Mizirath", "https://github.com/Gyztor/BepisMyInspectors")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MyInspectors : BasePlugin { [HarmonyPatch(typeof(SceneInspector), "OnAwake")] private class StupidInspectorFixupPatch { public static void Postfix(SceneInspector __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) ((ComponentBase)(object)__instance).RunInUpdates(0, (Action)delegate { ((MethodBase)AccessTools.Method(typeof(SceneInspector), "OnChanges", (global::System.Type[])null, (global::System.Type[])null)).Invoke((object)__instance, (object[])null); }); } } [HarmonyPatch] private class SceneInspector_Patch { [CompilerGenerated] private sealed class d__0 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private MethodInfo <>2__current; private int <>l__initialThreadId; MethodInfo global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = AccessTools.Method(typeof(WorkerInspector), "OnChanges", (global::System.Type[])null, (global::System.Type[])null); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = AccessTools.Method(typeof(SceneInspector), "OnChanges", (global::System.Type[])null, (global::System.Type[])null); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__5 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private global::System.Collections.Generic.IEnumerable instructions; public global::System.Collections.Generic.IEnumerable <>3__instructions; private List 5__2; private FieldInfo 5__3; private FieldInfo 5__4; private int 5__5; private CodeInstruction 5__6; private CodeInstruction 5__7; CodeInstruction global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { 5__2 = null; 5__3 = null; 5__4 = null; 5__6 = null; 5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_0159: 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_0169: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01bc: 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_01e1: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_023e: 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_0263: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = Enumerable.ToList(instructions); 5__3 = AccessTools.Field(typeof(SceneInspector), "Root"); 5__4 = AccessTools.Field(typeof(SceneInspector), "ComponentView"); 5__5 = 0; goto IL_0418; case 1: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ldc_I4_0, (object)null); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ceq, (object)null); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "IsHost", (global::System.Type[])null, (global::System.Type[])null)); <>1__state = 5; return true; case 5: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 6; return true; case 6: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ldfld, 5__7.operand); <>1__state = 7; return true; case 7: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "IsChangedLocally", (global::System.Type[])null, (global::System.Type[])null)); <>1__state = 8; return true; case 8: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Or, (object)null); <>1__state = 9; return true; case 9: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.And, (object)null); <>1__state = 10; return true; case 10: <>1__state = -1; 5__6.opcode = OpCodes.Brfalse; goto IL_02c7; case 11: <>1__state = -1; if (CodeInstructionExtensions.Calls(5__6, AccessTools.PropertyGetter(typeof(World), "IsAuthority"))) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 12; return true; } goto IL_0387; case 12: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "ShouldContinue", (global::System.Type[])null, (global::System.Type[])null)); <>1__state = 13; return true; case 13: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Or, (object)null); <>1__state = 14; return true; case 14: <>1__state = -1; goto IL_0387; case 15: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "ResetContainer", (global::System.Type[])null, (global::System.Type[])null)); <>1__state = 16; return true; case 16: { <>1__state = -1; goto IL_0401; } IL_02c7: 5__7 = null; goto IL_02ce; IL_0387: if (CodeInstructionExtensions.StoresField(5__6, AccessTools.Field(typeof(WorkerInspector), "_currentContainer"))) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 15; return true; } goto IL_0401; IL_0401: 5__6 = null; 5__5++; goto IL_0418; IL_0418: if (5__5 < 5__2.Count) { 5__6 = 5__2[5__5]; if (5__6.opcode == OpCodes.Beq && 5__5 >= 2) { 5__7 = 5__2[5__5 - 2]; object operand = 5__7.operand; FieldInfo val = (FieldInfo)((operand is FieldInfo) ? operand : null); if (val != null && (val == 5__3 || val == 5__4)) { <>2__current = new CodeInstruction(OpCodes.Ceq, (object)null); <>1__state = 1; return true; } goto IL_02c7; } goto IL_02ce; } return false; IL_02ce: <>2__current = 5__6; <>1__state = 11; return true; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { d__5 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__5(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] public static global::System.Collections.Generic.IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(WorkerInspector), "OnChanges", (global::System.Type[])null, (global::System.Type[])null); yield return AccessTools.Method(typeof(SceneInspector), "OnChanges", (global::System.Type[])null, (global::System.Type[])null); } public static bool IsChangedLocally(ConflictingSyncElement el) { if (el.LastConfirmedTime != el.LastHostVersion) { return ((SyncElement)el).IsSyncDirty; } return true; } public static bool ShouldContinue(Worker worker) { SceneInspector val = (SceneInspector)(object)((worker is SceneInspector) ? worker : null); if (val != null) { if (!IsChangedLocally((ConflictingSyncElement)(object)val.ComponentView)) { return IsChangedLocally((ConflictingSyncElement)(object)val.Root); } return true; } WorkerInspector val2 = (WorkerInspector)(object)((worker is WorkerInspector) ? worker : null); if (val2 != null && _targetContainer.GetValue((object)val2) is SyncRef val3) { if (val3.Target != null) { return IsChangedLocally((ConflictingSyncElement)(object)val3); } return false; } return false; } public static void ResetContainer(WorkerInspector i) { if (!((Worker)i).World.IsAuthority && _targetContainer.GetValue((object)i) is SyncRef val) { val.Target = null; } } public static bool IsHost(SceneInspector i) { return ((Worker)i).World.IsAuthority; } [IteratorStateMachine(typeof(d__5))] public static global::System.Collections.Generic.IEnumerable Transpiler(global::System.Collections.Generic.IEnumerable instructions) { List codes = Enumerable.ToList(instructions); FieldInfo rootField = AccessTools.Field(typeof(SceneInspector), "Root"); FieldInfo compField = AccessTools.Field(typeof(SceneInspector), "ComponentView"); for (int i = 0; i < codes.Count; i++) { CodeInstruction code = codes[i]; if (code.opcode == OpCodes.Beq && i >= 2) { CodeInstruction twoBefore = codes[i - 2]; object operand = twoBefore.operand; FieldInfo val = (FieldInfo)((operand is FieldInfo) ? operand : null); if (val != null && (val == rootField || val == compField)) { yield return new CodeInstruction(OpCodes.Ceq, (object)null); yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null); yield return new CodeInstruction(OpCodes.Ceq, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "IsHost", (global::System.Type[])null, (global::System.Type[])null)); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, twoBefore.operand); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "IsChangedLocally", (global::System.Type[])null, (global::System.Type[])null)); yield return new CodeInstruction(OpCodes.Or, (object)null); yield return new CodeInstruction(OpCodes.And, (object)null); code.opcode = OpCodes.Brfalse; } } yield return code; if (CodeInstructionExtensions.Calls(code, AccessTools.PropertyGetter(typeof(World), "IsAuthority"))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "ShouldContinue", (global::System.Type[])null, (global::System.Type[])null)); yield return new CodeInstruction(OpCodes.Or, (object)null); } if (CodeInstructionExtensions.StoresField(code, AccessTools.Field(typeof(WorkerInspector), "_currentContainer"))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SceneInspector_Patch), "ResetContainer", (global::System.Type[])null, (global::System.Type[])null)); } } } } [HarmonyPatch] private class InitializeSyncMemberPatch { [HarmonyPostfix] [HarmonyPatch(typeof(SlotInspector), "InitializeSyncMembers")] private static void SlotInspectorPostfix(SlotInspector __instance, ref SyncRef ____rootSlot) { MyInspectors.createPatchedSyncref(ref ____rootSlot, (IWorldElement)(object)__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(UserInspectorItem), "InitializeSyncMembers")] private static void UserInspectorItemPostfix(UserInspectorItem __instance, ref SyncRef ____user) { MyInspectors.createPatchedSyncref(ref ____user, (IWorldElement)(object)__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(BagEditor), "InitializeSyncMembers")] private static void BagEditorPostfix(BagEditor __instance, ref SyncRef ____targetBag) { MyInspectors.createPatchedSyncref(ref ____targetBag, (IWorldElement)(object)__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(ListEditor), "InitializeSyncMembers")] private static void ListEditorPostfix(ListEditor __instance, ref SyncRef ____targetList) { MyInspectors.createPatchedSyncref(ref ____targetList, (IWorldElement)(object)__instance); } } [HarmonyPatch(typeof(SlotInspector), "OnChanges")] private class SlotInspector_OnChanges_Patch { private static global::System.Collections.Generic.IEnumerable Transpiler(global::System.Collections.Generic.IEnumerable codes) { return Editor_OnChanges_Transpiler(codes, AccessTools.Field(typeof(SlotInspector), "_rootSlot")); } private static void Postfix(SyncRef ____expanderIndicator, SyncRef ____rootSlot) { if (!((SyncElement)____expanderIndicator).World.IsAuthority) { TextExpandIndicator target = ____expanderIndicator.Target; if (target != null && !((SyncElement)target.Empty).IsLinked) { target.CustomEmptyCheck.Target = null; Slot slot = ((Component)target).Slot; ValueObjectInput val = ((ContainerWorker)(object)slot).AttachComponent>(true, (Action>)null); ObjectValueSource val2 = ((ContainerWorker)(object)slot).AttachComponent>(true, (Action>)null); ChildrenCount val3 = ((ContainerWorker)(object)slot).AttachComponent(true, (Action)null); ValueEquals val4 = ((ContainerWorker)(object)slot).AttachComponent>(true, (Action>)null); ObjectConditional val5 = ((ContainerWorker)(object)slot).AttachComponent>(true, (Action>)null); ElementSource val6 = ((ContainerWorker)(object)slot).AttachComponent>(true, (Action>)null); ObjectFieldDrive obj = ((ContainerWorker)(object)slot).AttachComponent>(true, (Action>)null); ((SyncField)(object)val.Value).Value = Sync.op_Implicit(target.Empty); val2.TrySetRootSource((IWorldElement)(object)target.Closed); val6.TrySetRootSource((IWorldElement)(object)____rootSlot.Target); val3.Instance.Target = (INodeObjectOutput)(object)val6; val4.A.Target = (INodeValueOutput)(object)val3; val5.Condition.Target = (INodeValueOutput)(object)val4; val5.OnTrue.Target = (INodeObjectOutput)(object)val; val5.OnFalse.Target = (INodeObjectOutput)(object)val2; ((FieldDriveBase)(object)obj).TrySetRootTarget((IWorldElement)(object)target.Empty); obj.Value.Target = (INodeObjectOutput)(object)val5; } } } } [HarmonyPatch(typeof(BagEditor), "OnChanges")] private class BagEditor_Patch { private static global::System.Collections.Generic.IEnumerable Transpiler(global::System.Collections.Generic.IEnumerable codes) { return Editor_OnChanges_Transpiler(codes, AccessTools.Field(typeof(BagEditor), "_targetBag")); } [HarmonyPrefix] [HarmonyPatch("Target_ElementAdded")] private static bool AddedPrefix(BagEditor __instance, SyncField ____targetBag, IWorldElement element) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!ShouldBuild(____targetBag)) { return false; } Enumerator enumerator = ((Component)__instance).Slot.Children.GetEnumerator(); try { while (enumerator.MoveNext()) { BagEditorItem component = ((ContainerWorker)(object)enumerator.Current).GetComponent((Predicate)null, false); if (component != null && ((SyncRef)(object)component.Item).Target == element) { return false; } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return true; } } [HarmonyPatch(typeof(ListEditor), "OnChanges")] private class ListEditor_Patch { private static global::System.Collections.Generic.IEnumerable Transpiler(global::System.Collections.Generic.IEnumerable codes) { return Editor_OnChanges_Transpiler(codes, AccessTools.Field(typeof(ListEditor), "_targetList")); } [HarmonyPrefix] [HarmonyPatch("Target_ElementsAdded")] private static bool AddedPrefix(ListEditor __instance, SyncField ____targetList, ISyncList list, int startIndex, int count) { return ShouldBuild(____targetList); } } [HarmonyPatch(typeof(UserInspectorItem))] private class UserInspectorItem_Patch { [HarmonyTranspiler] [HarmonyPatch("OnChanges")] private static global::System.Collections.Generic.IEnumerable OnChangesTranspiler(global::System.Collections.Generic.IEnumerable codes) { return Editor_OnChanges_Transpiler(codes, AccessTools.Field(typeof(UserInspectorItem), "_user")); } [HarmonyPrefix] [HarmonyPatch("OpenComponents")] private static bool OpenComponentsPrefix(UserInspectorItem __instance, SyncRef ____user) { if (____user.Target != null && !((Worker)__instance).World.IsAuthority) { UserInspector componentInParents = ((Component)__instance).Slot.GetComponentInParents((Predicate)null, true, false); if (componentInParents != null) { OpenUserInspector(componentInParents, new UserInspectorState((View)1, ____user.Target, 0)); return false; } } return true; } [HarmonyPrefix] [HarmonyPatch("OpenStream")] private static bool OpenStreamPrefix(UserInspectorItem __instance, SyncRef ____user, ushort streamIndex) { if (____user.Target != null && !((Worker)__instance).World.IsAuthority) { UserInspector componentInParents = ((Component)__instance).Slot.GetComponentInParents((Predicate)null, true, false); if (componentInParents != null) { OpenUserInspector(componentInParents, new UserInspectorState((View)2, ____user.Target, streamIndex)); return false; } } return true; } [HarmonyPrefix] [HarmonyPatch("OpenUser")] private static bool OpenUserPrefix(UserInspectorItem __instance, SyncRef ____user) { if (____user.Target != null && !((Worker)__instance).World.IsAuthority) { UserInspector componentInParents = ((Component)__instance).Slot.GetComponentInParents((Predicate)null, true, false); if (componentInParents != null) { OpenUserInspector(componentInParents, new UserInspectorState((View)0, ____user.Target, 0)); return false; } } return true; } } [HarmonyPatch(typeof(UserInspector), "FilterWorker")] private class UserInspector_Patch { private static bool Prefix(UserInspector __instance, ref bool __result, Worker worker) { //IL_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected I4, but got Unknown UserInspectorState userInspectorState = default(UserInspectorState); if (!userInspectorStates.TryGetValue(__instance, ref userInspectorState)) { return true; } View view = userInspectorState.View; switch ((int)view) { case 1: __result = worker is UserComponent; break; case 2: { Stream val = (Stream)(object)((worker is Stream) ? worker : null); if (val != null) { __result = val.GroupIndex == userInspectorState.StreamGroup; } else { __result = false; } break; } case 0: __result = worker is User; break; default: __result = true; break; } return false; } } [HarmonyPatch(typeof(TypeManager), "InitializeAssemblies")] private class TypeManager_Patch { private static void Postfix(Dictionary ____assemblyToIndex, List ____allowedAssemblies) { int num = default(int); if (____assemblyToIndex.TryGetValue(typeof(SyncRef<>).Assembly, ref num)) { ____assemblyToIndex.TryAdd(typeof(PatchedSyncRef<>).Assembly, num); Dictionary val = (Dictionary)_typeToIndex.GetValue((object)____allowedAssemblies[num]); val.TryAdd(typeof(PatchedSyncRef<>), val[typeof(SyncRef<>)]); } } } [HarmonyPatch(typeof(SyncType), "set_Value")] private class SyncType_Patch { private static global::System.Exception Finalizer(global::System.Exception __exception, SyncType __instance, global::System.Type value) { if (__exception != null && __exception.Message.Contains("MyInspectors")) { SetBase(__instance, value); return null; } return __exception; } [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(SyncField), "set_Value")] public static void SetBase(object instance, global::System.Type value) { } } [HarmonyPatch(typeof(Coder), "IsEnginePrimitive")] private class Coder_Patch { private static bool Prefix(ref bool __result, global::System.Type type) { if (type != null && ((MemberInfo)type).Name?.Contains("MyInspectors") == true) { __result = true; return false; } return true; } } [CompilerGenerated] private sealed class d__11 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private global::System.Collections.Generic.IEnumerable codes; public global::System.Collections.Generic.IEnumerable <>3__codes; private FieldInfo targetField; public FieldInfo <>3__targetField; private int 5__2; private global::System.Collections.Generic.IEnumerator <>7__wrap2; CodeInstruction global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00c1: 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_00d5: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 0; <>7__wrap2 = codes.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)ShouldBuildInfo); <>1__state = 2; return true; case 2: <>1__state = -3; break; case 3: <>1__state = -3; break; } while (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext()) { CodeInstruction current = <>7__wrap2.Current; if (5__2 <= 0 && CodeInstructionExtensions.Calls(current, AccessTools.PropertyGetter(typeof(Worker), "World"))) { 5__2++; <>2__current = new CodeInstruction(OpCodes.Ldfld, (object)targetField); <>1__state = 1; return true; } if (5__2 == 1) { 5__2++; continue; } <>2__current = current; <>1__state = 3; return true; } <>m__Finally1(); <>7__wrap2 = null; return false; } catch { //try-fault ((global::System.IDisposable)this).Dispose(); throw; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { ((global::System.IDisposable)<>7__wrap2).Dispose(); } } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { d__11 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__11(0); } d__.codes = <>3__codes; d__.targetField = <>3__targetField; return d__; } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } internal static ManualLogSource Log = null; internal static ConfigEntry MyInspectorsEnabled; private static FieldInfo _targetContainer = AccessTools.Field(typeof(WorkerInspector), "_targetContainer"); private static ConditionalWeakTable userInspectorStates = new ConditionalWeakTable(); private static MethodInfo ShouldBuildInfo = AccessTools.Method(typeof(MyInspectors), "ShouldBuild", (global::System.Type[])null, (global::System.Type[])null); private static MethodInfo _FilterWorker = AccessTools.Method(typeof(UserInspector), "FilterWorker", (global::System.Type[])null, (global::System.Type[])null); private static FieldInfo _typeToIndex = AccessTools.Field(typeof(AssemblyTypeRegistry), "_typeToIndex"); public override void Load() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown Log = ((BasePlugin)this).Log; MyInspectorsEnabled = ((BasePlugin)this).Config.Bind("MyInspectors", "Enable MyInspectors", true, new ConfigDescription("Enables the MyInspectors mod.", (AcceptableValueBase)null, global::System.Array.Empty())); Harmony harmony = new Harmony("me.art0007i.MyInspectors"); Log.LogInfo((object)"MyInspectors Applying Patches"); if (MyInspectorsEnabled.Value) { harmony.PatchAll(); } MyInspectorsEnabled.SettingChanged += (EventHandler)delegate { if (MyInspectorsEnabled.Value) { Log.LogInfo((object)"Applying Inspector Patches"); harmony.PatchAll(); } else { Log.LogInfo((object)"Removing Inspector Patches"); Harmony.UnpatchID("me.art0007i.MyInspectors"); } }; } private static void createPatchedSyncref(ref SyncRef old, IWorldElement existingObj) where T : class, IWorldElement { if (!existingObj.World.IsAuthority) { old = (SyncRef)(object)new PatchedSyncRef(); } } private static bool ShouldBuild(SyncField field) { if (((SyncElement)field).World.IsAuthority) { return true; } if (field is EditorTargetField editorTargetField) { return editorTargetField.ShouldBuild; } return false; } [IteratorStateMachine(typeof(d__11))] private static global::System.Collections.Generic.IEnumerable Editor_OnChanges_Transpiler(global::System.Collections.Generic.IEnumerable codes, FieldInfo targetField) { int hit = 0; global::System.Collections.Generic.IEnumerator enumerator = codes.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { CodeInstruction current = enumerator.Current; if (hit <= 0 && CodeInstructionExtensions.Calls(current, AccessTools.PropertyGetter(typeof(Worker), "World"))) { hit++; yield return new CodeInstruction(OpCodes.Ldfld, (object)targetField); yield return new CodeInstruction(OpCodes.Call, (object)ShouldBuildInfo); } else if (hit == 1) { hit++; } else { yield return current; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } private static void OpenUserInspector(UserInspector Inspector, UserInspectorState state) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) userInspectorStates.AddOrUpdate(Inspector, state); Sync target = ((SyncRef>)(object)((Worker)Inspector).GetSyncMember("_userText")).Target; if (target != null) { global::System.Runtime.CompilerServices.DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new global::System.Runtime.CompilerServices.DefaultInterpolatedStringHandler(9, 2); defaultInterpolatedStringHandler.AppendLiteral("User: "); User target2 = state.Target; defaultInterpolatedStringHandler.AppendFormatted((target2 != null) ? target2.UserName : null); defaultInterpolatedStringHandler.AppendLiteral(" ("); User target3 = state.Target; defaultInterpolatedStringHandler.AppendFormatted((target3 != null) ? new RefID?(((Worker)target3).ReferenceID) : ((RefID?)null)); defaultInterpolatedStringHandler.AppendLiteral(")"); ((SyncField)(object)target).Value = defaultInterpolatedStringHandler.ToStringAndClear(); } Slot target4 = ((SyncRef)(object)((Worker)Inspector).GetSyncMember("_workersContentRoot")).Target; if (target4 != null) { target4.DestroyChildren(false, true, false, (Predicate)null); ((ContainerWorker)(object)target4.AddSlot("WorkersRoot", true)).AttachComponent(true, (Action)null).SetupContainer((Worker)(object)state.Target, (Predicate)null, _FilterWorker.CreateDelegate>((object)Inspector), (int)state.View == 0); } } } public static class PluginMetadata { public const string GUID = "MyInspectors"; public const string NAME = "MyInspectors"; public const string VERSION = "1.0.2"; public const string AUTHORS = "art0007i, Gyztor Mizirath"; public const string REPOSITORY_URL = "https://github.com/Gyztor/BepisMyInspectors"; }