Added stat caching, fixed all the bugs

Added RitualObligationTriggers analyzer category,
Fixed defs from other mods with broken market value breaking fish's storage patches,
Fixed storage caches not updating for quality, rotting and similar changes to stored things,
Fixed storage caches not updating capacity when reinstalling storage,
Fixed prison labor compatibility,
Improved multiplayer compatibility,
Fixed ideology style dominance and altar sharing patches throwing errors instead of defaulting to disabled when not having ideology,
Fixed compatibility with RIMMSqol's world pawn GC patch by disabling that patch,
Fixed rare threading issues throwing errors on startup
This commit is contained in:
bbradson
2024-03-10 20:05:24 +01:00
parent a4ee95fde1
commit be3dae46bb
45 changed files with 1090 additions and 414 deletions
+15 -12
View File
@@ -71,11 +71,11 @@ public sealed class MassUtilityCaching : ClassWithFishPatches
=> InventoryMassCache.GetExistingReference(p).Update(__result, p);
}
public record struct GearMassCacheValue
public record struct GearMassCacheValue()
{
public float Mass;
private int _nextRefreshTick;
private int _equipmentListsState;
private int _nextRefreshTick = -2;
private int _equipmentListsState = -69123;
public void Update(float mass, Pawn p)
{
@@ -87,9 +87,13 @@ public sealed class MassUtilityCaching : ClassWithFishPatches
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetEquipmentListsState(Pawn p)
{
var result = p.apparel != null ? p.apparel.WornApparel._version : 0;
var result = p.apparel != null ? p.apparel.WornApparel._version : -1;
if (p.equipment != null)
result += p.equipment.AllEquipmentListForReading._version;
{
var equipmentListVersion = (uint)p.equipment.AllEquipmentListForReading._version;
result += (int)((equipmentListVersion << 16) | (equipmentListVersion >> 16));
}
return result;
}
@@ -99,24 +103,23 @@ public sealed class MassUtilityCaching : ClassWithFishPatches
|| _equipmentListsState != GetEquipmentListsState(p);
}
public record struct InventoryMassCacheValue
public record struct InventoryMassCacheValue()
{
public float Mass;
private int _nextRefreshTick;
private int _inventoryListsState;
private int _nextRefreshTick = -2;
private int _inventoryListsState = -2;
public void Update(float mass, Pawn p)
{
Mass = mass;
//shorter refresh interval because of stack sizes not being considered by the listVersion check
_nextRefreshTick = TickHelper.Add(GenTicks.TickRareInterval, p.thingIDNumber);
_inventoryListsState
= GetInventoryListsState(
p); //shorter refresh interval because of stack sizes not being considered by the listVersion check
_inventoryListsState = GetInventoryListsState(p);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetInventoryListsState(Pawn p)
=> p.inventory?.innerContainer is { } container ? container.innerList._version : 0;
=> p.inventory?.innerContainer is { } container ? container.innerList._version : -42;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsDirty(Pawn p)