diff --git a/1.4/Assemblies/AlienRace.dll b/1.4/Assemblies/AlienRace.dll index 7ea644fd..07d49e6c 100644 Binary files a/1.4/Assemblies/AlienRace.dll and b/1.4/Assemblies/AlienRace.dll differ diff --git a/Source/AlienRace/AlienRace/ThingDef_AlienRace.cs b/Source/AlienRace/AlienRace/ThingDef_AlienRace.cs index c221f623..df1ab19a 100644 --- a/Source/AlienRace/AlienRace/ThingDef_AlienRace.cs +++ b/Source/AlienRace/AlienRace/ThingDef_AlienRace.cs @@ -419,16 +419,26 @@ public bool CanGetThought(ThoughtDef def) (!(this.cannotReceiveThoughts?.Contains(def) ?? false)); } - public static bool CanGetThought(ThoughtDef def, Pawn pawn) + public static bool CanGetThought(ThoughtDef thoughtDef, ThingDef thingDef) { - bool result = !(thoughtRestrictionDict.TryGetValue(def, out List races)); + bool result = !(thoughtRestrictionDict.TryGetValue(thoughtDef, out List races)); - return pawn.def is not ThingDef_AlienRace alienProps ? + return thingDef is not ThingDef_AlienRace alienProps ? result : - (races?.Contains(alienProps) ?? true) && alienProps.alienRace.thoughtSettings.CanGetThought(def); + (races?.Contains(alienProps) ?? true) && alienProps.alienRace.thoughtSettings.CanGetThought(thoughtDef); } + public static bool CanGetThought(ThoughtDef def, Pawn pawn) + => canGetThoughtCache.TryGetValue(def.shortHash | ((uint)pawn.def.shortHash << 16), out var value) + ? value + : UpdateCanGetThoughtCache(def, pawn); + + private static bool UpdateCanGetThoughtCache(ThoughtDef def, Pawn pawn) + => canGetThoughtCache[def.shortHash | ((uint)pawn.def.shortHash << 16)] = CanGetThought(def, pawn.def); + public List replacerList; + + public static Dictionary canGetThoughtCache = new(); } public class ButcherThought