public override void ResolveReferences()
        {
            if (!BackstoryDatabase.TryGetWithIdentifier(identifier: this.childhoodDef, bs: out this.resolvedChildhood))
            {
                Log.Error(text: "Error in " + this.defName + ": Childhood backstory not found");
            }
            if (!BackstoryDatabase.TryGetWithIdentifier(identifier: this.adulthoodDef, bs: out this.resolvedAdulthood))
            {
                Log.Error(text: "Error in " + this.defName + ": Adulthood backstory not found");
            }

            base.ResolveReferences();

            if (this.resolvedAdulthood.slot != BackstorySlot.Adulthood || this.resolvedChildhood.slot != BackstorySlot.Childhood)
            {
                return;
            }

            PawnBio bio = new PawnBio()
            {
                gender     = this.gender,
                name       = this.name,
                childhood  = this.resolvedChildhood,
                adulthood  = this.resolvedAdulthood,
                pirateKing = this.factionLeader
            };

            if (this.resolvedAdulthood.spawnCategories.Count == 1 && this.resolvedAdulthood.spawnCategories[index : 0] == "Trader")
            {
                this.resolvedAdulthood.spawnCategories.Add(item : "Civil");
            }

            if (!bio.ConfigErrors().Any())
            {
                SolidBioDatabase.allBios.Add(item: bio);
            }
            else
            {
                Log.Error(text: this.defName + " has errors");
            }
        }
        public override void ResolveReferences()
        {
            base.ResolveReferences();

            PawnBio bio = new PawnBio();
            bio.gender = this.gender;
            bio.name = name.Name;

            bio.childhood = BackstoryDatabase.GetWithKey(this.childhoodDef.UniqueSaveKeyFor());
            bio.childhood.shuffleable = false;
            bio.childhood.slot = BackstorySlot.Childhood;

            bio.adulthood = BackstoryDatabase.GetWithKey(this.adulthoodDef.UniqueSaveKeyFor());
            bio.adulthood.shuffleable = false;
            bio.adulthood.slot = BackstorySlot.Adulthood;

            bio.name.ResolveMissingPieces();
            //bio.PostLoad();

            bool flag = false;
            foreach (var error in bio.ConfigErrors())
            {
                if (!flag)
                {
                    flag = true;
                    Log.Error("Config error(s) in PawnBioDef " + this.defName + ". Skipping...");
                }
                Log.Error(error);
            }
            if (flag)
            {
                return;
            }
            if (!SolidBioDatabase.allBios.Contains(bio))
                SolidBioDatabase.allBios.Add(bio);
        }
Exemple #3
0
        public override void ResolveReferences()
        {
            base.ResolveReferences();

            PawnBio bio = new PawnBio()
            {
                gender = this.gender
            };

            if (!this.firstName.NullOrEmpty() && !this.lastName.NullOrEmpty())
            {
                bio.name = new NameTriple(this.firstName, this.nickName, this.lastName);
            }
            else
            {
                Debug.LogError("PawnBio with defName: " + this.defName + " has empty first or last name. It will not be added." + "Backstories");
                return;
            }
            BackstoryDatabase.TryGetWithIdentifier(this.childhoodDef.defName, out Backstory childhood);
            if (childhood != null)
            {
                bio.childhood             = childhood;
                bio.childhood.shuffleable = false;
                bio.childhood.slot        = BackstorySlot.Childhood;
            }
            else
            {
                Debug.LogError("PawnBio with defName: " + this.defName + " has null childhood. It will not be added." + "Backstories");
                return;
            }
            BackstoryDatabase.TryGetWithIdentifier(this.adulthoodDef.defName, out Backstory adulthood);
            if (adulthood != null)
            {
                bio.adulthood             = adulthood;
                bio.adulthood.shuffleable = false;
                bio.adulthood.slot        = BackstorySlot.Adulthood;
            }
            else
            {
                Debug.LogError("PawnBio with defName: " + this.defName + " has null adulthood. It will not be added." + "Backstories");
                return;
            }

            bio.name.ResolveMissingPieces();

            bool flag = false;

            foreach (string error in bio.ConfigErrors())
            {
                if (!flag)
                {
                    flag = true;
                    Debug.LogError("Config error(s) in PawnBioDef " + this.defName + ". Skipping..." + "Backstories");
                }
                Debug.LogError(error + "Backstories");
            }
            if (flag)
            {
                return;
            }

            if (!SolidBioDatabase.allBios.Contains(bio))
            {
                SolidBioDatabase.allBios.Add(bio);
            }
        }
        private void AddPawnBios(bool report = false)
        {
            int num = 0;
            foreach (var def in DefDatabase<PawnBioDef>.AllDefs)
            {
                PawnBio bio = new PawnBio();
                bio.gender = def.gender;
                bio.name = def.name;

                bio.childhood = BackstoryDatabase.GetWithKey(def.childhoodDef.UniqueSaveKeyFor());
                bio.childhood.shuffleable = false;
                bio.childhood.slot = BackstorySlot.Childhood;

                bio.adulthood = BackstoryDatabase.GetWithKey(def.adulthoodDef.UniqueSaveKeyFor());
                bio.adulthood.shuffleable = false;
                bio.adulthood.slot = BackstorySlot.Adulthood;

                bio.name.ResolveMissingPieces();
                bio.PostLoad();

                bool flag = false;
                foreach (var error in bio.ConfigErrors())
                {
                    if (!flag)
                    {
                        flag = true;
                        Log.Error("Config error(s) in PawnBioDef " + def.defName + ". Skipping...");
                    }
                    Log.Error(error);
                }
                if (flag)
                {
                    continue;
                }
                SolidBioDatabase.allBios.Add(bio);
                num++;
            }
            if (num > 0 && report)
                Log.Warning("BackstoriesCore added: " + num.ToString() + " PawnBios.");
        }
Exemple #5
0
        public override void ResolveReferences()
        {
            base.ResolveReferences();

            PawnBio bio = new PawnBio();

            bio.gender = this.gender;

            if (!firstName.NullOrEmpty() && !lastName.NullOrEmpty())
            {
                bio.name = new NameTriple(firstName, nickName, lastName);
            }
            else
            {
                CCL_Log.Error("PawnBio with defName: " + defName + " has empty first or last name. It will not be added.", "Backstories");
                return;
            }

            Backstory childhood = BackstoryDatabase.GetWithKey(this.childhoodDef.UniqueSaveKey());

            if (childhood != null)
            {
                bio.childhood             = childhood;
                bio.childhood.shuffleable = false;
                bio.childhood.slot        = BackstorySlot.Childhood;
            }
            else
            {
                CCL_Log.Error("PawnBio with defName: " + defName + " has null childhood. It will not be added.", "Backstories");
                return;
            }

            Backstory adulthood = BackstoryDatabase.GetWithKey(this.adulthoodDef.UniqueSaveKey());

            if (adulthood != null)
            {
                bio.adulthood             = adulthood;
                bio.adulthood.shuffleable = false;
                bio.adulthood.slot        = BackstorySlot.Adulthood;
            }
            else
            {
                CCL_Log.Error("PawnBio with defName: " + defName + " has null adulthood. It will not be added.", "Backstories");
                return;
            }

            bio.name.ResolveMissingPieces();

            bool flag = false;

            foreach (var error in bio.ConfigErrors())
            {
                if (!flag)
                {
                    flag = true;
                    CCL_Log.Error("Config error(s) in PawnBioDef " + this.defName + ". Skipping...", "Backstories");
                }
                CCL_Log.Error(error, "Backstories");
            }
            if (flag)
            {
                return;
            }

            if (!SolidBioDatabase.allBios.Contains(bio))
            {
                SolidBioDatabase.allBios.Add(bio);
            }
        }