diff --git a/1.3/Assemblies/PerformanceFish.dll b/1.3/Assemblies/PerformanceFish.dll index 45b3fe1..9b1618e 100644 Binary files a/1.3/Assemblies/PerformanceFish.dll and b/1.3/Assemblies/PerformanceFish.dll differ diff --git a/1.4/Assemblies/PerformanceFish.dll b/1.4/Assemblies/PerformanceFish.dll index 0db9b49..5465586 100644 Binary files a/1.4/Assemblies/PerformanceFish.dll and b/1.4/Assemblies/PerformanceFish.dll differ diff --git a/Source/PerformanceFish/JobSystem/WorkGiver_MergeOptimization.cs b/Source/PerformanceFish/JobSystem/WorkGiver_MergeOptimization.cs new file mode 100644 index 0000000..f80718d --- /dev/null +++ b/Source/PerformanceFish/JobSystem/WorkGiver_MergeOptimization.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2022 bradson +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +namespace PerformanceFish.JobSystem; + +public class WorkGiver_MergeOptimization : ClassWithFishPatches +{ + public class JobOnThing_Patch : FishPatch + { + public override string Description => "Removes mergeables from ListerMergeables if they no longer qualify as mergeable when trying to check for a merging job on them. Vanilla RimWorld just fails and keeps them in"; + public override MethodBase TargetMethodInfo => AccessTools.Method(typeof(WorkGiver_Merge), nameof(WorkGiver_Merge.JobOnThing)); + + public static void Prefix(Thing t) + { + if (t.GetSlotGroup() is null) + RemoveFromListerMergeables(t); + } + + private static void RemoveFromListerMergeables(Thing t) + { + var map = t.MapHeld; + map.listerMergeables.TryRemove(t); + map.listerHaulables.Check(t); + } + } +} \ No newline at end of file