Example #1
0
        // Token: 0x060000B1 RID: 177 RVA: 0x000061A4 File Offset: 0x000043A4
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 loc;

            if (!this.TryFindEntryCell(map, out loc))
            {
                return(false);
            }
            Gender?gender = null;

            if (this.def.pawnFixedGender != Gender.None)
            {
                gender = new Gender?(this.def.pawnFixedGender);
            }
            PawnKindDef        pawnKindDef = this.def.pawnKind;
            Faction            ofPlayer    = Faction.OfPlayer;
            List <PawnKindDef> list        = (from def in DefDatabase <PawnKindDef> .AllDefs
                                              where def.race == ofPlayer.def.basicMemberKind.race && def.defName.Contains("BKRescuer")
                                              select def).ToList <PawnKindDef>();

            if (list.Count > 0)
            {
                pawnKindDef = list.RandomElement <PawnKindDef>();
            }
            else
            {
                list = (from def in DefDatabase <PawnKindDef> .AllDefs
                        where def.defName.Contains("BKRescuer")
                        select def).ToList <PawnKindDef>();
                pawnKindDef = list.RandomElement <PawnKindDef>();
            }
            pawnKindDef.defaultFactionType = ofPlayer.def;
            bool   pawnMustBeCapableOfViolence = this.def.pawnMustBeCapableOfViolence;
            Gender?gender2 = gender;
            Pawn   pawn    = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKindDef, ofPlayer, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, pawnMustBeCapableOfViolence, 20f, false, true, true, false, false, false, false, false, 0, null, 1, null, null, null, null, null, null, null, gender2, null, null));

            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            TaggedString text  = GenText.AdjustedFor(GrammarResolverSimpleStringExtensions.Formatted(this.def.letterText, pawn.Named("PAWN")), pawn, "PAWN");
            TaggedString text2 = GenText.AdjustedFor(GrammarResolverSimpleStringExtensions.Formatted(this.def.letterLabel, pawn.Named("PAWN")), pawn, "PAWN");

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref text2, pawn);
            Find.LetterStack.ReceiveLetter(text2, text, LetterDefOf.PositiveEvent, pawn, null, null);
            return(true);
        }