public TaggedString FullDescriptionFor(Pawn p) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(baseDesc.Formatted(p.Named("PAWN")).AdjustedFor(p).Resolve()); stringBuilder.AppendLine(); stringBuilder.AppendLine(); List <SkillDef> allDefsListForReading = DefDatabase <SkillDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { SkillDef skillDef = allDefsListForReading[i]; if (skillGainsResolved.ContainsKey(skillDef)) { stringBuilder.AppendLine(skillDef.skillLabel.CapitalizeFirst() + ": " + skillGainsResolved[skillDef].ToString("+##;-##")); } } if (DisabledWorkTypes.Any() || DisabledWorkGivers.Any()) { stringBuilder.AppendLine(); } foreach (WorkTypeDef disabledWorkType in DisabledWorkTypes) { stringBuilder.AppendLine(disabledWorkType.gerundLabel.CapitalizeFirst() + " " + "DisabledLower".Translate()); } foreach (WorkGiverDef disabledWorkGiver in DisabledWorkGivers) { stringBuilder.AppendLine(disabledWorkGiver.workType.gerundLabel.CapitalizeFirst() + ": " + disabledWorkGiver.LabelCap + " " + "DisabledLower".Translate()); } if (ModsConfig.RoyaltyActive) { unlockedMeditationTypesTemp.Clear(); foreach (MeditationFocusDef allDef in DefDatabase <MeditationFocusDef> .AllDefs) { for (int j = 0; j < allDef.requiredBackstoriesAny.Count; j++) { BackstoryCategoryAndSlot backstoryCategoryAndSlot = allDef.requiredBackstoriesAny[j]; if (spawnCategories.Contains(backstoryCategoryAndSlot.categoryName) && backstoryCategoryAndSlot.slot == slot) { unlockedMeditationTypesTemp.Add(allDef.LabelCap); break; } } } if (unlockedMeditationTypesTemp.Count > 0) { stringBuilder.AppendLine(); stringBuilder.AppendLine("MeditationFocusesUnlocked".Translate() + ": "); stringBuilder.AppendLine(unlockedMeditationTypesTemp.ToLineList(" - ")); } } string str = stringBuilder.ToString().TrimEndNewlines(); return(Find.ActiveLanguageWorker.PostProcessed(str)); }
public string EnablingThingsExplanation(Pawn pawn) { List <string> reasons = new List <string>(); if (requiresRoyalTitle && pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0) { RoyalTitle royalTitle = pawn.royalty.AllTitlesInEffectForReading.MaxBy((RoyalTitle t) => t.def.seniority); reasons.Add("MeditationFocusEnabledByTitle".Translate(royalTitle.def.GetLabelCapFor(pawn).Named("TITLE"), royalTitle.faction.Named("FACTION")).Resolve()); } if (pawn.story != null) { Backstory adulthood = pawn.story.adulthood; Backstory childhood = pawn.story.childhood; if (!requiresRoyalTitle && requiredBackstoriesAny.Count == 0) { for (int i = 0; i < incompatibleBackstoriesAny.Count; i++) { BackstoryCategoryAndSlot backstoryCategoryAndSlot = incompatibleBackstoriesAny[i]; Backstory backstory2 = (backstoryCategoryAndSlot.slot == BackstorySlot.Adulthood) ? adulthood : childhood; if (!backstory2.spawnCategories.Contains(backstoryCategoryAndSlot.categoryName)) { AddBackstoryReason(backstoryCategoryAndSlot.slot, backstory2); } } for (int j = 0; j < DefDatabase <TraitDef> .AllDefsListForReading.Count; j++) { TraitDef traitDef = DefDatabase <TraitDef> .AllDefsListForReading[j]; List <MeditationFocusDef> disallowedMeditationFocusTypes = traitDef.degreeDatas[0].disallowedMeditationFocusTypes; if (disallowedMeditationFocusTypes != null && disallowedMeditationFocusTypes.Contains(this)) { reasons.Add("MeditationFocusDisabledByTrait".Translate() + ": " + traitDef.degreeDatas[0].LabelCap + "."); } } } for (int k = 0; k < requiredBackstoriesAny.Count; k++) { BackstoryCategoryAndSlot backstoryCategoryAndSlot2 = requiredBackstoriesAny[k]; Backstory backstory3 = (backstoryCategoryAndSlot2.slot == BackstorySlot.Adulthood) ? adulthood : childhood; if (backstory3.spawnCategories.Contains(backstoryCategoryAndSlot2.categoryName)) { AddBackstoryReason(backstoryCategoryAndSlot2.slot, backstory3); } } for (int l = 0; l < pawn.story.traits.allTraits.Count; l++) { Trait trait = pawn.story.traits.allTraits[l]; List <MeditationFocusDef> allowedMeditationFocusTypes = trait.CurrentData.allowedMeditationFocusTypes; if (allowedMeditationFocusTypes != null && allowedMeditationFocusTypes.Contains(this)) { reasons.Add("MeditationFocusEnabledByTrait".Translate() + ": " + trait.LabelCap + "."); } } } return(reasons.ToLineList(" - ", capitalizeItems: true)); void AddBackstoryReason(BackstorySlot slot, Backstory backstory) { if (slot == BackstorySlot.Adulthood) { reasons.Add("MeditationFocusEnabledByAdulthood".Translate() + ": " + backstory.title.CapitalizeFirst() + "."); } else { reasons.Add("MeditationFocusEnabledByChildhood".Translate() + ": " + backstory.title.CapitalizeFirst() + "."); } } }
private static bool PawnCanUseInt(Pawn p, MeditationFocusDef type) { if (p.story != null) { for (int i = 0; i < p.story.traits.allTraits.Count; i++) { List <MeditationFocusDef> disallowedMeditationFocusTypes = p.story.traits.allTraits[i].CurrentData.disallowedMeditationFocusTypes; if (disallowedMeditationFocusTypes != null && disallowedMeditationFocusTypes.Contains(type)) { return(false); } } List <string> list = p.story.adulthood?.spawnCategories; List <string> list2 = p.story.childhood?.spawnCategories; for (int j = 0; j < type.incompatibleBackstoriesAny.Count; j++) { BackstoryCategoryAndSlot backstoryCategoryAndSlot = type.incompatibleBackstoriesAny[j]; List <string> list3 = ((backstoryCategoryAndSlot.slot == BackstorySlot.Adulthood) ? list : list2); if (list3 != null && list3.Contains(backstoryCategoryAndSlot.categoryName)) { return(false); } } } if (type.requiresRoyalTitle) { if (p.royalty != null) { return(p.royalty.AllTitlesInEffectForReading.Any((RoyalTitle t) => t.def.allowDignifiedMeditationFocus)); } return(false); } if (p.story != null) { for (int k = 0; k < p.story.traits.allTraits.Count; k++) { List <MeditationFocusDef> allowedMeditationFocusTypes = p.story.traits.allTraits[k].CurrentData.allowedMeditationFocusTypes; if (allowedMeditationFocusTypes != null && allowedMeditationFocusTypes.Contains(type)) { return(true); } } List <string> list4 = p.story.adulthood?.spawnCategories; List <string> list5 = p.story.childhood?.spawnCategories; for (int l = 0; l < type.requiredBackstoriesAny.Count; l++) { BackstoryCategoryAndSlot backstoryCategoryAndSlot2 = type.requiredBackstoriesAny[l]; List <string> list6 = ((backstoryCategoryAndSlot2.slot == BackstorySlot.Adulthood) ? list4 : list5); if (list6 != null && list6.Contains(backstoryCategoryAndSlot2.categoryName)) { return(true); } } } if (type.requiredBackstoriesAny.Count == 0) { bool flag = false; for (int m = 0; m < DefDatabase <TraitDef> .AllDefsListForReading.Count; m++) { if (flag) { break; } TraitDef traitDef = DefDatabase <TraitDef> .AllDefsListForReading[m]; for (int n = 0; n < traitDef.degreeDatas.Count; n++) { List <MeditationFocusDef> allowedMeditationFocusTypes2 = traitDef.degreeDatas[n].allowedMeditationFocusTypes; if (allowedMeditationFocusTypes2 != null && allowedMeditationFocusTypes2.Contains(type)) { flag = true; break; } } } if (!flag) { return(true); } } return(false); }