using RimWorld; using System.Collections.Generic; using Verse; namespace RJWSexperience.Ideology { public static class IssueUtility { private static readonly Dictionary> issuePrecepts = new Dictionary>(); public static List GetAllPrecepts(this IssueDef issue) { if (issuePrecepts.TryGetValue(issue, out List precepts)) return precepts; precepts = DefDatabase.AllDefsListForReading.FindAll(x => x.issue == issue); issuePrecepts.Add(issue, precepts); return precepts; } public static Precept GetPreceptOfIssue(this Ideo ideo, IssueDef issue) { foreach (PreceptDef preceptDef in issue.GetAllPrecepts()) { Precept precept = ideo.GetPrecept(preceptDef); if (precept != null) return precept; } return null; } } }