diff --git a/1.4/Assemblies/PerformanceFish.dll b/1.4/Assemblies/PerformanceFish.dll index b6dcb27..b055210 100644 Binary files a/1.4/Assemblies/PerformanceFish.dll and b/1.4/Assemblies/PerformanceFish.dll differ diff --git a/1.4/Assemblies/PerformanceFish.pdb b/1.4/Assemblies/PerformanceFish.pdb index 85b3b04..c8e2b3f 100644 Binary files a/1.4/Assemblies/PerformanceFish.pdb and b/1.4/Assemblies/PerformanceFish.pdb differ diff --git a/1.5/Assemblies/PerformanceFish.dll b/1.5/Assemblies/PerformanceFish.dll index b38a742..3532fa8 100644 Binary files a/1.5/Assemblies/PerformanceFish.dll and b/1.5/Assemblies/PerformanceFish.dll differ diff --git a/1.5/Assemblies/PerformanceFish.pdb b/1.5/Assemblies/PerformanceFish.pdb index 182a5d5..15faaa1 100644 Binary files a/1.5/Assemblies/PerformanceFish.pdb and b/1.5/Assemblies/PerformanceFish.pdb differ diff --git a/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs b/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs index 9cd6e17..3efe82c 100644 --- a/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs +++ b/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs @@ -461,6 +461,36 @@ public sealed class StoreUtilityPrepatches : ClassWithFishPrepatches } } + public sealed class TryFindBestBetterStorageForPatch : FishPrepatch + { + public override string? Description { get; } + = "Cancel the removal of haulables if there is a better non-cell storage. " + + "Only needed when TryFindBestBetterStoreCellFor is enabled."; + + public override MethodBase TargetMethodBase { get; } = methodof(StoreUtility.TryFindBestBetterStorageFor); + + public static void Postfix(Thing t, Pawn carrier, Map map, StoragePriority currentPriority, Faction faction, ref IntVec3 foundCell, ref IHaulDestination haulDestination, bool needAccurateResult, ref bool __result) + { + if (StoreCellForPatchActive && __result && foundCell == IntVec3.Invalid && t.TryGetMapHeld() is { } m) + { + var cache = m.listerHaulables.Cache(); + cache.ThingsQueuedToRemove.Remove(t); + } + } + + private static int _storeCellForPatchActive = int.MaxValue; + + private static bool StoreCellForPatchActive + => _storeCellForPatchActive != int.MaxValue + ? _storeCellForPatchActive.AsBool() + : UpdateStoreCellForPatchActive(); + + [MethodImpl(MethodImplOptions.NoInlining)] + private static bool UpdateStoreCellForPatchActive() + => (_storeCellForPatchActive = (Get().IsActive + && Get().IsActive).AsInt()).AsBool(); + } + public sealed class GetSlotGroupPatch : FishPrepatch { public override string? Description { get; }