From 34b1754ba2f11305a10d2d3c02cd87116a79c5c9 Mon Sep 17 00:00:00 2001 From: Tyfon <29051038+tyfon7@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:19:49 -0700 Subject: [PATCH] Fix currentSelectGameObject null check (dont use ?.); block swapping components on an equipped gun with each other in raid --- Patches/ContextMenuShortcutPatches.cs | 2 +- Patches/SwapPatches.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Patches/ContextMenuShortcutPatches.cs b/Patches/ContextMenuShortcutPatches.cs index cbd19e5..861cac4 100644 --- a/Patches/ContextMenuShortcutPatches.cs +++ b/Patches/ContextMenuShortcutPatches.cs @@ -29,7 +29,7 @@ namespace UIFixes { // Need an item context to operate on, and ignore these keypresses if there's a focused textbox somewhere ItemContextAbstractClass itemContext = __instance.R().ItemContext; - if (itemContext == null || EventSystem.current?.currentSelectedGameObject?.GetComponent() != null) + if (itemContext == null || EventSystem.current?.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.GetComponent() != null) { return; } diff --git a/Patches/SwapPatches.cs b/Patches/SwapPatches.cs index 96aa0c2..80667db 100644 --- a/Patches/SwapPatches.cs +++ b/Patches/SwapPatches.cs @@ -1,5 +1,6 @@ using Aki.Reflection.Patching; using Aki.Reflection.Utils; +using EFT; using EFT.InventoryLogic; using EFT.UI; using EFT.UI.DragAndDrop; @@ -381,6 +382,17 @@ namespace UIFixes return; } + // Swapping items with each other when both are on an equipped gun in raid doesn't work + if (itemController is Player.PlayerInventoryController playerInventoryController) + { + Item item1 = __instance.Item.GetRootItem(); + Item item2 = targetItemContext.Item.GetRootItem(); + if (item1 == item2 && playerInventoryController.IsItemEquipped(item1)) + { + return; + } + } + if (!ValidPrerequisites(__instance, targetItemContext, operation)) { return;