Mainly more hauling optimizations, utilizing linked storage groups
This also adds an experimental, usually slower, threaded gas grid mode and implements a workaround for the whole mod and game failing to start when opening prepatcher's mod manager with unfortunate timing
This commit is contained in:
@@ -43,11 +43,11 @@ public sealed class JobGiver_HaulOptimization : ClassWithFishPatches
|
||||
|
||||
public static List<Thing> SortedThingsPotentiallyNeedingHauling(List<Thing> things, Pawn pawn)
|
||||
{
|
||||
_comparer.rootCell = pawn.Position;
|
||||
((ThingPositionComparer)_comparer.Target).rootCell = pawn.Position;
|
||||
things.Sort(_comparer);
|
||||
return things;
|
||||
}
|
||||
|
||||
private static WorkGiver_DoBillOptimization.ThingPositionComparer _comparer = new();
|
||||
private static Comparison<Thing> _comparer = new ThingPositionComparer().Compare;
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public sealed class WorkGiver_DoBillPrepatches : ClassWithFishPrepatches
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly WorkGiver_DoBillOptimization.ThingPositionComparer _insertAtCorrectPositionComparer
|
||||
private static readonly ThingPositionComparer _insertAtCorrectPositionComparer
|
||||
= new();
|
||||
|
||||
public static void ActualLoop(List<Thing> list, Region r, Pawn pawn, Predicate<Thing> baseValidator,
|
||||
@@ -599,16 +599,6 @@ public sealed class WorkGiver_DoBillOptimization : ClassWithFishPatches
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ThingPositionComparer : IComparer<Thing>
|
||||
{
|
||||
public IntVec3 rootCell;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Compare(Thing x, Thing y)
|
||||
=> (x.Position - rootCell).LengthHorizontalSquared.CompareTo(
|
||||
(y.Position - rootCell).LengthHorizontalSquared);
|
||||
}
|
||||
|
||||
public record struct RecipeIngredientCacheValue
|
||||
{
|
||||
public IngredientCacheList? thingDefs;
|
||||
|
||||
@@ -29,10 +29,10 @@ public sealed class WorkGiver_HaulOptimization : ClassWithFishPatches
|
||||
|
||||
private static void Sort(List<Thing> list, Pawn pawn)
|
||||
{
|
||||
_comparer.rootCell = pawn.Position;
|
||||
((ThingPositionComparer)_comparer.Target).rootCell = pawn.Position;
|
||||
list.Sort(_comparer);
|
||||
}
|
||||
|
||||
private static WorkGiver_DoBillOptimization.ThingPositionComparer _comparer = new();
|
||||
private static Comparison<Thing> _comparer = new ThingPositionComparer().Compare;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user