コード例 #1
0
        private Thing CreateAnimal(EquipmentDatabaseEntry entry)
        {
            ThingDef    def     = entry.def;
            PawnKindDef kindDef = (from td in DefDatabase <PawnKindDef> .AllDefs
                                   where td.race == def
                                   select td).FirstOrDefault();

            if (kindDef != null)
            {
                Pawn pawn = PawnGenerator.GeneratePawn(kindDef, Faction.OfPlayer);
                pawn.gender = entry.gender;
                if (pawn.Name == null || pawn.Name.Numerical)
                {
                    pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, null);
                }
                if (kindDef.RaceProps.petness > 0)
                {
                    Pawn bondedColonist = Find.GameInitData.startingPawns.RandomElement <Pawn>();
                    bondedColonist.relations.AddDirectRelation(PawnRelationDefOf.Bond, pawn);
                }
                return(pawn);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
 public override IEnumerable<Thing> PlayerStartingThings() {
     List<Thing> result = new List<Thing>();
     if (animalKindDef == null) {
         return result;
     }
     for (int i=0; i<count; i++) {
         Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequestWrapper() {
             FixedGender = gender,
             Faction = Faction.OfPlayer,
             KindDef = animalKindDef,
             Context = PawnGenerationContext.NonPlayer
         }.Request);
         if (pawn.Name == null || pawn.Name.Numerical) {
             pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, null);
         }
         if (Rand.Value < bondToRandomPlayerPawnChance) {
             Pawn bonded = Find.GameInitData.startingAndOptionalPawns.RandomElement<Pawn>();
             if (!bonded.story.traits.HasTrait(TraitDefOf.Psychopath)) {
                 bonded.relations.AddDirectRelation(PawnRelationDefOf.Bond, pawn);
             }
         }
         result.Add(pawn);
     }
     return result;
 }
コード例 #3
0
ファイル: GenSpawn.cs プロジェクト: kbatbouta/WhatTheHack
 private static void NameUnnamedMechs(Thing newThing)
 {
     if (newThing is Pawn pawn && pawn.IsHacked() && (pawn.Name == null || !pawn.Name.IsValid))
     {
         pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full);
     }
 }
コード例 #4
0
        static bool Prefix(ref Pawn __result, Quest quest, PawnKindDef kindDef, Faction faction, bool allowAddictions = true, IEnumerable <TraitDef> forcedTraits = null, float biocodeWeaponChance = 0f, bool mustBeCapableOfViolence = true, Pawn extraPawnForExtraRelationChance = null, float relationWithExtraPawnChanceFactor = 0f, float biocodeApparelChance = 0f, bool ensureNonNumericName = false, bool forceGenerateNewPawn = false)
        {
            if (faction == FactionColonies.getPlayerColonyFaction())
            {
                List <PawnKindDef> list = new List <PawnKindDef>();
                foreach (ThingDef def in Find.World.GetComponent <FactionFC>().raceFilter.AllowedThingDefs)
                {
                    list.Add(def.race.AnyPawnKind);
                }



                Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(list.RandomElement(), faction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn, false, false, false, true, mustBeCapableOfViolence, 1f, false, true, true, allowAddictions, false, false, false, false, biocodeWeaponChance, extraPawnForExtraRelationChance, relationWithExtraPawnChanceFactor, null, null, forcedTraits, null, null, null, null, null, null, null, null, null)
                {
                    BiocodeApparelChance = biocodeApparelChance
                });
                if (ensureNonNumericName && (pawn.Name == null || pawn.Name.Numerical))
                {
                    pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, null);
                }
                QuestGen.AddToGeneratedPawns(pawn);
                if (!pawn.IsWorldPawn())
                {
                    Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Decide);
                }
                __result = pawn;


                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #5
0
        protected override void PostSuccessfulApply(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            pawn.health.AddHediff(WTH_DefOf.WTH_BackupBattery, pawn.TryGetReactor());
            pawn.SetFaction(Faction.OfPlayer);
            if (pawn.relations == null)
            {
                pawn.relations = new Pawn_RelationsTracker(pawn);
            }

            if (pawn.story == null)
            {
                pawn.story = new Pawn_StoryTracker(pawn);
            }
            if (pawn.ownership == null)
            {
                pawn.ownership = new Pawn_Ownership(pawn);
            }
            ExtendedPawnData pawnData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn);

            Utilities.InitWorkTypesAndSkills(pawn, pawnData);

            pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full);
            Find.LetterStack.ReceiveLetter("WTH_Letter_Success_Label".Translate(), "WTH_Letter_Success_Label_Description".Translate(new object[] { billDoer.Name.ToStringShort, pawn.Name }), LetterDefOf.PositiveEvent, pawn);
            billDoer.jobs.jobQueue.EnqueueFirst(new Job(WTH_DefOf.WTH_ClearHackingTable, pawn, pawn.CurrentBed())
            {
                count = 1
            });
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Power, OpportunityType.Important);
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Maintenance, OpportunityType.Important);
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Concept_MechanoidParts, OpportunityType.Important);
        }
コード例 #6
0
        protected override void PostSuccessfulApply(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            pawn.health.AddHediff(WTH_DefOf.WTH_BackupBattery, pawn.TryGetReactor());
            pawn.SetFaction(Faction.OfPlayer);
            if (pawn.relations == null)
            {
                pawn.relations = new Pawn_RelationsTracker(pawn);
            }

            /*
             * if (pawn.jobs.curDriver != null)
             * {
             *  pawn.jobs.posture = PawnPosture.LayingOnGroundNormal;
             * }
             */
            if (pawn.story == null)
            {
                pawn.story = new Pawn_StoryTracker(pawn);
            }
            pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full);
            Find.LetterStack.ReceiveLetter("WTH_Letter_Success_Label".Translate(), "WTH_Letter_Success_Label_Description".Translate(new object[] { billDoer.Name.ToStringShort, pawn.Name }), LetterDefOf.PositiveEvent, pawn);
            billDoer.jobs.jobQueue.EnqueueFirst(new Job(WTH_DefOf.WTH_ClearHackingTable, pawn, pawn.CurrentBed())
            {
                count = 1
            });
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Power, OpportunityType.Important);
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Maintenance, OpportunityType.Important);
        }
コード例 #7
0
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;
            PawnGenerationRequest request = new PawnGenerationRequest(kindDef.GetValue(slate), faction.GetValue(slate), PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, allowAddictions: allowAddictions.GetValue(slate) ?? true, forcedTraits: forcedTraits.GetValue(slate), biocodeWeaponChance: biocodeWeaponChance.GetValue(slate), mustBeCapableOfViolence: mustBeCapableOfViolence.GetValue(slate), colonistRelationChanceFactor: 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood: true, inhabitant: false, certainlyBeenInCryptosleep: false, forceRedressWorldPawnIfFormerColonist: false, worldPawnFactionDoesntMatter: false, extraPawnForExtraRelationChance: extraPawnForExtraRelationChance.GetValue(slate), relationWithExtraPawnChanceFactor: relationWithExtraPawnChanceFactor.GetValue(slate));

            request.BiocodeApparelChance = biocodeApparelChance.GetValue(slate);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            if (ensureNonNumericName.GetValue(slate) && (pawn.Name == null || pawn.Name.Numerical))
            {
                pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn);
            }
            if (storeAs.GetValue(slate) != null)
            {
                QuestGen.slate.Set(storeAs.GetValue(slate), pawn);
            }
            if (addToList.GetValue(slate) != null)
            {
                QuestGenUtility.AddToOrMakeList(QuestGen.slate, addToList.GetValue(slate), pawn);
            }
            if (addToLists.GetValue(slate) != null)
            {
                foreach (string item in addToLists.GetValue(slate))
                {
                    QuestGenUtility.AddToOrMakeList(QuestGen.slate, item, pawn);
                }
            }
            QuestGen.AddToGeneratedPawns(pawn);
            if (!pawn.IsWorldPawn())
            {
                Find.WorldPawns.PassToWorld(pawn);
            }
        }
コード例 #8
0
        public void RandomizeName()
        {
            Pawn       sourcePawn = randomizer.GenerateSameKindAndGenderOfPawn(state.CurrentPawn);
            Name       name       = PawnBioAndNameGenerator.GeneratePawnName(sourcePawn, NameStyle.Full, null);
            NameTriple nameTriple = name as NameTriple;

            state.CurrentPawn.Name = nameTriple;
        }
 private static void GiveShuffledBioTo(Pawn pawn, FactionDef factionType, string requiredLastName, List <BackstoryCategoryFilter> backstoryCategories)
 {
     AM_PawnBioAndNameGenerator_GiveShuffledBioTo_AdultAge_Patch.FillBackstorySlotShuffled(pawn, BackstorySlot.Childhood, ref pawn.story.childhood, pawn.story.adulthood, backstoryCategories, factionType);
     if (pawn.ageTracker.AgeBiologicalYearsFloat >= pawn.RaceProps.lifeStageAges.First(x => x.def.reproductive).minAge)
     {
         AM_PawnBioAndNameGenerator_GiveShuffledBioTo_AdultAge_Patch.FillBackstorySlotShuffled(pawn, BackstorySlot.Adulthood, ref pawn.story.adulthood, pawn.story.childhood, backstoryCategories, factionType);
     }
     pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, requiredLastName);
 }
コード例 #10
0
        public void RandomizeName(CustomPawn customPawn)
        {
            Pawn pawn = GenerateSameKindOfPawn(customPawn);

            pawn.gender = customPawn.Gender;
            Name       name       = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, null);
            NameTriple nameTriple = name as NameTriple;

            customPawn.Name = nameTriple;
        }
コード例 #11
0
    public static bool Prefix_GiveShuffledBioTo_Orkoid(Pawn pawn, FactionDef factionType, string requiredLastName, ref List <BackstoryCategoryFilter> backstoryCategories)
    {
        if (pawn == null)
        {
            return(true);
        }
        if (!pawn.RaceProps.Humanlike)
        {
            return(true);
        }
        if (pawn.ageTracker == null || pawn.health == null || pawn.story == null || pawn.RaceProps.FleshType != OGOrkThingDefOf.OG_Flesh_Orkoid)
        {
            return(true);
        }
        bool ext = pawn.kindDef.HasModExtension <BackstoryExtension>();

        if (ext)
        {
            BackstoryCategoryFilter backstoryCategoryFilter = backstoryCategories.RandomElementByWeight((BackstoryCategoryFilter c) => c.commonality);
            backstoryCategories.Clear();
            backstoryCategories.Add(backstoryCategoryFilter);
            //    Log.Message(pawn.LabelShortCap + " BackstoryExtension using "+ backstoryCategoryFilter.categories.ToCommaList());
        }
        else
        {
            //    Log.Message(pawn.LabelShortCap + " No BackstoryExtension");
        }
        if (pawn.health.hediffSet.hediffs.Any(x => x.def.defName.Contains("TM_") && (x.def.defName.Contains("Undead") || x.def.defName.Contains("Lich"))))
        {
            return(true);
        }
        if ((pawn.ageTracker.AgeBiologicalYears < 20 && (pawn.def.defName.StartsWith("OG_") || pawn.kindDef.defName.StartsWith("OG_"))) || ext)
        {
            //    Log.Message(string.Format("AdMech mod pawn: {0} {1} {2}",pawn.NameShortColored, pawn.kindDef, pawn.def.modContentPack.PackageIdPlayerFacing));
            bool act = pawn.RaceProps.lifeStageAges.Any(x => x.def.reproductive);
            if (act)
            {
                if (pawn.ageTracker.AgeBiologicalYears > pawn.RaceProps.lifeStageAges.First(x => x.def.reproductive).minAge)
                {
                    FillBackstorySlotShuffled(pawn, BackstorySlot.Childhood, ref pawn.story.childhood, pawn.story.adulthood, backstoryCategories, factionType);
                    if (pawn.ageTracker.AgeBiologicalYearsFloat >= pawn.RaceProps.lifeStageAges.First(x => x.def.reproductive).minAge)
                    {
                        FillBackstorySlotShuffled(pawn, BackstorySlot.Adulthood, ref pawn.story.adulthood, pawn.story.childhood, backstoryCategories, factionType);
                    }
                    pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, requiredLastName);
                    return(false);
                }
            }
        }
        return(true);
    }
        public static void GiveShuffledBioTo_AdultAge_Postfix(Pawn pawn, FactionDef factionType, string requiredLastName, List <string> backstoryCategories)
        {
            //    MethodInfo dynMethod = typeof(PawnBioAndNameGenerator).GetMethod("FillBackstorySlotShuffled", BindingFlags.NonPublic | BindingFlags.Instance);

            pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, requiredLastName);
            AM_PawnBioAndNameGenerator_GiveShuffledBioTo_AdultAge_Patch.FillBackstorySlotShuffled(pawn, BackstorySlot.Childhood, ref pawn.story.childhood, backstoryCategories, factionType);
            //    dynMethod.Invoke(typeof(PawnBioAndNameGenerator), new object[] { pawn, BackstorySlot.Childhood, pawn.story.childhood, backstoryCategories, factionType });
            if (pawn.RaceProps.lifeStageAges.First(x => x.def.reproductive) != null)
            {
                //    Log.Message(string.Format("Pawn: {0}, Comes of age at: {1}, Adult: {2}", pawn.LabelShortCap, pawn.RaceProps.lifeStageAges.First(x => x.def.reproductive).minAge, pawn.ageTracker.AgeBiologicalYearsFloat));
                if (pawn.ageTracker.AgeBiologicalYearsFloat >= pawn.RaceProps.lifeStageAges.First(x => x.def.reproductive).minAge)
                {
                    //        Log.Message(string.Format("Adult"));
                    AM_PawnBioAndNameGenerator_GiveShuffledBioTo_AdultAge_Patch.FillBackstorySlotShuffled(pawn, BackstorySlot.Adulthood, ref pawn.story.adulthood, backstoryCategories, factionType);
                    //    dynMethod.Invoke(typeof(PawnBioAndNameGenerator), new object[] { pawn, BackstorySlot.Adulthood, pawn.story.adulthood, backstoryCategories, factionType });
                }
            }
        }
コード例 #13
0
        public static Pawn GeneratePawn(this Quest quest, PawnKindDef kindDef, Faction faction, bool allowAddictions = true, IEnumerable <TraitDef> forcedTraits = null, float biocodeWeaponChance = 0f, bool mustBeCapableOfViolence = true, Pawn extraPawnForExtraRelationChance = null, float relationWithExtraPawnChanceFactor = 0f, float biocodeApparelChance = 0f, bool ensureNonNumericName = false, bool forceGenerateNewPawn = false)
        {
            bool allowAddictions2         = allowAddictions;
            bool mustBeCapableOfViolence2 = mustBeCapableOfViolence;
            PawnGenerationRequest request = new PawnGenerationRequest(kindDef, faction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence2, 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood: true, allowAddictions2, inhabitant: false, certainlyBeenInCryptosleep: false, forceRedressWorldPawnIfFormerColonist: false, worldPawnFactionDoesntMatter: false, biocodeWeaponChance, extraPawnForExtraRelationChance, relationWithExtraPawnChanceFactor, null, null, forcedTraits);

            request.BiocodeApparelChance = biocodeApparelChance;
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            if (ensureNonNumericName && (pawn.Name == null || pawn.Name.Numerical))
            {
                pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn);
            }
            QuestGen.AddToGeneratedPawns(pawn);
            if (!pawn.IsWorldPawn())
            {
                Find.WorldPawns.PassToWorld(pawn);
            }
            return(pawn);
        }
コード例 #14
0
 // Token: 0x06002241 RID: 8769 RVA: 0x00101EB8 File Offset: 0x001002B8
 public override IEnumerable <Thing> PlayerStartingThings()
 {
     for (int i = 0; i < this.count; i++)
     {
         PawnKindDef kind;
         if (this.animalKind != null)
         {
             kind = this.animalKind;
         }
         else
         {
             kind = this.RandomPets().RandomElementByWeight((PawnKindDef td) => td.RaceProps.petness);
         }
         Pawn animal = PawnGenerator.GeneratePawn(kind, Faction.OfPlayer);
         if (animal.Name == null || animal.Name.Numerical)
         {
             animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal, NameStyle.Full, null);
         }
         Rand.PushState();
         if (Rand.Value < this.bondToRandomPlayerPawnChance && animal.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted)
         {
             Pawn pawn = (from p in Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount)
                          where TrainableUtility.CanBeMaster(p, animal, false) && !p.story.traits.HasTrait(TraitDefOf.Psychopath)
                          select p).RandomElementWithFallback(null);
             if (pawn != null)
             {
                 animal.training.Train(TrainableDefOf.Obedience, null, true);
                 animal.training.SetWantedRecursive(TrainableDefOf.Obedience, true);
                 pawn.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal);
                 animal.playerSettings.Master = pawn;
             }
         }
         Rand.PopState();
         if (gender != Gender.None)
         {
             animal.gender = gender;
         }
         yield return(animal);
     }
     yield break;
 }
コード例 #15
0
        private void CheckChangePawnKindName()
        {
            NameSingle nameSingle = this.pawn.Name as NameSingle;

            if (nameSingle != null && nameSingle.Numerical)
            {
                string kindLabel = this.pawn.KindLabel;
                if (!(nameSingle.NameWithoutNumber == kindLabel))
                {
                    int    number = nameSingle.Number;
                    string text   = this.pawn.KindLabel + " " + number;
                    if (!NameUseChecker.NameSingleIsUsed(text))
                    {
                        this.pawn.Name = new NameSingle(text, true);
                    }
                    else
                    {
                        this.pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(this.pawn, NameStyle.Numeric, null);
                    }
                }
            }
        }
コード例 #16
0
        private static void Postfix(ref Pawn __result, ref PawnGenerationRequest request)
        {
            RaceAddonComp racomp = null;

            if (__result.def is RaceAddonThingDef thingDef)
            {
                // get backstorydef
                SimpleBackstoryDef simpleBackstoryDef = null;
                foreach (var backstory in __result.story.AllBackstories)
                {
                    if (DefDatabase <SimpleBackstoryDef> .AllDefsListForReading.Find(x => x.defName == backstory.identifier) is var def && def != null)
                    {
                        simpleBackstoryDef = def;
                    }
                }

                // make default setting
                racomp = __result.GetComp <RaceAddonComp>();

                float maleChance = (simpleBackstoryDef != null && simpleBackstoryDef.maleChance >= 0) ? simpleBackstoryDef.maleChance : thingDef.raceAddonSettings.basicSetting.maleChance;
                __result.gender = GetGender(maleChance, request.FixedGender);
                var gender = __result.gender;

                __result.Name = PawnBioAndNameGenerator.GeneratePawnName(__result, NameStyle.Full, request.FixedLastName);

                racomp.drawSize = RaceAddonTools.GetPawnDrawSize(__result, thingDef);
                var drawSize = thingDef.raceAddonSettings.graphicSetting.drawSize[racomp.drawSize];

                AppearanceDef appearanceDef = null;
                var           list          = (simpleBackstoryDef != null && simpleBackstoryDef.raceAppearances != null) ? simpleBackstoryDef.raceAppearances : thingDef.raceAddonSettings.graphicSetting.raceAppearances;
                if (drawSize.apparanceOverwrite.FindAll(x => x.gender == Gender.None || x.gender == gender) is var list2 && list2.Count > 0)
                {
                    appearanceDef = list2.RandomElementByWeight(x => x.weight).appearanceDef;
                }
                else if (list.FindAll(x => x.gender == Gender.None || x.gender == gender) is var list3 && list3.Count > 0)
                {
                    appearanceDef = list3.RandomElementByWeight(x => x.weight).appearanceDef;
                }
コード例 #17
0
        private void CheckChangePawnKindName()
        {
            NameSingle nameSingle = pawn.Name as NameSingle;

            if (nameSingle == null || !nameSingle.Numerical)
            {
                return;
            }
            string kindLabel = pawn.KindLabel;

            if (!(nameSingle.NameWithoutNumber == kindLabel))
            {
                int    number = nameSingle.Number;
                string text   = pawn.KindLabel + " " + number;
                if (!NameUseChecker.NameSingleIsUsed(text))
                {
                    pawn.Name = new NameSingle(text, numerical: true);
                }
                else
                {
                    pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Numeric);
                }
            }
        }
コード例 #18
0
 public static void Die(this Pawn me, StringBuilder message)
 {
     me.Name = PawnBioAndNameGenerator.GeneratePawnName(me);
     message.Append("Your pawn has been released. Someone else's problem now.");
 }
コード例 #19
0
        public static bool RaceAddonGenerator(Pawn pawn, ref PawnGenerationRequest request)
        {
            if (pawn.def is RaceAddonThingDef thingDef)
            {
                FactionDef factionDef;
                if (request.Faction != null)
                {
                    factionDef = request.Faction.def;
                }
                else if (Find.FactionManager.TryGetRandomNonColonyHumanlikeFaction_NewTemp(out Faction faction, false, true, TechLevel.Undefined))
                {
                    factionDef = faction.def;
                }
                else
                {
                    factionDef = Faction.OfAncients.def;
                }
                // Race Addon Comp
                var racomp = pawn.GetComp <RaceAddonComp>();
                // Backstory

                /*
                 * if (request.Newborn && factionDef == Find.FactionManager.OfPlayer.def && thingDef.raceAddonSettings.ageSettings[0].ageBackstory != null)
                 * {
                 *  pawn.story.childhood = thingDef.raceAddonSettings.ageSettings[0].ageBackstory.Backstory;
                 * }
                 */
                GiveAppropriateBioAndNameTo.cachedNewborn = request.Newborn;
                PawnBioAndNameGenerator.GiveAppropriateBioAndNameTo(pawn, request.FixedLastName, factionDef);
                GiveAppropriateBioAndNameTo.cachedNewborn = false;
                SimpleBackstoryDef backstoryDef = null;
                foreach (var backstory in pawn.story.AllBackstories)
                {
                    backstoryDef = backstory.GetDef();
                    if (backstoryDef != null)
                    {
                        // set age
                        bool flag1 = false;
                        bool flag2 = false;
                        if (backstoryDef.bioAgeRange.Average >= 0)
                        {
                            request.FixedBiologicalAge = backstoryDef.bioAgeRange.RandomInRange;
                            flag1 = true;
                        }
                        if (backstoryDef.chronoAgeRange.Average >= 0)
                        {
                            request.FixedChronologicalAge = flag1 ? request.FixedBiologicalAge + backstoryDef.chronoAgeRange.RandomInRange : pawn.ageTracker.AgeBiologicalYearsFloat + backstoryDef.chronoAgeRange.RandomInRange;
                            flag2 = true;
                        }
                        if (flag1 || flag2)
                        {
                            AccessTools.Method(typeof(PawnGenerator), "GenerateRandomAge").Invoke(null, new object[] { pawn, request });
                        }
                        // set gender
                        if (backstoryDef.maleChance >= 0f)
                        {
                            pawn.gender         = Rand.Chance(backstoryDef.maleChance) ? Gender.Male : Gender.Female;
                            request.FixedGender = pawn.gender;
                        }
                        else
                        {
                            pawn.gender         = Rand.Chance(thingDef.raceAddonSettings.basicSetting.maleChance) ? Gender.Male : Gender.Female;
                            request.FixedGender = pawn.gender;
                        }
                    }
                }
                // Fix Name
                pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, request.FixedLastName);
                // Choose AppearanceDef
                AppearanceDef appearanceDef = null;
                if (backstoryDef?.appearances?.GetAppearanceDef(pawn) is var def && def != null)
                {
                    appearanceDef = def;
                }