diff --git a/1.4/Assemblies/PerformanceFish.dll b/1.4/Assemblies/PerformanceFish.dll index f670c4a..2ce0ba9 100644 Binary files a/1.4/Assemblies/PerformanceFish.dll and b/1.4/Assemblies/PerformanceFish.dll differ diff --git a/1.4/Assemblies/PerformanceFish.pdb b/1.4/Assemblies/PerformanceFish.pdb index fa7a7c2..ca25333 100644 Binary files a/1.4/Assemblies/PerformanceFish.pdb and b/1.4/Assemblies/PerformanceFish.pdb differ diff --git a/README.md b/README.md index d9db69f..74dc654 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![](About/Preview.png?raw=true) Performance Mod for Rimworld. -Requires Prepatcher and Fishery. +Requires [Prepatcher](https://github.com/Zetrith/Prepatcher) and [Fishery](https://github.com/bbradson/Fishery). Performance Fish attempts to improve overall framerates and tick times by patching various methods for improved efficiency, while keeping functionality identical. Designed to be used alongside other performance mods, like RocketMan, and intended to be compatible with very large modlists. Most patches become more impactful as the game progresses further into the lategame. diff --git a/Source/PerformanceFish/Cache/Utility.cs b/Source/PerformanceFish/Cache/Utility.cs index 632f7ff..d9f2d67 100644 --- a/Source/PerformanceFish/Cache/Utility.cs +++ b/Source/PerformanceFish/Cache/Utility.cs @@ -15,6 +15,8 @@ public static class Utility { public static event Action? 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() diff --git a/Source/PerformanceFish/ContentFinderCaching.cs b/Source/PerformanceFish/ContentFinderCaching.cs index 51be435..42d9c40 100644 --- a/Source/PerformanceFish/ContentFinderCaching.cs +++ b/Source/PerformanceFish/ContentFinderCaching.cs @@ -22,7 +22,7 @@ public class ContentFinderCaching : ClassWithFishPrepatches { ref var cache = ref Cache.ByReference>.GetOrAddReference(itemPath); - if (!cache.Cached) + if (!cache.Cached || !OnStartup.State.Initialized) return __state = true; __result = cache.Value; diff --git a/Source/PerformanceFish/Planet/WorldObjectsOptimization.cs b/Source/PerformanceFish/Planet/WorldObjectsOptimization.cs index e2385ed..a0614e2 100644 --- a/Source/PerformanceFish/Planet/WorldObjectsOptimization.cs +++ b/Source/PerformanceFish/Planet/WorldObjectsOptimization.cs @@ -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; } } \ No newline at end of file diff --git a/Source/PerformanceFish/ThingFilterPatches.cs b/Source/PerformanceFish/ThingFilterPatches.cs index af4553b..55f9df5 100644 --- a/Source/PerformanceFish/ThingFilterPatches.cs +++ b/Source/PerformanceFish/ThingFilterPatches.cs @@ -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