Exemple #1
0
        private Pawn RandomKidnappedColonist()
        {
            IncidentWorker_RansomDemand.candidates.Clear();
            List <Faction> allFactionsListForReading = Find.FactionManager.AllFactionsListForReading;

            for (int i = 0; i < allFactionsListForReading.Count; i++)
            {
                List <Pawn> kidnappedPawnsListForReading = allFactionsListForReading[i].kidnapped.KidnappedPawnsListForReading;
                for (int j = 0; j < kidnappedPawnsListForReading.Count; j++)
                {
                    if (kidnappedPawnsListForReading[j].Faction == Faction.OfPlayer)
                    {
                        IncidentWorker_RansomDemand.candidates.Add(kidnappedPawnsListForReading[j]);
                    }
                }
            }
            List <Letter> lettersListForReading = Find.LetterStack.LettersListForReading;

            for (int k = 0; k < lettersListForReading.Count; k++)
            {
                ChoiceLetter_RansomDemand choiceLetter_RansomDemand = lettersListForReading[k] as ChoiceLetter_RansomDemand;
                if (choiceLetter_RansomDemand != null)
                {
                    IncidentWorker_RansomDemand.candidates.Remove(choiceLetter_RansomDemand.kidnapped);
                }
            }
            Pawn result;

            if (!IncidentWorker_RansomDemand.candidates.TryRandomElement(out result))
            {
                return(null);
            }
            IncidentWorker_RansomDemand.candidates.Clear();
            return(result);
        }
Exemple #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map  map  = (Map)parms.target;
            Pawn pawn = this.RandomKidnappedColonist();

            if (pawn == null)
            {
                return(false);
            }
            Faction faction = this.FactionWhichKidnapped(pawn);
            int     num     = this.RandomFee(pawn);
            ChoiceLetter_RansomDemand choiceLetter_RansomDemand = (ChoiceLetter_RansomDemand)LetterMaker.MakeLetter(this.def.letterLabel, "RansomDemand".Translate(new object[]
            {
                pawn.LabelShort,
                faction.Name,
                num
            }).AdjustedFor(pawn, "PAWN"), this.def.letterDef);

            choiceLetter_RansomDemand.title = "RansomDemandTitle".Translate(new object[]
            {
                map.Parent.Label
            });
            choiceLetter_RansomDemand.radioMode      = true;
            choiceLetter_RansomDemand.kidnapped      = pawn;
            choiceLetter_RansomDemand.faction        = faction;
            choiceLetter_RansomDemand.map            = map;
            choiceLetter_RansomDemand.fee            = num;
            choiceLetter_RansomDemand.relatedFaction = faction;
            choiceLetter_RansomDemand.StartTimeout(60000);
            Find.LetterStack.ReceiveLetter(choiceLetter_RansomDemand, null);
            return(true);
        }