Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified 1.4/Assemblies/AlienRace.dll
Binary file not shown.
18 changes: 14 additions & 4 deletions Source/AlienRace/AlienRace/ThingDef_AlienRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ThingDef_AlienRace> races));
bool result = !(thoughtRestrictionDict.TryGetValue(thoughtDef, out List<ThingDef_AlienRace> 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<ThoughtReplacer> replacerList;

public static Dictionary<uint, bool> canGetThoughtCache = new();
}

public class ButcherThought
Expand Down