static WorkTags WorkDisables(BackstoryDef bs) { var wt = WorkTags.None; if (bs.workAllows.NullOrEmpty()) { if (bs.workDisables != null) { foreach (var tag in bs.workDisables) { wt |= tag; } } } else { foreach (WorkTags tag in Enum.GetValues(typeof(WorkTags))) { if (!bs.workAllows.Contains(tag)) { wt |= tag; } } } return(wt); }
static WorkTags RequiredWorkTags(BackstoryDef bs) { var wt = WorkTags.None; foreach (var tag in bs.requiredWorkTags) { wt |= tag; } return(wt); }
internal static void UpdateTranslateableFields(BackstoryDef bs) { if (bs.backstory == null) { return; } bs.backstory.baseDesc = bs.baseDescription.NullOrEmpty() ? "Empty." : bs.baseDescription; bs.backstory.SetTitle(newTitle: bs.title, newTitleFemale: bs.titleFemale); bs.backstory.SetTitleShort(newTitleShort: bs.titleShort.NullOrEmpty() ? bs.backstory.title : bs.titleShort, newTitleShortFemale: bs.titleShortFemale.NullOrEmpty() ? bs.backstory.titleFemale : bs.titleShortFemale); }
static List <TraitEntry> DisallowedTraits(BackstoryDef bs) { if (bs.disallowedTraits.NullOrEmpty()) { return(null); } var disallowedTraits = new List <TraitEntry>(); foreach (var trait in bs.disallowedTraits) { if (Rand.Range(0, 100) < trait.chance) { disallowedTraits.Add(new TraitEntry(TraitDef.Named(trait.defName), trait.degree)); } } return(disallowedTraits); }