TaskSerializer handle being disabled/deactivated mid-operation

This commit is contained in:
Tyfon
2024-07-02 00:45:58 -07:00
parent 214062b1f2
commit 799fc6fa94
3 changed files with 10 additions and 5 deletions

View File

@@ -33,7 +33,6 @@ namespace UIFixes
// Grab the selection objects from ragfair as templates // Grab the selection objects from ragfair as templates
RagfairNewOfferItemView ragfairNewOfferItemView = ItemViewFactory.CreateFromPool<RagfairNewOfferItemView>("ragfair_layout"); RagfairNewOfferItemView ragfairNewOfferItemView = ItemViewFactory.CreateFromPool<RagfairNewOfferItemView>("ragfair_layout");
if (SelectedMarkTemplate == null) if (SelectedMarkTemplate == null)
{ {
SelectedMarkTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedMark, null, false); SelectedMarkTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedMark, null, false);
@@ -271,6 +270,7 @@ namespace UIFixes
taskSerializer.Initialize( taskSerializer.Initialize(
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Equip, itemUiContext)), SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Equip, itemUiContext)),
itemContext => itemUiContext.QuickEquip(itemContext.Item)); itemContext => itemUiContext.QuickEquip(itemContext.Item));
itemUiContext.Tooltip?.Close(); itemUiContext.Tooltip?.Close();
} }
} }
@@ -283,6 +283,7 @@ namespace UIFixes
taskSerializer.Initialize( taskSerializer.Initialize(
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unequip, itemUiContext)), SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unequip, itemUiContext)),
itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0)); itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0));
itemUiContext.Tooltip?.Close(); itemUiContext.Tooltip?.Close();
} }
} }

View File

@@ -1,7 +1,6 @@
using Aki.Reflection.Patching; using Aki.Reflection.Patching;
using EFT.UI.DragAndDrop; using EFT.UI.DragAndDrop;
using HarmonyLib; using HarmonyLib;
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -75,9 +74,9 @@ namespace UIFixes
// This won't block the first action from swapping, but will prevent follow up swaps // This won't block the first action from swapping, but will prevent follow up swaps
SwapPatches.BlockSwaps = true; SwapPatches.BlockSwaps = true;
__result.ContinueWith(_ => __result.ContinueWith(_ =>
{ {
InPatch = false; InPatch = false;
SwapPatches.BlockSwaps = false; SwapPatches.BlockSwaps = false;
}); });

View File

@@ -31,6 +31,11 @@ namespace UIFixes
Complete(); Complete();
} }
public void OnDisable()
{
Cancel();
}
public void LateUpdate() public void LateUpdate()
{ {
if (currentTask.IsCanceled) if (currentTask.IsCanceled)