private static float GetPawnLabelNameWidth(Pawn pawn, float truncateToWidth, Dictionary <string, string> truncatedLabelsCache) { if (pawnLabelCaches.TryGetValue(pawn, out PawnLabelCache pawnLabelCache)) { if (pawnLabelCache.updateWidthCount == 0) { pawnLabelCache.width = GetPawnLabelNameWidthRecheck(pawn, truncateToWidth, truncatedLabelsCache); pawnLabelCache.updateWidthCount = 300; } pawnLabelCache.updateWidthCount--; return(pawnLabelCache.width); } else { pawnLabelCaches[pawn] = new PawnLabelCache(); pawnLabelCaches[pawn].width = GetPawnLabelNameWidthRecheck(pawn, truncateToWidth, truncatedLabelsCache); return(pawnLabelCaches[pawn].width); } }
private static string GetPawnLabel(Pawn pawn, float truncateToWidth, Dictionary <string, string> truncatedLabelsCache) { if (pawnLabelCaches.TryGetValue(pawn, out PawnLabelCache pawnLabelCache)) { if (pawnLabelCache.updateLabelCount == 0) { pawnLabelCache.label = pawn.LabelShortCap.Truncate(truncateToWidth, truncatedLabelsCache); pawnLabelCache.updateLabelCount = 60; } pawnLabelCache.updateLabelCount--; return(pawnLabelCache.label); } else { pawnLabelCaches[pawn] = new PawnLabelCache(); pawnLabelCaches[pawn].label = pawn.LabelShortCap.Truncate(truncateToWidth, truncatedLabelsCache); return(pawnLabelCache.label); } }