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 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);
     }
 }
Esempio n. 3
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*/;
            }
        }
Esempio n. 4
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*/;
            }
        }
 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);
     }
 }
        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);
            }
        }
Esempio n. 7
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);
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
 public static string GetRandomBirthName(Pawn forPawn)
 {
     return((PawnBioAndNameGenerator.GeneratePawnName(forPawn) as NameTriple).Last);
 }