Stabilize RimWorld 1.6 caches and tick optimizations
This commit is contained in:
@@ -53,11 +53,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : ThingComp
|
||||
{
|
||||
private List<ThingComp>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<ThingComp> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<ThingComp> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(ThingWithComps thing, T? comp)
|
||||
@@ -65,6 +67,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (thing.thingIDNumber < 0)
|
||||
return;
|
||||
|
||||
_listReference = thing.comps;
|
||||
_listVersion = thing.comps._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -113,11 +116,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : CompProperties
|
||||
{
|
||||
private List<CompProperties>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<CompProperties> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<CompProperties> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(ThingDef thingDef, T? comp)
|
||||
@@ -125,6 +130,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (thingDef.shortHash == default)
|
||||
return;
|
||||
|
||||
_listReference = thingDef.comps;
|
||||
_listVersion = thingDef.comps._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -174,11 +180,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue()
|
||||
{
|
||||
private List<CompProperties>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public bool HasComp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<CompProperties> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<CompProperties> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(ThingDef thingDef, bool hasComp)
|
||||
@@ -186,6 +194,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (thingDef.shortHash == default)
|
||||
return;
|
||||
|
||||
_listReference = thingDef.comps;
|
||||
_listVersion = thingDef.comps._version;
|
||||
HasComp = hasComp;
|
||||
}
|
||||
@@ -236,11 +245,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : ThingComp
|
||||
{
|
||||
private List<CompProperties>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public bool HasComp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<CompProperties> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<CompProperties> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(ThingDef thingDef, bool hasComp)
|
||||
@@ -248,6 +259,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (thingDef.shortHash == default)
|
||||
return;
|
||||
|
||||
_listReference = thingDef.comps;
|
||||
_listVersion = thingDef.comps._version;
|
||||
HasComp = hasComp;
|
||||
}
|
||||
@@ -296,11 +308,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : HediffComp
|
||||
{
|
||||
private List<HediffComp>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<HediffComp> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<HediffComp> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(HediffWithComps hediff, T? comp)
|
||||
@@ -308,6 +322,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (hediff.loadID < 0)
|
||||
return;
|
||||
|
||||
_listReference = hediff.comps;
|
||||
_listVersion = hediff.comps._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -355,11 +370,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : HediffCompProperties
|
||||
{
|
||||
private List<HediffCompProperties>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<HediffCompProperties> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<HediffCompProperties> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(HediffDef hediffDef, T? comp)
|
||||
@@ -367,6 +384,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (hediffDef.shortHash == 0)
|
||||
return;
|
||||
|
||||
_listReference = hediffDef.comps;
|
||||
_listVersion = hediffDef.comps._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -414,11 +432,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : AbilityComp
|
||||
{
|
||||
private List<AbilityComp>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<AbilityComp> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<AbilityComp> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(Ability ability, T? comp)
|
||||
@@ -426,6 +446,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (ability.Id < 0)
|
||||
return;
|
||||
|
||||
_listReference = ability.comps;
|
||||
_listVersion = ability.comps._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -468,11 +489,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : WorldObjectComp
|
||||
{
|
||||
private List<WorldObjectComp>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<WorldObjectComp> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<WorldObjectComp> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(WorldObject worldObject, T? comp)
|
||||
@@ -480,6 +503,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (worldObject.ID < 0)
|
||||
return;
|
||||
|
||||
_listReference = worldObject.comps;
|
||||
_listVersion = worldObject.comps._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -522,11 +546,13 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
|
||||
public record struct CacheValue<T>() where T : MapComponent
|
||||
{
|
||||
private List<MapComponent>? _listReference;
|
||||
private int _listVersion = -2;
|
||||
public T? Comp;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsDirty(List<MapComponent> comps) => comps._version != _listVersion;
|
||||
public bool IsDirty(List<MapComponent> comps)
|
||||
=> !ReferenceEquals(comps, _listReference) || comps._version != _listVersion;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Update(Map map, T? comp)
|
||||
@@ -534,6 +560,7 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
if (map.uniqueID < 0)
|
||||
return;
|
||||
|
||||
_listReference = map.components;
|
||||
_listVersion = map.components._version;
|
||||
Comp = comp;
|
||||
}
|
||||
@@ -641,4 +668,4 @@ public sealed class GetCompCaching : ClassWithFishPrepatches
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user