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.");
        }
        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");
            }
        }
Example #3
0
        public override void ResolveReferences()
        {
            if (BackstoryDatabase.allBackstories.ContainsKey(this.saveKeyIdentifier))
            {
                Log.Error(this.defName + " contains a saveKeyIdentifier value " + saveKeyIdentifier + " which is used already. It won't be added as a def. Make sure that the identifier is unique.");
                return;
            }

            Backstory backstory = new Backstory();

            if (this.forcedTraits?.Any() ?? false)
            {
                backstory.forcedTraits = new List <TraitEntry>();
                foreach (var trait in this.forcedTraits.Where(x => Rand.RangeInclusive(0, 100) < x.chance))
                {
                    backstory.forcedTraits.Add(new TraitEntry(trait.defName, trait.degree));
                }
            }

            if (this.disallowedTraits?.Any() ?? false)
            {
                backstory.disallowedTraits = new List <TraitEntry>();
                foreach (var trait in this.disallowedTraits.Where(x => Rand.RangeInclusive(0, 100) < x.chance))
                {
                    backstory.disallowedTraits.Add(new TraitEntry(trait.defName, trait.degree));
                }
            }

            backstory.SetTitle(this.title, this.title);
            if (!GenText.NullOrEmpty(this.titleShort))
            {
                backstory.SetTitleShort(this.titleShort, this.titleShort);
            }
            else
            {
                backstory.SetTitleShort(backstory.title, backstory.title);
            }
            if (!GenText.NullOrEmpty(this.baseDescription))
            {
                backstory.baseDesc = this.baseDescription;
            }

            Traverse.Create(backstory).Field("bodyTypeGlobal").SetValue(this.bodyTypeGlobal);
            Traverse.Create(backstory).Field("bodyTypeMale").SetValue(this.bodyTypeMale);
            Traverse.Create(backstory).Field("bodyTypeFemale").SetValue(this.bodyTypeFemale);
            if (skillGains?.Any() ?? false)
            {
                var skillGainsDict = skillGains.ToDictionary(x => x.skill.defName, y => y.minLevel);
                Traverse.Create(backstory).Field("skillGains").SetValue(skillGainsDict);
            }

            backstory.slot            = this.slot;
            backstory.shuffleable     = this.shuffleable;
            backstory.spawnCategories = this.spawnCategories;

            if (this.workDisables.Any())
            {
                foreach (var workTag in this.workDisables)
                {
                    backstory.workDisables |= workTag;
                }
            }
            else
            {
                backstory.workDisables = WorkTags.None;
            }

            backstory.PostLoad();
            backstory.ResolveReferences();
            backstory.identifier = this.saveKeyIdentifier;

            if (!backstory.ConfigErrors(true).Any())
            {
                BackstoryDatabase.AddBackstory(backstory);
            }
            else
            {
                foreach (var err in backstory.ConfigErrors(true))
                {
                    Log.Error(backstory + " - " + err);
                }
            }
        }
Example #4
0
        public override void ResolveReferences()
        {
            base.ResolveReferences();
            if (!this.addToDatabase)
            {
                return;
            }
            if (BackstoryDatabase.allBackstories.ContainsKey(this.UniqueSaveKey()))
            {
                Log.Error("Backstory Error (" + this.defName + "): Duplicate defName.");
                return;
            }
            Backstory b = new Backstory();

            if (!this.title.NullOrEmpty())
            {
                b.SetTitle(this.title, this.title);
            }
            else
            {
                return;
            }
            if (!titleShort.NullOrEmpty())
            {
                b.SetTitleShort(titleShort, titleShort);
            }
            else
            {
                b.SetTitleShort(b.title, b.title);
            }
            if (!baseDesc.NullOrEmpty())
            {
                b.baseDesc = baseDesc;
            }
            else
            {
                b.baseDesc = "Empty.";
            }
            bool bodyTypeSet = false;

            if (!string.IsNullOrEmpty(bodyTypeGlobal))
            {
                bodyTypeSet = SetGlobalBodyType(b, bodyTypeGlobal);
            }
            if (!bodyTypeSet)
            {
                if (!SetMaleBodyType(b, bodyTypeMale))
                {
                    SetMaleBodyType(b, "Male");
                }
                if (!SetFemaleBodyType(b, bodyTypeFemale))
                {
                    SetFemaleBodyType(b, "Female");
                }
            }
            b.slot        = slot;
            b.shuffleable = shuffleable;
            if (spawnCategories.NullOrEmpty())
            {
                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;
            }
            if (requiredWorkTags.Count > 0)
            {
                foreach (var tag in requiredWorkTags)
                {
                    b.requiredWorkTags |= tag;
                }
            }
            else
            {
                b.requiredWorkTags = WorkTags.None;
            }
            Dictionary <SkillDef, int> skillDefs = new Dictionary <SkillDef, int>();

            foreach (BackstoryDefSkillListItem skillGain in this.skillGains)
            {
                SkillDef named = DefDatabase <SkillDef> .GetNamed(skillGain.key, false);

                if (named == null)
                {
                    Log.Error(string.Concat(new string[] { "Tribal Raiders: Unable to find SkillDef of [", skillGain.key, "] for Backstory.Title [", b.title, "]" }), false);
                    continue;
                }
                skillDefs.Add(named, skillGain.@value);
            }
            b.skillGainsResolved = skillDefs;
            Dictionary <string, int> fTraitList = forcedTraits.ToDictionary(i => i.key, i => i.value);

            if (fTraitList.Count > 0)
            {
                b.forcedTraits = new List <TraitEntry>();
                foreach (KeyValuePair <string, int> trait in fTraitList)
                {
                    b.forcedTraits.Add(new TraitEntry(TraitDef.Named(trait.Key), trait.Value));
                }
            }
            Dictionary <string, int> dTraitList = disallowedTraits.ToDictionary(i => i.key, i => i.value);

            if (dTraitList.Count > 0)
            {
                b.disallowedTraits = new List <TraitEntry>();
                foreach (KeyValuePair <string, int> trait in dTraitList)
                {
                    b.disallowedTraits.Add(new TraitEntry(TraitDef.Named(trait.Key), trait.Value));
                }
            }
            b.ResolveReferences();
            b.PostLoad();
            b.identifier = this.UniqueSaveKey();
            bool flag2 = false;

            foreach (var s in b.ConfigErrors(false))
            {
                Log.Error("Backstory Error (" + b.identifier + "): " + s);
                if (!flag2)
                {
                    flag2 = true;
                }
            }
            if (!flag2)
            {
                BackstoryDatabase.allBackstories.Add(b.identifier, b);
            }
        }
        public override void ResolveReferences()
        {
            base.ResolveReferences();
            if (!this.addToDatabase)
            {
                return;
            }
            if (BackstoryDatabase.allBackstories.ContainsKey(this.UniqueSaveKey()))
            {
                Log.Error("Backstory Error (" + this.defName + "): Duplicate defName.");
                return;
            }
            Backstory b = new Backstory();

            if (!string.IsNullOrEmpty(this.title) || !string.IsNullOrEmpty(this.titleFemale))
            {
                b.SetTitle((string.IsNullOrEmpty(this.title) ? this.titleFemale : this.title), (string.IsNullOrEmpty(this.titleFemale) ? this.title : this.titleFemale));
            }
            else
            {
                return;
            }
            if (!string.IsNullOrEmpty(titleShort) || !string.IsNullOrEmpty(titleShortFemale))
            {
                b.SetTitleShort((string.IsNullOrEmpty(this.titleShort) ? this.titleShortFemale : this.titleShort), (string.IsNullOrEmpty(this.titleShortFemale) ? this.titleShort : this.titleShortFemale));
            }
            else
            {
                b.SetTitleShort((string.IsNullOrEmpty(this.title) ? this.titleFemale : this.title), (string.IsNullOrEmpty(this.titleFemale) ? this.title : this.titleFemale));
            }
            if (!baseDesc.NullOrEmpty())
            {
                b.baseDesc = baseDesc;
            }
            else
            {
                b.baseDesc = "Empty.";
            }
            bool bodyTypeSet = false;

            if (!string.IsNullOrEmpty(bodyTypeGlobal))
            {
                bodyTypeSet = SetGlobalBodyType(b, bodyTypeGlobal);
            }
            if (!bodyTypeSet)
            {
                if (!SetMaleBodyType(b, bodyTypeMale))
                {
                    SetMaleBodyType(b, "Male");
                }
                if (!SetFemaleBodyType(b, bodyTypeFemale))
                {
                    SetFemaleBodyType(b, "Female");
                }
            }
            b.slot        = slot;
            b.shuffleable = shuffleable;
            if (spawnCategories.NullOrEmpty())
            {
                return;
            }
            else
            {
                for (int i = 0; i < spawnCategories.Count; i++)
                {
                    if (Util.Categories.Contains(spawnCategories[i]))
                    {
                        spawnCategories[i] = "REB" + spawnCategories[i];
                    }
                }
            }
            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;
            }
            if (requiredWorkTags.Count > 0)
            {
                foreach (var tag in requiredWorkTags)
                {
                    b.requiredWorkTags |= tag;
                }
            }
            else
            {
                b.requiredWorkTags = WorkTags.None;
            }
            Dictionary <SkillDef, int> d = new Dictionary <SkillDef, int>();

            foreach (BackstoryDefSkillListItem i in skillGains)
            {
                SkillDef def = DefDatabase <SkillDef> .GetNamed(i.key, false);

                if (def == null)
                {
                    if (i.key.Equals("Growing"))
                    {
                        Log.Message("Editable Backstories: Converting SkillDef of [" + i.key + "] to [" + SkillDefOf.Plants.ToString() + "] for Backstory.Title [" + b.title + "]");
                        def = SkillDefOf.Plants;
                    }
                    else
                    {
                        Log.Error("Editable Backstories: Unable to find SkillDef of [" + i.key + "] for Backstory.Title [" + b.title + "]");
                    }
                }
                if (def != null)
                {
                    d.Add(def, i.value);
                }
            }
            b.skillGainsResolved = d;
            Dictionary <string, int> fTraitList = forcedTraits.ToDictionary(i => i.key, i => i.value);

            if (fTraitList.Count > 0)
            {
                b.forcedTraits = new List <TraitEntry>();
                foreach (KeyValuePair <string, int> trait in fTraitList)
                {
                    b.forcedTraits.Add(new TraitEntry(TraitDef.Named(trait.Key), trait.Value));
                }
            }
            Dictionary <string, int> dTraitList = disallowedTraits.ToDictionary(i => i.key, i => i.value);

            if (dTraitList.Count > 0)
            {
                b.disallowedTraits = new List <TraitEntry>();
                foreach (KeyValuePair <string, int> trait in dTraitList)
                {
                    b.disallowedTraits.Add(new TraitEntry(TraitDef.Named(trait.Key), trait.Value));
                }
            }
            b.ResolveReferences();
            b.PostLoad();
            b.identifier = this.UniqueSaveKey();
            bool skip = false;

            foreach (var s in b.ConfigErrors(false))
            {
                Log.Error("Backstory Error (" + b.identifier + "): " + s);
                skip = true;
            }
            if (!skip)
            {
                if (b.slot.Equals(BackstorySlot.Adulthood))
                {
                    if (b.shuffleable.Equals(true))
                    {
                        REB_Initializer.adultCount++;
                    }
                    else
                    {
                        REB_Initializer.adultNSCount++;
                    }
                }
                if (b.slot.Equals(BackstorySlot.Childhood))
                {
                    if (b.shuffleable.Equals(true))
                    {
                        REB_Initializer.childCount++;
                    }
                    else
                    {
                        REB_Initializer.childNSCount++;
                    }
                }
                BackstoryDatabase.allBackstories[b.identifier] = b;
            }
        }
        public override void ResolveReferences()
        {
            base.ResolveReferences();

            WorkTags workDisables = WorkTags.None;

            if (this.workDisables != null)
            {
                this.workDisables.ForEach(x => workDisables |= x);
            }

            WorkTags requiredWorkTags = WorkTags.None;

            if (this.requiredWorkTags != null)
            {
                this.requiredWorkTags.ForEach(x => requiredWorkTags |= x);
            }

            List <TraitEntry> forcedTraits = new List <TraitEntry>();

            if (this.forcedTraits != null)
            {
                this.forcedTraits.ForEach(x => forcedTraits.Add(new TraitEntry(x.traitDef, x.degree)));
            }

            List <TraitEntry> disallowedTraits = new List <TraitEntry>();

            if (this.disallowedTraits != null)
            {
                this.disallowedTraits.ForEach(x => disallowedTraits.Add(new TraitEntry(x.traitDef, x.degree)));
            }

            Dictionary <SkillDef, int> skillGainsResolved = new Dictionary <SkillDef, int>();

            if (skillGains != null)
            {
                skillGains.ForEach(x => skillGainsResolved.Add(x.skill, x.xp));
            }

            Backstory = new Backstory
            {
                identifier = defName,

                slot            = backstoryInfo.slot,
                title           = backstoryInfo.title,
                titleShort      = backstoryInfo.titleShort,
                baseDesc        = backstoryInfo.description,
                spawnCategories = spawnCategories,

                workDisables       = workDisables,
                requiredWorkTags   = requiredWorkTags,
                forcedTraits       = forcedTraits,
                disallowedTraits   = disallowedTraits,
                skillGainsResolved = skillGainsResolved
            };
            Traverse.Create(Backstory).Field("bodyTypeMaleResolved").SetValue(BodyTypeDefOf.Male);
            Traverse.Create(Backstory).Field("bodyTypeFemaleResolved").SetValue(BodyTypeDefOf.Female);
            Backstory.ResolveReferences();
            Backstory.PostLoad();
            Backstory.identifier = defName;

            IEnumerable <string> errors = Backstory.ConfigErrors(false);

            if (errors.Any())
            {
                RaceAddon.Notify("BackstoryDef has errors! => " + defName + string.Join("\n", errors.ToArray()), true);
            }
            else
            {
                BackstoryDatabase.AddBackstory(Backstory);
            }
        }
Example #7
0
        public override void ResolveReferences()
        {
            base.ResolveReferences();


            if (!this.addToDatabase || BackstoryDatabase.allBackstories.ContainsKey(this.defName) || this.title.NullOrEmpty() || this.spawnCategories.NullOrEmpty())
            {
                return;
            }

            Backstory b = new Backstory()
            {
                baseDesc         = this.baseDescription.NullOrEmpty() ? "Empty." : this.baseDescription,
                bodyTypeGlobal   = this.bodyTypeGlobal,
                bodyTypeFemale   = this.bodyTypeFemale,
                bodyTypeMale     = this.bodyTypeMale,
                slot             = this.slot,
                shuffleable      = this.shuffleable,
                spawnCategories  = this.spawnCategories,
                skillGains       = this.skillGains.ToDictionary(i => i.defName, i => i.amount),
                forcedTraits     = this.forcedTraits.NullOrEmpty() ? null : this.forcedTraits.Where(trait => Rand.Range(0, 100) < trait.chance).ToList().ConvertAll(trait => new TraitEntry(TraitDef.Named(trait.defname), trait.degree)),
                disallowedTraits = this.disallowedTraits.NullOrEmpty() ? null : this.disallowedTraits.Where(trait => Rand.Range(0, 100) < trait.chance).ToList().ConvertAll(trait => new TraitEntry(TraitDef.Named(trait.defname), trait.degree)),
                workDisables     = this.workAllows.NullOrEmpty() ? this.workDisables.NullOrEmpty() ? WorkTags.None : ((Func <WorkTags>) delegate
                {
                    WorkTags wt = WorkTags.None;
                    this.workDisables.ForEach(tag => wt |= tag);
                    return(wt);
                })() : ((Func <WorkTags>) delegate
                {
                    WorkTags wt = WorkTags.None;
                    Enum.GetValues(typeof(WorkTags)).Cast <WorkTags>().ToList().ForEach(tag => { if (this.workAllows.Contains(tag))
                                                                                                 {
                                                                                                     wt |= tag;
                                                                                                 }
                                                                                        });
                    return(wt);
                })(),
                identifier = this.defName
            };

            b.SetTitle(this.title);
            if (!this.titleShort.NullOrEmpty())
            {
                b.SetTitleShort(this.titleShort);
            }
            else
            {
                b.SetTitleShort(b.Title);
            }

            b.ResolveReferences();
            b.PostLoad();

            b.identifier = this.defName;

            IEnumerable <string> errors;

            if (!(errors = b.ConfigErrors(false)).Any())
            {
                BackstoryDatabase.AddBackstory(b);
            }
            else
            {
                Log.Error(this.defName + " has errors: " + string.Join("\n", errors.ToArray()));
            }
        }
Example #8
0
        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
            {
                return;
            }
            if (!titleShort.NullOrEmpty())
            {
                b.titleShort = titleShort;
            }
            else
            {
                b.titleShort = b.title;
            }

            if (!baseDescription.NullOrEmpty())
            {
                b.baseDesc = baseDescription;
            }
            else
            {
                b.baseDesc = "Empty.";
            }

            b.bodyTypeGlobal = bodyTypeGlobal;
            b.bodyTypeMale   = bodyTypeMale;
            b.bodyTypeFemale = bodyTypeFemale;

            b.slot = slot;

            b.shuffleable = shuffleable;
            if (spawnCategories.NullOrEmpty())
            {
                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);

            if (forcedTraits.Count > 0)
            {
                b.forcedTraits = new List <TraitEntry>();
                foreach (var trait in forcedTraits)
                {
                    var newTrait = new TraitEntry(trait.def, trait.degree);
                    b.forcedTraits.Add(newTrait);
                }
            }

            if (disallowedTraits.Count > 0)
            {
                b.disallowedTraits = new List <TraitEntry>();
                foreach (var trait in disallowedTraits)
                {
                    var newTrait = new TraitEntry(trait.def, trait.degree);
                    b.disallowedTraits.Add(newTrait);
                }
            }

            b.ResolveReferences();
            b.PostLoad();
            b.uniqueSaveKey = this.UniqueSaveKey();

            bool flag = false;

            foreach (var s in b.ConfigErrors(false))
            {
                if (!flag)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                BackstoryDatabase.AddBackstory(b);
                //CCL_Log.Message("Added " + this.UniqueSaveKey() + " backstory", "Backstories");
            }
        }
        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.SetTitle(this.title, this.title);
            }
            else
            {
                return;
            }
            if (!titleShort.NullOrEmpty())
            {
                b.SetTitleShort(titleShort, titleShort);
            }
            else
            {
                b.SetTitleShort(b.title, b.title);
            }

            if (!baseDescription.NullOrEmpty())
            {
                b.baseDesc = baseDescription;
            }
            else
            {
                b.baseDesc = "Empty.";
            }

            // [B19] These are now private variables.
            Traverse.Create(b).Field("bodyTypeGlobal").SetValue(bodyTypeGlobal);
            Traverse.Create(b).Field("bodyTypeMale").SetValue(bodyTypeMale);
            Traverse.Create(b).Field("bodyTypeFemale").SetValue(bodyTypeFemale);

            b.slot = slot;

            b.shuffleable = shuffleable;
            if (spawnCategories.NullOrEmpty())
            {
                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;
            }
            Dictionary <string, int> skGains = skillGains.ToDictionary(i => i.defName, i => i.amount);

            foreach (KeyValuePair <string, int> current in skGains)
            {
                b.skillGainsResolved.Add(DefDatabase <SkillDef> .GetNamed(current.Key, true), current.Value);
            }

            if (forcedTraits.Count > 0)
            {
                b.forcedTraits = new List <TraitEntry>();
                foreach (var trait in forcedTraits)
                {
                    var newTrait = new TraitEntry(trait.def, trait.degree);
                    b.forcedTraits.Add(newTrait);
                }
            }

            if (disallowedTraits.Count > 0)
            {
                b.disallowedTraits = new List <TraitEntry>();
                foreach (var trait in disallowedTraits)
                {
                    var newTrait = new TraitEntry(trait.def, trait.degree);
                    b.disallowedTraits.Add(newTrait);
                }
            }

            b.ResolveReferences();
            b.PostLoad();
            b.identifier = this.UniqueSaveKey();

            bool flag = false;

            foreach (var s in b.ConfigErrors(false))
            {
                if (!flag)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                BackstoryDatabase.AddBackstory(b);
                //Log.Message("Added " + this.UniqueSaveKey() + " backstory");
                //CCL_Log.Message("Added " + this.UniqueSaveKey() + " backstory", "Backstories");
            }
        }
Example #10
0
        static PostDefFixer()
        {
            //Add recipes to valid Genome Sequencing targets.
            foreach (ThingDef def in DefDatabase <ThingDef> .AllDefs.Where(def => def.category == ThingCategory.Pawn))
            {
                if (def.GetModExtension <RaceExclusionProperties>() is RaceExclusionProperties props)
                {
                    if (props.excludeThisRace)
                    {
                        GeneralCompatibility.excludedRaces.Add(def);
                    }

                    if (props.excludeTheseHediffs.Count > 0)
                    {
                        GeneralCompatibility.excludedHediffs.AddRange(props.excludeTheseHediffs);
                    }
                }

                if (def.IsValidGenomeSequencingTargetDef())
                {
                    if (def.recipes == null)
                    {
                        def.recipes = new List <RecipeDef>();
                    }
                    if (def.recipes.Count > 0)
                    {
                        def.recipes.Insert(0, QERecipeDefOf.QE_GenomeSequencing);
                    }
                    else
                    {
                        def.recipes.Add(QERecipeDefOf.QE_GenomeSequencing);
                    }
                }

                if (def.IsValidBrainScanningDef())
                {
                    if (def.recipes == null)
                    {
                        def.recipes = new List <RecipeDef>();
                    }
                    if (def.recipes.Count > 0)
                    {
                        def.recipes.Insert(0, QERecipeDefOf.QE_BrainScanning);
                    }
                    else
                    {
                        def.recipes.Add(QERecipeDefOf.QE_BrainScanning);
                    }
                }
            }

            //Inject our own backstories.
            foreach (BackstoryDef def in DefDatabase <BackstoryDef> .AllDefs)
            {
                Backstory backstory = new Backstory();
                backstory.slot             = def.slot;
                backstory.title            = def.title;
                backstory.titleShort       = def.titleShort;
                backstory.titleFemale      = def.titleFemale;
                backstory.titleShortFemale = def.titleShortFemale;
                backstory.baseDesc         = def.baseDesc;
                AccessTools.Field(typeof(Backstory), "bodyTypeFemale").SetValue(backstory, def.bodyTypeFemale);
                AccessTools.Field(typeof(Backstory), "bodyTypeMale").SetValue(backstory, def.bodyTypeMale);
                AccessTools.Field(typeof(Backstory), "bodyTypeGlobal").SetValue(backstory, def.bodyTypeGlobal);
                backstory.spawnCategories.AddRange(def.spawnCategories);
                backstory.PostLoad();
                backstory.ResolveReferences();

                BackstoryDatabase.AddBackstory(backstory);

                def.identifier = backstory.identifier;
                //Log.Message("'" + def.defName + "' identifier is '" + backstory.identifier + "'");
            }
        }
Example #11
0
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                /* Mod settings */

                toggleEmpathy        = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey         = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode           = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleIndividuality  = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);
                toggleElections      = Settings.GetHandle <bool>("EnableElections", "ElectionsTitle".Translate(), "ElectionsTooltip".Translate(), true);
                conversationDuration = Settings.GetHandle <float>("ConversationDuration", "DurationTitle".Translate(), "DurationTooltip".Translate(), 60f, (String s) => float.Parse(s) >= 15f && float.Parse(s) <= 180f);
                toggleDateLetters    = Settings.GetHandle <bool>("SendDateLetters", "SendDateLettersTitle".Translate(), "SendDateLettersTooltip".Translate(), true);
                toggleBenchmarking   = Settings.GetHandle <bool>("Benchmarking", "BenchmarkingTitle".Translate(), "BenchmarkingTooltip".Translate(), false);

                kinsey        = toggleKinsey.Value;
                notBabyMode   = toggleIndividuality.Value;
                elections     = toggleElections.Value;
                dateLetters   = toggleDateLetters.Value;
                benchmark     = toggleBenchmarking.Value;
                convoDuration = conversationDuration.Value;

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                }

                /* Mod conflict detection */

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                    }
                    kinsey = false;
                }

                /* Conditional vanilla Def edits */

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    knowGuestExecuted = ModifyThoughtStages(knowGuestExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    knowColonistExecuted = ModifyThoughtStages(knowColonistExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    knowPrisonerDiedInnocent = ModifyThoughtStages(knowPrisonerDiedInnocent, new int[] { -4 });
                }
                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    knowColonistDied = ModifyThoughtStages(knowColonistDied, new int[] { -2 });
                }
                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistBanished", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    colonistAbandoned = ModifyThoughtStages(colonistAbandoned, new int[] { -2 });
                }
                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistBanishedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    colonistAbandonedToDie = ModifyThoughtStages(colonistAbandonedToDie, new int[] { -4 });
                }
                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerBanishedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    prisonerAbandonedToDie = ModifyThoughtStages(prisonerAbandonedToDie, new int[] { -3 });
                }
                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    knowPrisonerSold = ModifyThoughtStages(knowPrisonerSold, new int[] { -4 });
                }
                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    knowGuestOrganHarvested = ModifyThoughtStages(knowGuestOrganHarvested, new int[] { -4 });
                }
                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }
                ThoughtDef beauty = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }

                /* ThingDef injection reworked by notfood */
                var zombieThinkTree = DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie");

                IEnumerable <ThingDef> things = (
                    from def in DefDatabase <ThingDef> .AllDefs
                    where def.race?.intelligence == Intelligence.Humanlike &&
                    !def.defName.Contains("AIPawn") && !def.defName.Contains("Android") && !def.defName.Contains("Robot") &&
                    (zombieThinkTree == null || def.race.thinkTreeMain != zombieThinkTree)
                    select def
                    );

                List <string> registered = new List <string>();
                foreach (ThingDef t in things)
                {
                    if (t.inspectorTabsResolved == null)
                    {
                        t.inspectorTabsResolved = new List <InspectTabBase>(1);
                    }
                    t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Psyche)));

                    if (t.recipes == null)
                    {
                        t.recipes = new List <RecipeDef>(6);
                    }
                    t.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                    t.recipes.Add(RecipeDefOfPsychology.TreatChemicalInterest);
                    t.recipes.Add(RecipeDefOfPsychology.TreatChemicalFascination);
                    t.recipes.Add(RecipeDefOfPsychology.TreatDepression);
                    t.recipes.Add(RecipeDefOfPsychology.TreatInsomnia);
                    t.recipes.Add(RecipeDefOfPsychology.CureAnxiety);

                    if (t.comps == null)
                    {
                        t.comps = new List <CompProperties>(1);
                    }
                    t.comps.Add(new CompProperties_Psychology());

                    if (!t.race.hediffGiverSets.NullOrEmpty())
                    {
                        if (t.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                        {
                            t.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                        }
                    }
                    registered.Add(t.defName);
                }
                if (Prefs.DevMode && Prefs.LogVerbose)
                {
                    Log.Message("Psychology :: Registered " + string.Join(", ", registered.ToArray()));
                }

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Traverse.Create(child).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(child).Field("bodyTypeFemale").SetValue("Female");
                child.slot = BackstorySlot.Childhood;
                child.SetTitle("Child soldier", "Child soldier");
                child.SetTitleShort("Scout", "Scout");
                child.baseDesc = "[PAWN_nameDef] was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and [PAWN_pronoun] was conscripted at a young age into the military to serve as a scout due to [PAWN_possessive] runner's build. [PAWN_pronoun] learned how to use a gun, patch wounds on the battlefield, and communicate with [PAWN_possessive] squad. It was there [PAWN_pronoun] earned [PAWN_possessive] nickname.";
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Shooting", 4);
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Medicine", 2);
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                child.requiredWorkTags = WorkTags.Violent;
                child.shuffleable      = false;
                child.PostLoad();
                child.ResolveReferences();
                Backstory adultMale = new Backstory();
                Traverse.Create(adultMale).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(adultMale).Field("bodyTypeFemale").SetValue("Female");
                adultMale.slot = BackstorySlot.Adulthood;
                adultMale.SetTitle("Missing in action", "Missing in action");
                adultMale.SetTitleShort("Ex-P.O.W.", "Ex-P.O.W.");
                adultMale.baseDesc = "Eventually, [PAWN_pronoun] was captured on a mission by one of [PAWN_possessive] faction's many enemies. [PAWN_pronoun] was tortured for information, the techniques of which [PAWN_pronoun] never forgot. When they could get no more out of [PAWN_objective], [PAWN_pronoun] was sent to a prison camp, where [PAWN_pronoun] worked for years before staging an escape and fleeing into civilization.";
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Crafting", 4);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Construction", 3);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Mining", 2);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                adultMale.spawnCategories = new List <string>();
                adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultMale.shuffleable = false;
                adultMale.PostLoad();
                adultMale.ResolveReferences();
                Backstory adultFemale = new Backstory();
                Traverse.Create(adultFemale).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(adultFemale).Field("bodyTypeFemale").SetValue("Female");
                adultFemale.slot = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic", "Battlefield medic");
                adultFemale.SetTitleShort("Medic", "Medic");
                adultFemale.baseDesc = "[PAWN_pronoun] continued to serve in the military, being promoted through the ranks as [PAWN_possessive] skill increased. [PAWN_pronoun] learned how to treat more serious wounds as [PAWN_possessive] role slowly transitioned from scout to medic, as well as how to make good use of army rations. [PAWN_pronoun] built good rapport with [PAWN_possessive] squad as a result.";
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Shooting", 4);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Medicine", 3);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Cooking", 2);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();
                PawnBio male = new PawnBio();
                male.childhood = child;
                male.adulthood = adultMale;
                male.gender    = GenderPossibility.Male;
                male.name      = NameTriple.FromString("Jason 'Jackal' Tarai");
                male.PostLoad();
                SolidBioDatabase.allBios.Add(male);
                PawnBio female = new PawnBio();
                female.childhood = child;
                female.adulthood = adultFemale;
                female.gender    = GenderPossibility.Female;
                female.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                female.PostLoad();
                SolidBioDatabase.allBios.Add(female);
                BackstoryDatabase.AddBackstory(child);
                BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }
Example #12
0
        public void GetNeoChildStory(ref Backstory _bs, int _index = 0)
        {
            tempBS = new Backstory();
            int i = 0;

            if (_index == 0)
            {
                i = Rand.Range(1, intChildStoriesAmount + 1);
            }
            else
            {
                i = _index;
            }

            try
            {
                switch (i)
                {
                case 1:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Amateur astronomer");
                    tempBS.SetTitleShort("Astronomer");
                    tempBS.baseDesc   = "NAME was fascinated with the stars. HECAP would spend hours gazing at night. HECAP has even made discoveries unkown to most scholars.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Artistic", 1 }, { "Intellectual", 3 }, { "Social", 1 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 2:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Amateur botanist");
                    tempBS.SetTitleShort("Botanist");
                    tempBS.baseDesc   = "Spending many summers crawling through dirt, NAME found he had quite the green thumb. Instead of learning to cook the food HE grew, HE just grew more and more.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Growing", 4 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 3:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Cave child");
                    tempBS.SetTitleShort("Cave child");
                    tempBS.baseDesc   = "NAME grew up in a large and intricate cave complex that extended deep into a mountainside. HECAP helped the adults maintain and improve the deep caves.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Construction", 2 }, { "Mining", 3 }, { "Shooting", -1 }, { "Social", 1 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 4:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Caveworld tender");
                    tempBS.SetTitleShort("Cave kid");
                    tempBS.baseDesc   = "NAME grew up in cave complex deep beneath the surface of an inhospitable world. HECAP worked with the other children tending the tribe’s fungus crops.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Construction", 2 }, { "Mining", 3 }, { "Shooting", -1 }, { "Social", 1 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 5:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Disaster survivor");
                    tempBS.SetTitleShort("Survivor");
                    tempBS.baseDesc   = "NAME was uprooted when marauders attacked HIS family farm, destroying machinery and killing farmhands and beasts alike. After the death of all HE knew, HE was left in the ruins to fend for HIMself.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Crafting", 2 }, { "Growing", 2 }, { "Melee", 2 }, { "Shooting", 1 }, { "Social", -1 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 6:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Feral child");
                    tempBS.SetTitleShort("Feral");
                    tempBS.baseDesc   = "Abandoned in the wilderness as a small child with nought but a blanket with a name embroidered on it, NAME made HIMself one with the wild. When HE was 13, HE encountered a group of hunters, who \"offered\" HIM a home.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Animals", 3 }, { "Melee", 3 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 7:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Fire keeper");
                    tempBS.SetTitleShort("Firekeep");
                    tempBS.baseDesc   = "NAME was responsible for keeping the tribe’s fire going. HECAP took this responsibility very seriously.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Construction", 1 }, { "Cooking", 2 }, { "Crafting", 2 }, { "Growing", -1 }, { "Intellectual", 2 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 8:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Fire-scarred child");
                    tempBS.SetTitleShort("Scarred");
                    tempBS.baseDesc     = "NAMED was an active child who lived an uneventful childhood until HE fell into a fire and suffered horrific burns to HIS hands and arms. Although the scars have faded, HE can't bear to be in close proximity to fire.";
                    tempBS.workDisables = WorkTags.Firefighting;
                    tempBS.skillGains   = new Dictionary <string, int> {
                        { "Artistic", 3 }, { "Growing", 2 }, { "Melee", 1 }, { "Mining", 2 }, { "Social", -1 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 9:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Frightened child");
                    tempBS.SetTitleShort("Scared");
                    tempBS.baseDesc     = "NAME grew up with a laundry list of phobias and neuroses. HECAP feared, among other things, doctors and foodborne pathogens. As a result, HE learned to cook and care for HIMself, but many of HIS fears dog HIM in adulthood.";
                    tempBS.workDisables = WorkTags.Violent;
                    tempBS.skillGains   = new Dictionary <string, int> {
                        { "Animals", -1 }, { "Construction", 1 }, { "Cooking", 3 }, { "Crafting", 1 }, { "Growing", 1 }, { "Medicine", 3 }, { "Intellectual", -1 }, { "Social", -2 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 10:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Herder");
                    tempBS.SetTitleShort("Herder");
                    tempBS.baseDesc   = "As a child, NAME tended the tribe’s muffalo herds, keeping them safe from predators and treating the sick. It was quiet work, but HE enjoyed being away from people.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Animals", 3 }, { "Medicine", 2 }, { "Melee", 2 }, { "Social", -2 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 11:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Tundra child");
                    tempBS.SetTitleShort("Ice child");
                    tempBS.baseDesc   = "Growing up on the frozen wastes of the far North, NAME only had animals and a few hard-bitten sailors as companions. The lack of social interaction made HIM develop a interest in engineering - but HE never developed any great fondness for humans.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Animals", 2 }, { "Construction", 2 }, { "Crafting", 2 }, { "Growing", -4 }, { "Melee", 2 }, { "Intellectual", 1 }, { "Social", -4 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                case 12:
                    tempBS.slot = BackstorySlot.Childhood;
                    tempBS.SetTitle("Hunting child");
                    tempBS.SetTitleShort("Hunter");
                    tempBS.baseDesc   = "NAME had an great understanding of the sling and bow. HECAP spent hours almost everyday perfecting HIS shot. HECAP wanted to be the best hunter that ever lived.";
                    tempBS.skillGains = new Dictionary <string, int> {
                        { "Animals", 1 }, { "Crafting", 2 }, { "Shooting", 3 }
                    };
                    tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                    tempBS.bodyTypeMale    = BodyType.Male;
                    tempBS.bodyTypeFemale  = BodyType.Female;
                    break;

                default:
                    Log.Message("ProBackstories.GetNeoChildStory failed switch.");
                    break;
                }
            }
            catch (Exception e)
            {
                Log.Message(e.TargetSite.Name + " \n" + e.Message);
            }


            tempBS.PostLoad();
            tempBS.ResolveReferences();

            _bs = tempBS;
        }
Example #13
0
        public void GetNeoAdultStory(ref Backstory _bs, int _index = 0)
        {
            tempBS = new Backstory();
            int i = 0;

            if (_index == 0)
            {
                i = Rand.Range(1, intAdultStoriesAmount + 1);
            }
            else
            {
                i = _index;
            }

            switch (i)
            {
            case 1:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Foreign herd owner");
                tempBS.SetTitleShort("Herder");
                tempBS.baseDesc         = "NAME had wealthy life as a owner of a large herd in a remote and foreign land. That is, until disaster struck. Now HE strives to carve a new life among people HE can't understand. HISCAP culture is so different that HE has chosen to remain silent.";
                tempBS.workDisables     = WorkTags.Social;
                tempBS.requiredWorkTags = WorkTags.ManualSkilled | WorkTags.Animals;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", 3 }, { "Artistic", 1 }, { "Cooking", 2 }, { "Crafting", 2 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 2:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Storyteller");
                tempBS.SetTitleShort("Storyteller");
                tempBS.baseDesc         = "NAME has traveled the world gathering and recounting many legends and histories. After many years, HE now looks for place to belong.";
                tempBS.requiredWorkTags = WorkTags.Social | WorkTags.Artistic;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Artistic", 4 }, { "Construction", -4 }, { "Crafting", 1 }, { "Growing", -4 }, { "Medicine", -2 }, { "Mining", -4 }, { "Social", 3 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 3:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Maker");
                tempBS.SetTitleShort("Maker");
                tempBS.baseDesc         = "NAME struggled with hunting, but when it came to farming, HE had no patients. HECAP found his calling in building and creating things. HECAP has a natural talent for making plans become a reality.";
                tempBS.workDisables     = WorkTags.PlantWork;
                tempBS.requiredWorkTags = WorkTags.ManualSkilled;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Construction", 4 }, { "Crafting", 2 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 4:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Warrior cook");
                tempBS.SetTitleShort("Cook");
                tempBS.baseDesc         = "NAME joined a raiding tribe and spent most of HIS time cooking and repairing. During HIS travels, HE managed to get a basic knoweldge of combat.";
                tempBS.requiredWorkTags = WorkTags.ManualSkilled | WorkTags.Violent | WorkTags.Cooking;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", -1 }, { "Construction", 1 }, { "Cooking", 3 }, { "Growing", -2 }, { "Medicine", -1 }, { "Melee", 3 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 5:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Adornment crafter");
                tempBS.SetTitleShort("Crafter");
                tempBS.baseDesc         = "Name was quite good at making tinkets and pendants. As people traded HIM goods for these, NAME soon found that HE could spend all of HIS time and energy crafting more complicated and intrquet things.";
                tempBS.requiredWorkTags = WorkTags.ManualSkilled | WorkTags.Artistic | WorkTags.Crafting;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", -4 }, { "Artistic", 3 }, { "Crafting", 4 }, { "Growing", -4 }, { "Melee", -2 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 6:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Stalwart farmer");
                tempBS.SetTitleShort("Farmer");
                tempBS.baseDesc         = "NAME had deadly shot with the bow and arrow, but that couldn't save HIS farm from the brigands. HECAP had done such a good job growing wheat and vegetables, people thought it was the soil. ";
                tempBS.workDisables     = WorkTags.None;
                tempBS.requiredWorkTags = WorkTags.PlantWork | WorkTags.Violent | WorkTags.ManualDumb | WorkTags.Hauling;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", -2 }, { "Artistic", -2 }, { "Construction", 0 }, { "Cooking", 0 }, { "Crafting", 0 }, { "Growing", 4 }
                    , { "Medicine", 0 }, { "Melee", 0 }, { "Mining", -2 }, { "Intellectual", 0 }, { "Shooting", 3 }, { "Social", -4 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 7:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Forest shaman");
                tempBS.SetTitleShort("Shaman");
                tempBS.baseDesc         = "NAME stuidied the shamanistic ways, but was dissatisified with HIS tribe elders. HECAP chose to wander the forests and practice HIS learnings until HS could find a place that needed HIM most.";
                tempBS.workDisables     = WorkTags.None;
                tempBS.requiredWorkTags = WorkTags.Caring | WorkTags.Animals | WorkTags.PlantWork;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", 2 }, { "Artistic", 0 }, { "Construction", -4 }, { "Cooking", 0 }, { "Crafting", -4 }, { "Growing", 2 }
                    , { "Medicine", 4 }, { "Melee", 0 }, { "Mining", -4 }, { "Intellectual", 0 }, { "Shooting", 0 }, { "Social", 0 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 8:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Runaway mine slave");
                tempBS.SetTitleShort("Ex slave");
                tempBS.baseDesc         = "NAME was captured by a hostile clan and forced to mine stone and flint as a slave. Secretly the slaves practiced combat until the day came where they incited a massive revolt and fought their way to freedom. NAME can never pick at stone again without remembering the horrors HE endured as a cruely treated slave.";
                tempBS.workDisables     = WorkTags.Mining;
                tempBS.requiredWorkTags = WorkTags.ManualDumb | WorkTags.Violent | WorkTags.Hauling;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", 0 }, { "Artistic", 0 }, { "Construction", 2 }, { "Cooking", 0 }, { "Crafting", 0 }, { "Growing", 0 }
                    , { "Medicine", 1 }, { "Melee", 3 }, { "Mining", 0 }, { "Intellectual", 0 }, { "Shooting", 2 }, { "Social", 0 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 9:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Gold miner");
                tempBS.SetTitleShort("Miner");
                tempBS.baseDesc         = "NAME made HIS mark in the world when HE joined a lucrative gold mining community deep in the jungle mountains. HECAP learned a lot about life, but most of all, HE learned how to mine and HE learned how to grow food in the harshest conditions.";
                tempBS.workDisables     = WorkTags.None;
                tempBS.requiredWorkTags = WorkTags.ManualSkilled | WorkTags.ManualDumb | WorkTags.Hauling | WorkTags.PlantWork | WorkTags.Mining;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", -3 }, { "Artistic", -3 }, { "Construction", 0 }, { "Cooking", -3 }, { "Crafting", -3 }, { "Growing", 3 }
                    , { "Medicine", -2 }, { "Melee", 1 }, { "Mining", 4 }, { "Intellectual", 0 }, { "Shooting", 0 }, { "Social", 0 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 10:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Lore keeper");
                tempBS.SetTitleShort("Keeper");
                tempBS.baseDesc         = "NAME learned to read and write from a long line of lore keepers in HIS tribe. HECAP would stay up by fire every night and work on scrolls to pass on knowledge and helpful wisdom. It is through this mass of information that NAME now finds HIS purpose.";
                tempBS.workDisables     = WorkTags.None;
                tempBS.requiredWorkTags = WorkTags.Social | WorkTags.Intellectual;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", 0 }, { "Artistic", 0 }, { "Construction", 0 }, { "Cooking", 0 }, { "Crafting", 0 }, { "Growing", 0 }
                    , { "Medicine", 0 }, { "Melee", 0 }, { "Mining", 0 }, { "Intellectual", 4 }, { "Shooting", 0 }, { "Social", 0 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 11:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Cave tribe hunter");
                tempBS.SetTitleShort("Hunter");
                tempBS.baseDesc         = "NAME would leave HIS tribe's cave system and only return home once HE had a fresh kill. NAME was usually home by sunset. HISCAP tribe would have loved HIM, if HE only learned to clean up after HIMSELF. And this is coming from cave people.";
                tempBS.workDisables     = WorkTags.Cleaning;
                tempBS.requiredWorkTags = WorkTags.Violent | WorkTags.Animals | WorkTags.Hauling | WorkTags.Mining;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", 0 }, { "Artistic", -2 }, { "Construction", 1 }, { "Cooking", 0 }, { "Crafting", 0 }, { "Growing", 0 }
                    , { "Medicine", 0 }, { "Melee", 2 }, { "Mining", 2 }, { "Intellectual", -4 }, { "Shooting", 4 }, { "Social", -4 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            case 12:
                tempBS.slot = BackstorySlot.Adulthood;
                tempBS.SetTitle("Clan missionary");
                tempBS.SetTitleShort("Missionary");
                tempBS.baseDesc         = "NAME decided to devote HIS life to religious service. HECAP would do farm work by day in exchange for religious teachings in the evening. HECAP was an important member of HIS clan's society until a new warcheif took over, and kicked HIM out.";
                tempBS.workDisables     = WorkTags.None;
                tempBS.requiredWorkTags = WorkTags.ManualDumb | WorkTags.Caring | WorkTags.Social | WorkTags.Intellectual | WorkTags.Animals | WorkTags.Cleaning | WorkTags.Hauling | WorkTags.PlantWork;
                tempBS.skillGains       = new Dictionary <string, int> {
                    { "Animals", 3 }, { "Artistic", 0 }, { "Construction", 0 }, { "Cooking", -3 }, { "Crafting", -3 }, { "Growing", 2 }
                    , { "Medicine", 0 }, { "Melee", -4 }, { "Mining", 0 }, { "Intellectual", 2 }, { "Shooting", -4 }, { "Social", 3 }
                };
                tempBS.spawnCategories = new List <string>(new string[] { "New_Arrival", "Tribal" });
                tempBS.bodyTypeMale    = BodyType.Male;
                tempBS.bodyTypeFemale  = BodyType.Female;
                break;

            default:
                Log.Message("ProBackstories.GetNeoAdultStory failed switch.");
                break;
            }

            tempBS.PostLoad();
            tempBS.ResolveReferences();

            _bs = tempBS;
        }