Fixed rare TryFindBestBetterStoreCellFor errors, added better exception handling for drawing errors thrown by other mods

Those log messages now include things and the position where drawing fails
Plant printing was slightly improved further too, correctly handling theoretical hydroponics of sizes above 20 now
This commit is contained in:
bbradson
2024-04-30 20:37:18 +02:00
parent 1ca55fc7b8
commit 79e8b5f70d
16 changed files with 183 additions and 75 deletions
@@ -11,16 +11,15 @@ public record struct HaulDestinationManagerCache()
public event Action<HaulDestinationManager>? PriorityChanged;
public int[] GroupCountByPriority = new int[StoragePriorityCount];
public readonly int[] GroupCountByPriority = new int[StoragePriorityCount];
[MethodImpl(MethodImplOptions.NoInlining)]
public void OnPriorityChanged(HaulDestinationManager manager)
{
var slotGroupsByPriority = manager.AllGroupsListInPriorityOrder;
Array.Clear(GroupCountByPriority, 0, GroupCountByPriority.Length);
for (var i = slotGroupsByPriority.Count; i-- > 0;)
GroupCountByPriority[(int)slotGroupsByPriority[i].Settings.Priority]++;
GroupCountByPriority.Clear();
manager.AllGroupsListInPriorityOrder.UnwrapArray(out var slotGroupsByPriority, out var slotGroupCount);
for (var i = slotGroupCount; --i >= 0;)
GroupCountByPriority[(int)slotGroupsByPriority.UnsafeLoad(i).Settings.Priority]++;
PriorityChanged?.Invoke(manager);
}