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
@@ -56,19 +56,10 @@ public sealed class ImmunityHandlerCaching : ClassWithFishPatches
public sealed class ImmunityRecordExists : FishPatch
{
public override List<Type> LinkedPatches { get; } = [typeof(TryAddImmunityRecord)];
public override string? Description { get; } = "Required by the TryAddImmunityRecord optimization.";
public override bool Enabled
{
set
{
if (base.Enabled == value)
return;
Get<TryAddImmunityRecord>().Enabled = base.Enabled = value;
}
}
public override MethodBase TargetMethodInfo { get; }
= AccessTools.Method(typeof(ImmunityHandler), nameof(ImmunityHandler.ImmunityRecordExists));
@@ -84,19 +75,10 @@ public sealed class ImmunityHandlerCaching : ClassWithFishPatches
public sealed class TryAddImmunityRecord : FishPatch
{
public override List<Type> LinkedPatches { get; } = [typeof(ImmunityRecordExists)];
public override string? Description { get; }
= "Optimization for this specific method to not run more checks than necessary.";
public override bool Enabled
{
set
{
if (base.Enabled == value)
return;
Get<ImmunityRecordExists>().Enabled = base.Enabled = value;
}
}
public override MethodBase TargetMethodInfo { get; }
= AccessTools.Method(typeof(ImmunityHandler), nameof(ImmunityHandler.TryAddImmunityRecord));
@@ -110,7 +92,7 @@ public sealed class ImmunityHandlerCaching : ClassWithFishPatches
}
}
public record struct ImmunityInfoCacheValue
public record struct ImmunityInfoCacheValue()
{
private int _version = -1;
private List<Hediff> _hediffsInSet = [];
@@ -132,15 +114,11 @@ public sealed class ImmunityHandlerCaching : ClassWithFishPatches
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _version != _hediffsInSet._version || TickHelper.Past(_nextRefreshTick);
}
public ImmunityInfoCacheValue()
{
}
}
public record struct ImmunityRecordExistsCacheValue
public record struct ImmunityRecordExistsCacheValue()
{
public bool Value;
public int ImmunityListVersion;
public int ImmunityListVersion = -2;
}
}