public static string ThingLabel(Thing t, int stackCount, bool includeHp = true) { GenLabel.LabelRequest key = default(GenLabel.LabelRequest); key.entDef = t.def; key.stuffDef = t.Stuff; key.stackCount = stackCount; t.TryGetQuality(out key.quality); if (t.def.useHitPoints && includeHp) { key.health = t.HitPoints; key.maxHealth = t.MaxHitPoints; } Apparel apparel = t as Apparel; if (apparel != null) { key.wornByCorpse = apparel.WornByCorpse; } string text; if (!GenLabel.labelDictionary.TryGetValue(key, out text)) { if (GenLabel.labelDictionary.Count > 2000) { GenLabel.labelDictionary.Clear(); } text = GenLabel.NewThingLabel(t, stackCount, includeHp); GenLabel.labelDictionary.Add(key, text); } return(text); }
public static string ThingLabel(BuildableDef entDef, ThingDef stuffDef, int stackCount = 1) { GenLabel.LabelRequest key = default(GenLabel.LabelRequest); key.entDef = entDef; key.stuffDef = stuffDef; key.stackCount = stackCount; string text; if (!GenLabel.labelDictionary.TryGetValue(key, out text)) { if (GenLabel.labelDictionary.Count > 2000) { GenLabel.labelDictionary.Clear(); } text = GenLabel.NewThingLabel(entDef, stuffDef, stackCount); GenLabel.labelDictionary.Add(key, text); } return(text); }