Bugfixes for world object caches not clearing when reloading without restart and retextures of a small number of things like fire not working
This commit is contained in:
@@ -15,6 +15,8 @@ public static class Utility
|
||||
{
|
||||
public static event Action<Thing>? ThingDestroyed; // TODO
|
||||
|
||||
public static event Action? Cleared;
|
||||
|
||||
private static volatile int _destroyedThingCounter, _lastGCTick, _gcRate = 1000;
|
||||
private static int _currentGCProgress;
|
||||
private static volatile bool _gcInProgress;
|
||||
@@ -88,6 +90,8 @@ public static class Utility
|
||||
{
|
||||
foreach (var cache in All)
|
||||
cache.Clear();
|
||||
|
||||
Cleared?.Invoke();
|
||||
}
|
||||
|
||||
public static void LogCurrentCacheUtilization()
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ContentFinderCaching : ClassWithFishPrepatches
|
||||
{
|
||||
ref var cache = ref Cache.ByReference<string, CacheValue<T>>.GetOrAddReference(itemPath);
|
||||
|
||||
if (!cache.Cached)
|
||||
if (!cache.Cached || !OnStartup.State.Initialized)
|
||||
return __state = true;
|
||||
|
||||
__result = cache.Value;
|
||||
|
||||
@@ -84,8 +84,8 @@ public class WorldObjectsOptimization : ClassWithFishPrepatches
|
||||
}
|
||||
|
||||
public static int
|
||||
CachedWorldObjectsVersion,
|
||||
CachedMapsVersion;
|
||||
CachedWorldObjectsVersion = -2,
|
||||
CachedMapsVersion = -2;
|
||||
|
||||
private static Type[]
|
||||
_whitelistedTickingCompTypes
|
||||
@@ -110,5 +110,9 @@ public class WorldObjectsOptimization : ClassWithFishPrepatches
|
||||
public static bool CacheDirty(WorldObjectsHolder instance)
|
||||
=> CachedWorldObjectsVersion != instance.worldObjects._version
|
||||
|| CachedMapsVersion != Current.gameInt.maps._version;
|
||||
|
||||
public static void SetDirty() => CachedWorldObjectsVersion = CachedMapsVersion = -2;
|
||||
|
||||
static WorldObjectsHolderTickPatch() => Cache.Utility.Cleared += SetDirty;
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,8 @@ public class ThingFilterPatches : ClassWithFishPatches
|
||||
|
||||
if (recipe?.ingredients is { } ingredients)
|
||||
ingredients.RemoveAll(static ingredientCount => ingredientCount is null);
|
||||
else if (def.CostList is { } costList)
|
||||
|
||||
if (def.CostList is { } costList)
|
||||
costList.RemoveAll(static thingDefCountClass => thingDefCountClass?.thingDef is null);
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user