예제 #1
0
        public override IEnumerable <Thing> PlayerStartingThings()
        {
            int i = 0;

            if (i < count)
            {
                _003CPlayerStartingThings_003Ec__Iterator1 _003CPlayerStartingThings_003Ec__Iterator = (_003CPlayerStartingThings_003Ec__Iterator1) /*Error near IL_003e: stateMachine*/;
                PawnKindDef kind   = (animalKind == null) ? RandomPets().RandomElementByWeight((PawnKindDef td) => td.RaceProps.petness) : animalKind;
                Pawn        animal = PawnGenerator.GeneratePawn(kind, Faction.OfPlayer);
                if (animal.Name == null || animal.Name.Numerical)
                {
                    animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal);
                }
                if (Rand.Value < bondToRandomPlayerPawnChance && animal.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted)
                {
                    Pawn pawn = (from p in Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount)
                                 where TrainableUtility.CanBeMaster(p, animal, checkSpawned: false) && !p.story.traits.HasTrait(TraitDefOf.Psychopath)
                                 select p).RandomElementWithFallback();
                    if (pawn != null)
                    {
                        animal.training.Train(TrainableDefOf.Obedience, null, complete: true);
                        animal.training.SetWantedRecursive(TrainableDefOf.Obedience, checkOn: true);
                        pawn.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal);
                        animal.playerSettings.Master = pawn;
                    }
                }
                yield return((Thing)animal);

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
예제 #2
0
        private static bool TryGiveSolidBioTo(Pawn pawn, string requiredLastName, FactionDef factionType)
        {
            PawnBio pawnBio = PawnBioAndNameGenerator.TryGetRandomUnusedSolidBioFor(factionType.backstoryCategory, pawn.kindDef, pawn.gender, requiredLastName);
            bool    result;

            if (pawnBio == null)
            {
                result = false;
            }
            else
            {
                if (pawnBio.name.First == "Tynan" && pawnBio.name.Last == "Sylvester")
                {
                    if (Rand.Value < 0.5f)
                    {
                        pawnBio = PawnBioAndNameGenerator.TryGetRandomUnusedSolidBioFor(factionType.backstoryCategory, pawn.kindDef, pawn.gender, requiredLastName);
                    }
                }
                if (pawnBio == null)
                {
                    result = false;
                }
                else
                {
                    pawn.Name            = pawnBio.name;
                    pawn.story.childhood = pawnBio.childhood;
                    if (pawn.ageTracker.AgeBiologicalYearsFloat >= 20f)
                    {
                        pawn.story.adulthood = pawnBio.adulthood;
                    }
                    result = true;
                }
            }
            return(result);
        }
예제 #3
0
        public override IEnumerable <Thing> PlayerStartingThings()
        {
            int i = 0;

            if (i < this.count)
            {
                PawnKindDef kind   = (this.animalKind == null) ? this.RandomPets().RandomElementByWeight((PawnKindDef td) => td.RaceProps.petness) : this.animalKind;
                Pawn        animal = PawnGenerator.GeneratePawn(kind, Faction.OfPlayer);
                if (animal.Name == null || animal.Name.Numerical)
                {
                    animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal, NameStyle.Full, null);
                }
                if (Rand.Value < this.bondToRandomPlayerPawnChance)
                {
                    Pawn pawn = Find.GameInitData.startingPawns.RandomElement();
                    if (!pawn.story.traits.HasTrait(TraitDefOf.Psychopath))
                    {
                        pawn.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal);
                    }
                }
                yield return((Thing)animal);

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
 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);
         }
         if (Rand.Value < this.bondToRandomPlayerPawnChance)
         {
             Pawn pawn = Find.GameInitData.startingPawns.RandomElement <Pawn>();
             if (!pawn.story.traits.HasTrait(TraitDefOf.Psychopath))
             {
                 pawn.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal);
             }
         }
         yield return(animal);
     }
 }
 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);
         }
         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;
             }
         }
         yield return animal;
     }
 }
 public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
 {
     if (style == NameStyle.Full)
     {
         RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
         if (nameGenerator != null)
         {
             string name = NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x, false).UsedThisGame, false, null);
             return(new NameSingle(name, false));
         }
         if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
         {
             string rawName = NameGenerator.GenerateName(pawn.Faction.def.pawnNameMaker, delegate(string x)
             {
                 NameTriple nameTriple4 = NameTriple.FromString(x);
                 nameTriple4.ResolveMissingPieces(forcedLastName);
                 return(!nameTriple4.UsedThisGame);
             }, false, null);
             NameTriple nameTriple = NameTriple.FromString(rawName);
             nameTriple.CapitalizeNick();
             nameTriple.ResolveMissingPieces(forcedLastName);
             return(nameTriple);
         }
         if (pawn.RaceProps.nameCategory != PawnNameCategory.NoName)
         {
             if (Rand.Value < 0.5f)
             {
                 NameTriple nameTriple2 = PawnBioAndNameGenerator.TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                 if (nameTriple2 != null)
                 {
                     return(nameTriple2);
                 }
             }
             return(PawnBioAndNameGenerator.GeneratePawnName_Shuffled(pawn, forcedLastName));
         }
         Log.Error("No name making method for " + pawn);
         NameTriple nameTriple3 = NameTriple.FromString(pawn.def.label);
         nameTriple3.ResolveMissingPieces(null);
         return(nameTriple3);
     }
     else
     {
         if (style == NameStyle.Numeric)
         {
             int    num = 1;
             string text;
             while (true)
             {
                 text = pawn.KindLabel + " " + num.ToString();
                 if (!NameUseChecker.NameSingleIsUsed(text))
                 {
                     break;
                 }
                 num++;
             }
             return(new NameSingle(text, true));
         }
         throw new InvalidOperationException();
     }
 }
 public static void GiveAppropriateBioAndNameTo(Pawn pawn, string requiredLastName)
 {
     if ((Rand.Value < 0.25f || pawn.kindDef.factionLeader) && PawnBioAndNameGenerator.TryGiveSolidBioTo(pawn, requiredLastName))
     {
         return;
     }
     PawnBioAndNameGenerator.GiveShuffledBioTo(pawn, pawn.Faction.def, requiredLastName);
 }
 private static void GiveShuffledBioTo(Pawn pawn, FactionDef factionType, string requiredLastName)
 {
     pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full, requiredLastName);
     PawnBioAndNameGenerator.FillBackstorySlotShuffled(pawn, BackstorySlot.Childhood, ref pawn.story.childhood, factionType);
     if (pawn.ageTracker.AgeBiologicalYearsFloat >= 20f)
     {
         PawnBioAndNameGenerator.FillBackstorySlotShuffled(pawn, BackstorySlot.Adulthood, ref pawn.story.adulthood, factionType);
     }
 }
예제 #9
0
        public static void GiveNameBecauseOfNuzzle(Pawn namer, Pawn namee)
        {
            string text = (namee.Name != null) ? namee.Name.ToStringFull : namee.LabelIndefinite();

            namee.Name = PawnBioAndNameGenerator.GeneratePawnName(namee, NameStyle.Full, null);
            if (namer.Faction == Faction.OfPlayer)
            {
                Messages.Message("MessageNuzzledPawnGaveNameTo".Translate(namer, text, namee.Name.ToStringFull), namee, MessageTypeDefOf.NeutralEvent);
            }
        }
예제 #10
0
        public static void GiveNameBecauseOfNuzzle(Pawn namer, Pawn namee)
        {
            string value = (namee.Name == null) ? namee.LabelIndefinite() : namee.Name.ToStringFull;

            namee.Name = PawnBioAndNameGenerator.GeneratePawnName(namee);
            if (namer.Faction == Faction.OfPlayer)
            {
                Messages.Message("MessageNuzzledPawnGaveNameTo".Translate(namer.Named("NAMER"), value, namee.Name.ToStringFull, namee.Named("NAMEE")), namee, MessageTypeDefOf.NeutralEvent);
            }
        }
예제 #11
0
 public static void GiveAppropriateBioAndNameTo(Pawn pawn, string requiredLastName, FactionDef factionType)
 {
     if (Rand.Value < 0.25f || pawn.kindDef.factionLeader)
     {
         bool flag = PawnBioAndNameGenerator.TryGiveSolidBioTo(pawn, requiredLastName, factionType);
         if (flag)
         {
             return;
         }
     }
     PawnBioAndNameGenerator.GiveShuffledBioTo(pawn, factionType, requiredLastName);
 }
예제 #12
0
        private static bool TryGiveSolidBioTo(Pawn pawn, string requiredLastName)
        {
            PawnBio pawnBio = PawnBioAndNameGenerator.TryGetRandomUnusedSolidBioFor(pawn.Faction.def.backstoryCategory, pawn.kindDef, pawn.gender, requiredLastName);

            if (pawnBio == null)
            {
                return(false);
            }
            if (pawnBio.name.First == "Tynan" && pawnBio.name.Last == "Sylvester" && Rand.Value < 0.5)
            {
                pawnBio = PawnBioAndNameGenerator.TryGetRandomUnusedSolidBioFor(pawn.Faction.def.backstoryCategory, pawn.kindDef, pawn.gender, requiredLastName);
            }
            if (pawnBio == null)
            {
                return(false);
            }
            pawn.Name            = pawnBio.name;
            pawn.story.childhood = pawnBio.childhood;
            if (pawn.ageTracker.AgeBiologicalYearsFloat >= 20.0)
            {
                pawn.story.adulthood = pawnBio.adulthood;
            }
            return(true);
        }
예제 #13
0
        public static bool TryDevelopBondRelation(Pawn humanlike, Pawn animal, float baseChance)
        {
            if (!animal.RaceProps.Animal)
            {
                return(false);
            }
            if (animal.RaceProps.TrainableIntelligence.intelligenceOrder < TrainableIntelligenceDefOf.Intermediate.intelligenceOrder)
            {
                return(false);
            }
            if (humanlike.relations.DirectRelationExists(PawnRelationDefOf.Bond, animal))
            {
                return(false);
            }
            if (animal.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, (Pawn x) => x.Spawned) != null)
            {
                return(false);
            }
            int num = 0;
            List <DirectPawnRelation> directRelations = animal.relations.DirectRelations;

            for (int i = 0; i < directRelations.Count; i++)
            {
                if (directRelations[i].def == PawnRelationDefOf.Bond && !directRelations[i].otherPawn.Dead)
                {
                    num++;
                }
            }
            int num2 = 0;
            List <DirectPawnRelation> directRelations2 = humanlike.relations.DirectRelations;

            for (int j = 0; j < directRelations2.Count; j++)
            {
                if (directRelations2[j].def == PawnRelationDefOf.Bond && !directRelations2[j].otherPawn.Dead)
                {
                    num2++;
                }
            }
            if (num > 0)
            {
                baseChance *= Mathf.Pow(0.2f, (float)num);
            }
            if (num2 > 0)
            {
                baseChance *= Mathf.Pow(0.55f, (float)num2);
            }
            if (Rand.Value < baseChance)
            {
                if (!humanlike.story.traits.HasTrait(TraitDefOf.Psychopath))
                {
                    humanlike.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal);
                }
                if (humanlike.Faction == Faction.OfPlayer || animal.Faction == Faction.OfPlayer)
                {
                    TaleRecorder.RecordTale(TaleDefOf.BondedWithAnimal, new object[]
                    {
                        humanlike,
                        animal
                    });
                }
                bool   flag = false;
                string text = null;
                if (animal.Name == null || animal.Name.Numerical)
                {
                    flag        = true;
                    text        = ((animal.Name != null) ? animal.Name.ToStringFull : animal.LabelIndefinite());
                    animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal, NameStyle.Full, null);
                }
                if (PawnUtility.ShouldSendNotificationAbout(humanlike) || PawnUtility.ShouldSendNotificationAbout(animal))
                {
                    string text2;
                    if (flag)
                    {
                        text2 = "MessageNewBondRelationNewName".Translate(new object[]
                        {
                            humanlike.LabelShort,
                            text,
                            animal.Name.ToStringFull
                        }).AdjustedFor(animal).CapitalizeFirst();
                    }
                    else
                    {
                        text2 = "MessageNewBondRelation".Translate(new object[]
                        {
                            humanlike.LabelShort,
                            animal.LabelShort
                        }).CapitalizeFirst();
                    }
                    Messages.Message(text2, humanlike, MessageTypeDefOf.PositiveEvent);
                }
                return(true);
            }
            return(false);
        }
예제 #14
0
 public static string GetRandomBirthName(Pawn forPawn)
 {
     return((PawnBioAndNameGenerator.GeneratePawnName(forPawn) as NameTriple).Last);
 }
예제 #15
0
 private static float BackstorySelectionWeight(Backstory bs)
 {
     return(PawnBioAndNameGenerator.SelectionWeightFactorFromWorkTagsDisabled(bs.workDisables));
 }
예제 #16
0
 private static float BioSelectionWeight(PawnBio bio)
 {
     return(PawnBioAndNameGenerator.SelectionWeightFactorFromWorkTagsDisabled(bio.adulthood.workDisables | bio.childhood.workDisables));
 }
 private static float BioSelectionWeight(PawnBio bio)
 {
     return(PawnBioAndNameGenerator.WorkDisablesSelectionWeight(bio.adulthood.workDisables & bio.childhood.workDisables));
 }
 private static float BackstorySelectionWeight(Backstory bs)
 {
     return(PawnBioAndNameGenerator.WorkDisablesSelectionWeight(bs.workDisables));
 }