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:
@@ -74,6 +74,11 @@ public static class PrepatcherFields
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static extern GasGridOptimization.ParallelGasGrid[] ParallelGasGrids(this GasGrid gasGrid);
|
||||
|
||||
[PrepatcherField]
|
||||
[ValueInitializer(nameof(CreateGroupMonitorObject))]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static extern object GasGridMonitorObject(this Map map);
|
||||
|
||||
[PrepatcherField]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static extern ref Texture2D? ExpandingIconCache(this WorldObject worldObject);
|
||||
@@ -151,6 +156,9 @@ public static class PrepatcherFields
|
||||
public static Listers.Haulables.Cache CreateListerHaulablesCache() => new();
|
||||
public static HaulDestinationManagerCache CreateHaulDestinationManagerCache() => new();
|
||||
|
||||
public static object CreateGroupMonitorObject()
|
||||
=> ParallelNoAlloc.RegisterBackgroundWaitingWorkers(Array.Empty<Action>());
|
||||
|
||||
public static GasGridOptimization.ParallelGasGrid[] CreateParallelGasGridArray(GasGrid gasGrid)
|
||||
{
|
||||
DefDatabase<GasDef>.SetIndices();
|
||||
@@ -185,6 +193,17 @@ public static class PrepatcherFields
|
||||
for (var i = 0; i < grids.Length; i++)
|
||||
grids[i] = new(map, gasDefs[i]);
|
||||
|
||||
if (FishSettings.ThreadingEnabled)
|
||||
{
|
||||
var monitorObject = map.GasGridMonitorObject();
|
||||
|
||||
for (var i = 1; i < grids.Length; i++)
|
||||
{
|
||||
var grid = grids[i];
|
||||
ParallelNoAlloc.RegisterBackgroundWaitingWorker(monitorObject, () => grid.Tick());
|
||||
}
|
||||
}
|
||||
|
||||
return grids;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user