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()
        {
            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*/;
            }
        }
Beispiel #3
0
 protected override void PaintedIcon(Pawn pawn)
 {
     if (!(GetIconFor(pawn) != BondBrokenIcon) && pawn.training.HasLearned(TrainableDefOf.Obedience))
     {
         pawn.playerSettings.Master = (from master in TrainableUtility.GetAllColonistBondsFor(pawn)
                                       where TrainableUtility.CanBeMaster(master, pawn)
                                       select master).FirstOrDefault();
     }
 }
Beispiel #4
0
 protected override void PaintedIcon(Pawn pawn)
 {
     if (this.GetIconFor(pawn) != PawnColumnWorker_Bond.BondBrokenIcon)
     {
         return;
     }
     if (!pawn.training.HasLearned(TrainableDefOf.Obedience))
     {
         return;
     }
     pawn.playerSettings.Master = (from master in TrainableUtility.GetAllColonistBondsFor(pawn)
                                   where TrainableUtility.CanBeMaster(master, pawn, true)
                                   select master).FirstOrDefault <Pawn>();
 }
        private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > MasterSelectButton_GenerateMenu(Pawn p)
        {
            yield return(new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate()
                {
                    p.playerSettings.Master = null;
                }, MenuOptionPriority.Default, null, null, 0f, null, null),
                payload = null
            });

            using (IEnumerator <Pawn> enumerator = PawnsFinder.AllMaps_FreeColonistsSpawned.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Pawn   col      = enumerator.Current;
                    string lab      = RelationsUtility.LabelWithBondInfo(col, p);
                    Action action   = null;
                    int    level    = col.skills.GetSkill(SkillDefOf.Animals).Level;
                    int    minLevel = TrainableUtility.MinimumHandlingSkill(p);
                    if (level < minLevel)
                    {
                        action = null;
                        lab    = lab + " (" + "SkillTooLow".Translate(new object[]
                        {
                            SkillDefOf.Animals.LabelCap,
                            level,
                            minLevel
                        }) + ")";
                    }
                    else if (TrainableUtility.CanBeMaster(col, p, true))
                    {
                        action = delegate()
                        {
                            p.playerSettings.Master = col;
                        };
                    }
                    yield return(new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption(lab, action, MenuOptionPriority.Default, null, null, 0f, null, null),
                        payload = col
                    });
                }
            }
            yield break;
        }