using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading.Tasks; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using Elements.Core; using FrooxEngine; 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("Gyztor Mizirath")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d045b9bf884b108fcc818403d3d72dc7acb848a9")] [assembly: AssemblyProduct("FixCopyComp")] [assembly: AssemblyTitle("FixCopyComp")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Gyztor/FixCopyComponentDrives")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace FixCopyComp; [ResonitePlugin("xyz.gyztormizirath.FixCopyComp", "FixCopyComp", "1.0.0", "Gyztor Mizirath", "https://github.com/Gyztor/FixCopyComponentDrives")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class FixCopyComponentDrives : BasePlugin { [HarmonyPatch(typeof(SlotComponentReceiver), "TryReceive")] private static class DragAndDropCopiedComponentDrives { [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public SlotComponentReceiver __instance; public InteractionData eventData; public ButtonEventHandler <>9__3; internal void b__3(IButton , ButtonEventData ) { ContextMenuExtensions.CloseContextMenu(((Worker)__instance).LocalUser, (IWorldElement)(object)__instance); } } [CompilerGenerated] private sealed class <>c__DisplayClass0_1 { [StructLayout((LayoutKind)3)] private struct <b__0>d : IAsyncStateMachine { public int <>1__state; public AsyncTaskMethodBuilder <>t__builder; public <>c__DisplayClass0_1 <>4__this; private TaskAwaiter <>u__1; private void MoveNext() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0140: Expected O, but got Unknown //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_0167: Expected O, but got Unknown //IL_016c: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01a6: Expected O, but got Unknown int num = <>1__state; <>c__DisplayClass0_1 CS$<>8__locals19 = <>4__this; try { TaskAwaiter val; if (num != 0) { val = ContextMenuExtensions.OpenContextMenu(((Worker)CS$<>8__locals19.CS$<>8__locals1.__instance).LocalUser, (IWorldElement)(object)CS$<>8__locals19.CS$<>8__locals1.__instance, ((Component)CS$<>8__locals19.CS$<>8__locals1.eventData.source).Slot, default(ContextMenuOptions)).GetAwaiter(); if (!val.IsCompleted) { num = (<>1__state = 0); <>u__1 = val; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted, <b__0>d>(ref val, ref this); return; } } else { val = <>u__1; <>u__1 = default(TaskAwaiter); num = (<>1__state = -1); } ContextMenu result = val.GetResult(); LocaleString val2 = LocaleHelper.AsLocaleKey("Inspector.Actions.CopyComponent", (string)null, true, (Dictionary)null); colorX? val3 = Hero.GREEN; ContextMenuItem val4 = result.AddItem(ref val2, (Uri)null, ref val3); val2 = LocaleHelper.AsLocaleKey("Inspector.Actions.MoveComponent", (string)null, true, (Dictionary)null); val3 = Hero.PURPLE; ContextMenuItem val5 = result.AddItem(ref val2, (Uri)null, ref val3); val2 = LocaleHelper.AsLocaleKey("General.Cancel", (string)null, true, (Dictionary)null); val3 = colorX.White; ContextMenuItem obj = result.AddItem(ref val2, (Uri)null, ref val3); Button button = val4.Button; ButtonEventHandler obj2 = CS$<>8__locals19.<>9__1; if (obj2 == null) { ButtonEventHandler val6 = delegate { CS$<>8__locals19.CS$<>8__locals1.__instance.Target.Target.DuplicateComponent(CS$<>8__locals19.component, false); ContextMenuExtensions.CloseContextMenu(((Worker)CS$<>8__locals19.CS$<>8__locals1.__instance).LocalUser, (IWorldElement)(object)CS$<>8__locals19.CS$<>8__locals1.__instance); }; ButtonEventHandler val7 = val6; CS$<>8__locals19.<>9__1 = val6; obj2 = val7; } button.LocalPressed += obj2; Button button2 = val5.Button; ButtonEventHandler obj3 = CS$<>8__locals19.<>9__2; if (obj3 == null) { ButtonEventHandler val8 = delegate { ((ContainerWorker)(object)CS$<>8__locals19.CS$<>8__locals1.__instance.Target.Target).MoveComponent(CS$<>8__locals19.component); ContextMenuExtensions.CloseContextMenu(((Worker)CS$<>8__locals19.CS$<>8__locals1.__instance).LocalUser, (IWorldElement)(object)CS$<>8__locals19.CS$<>8__locals1.__instance); }; ButtonEventHandler val7 = val8; CS$<>8__locals19.<>9__2 = val8; obj3 = val7; } button2.LocalPressed += obj3; Button button3 = obj.Button; ButtonEventHandler obj4 = CS$<>8__locals19.CS$<>8__locals1.<>9__3; if (obj4 == null) { <>c__DisplayClass0_0 <>c__DisplayClass0_ = CS$<>8__locals19.CS$<>8__locals1; ButtonEventHandler val9 = delegate { ContextMenuExtensions.CloseContextMenu(((Worker)CS$<>8__locals19.CS$<>8__locals1.__instance).LocalUser, (IWorldElement)(object)CS$<>8__locals19.CS$<>8__locals1.__instance); }; ButtonEventHandler val7 = val9; <>c__DisplayClass0_.<>9__3 = val9; obj4 = val7; } button3.LocalPressed += obj4; } 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 Component component; public <>c__DisplayClass0_0 CS$<>8__locals1; public ButtonEventHandler <>9__1; public ButtonEventHandler <>9__2; [AsyncStateMachine(typeof(<b__0>d))] internal global::System.Threading.Tasks.Task 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) <b__0>d <b__0>d = default(<b__0>d); <b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create(); <b__0>d.<>4__this = this; <b__0>d.<>1__state = -1; ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Start<<b__0>d>(ref <b__0>d); return ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Task; } internal void b__1(IButton , ButtonEventData ) { CS$<>8__locals1.__instance.Target.Target.DuplicateComponent(component, false); ContextMenuExtensions.CloseContextMenu(((Worker)CS$<>8__locals1.__instance).LocalUser, (IWorldElement)(object)CS$<>8__locals1.__instance); } internal void b__2(IButton , ButtonEventData ) { ((ContainerWorker)(object)CS$<>8__locals1.__instance.Target.Target).MoveComponent(component); ContextMenuExtensions.CloseContextMenu(((Worker)CS$<>8__locals1.__instance).LocalUser, (IWorldElement)(object)CS$<>8__locals1.__instance); } } private static bool Prefix(SlotComponentReceiver __instance, global::System.Collections.Generic.IEnumerable items, InteractionData eventData, out bool __result) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass0_0 <>c__DisplayClass0_ = new <>c__DisplayClass0_0(); <>c__DisplayClass0_.__instance = __instance; <>c__DisplayClass0_.eventData = eventData; __result = false; if (<>c__DisplayClass0_.__instance.Target.Target == null) { return false; } global::System.Collections.Generic.IEnumerator enumerator = items.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { Enumerator enumerator2 = ((IComponent)enumerator.Current).Slot.GetComponentsInChildren((Predicate)null, false, false, (Predicate)null).GetEnumerator(); try { while (enumerator2.MoveNext()) { ReferenceProxy current = enumerator2.Current; <>c__DisplayClass0_1 CS$<>8__locals7 = new <>c__DisplayClass0_1(); CS$<>8__locals7.CS$<>8__locals1 = <>c__DisplayClass0_; IWorldElement target = ((SyncRef)(object)current.Reference).Target; CS$<>8__locals7.component = (Component)(object)((target is Component) ? target : null); if (CS$<>8__locals7.component != null && CS$<>8__locals7.CS$<>8__locals1.__instance.Target.Target != CS$<>8__locals7.component.Slot) { ((Worker)CS$<>8__locals7.CS$<>8__locals1.__instance).StartTask((Func)([AsyncStateMachine(typeof(<>c__DisplayClass0_1.<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_1.<b__0>d <b__0>d = default(<>c__DisplayClass0_1.<b__0>d); <b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create(); <b__0>d.<>4__this = CS$<>8__locals7; <b__0>d.<>1__state = -1; ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Start<<>c__DisplayClass0_1.<b__0>d>(ref <b__0>d); return ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Task; })); __result = true; return false; } } } finally { ((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } return false; } } internal static ManualLogSource Log; public override void Load() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown Log = ((BasePlugin)this).Log; try { ((BasePlugin)this).HarmonyInstance.PatchAll(); Log.LogInfo((object)"Fix Copy Component Drives Loaded!"); } catch (global::System.Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fix Copy Component Drives failed to patch: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } public static class PluginMetadata { public const string GUID = "xyz.gyztormizirath.FixCopyComp"; public const string NAME = "FixCopyComp"; public const string VERSION = "1.0.0"; public const string AUTHORS = "Gyztor Mizirath"; public const string REPOSITORY_URL = "https://github.com/Gyztor/FixCopyComponentDrives"; }