public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense) { if (AnimalGroupDef.TryGetGroups(req, out var groups)) { return(groups.Where(g => g.pawnKinds.Count >= 2).Select(m => (string)m.LabelCap) .OrderBy(m => m, StringComparer.InvariantCultureIgnoreCase).ToCommaList(true)); } return(""); }
public override string GetStatDrawEntryLabel(StatDef statDef, float value, ToStringNumberSense numberSense, StatRequest optionalReq, bool finalized = true) { if (AnimalGroupDef.TryGetGroups(optionalReq, out var groups)) { return(groups.Where(g => g.canMate && g.pawnKinds.Count >= 2).Select(g => (string)g.LabelCap) .ToCommaList()); } return(""); }
private static bool TryGetHybrids(StatRequest req, out IEnumerable <HybridDef> hybridDefs) { if (AnimalGroupDef.TryGetGroups(req, out var groups)) { hybridDefs = groups.Select(a => HybridDef.TryGetHybrids(a, out var h) ? h : null).Where(h => h != null) .SelectMany(x => x).Select(h => h.Value).SelectMany(x => x).Distinct(); return(true); } hybridDefs = default; return(false); }
public override IEnumerable <Dialog_InfoCard.Hyperlink> GetInfoCardHyperlinks(StatRequest req) { if (AnimalGroupDef.TryGetGroups(req, out var group)) { return(group.Where(g => g.pawnKinds.Count >= 2).Select(g => g.pawnKinds).SelectMany(x => x) .Select(m => (Def)DefDatabase <ThingDef> .GetNamedSilentFail(m.defName) ?? m) .OrderBy(x => x.label, StringComparer.InvariantCultureIgnoreCase) .Select(m => new Dialog_InfoCard.Hyperlink(m))); } return(Array.Empty <Dialog_InfoCard.Hyperlink>()); }
public override string GetExplanationFinalizePart(StatRequest req, ToStringNumberSense numberSense, float finalVal) { if (AnimalGroupDef.TryGetGroups(req, out var groups)) { return(string.Join("\n\n", groups.Where(g => g.canMate && g.pawnKinds.Count >= 2 && !g.description.NullOrEmpty()) .OrderBy(g => g.label, StringComparer.InvariantCultureIgnoreCase).Select(g => g.description))); } return(""); }
public static bool TryGetHybrids(PawnKindDef a, PawnKindDef b, out IReadOnlyList <HybridDef> hybrids) { if (a == b || !TryGetHybrids(a, out var aHybridDict) || !AnimalGroupDef.TryGetGroups(b, out var bGroupsList)) { hybrids = default; return(false); } hybrids = bGroupsList.Select(bGroup => aHybridDict.TryGetValue(bGroup, out var l) ? l : null) .Where(l => l != null).SelectMany(x => x).Distinct().ToList(); return(hybrids.Count > 0); }
public static bool TryGetHybrids(PawnKindDef kindDef, out IReadOnlyDictionary <AnimalGroupDef, IReadOnlyList <HybridDef> > hybrids) { if (kindToHybrids.TryGetValue(kindDef, out hybrids)) { return(hybrids != null && hybrids.Count > 0); } if (AnimalGroupDef.TryGetGroups(kindDef, out var groups)) { hybrids = groups.Select(a => TryGetHybrids(a, out var d) ? d : null).Where(d => d != null) .SelectMany(x => x).GroupBy(kv => kv.Key).ToDictionary(g => g.Key, g => g.Select(kv => kv.Value.Where(h => h.IsUsable)).SelectMany(x => x).Distinct().ToList() .AsReadOnlyList()).AsReadOnlyDict(); } kindToHybrids.Add(kindDef, hybrids); return(hybrids != null && hybrids.Count > 0); }
public override bool ShouldShowFor(StatRequest req) { return(AnimalGroupDef.TryGetGroups(req, out var groups) && groups.Any(a => HybridDef.TryGetHybrids(a, out _))); }
public override bool ShouldShowFor(StatRequest req) { return(AnimalGroupDef.TryGetGroups(req, out var groupDefs) && groupDefs.Any(g => g.canMate && g.pawnKinds.Count >= 2)); }