Stabilize RimWorld 1.6 caches and tick optimizations
This commit is contained in:
@@ -16,6 +16,8 @@ public sealed class NeedsTrackerCaching : ClassWithFishPrepatches
|
||||
{
|
||||
public sealed class TryGetNeedPatch : FishPrepatch
|
||||
{
|
||||
public override bool DefaultState => true;
|
||||
|
||||
public override string? Description { get; }
|
||||
= "Caches generic need lookups behind the needs list version.";
|
||||
|
||||
@@ -30,6 +32,8 @@ public sealed class NeedsTrackerCaching : ClassWithFishPrepatches
|
||||
|
||||
public sealed class TryGetNeedOutPatch : FishPrepatch
|
||||
{
|
||||
public override bool DefaultState => true;
|
||||
|
||||
public override string? Description { get; }
|
||||
= "Caches generic need lookups behind the needs list version.";
|
||||
|
||||
@@ -55,18 +59,18 @@ public sealed class NeedsTrackerCaching : ClassWithFishPrepatches
|
||||
return cache.Found;
|
||||
}
|
||||
|
||||
return UpdateCache(instance, typeof(T), out need, ref cache);
|
||||
return UpdateCache(instance, out need, ref cache);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static bool UpdateCache<T>(Pawn_NeedsTracker instance, Type needType, out T? need, ref CacheValue cache)
|
||||
private static bool UpdateCache<T>(Pawn_NeedsTracker instance, out T? need, ref CacheValue cache)
|
||||
where T : Need
|
||||
{
|
||||
var needs = instance.needs;
|
||||
for (var i = 0; i < needs.Count; i++)
|
||||
{
|
||||
var candidate = needs[i];
|
||||
if (candidate.GetType() != needType)
|
||||
if (candidate.GetType() != typeof(T))
|
||||
continue;
|
||||
|
||||
need = (T)candidate;
|
||||
|
||||
Reference in New Issue
Block a user