1+ using Elements . Core ;
2+ using FrooxEngine ;
3+ using FrooxEngine . UIX ;
4+ using HarmonyLib ;
5+ using MonkeyLoader . Resonite ;
6+ using System ;
7+ using System . Collections . Generic ;
8+ using System . Text ;
9+
10+ namespace CommunityBugFixCollection
11+ {
12+ [ HarmonyPatchCategory ( nameof ( BreakDragAndDropCopiedComponentDrives ) ) ]
13+ [ HarmonyPatch ( typeof ( SlotComponentReceiver ) , nameof ( SlotComponentReceiver . TryReceive ) ) ]
14+ internal sealed class BreakDragAndDropCopiedComponentDrives : ResoniteMonkey < BreakDragAndDropCopiedComponentDrives >
15+ {
16+ public override IEnumerable < string > Authors => Contributors . Banane9 ;
17+
18+ public override bool CanBeDisabled => true ;
19+
20+ private static bool Prefix ( SlotComponentReceiver __instance , IEnumerable < IGrabbable > items , Canvas . InteractionData eventData , in float3 globalPoint , out bool __result )
21+ {
22+ __result = false ;
23+
24+ if ( __instance . Target . Target is null )
25+ return false ;
26+
27+ foreach ( var item in items )
28+ {
29+ foreach ( ReferenceProxy componentsInChild in item . Slot . GetComponentsInChildren < ReferenceProxy > ( ) )
30+ {
31+ if ( componentsInChild . Reference . Target is not Component component || __instance . Target . Target == component . Slot )
32+ continue ;
33+
34+ __instance . StartTask ( async ( ) =>
35+ {
36+ var contextMenu = await __instance . LocalUser . OpenContextMenu ( __instance , eventData . source . Slot ) ;
37+
38+ var copyItem = contextMenu . AddItem ( "Inspector.Actions.CopyComponent" . AsLocaleKey ( ) , ( Uri ) null ! , RadiantUI_Constants . Hero . GREEN ) ;
39+ var moveItem = contextMenu . AddItem ( "Inspector.Actions.MoveComponent" . AsLocaleKey ( ) , ( Uri ) null ! , RadiantUI_Constants . Hero . PURPLE ) ;
40+ var cancelItem = contextMenu . AddItem ( "General.Cancel" . AsLocaleKey ( ) , ( Uri ) null ! , colorX . White ) ;
41+
42+ copyItem . Button . LocalPressed += delegate
43+ {
44+ __instance . Target . Target . DuplicateComponent ( component ) ;
45+ __instance . LocalUser . CloseContextMenu ( __instance ) ;
46+ } ;
47+
48+ moveItem . Button . LocalPressed += delegate
49+ {
50+ __instance . Target . Target . MoveComponent ( component ) ;
51+ __instance . LocalUser . CloseContextMenu ( __instance ) ;
52+ } ;
53+
54+ cancelItem . Button . LocalPressed += delegate
55+ {
56+ __instance . LocalUser . CloseContextMenu ( __instance ) ;
57+ } ;
58+ } ) ;
59+
60+ __result = true ;
61+ return false ;
62+ }
63+ }
64+
65+ return false ;
66+ }
67+ }
68+ }
0 commit comments