internal void <> m__0() { this.$this.trait = this.localDef; this.$this.degree = this.localDeg.degree; }
public TraitEntry(TraitDef def, int degree) { this.def = def; this.degree = degree; }
private static bool PawnHasTraitForcedByBackstory(Pawn pawn, TraitDef trait) { return((pawn.story.childhood != null && pawn.story.childhood.forcedTraits != null && pawn.story.childhood.forcedTraits.Any((TraitEntry te) => te.def == trait)) || (pawn.story.adulthood != null && pawn.story.adulthood.forcedTraits != null && pawn.story.adulthood.forcedTraits.Any((TraitEntry te) => te.def == trait))); }
private static string <DoEditInterface> m__0(TraitDef td) { return(td.label); }
public Trait(TraitDef def, int degree = 0, bool forced = false) { this.def = def; this.degree = degree; this.scenForced = forced; }
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); }
protected override ThoughtState CurrentStateInternal(Pawn p) { if (p.Map.terrainGrid.TerrainAt(p.Position).defName == "HardVacuum") { if (p.story.traits.HasTrait(TraitDefOf.Undergrounder) || p.story.traits.HasTrait(TraitDef.Named("Wimp"))) { return(ThoughtState.ActiveAtStage(3)); } else { return(ThoughtState.ActiveAtStage(2)); } } else if (p.Map.terrainGrid.TerrainAt(IntVec3.Zero).defName == "HardVacuum") { if (p.story.traits.HasTrait(TraitDefOf.Undergrounder) || p.story.traits.HasTrait(TraitDef.Named("Wimp"))) { return(ThoughtState.ActiveAtStage(1)); } else { return(ThoughtState.ActiveAtStage(0)); } } return(ThoughtState.Inactive); }
private static List <Trait> MakeRows(RimWorld.TraitDef td) { var result = new List <Trait>(); string defName = td.defName, conflictingTraits = "", disabledWorkTypes = "", disabledWorkTags = "", requiredWorkTypes = "", requiredWorkTags = ""; if (td.conflictingTraits?.Any() ?? false) { conflictingTraits = String.Join(", ", td.conflictingTraits.Select(x => x.defName).OrderBy(x => x).ToArray()); } if (td.disabledWorkTypes?.Any() ?? false) { disabledWorkTypes = String.Join(", ", td.disabledWorkTypes.Select(x => x.label).OrderBy(x => x).ToArray()); } if (td.disabledWorkTags != WorkTags.None) { disabledWorkTags = td.disabledWorkTags.ToString(); } if (td.requiredWorkTypes?.Any() ?? false) { requiredWorkTypes = String.Join(", ", td.requiredWorkTypes.Select(x => x.label).OrderBy(x => x).ToArray()); } if (td.requiredWorkTags != WorkTags.None) { requiredWorkTags = td.requiredWorkTags.ToString(); } if (td.degreeDatas?.Any() ?? false) { foreach (var deg in td.degreeDatas) { var row = new Trait { Label = Regex.Replace(deg.label, "<.*?>", ""), // remove html tags Description = deg.description }; row.defName = defName; row.conflictingTraits = conflictingTraits; row.disabledWorkTypes = disabledWorkTypes; row.disabledWorkTags = disabledWorkTags; row.requiredWorkTypes = requiredWorkTypes; row.requiredWorkTags = requiredWorkTags; if (deg.skillGains?.Any() ?? false) { foreach (var s in deg.skillGains) { var skillDef = s.Key; var rowProp = typeof(Trait).GetProperty(skillDef.defName); if (rowProp != null) { float?value = s.Value; rowProp.SetValue(row, value.Nullify(), null); } else { Log.Error($"[Trait] Can't find skill row: {skillDef.defName}"); } } } if (deg.statFactors?.Any() ?? false) { foreach (var s in deg.statFactors) { var rowProp = typeof(Trait).GetProperty(s.stat.defName); if (rowProp != null) { float?value = s.value; rowProp.SetValue(row, value.Nullify(), null); } else { Log.Error($"[Trait] Can't find statFactor row: {s.stat.defName}"); } } } if (deg.statOffsets?.Any() ?? false) { foreach (var s in deg.statOffsets) { var rowProp = typeof(Trait).GetProperty(s.stat.defName); if (rowProp != null) { float?value = s.value; rowProp.SetValue(row, value.Nullify(), null); } else { Log.Error($"[Trait] Can't find statOffset row: {s.stat.defName}"); } } } result.Add(row); } } return(result); }