Skip to content

Commit

Permalink
Generic def performance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ProTriforcer authored May 30, 2024
1 parent 96ef074 commit c6b68e7
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1046,15 +1046,16 @@ private void initGenericVisibilityDictionary()
{
int tick = GenTicks.TicksAbs;
int position = 1;
foreach (LoadoutGenericDef def in _sourceGeneric)
List<ThingDef> mapDefs = Find.CurrentMap.listerThings.AllThings.Where((Thing thing) => !thing.PositionHeld.Fogged(thing.MapHeld) && !thing.GetInnerIfMinified().def.Minifiable).Select((Thing thing) => thing.def).Distinct().ToList();
foreach (LoadoutGenericDef loadoutDef in _sourceGeneric)
{
if (!genericVisibility.ContainsKey(def))
if (!genericVisibility.ContainsKey(loadoutDef))
{
genericVisibility.Add(def, new VisibilityCache());
genericVisibility.Add(loadoutDef, new VisibilityCache());
}
genericVisibility[def].ticksToRecheck = tick;
genericVisibility[def].check = Find.CurrentMap.listerThings.AllThings.Find(x => def.lambda(x.GetInnerIfMinified().def) && !x.def.Minifiable) == null;
genericVisibility[def].position = position;
genericVisibility[loadoutDef].ticksToRecheck = tick;
genericVisibility[loadoutDef].check = mapDefs.Find((ThingDef def) => loadoutDef.lambda(def)) == null;
genericVisibility[loadoutDef].position = position;
position++;
tick += advanceTicks;
}
Expand Down

0 comments on commit c6b68e7

Please sign in to comment.