public VampireRecord(Pawn originPawn, int originGeneration, BloodlineDef originBloodline, float originAge, string originSireId, Faction originFaction = null) { kindDef = originPawn.kindDef; nameInt = originPawn.Name; gender = originPawn.gender; generation = originGeneration; bloodline = originBloodline; age = originAge; sireId = originSireId; recordAge = Find.TickManager.TicksGame; faction = originFaction ?? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires); if (originPawn.story == null) { Log.Warning(originPawn.Name.ToStringFull + " has no story to copy."); return; } childhood = originPawn.story.childhood; adulthood = originPawn.story.adulthood; melanin = originPawn.story.melanin; hairColor = originPawn.story.hairColor; crownType = originPawn.story.crownType; bodyType = originPawn.story.bodyType; hairDef = originPawn.story.hairDef; traits = originPawn.story.traits; id = generation.ToString() + "_" + bloodline.ToString() + "_" + nameInt.ToStringFull + "_" + gender.ToString(); }
static ConstructBackstories() { LongEventHandler.ExecuteWhenFinished(() => { childhood = new Backstory() { title = "Artificial Construct", titleShort = "Construct", identifier = "ConstructBackstoryC", workDisables = WorkTags.Social, slot = BackstorySlot.Childhood, baseDesc = "" }; BackstoryDatabase.AddBackstory(childhood); adulthood = new Backstory() { title = "Artificial Construct", titleShort = "Construct", identifier = "ConstructBackstoryA", workDisables = WorkTags.Social, slot = BackstorySlot.Adulthood, baseDesc = "" }; BackstoryDatabase.AddBackstory(adulthood); }); }
static DroneBackstories() { LongEventHandler.ExecuteWhenFinished(() => { childhood = new Backstory() { title = "PRFDroneName".Translate(), titleShort = "PRFDroneName".Translate(), identifier = "PRFNoneBracketsC", workDisables = WorkTags.Social, slot = BackstorySlot.Childhood, baseDesc = "NoneBrackets".Translate() }; BackstoryDatabase.AddBackstory(childhood); adulthood = new Backstory() { title = "PRFDroneName".Translate(), titleShort = "PRFDroneName".Translate(), identifier = "PRFNoneBracketsA", workDisables = WorkTags.Social, slot = BackstorySlot.Adulthood, baseDesc = "NoneBrackets".Translate() }; BackstoryDatabase.AddBackstory(adulthood); }); }
protected void ShowBackstoryDialog(CustomPawn customPawn, BackstorySlot slot) { Backstory originalBackstory = (slot == BackstorySlot.Childhood) ? customPawn.Childhood : customPawn.Adulthood; Backstory selectedBackstory = originalBackstory; Dialog_Options <Backstory> dialog = new Dialog_Options <Backstory>(slot == BackstorySlot.Childhood ? this.providerBackstories.ChildhoodBackstories : this.providerBackstories.AdulthoodBackstories) { NameFunc = (Backstory backstory) => { return(backstory.Title); }, DescriptionFunc = (Backstory backstory) => { return(backstory.FullDescriptionFor(customPawn.Pawn)); }, SelectedFunc = (Backstory backstory) => { return(selectedBackstory == backstory); }, SelectAction = (Backstory backstory) => { selectedBackstory = backstory; }, CloseAction = () => { if (slot == BackstorySlot.Childhood) { BackstoryUpdated(BackstorySlot.Childhood, selectedBackstory); } else { BackstoryUpdated(BackstorySlot.Adulthood, selectedBackstory); } } }; Find.WindowStack.Add(dialog); }
public ProBackstories() { try { tempBS = new Backstory(); } catch (Exception e) { Log.Message("ProBackstories.ctor failed. /n " + e.Message); } }
/* public static void AddNewBackstorieToDatabase() { // Create minimal backstory backstory = new Backstory(); backstory.baseDesc = txtBaseDesc; backstory.title = txtTitle; backstory.titleShort = txtTitleShort; backstory.bodyTypeGlobal = bodyType; backstory.workDisables = workDisables1; backstory.defName = baseBackstoryDefName + backstory.workDisables.ToString().Replace(", ", "_"); backstories.Add(backstory); } */ public static Backstory GetBackstory() { Backstory backstory; WorkTags workDisables = WorkTags.Artistic; workDisables = workDisables | WorkTags.Caring; workDisables = workDisables | WorkTags.Cleaning; workDisables = workDisables | WorkTags.Cooking; workDisables = workDisables | WorkTags.Crafting; workDisables = workDisables | WorkTags.Firefighting; workDisables = workDisables | WorkTags.Hauling; workDisables = workDisables | WorkTags.Intellectual; workDisables = workDisables | WorkTags.ManualDumb; workDisables = workDisables | WorkTags.ManualSkilled; workDisables = workDisables | WorkTags.Mining; workDisables = workDisables | WorkTags.None; workDisables = workDisables | WorkTags.PlantWork; workDisables = workDisables | WorkTags.Scary; workDisables = workDisables | WorkTags.Social; workDisables = workDisables | WorkTags.Violent; // Create minimal backstory backstory = new Backstory(); backstory.baseDesc = "Vehicle"; backstory.title = "Vehicle"; backstory.titleShort = "Vehicle"; backstory.bodyTypeGlobal = BodyType.Female; backstory.workDisables = workDisables; //backstory.defName = baseBackstoryDefName + backstory.workDisables.ToString().Replace(", ", "_"); //WorkTags workDisables = WorkTags.Artistic | WorkTags.Social; //workDisables = workDisables | WorkTags.Violent; //string backstoryDefName = "AutonomicAI" + "_disabled_" + workDisables.ToString().Replace(", ", "_"); //return BackstoryDatabase.GetWithKey(backstoryDefName); return backstory; }
public override void ResolveReferences() { base.ResolveReferences(); if (!this.addToDatabase) return; if (BackstoryDatabase.allBackstories.ContainsKey(this.UniqueSaveKey())) return; Backstory b = new Backstory(); if (!this.title.NullOrEmpty()) b.title = this.title; else { CCL_Log.Error(defName + " backstory has empty title. Skipping...", "Backstories"); return; } if (!titleShort.NullOrEmpty()) b.titleShort = titleShort; else b.titleShort = b.title; if (!baseDescription.NullOrEmpty()) b.baseDesc = baseDescription; else { CCL_Log.Message(defName + " backstory has empty description.", "Backstories"); b.baseDesc = "Empty."; } b.bodyTypeGlobal = bodyTypeGlobal; b.bodyTypeMale = bodyTypeMale; b.bodyTypeFemale = bodyTypeFemale; b.slot = slot; b.shuffleable = shuffleable; if (spawnCategories.NullOrEmpty()) { CCL_Log.Error(defName + " backstory doesn't have any spawn categories defined. Skipping...", "Backstories"); return; } else b.spawnCategories = spawnCategories; if (workAllows.Count > 0) { foreach (WorkTags current in Enum.GetValues(typeof(WorkTags))) { if (!workAllows.Contains(current)) { b.workDisables |= current; } } } else if (workDisables.Count > 0) { foreach (var tag in workDisables) { b.workDisables |= tag; } } else { b.workDisables = WorkTags.None; } b.skillGains = skillGains.ToDictionary(i => i.defName, i => i.amount); b.ResolveReferences(); b.PostLoad(); b.uniqueSaveKey = this.UniqueSaveKey(); bool flag = false; foreach (var s in b.ConfigErrors(false)) { if (!flag) { flag = true; CCL_Log.Error("Errors in custom backstory with defName: " + defName + ", backstory will be skipped.", "Backstories"); } CCL_Log.Error(defName + " error: " + s, "Backstories"); } if (!flag) { BackstoryDatabase.AddBackstory(b); //CCL_Log.Message("Added " + this.UniqueSaveKey() + " backstory", "Backstories"); } }
private void AddBackstories(bool report) { if (Config.debugRemoveAllVanillaBackstories) { BackstoryDatabase.Clear(); } int num = 0; foreach (var def in DefDatabase<BackstoryDef>.AllDefs) { if (!def.addToDatabase) continue; if (BackstoryDatabase.allBackstories.ContainsKey(def.UniqueSaveKeyFor())) continue; Backstory b = new Backstory(); if (!def.title.NullOrEmpty()) b.title = def.title; else { Log.Error(def.defName + " backstory has empty title. Skipping..."); continue; } if (!def.titleShort.NullOrEmpty()) b.titleShort = def.titleShort; else b.titleShort = b.title; b.baseDesc = def.baseDescription; b.bodyTypeGlobal = def.bodyTypeGlobal; b.bodyTypeMale = def.bodyTypeMale; b.bodyTypeFemale = def.bodyTypeFemale; b.slot = def.slot; b.shuffleable = def.shuffleable; b.spawnCategories = def.spawnCategories; if (def.workAllows.Count > 0) { foreach (WorkTags current in Enum.GetValues(typeof(WorkTags))) { if (!def.workAllows.Contains(current)) { b.workDisables |= current; } } } else if (def.workDisables.Count > 0) { foreach (var tag in def.workDisables) { b.workDisables |= tag; } } else { b.workDisables = WorkTags.None; } b.skillGains = def.skillGains.ToDictionary(i => i.defName, i => i.amount); b.ResolveReferences(); b.PostLoad(); b.uniqueSaveKey = def.UniqueSaveKeyFor(); bool flag = false; foreach (var s in b.ConfigErrors(false)) { if (!flag) { flag = true; Log.Error("Backstories! backstory errors in custom backstory with defName: " + def.defName + ", backstory will be skipped"); } Log.Error(def.defName + " error: " + s); } if (!flag) { BackstoryDatabase.AddBackstory(b); num++; } } if (num > 0 && report) Log.Warning("BackstoriesCore added " + num.ToString() + " custom backstories."); }