Ejemplo n.º 1
0
        /// <param name="prisoner"></param>
        /// <returns>A <c>Command_Action</c> that sends the selected <paramref name="prisoner"/> to an empire settlementFC. Only displays if the <paramref name="prisoner"/> can be send.</returns>
        private static Command_Action SendPrisonerAction(Pawn prisoner) => new Command_Action
        {
            defaultLabel = "SendToSettlement".Translate(),
            defaultDesc  = "",
            icon         = TexLoad.iconMilitary,
            action       = delegate
            {
                if (prisoner.Map.dangerWatcher.DangerRating != StoryDanger.None)
                {
                    Messages.Message("cantSendWithDangerLevel".Translate(prisoner.Map.dangerWatcher.DangerRating.ToString()), MessageTypeDefOf.RejectInput);
                    return;
                }

                List <FloatMenuOption> settlementList = Find.World.GetComponent <FactionFC>().settlements.Select(settlement => new FloatMenuOption("floatMenuOptionSendPrisonerToSettlement".Translate(settlement.name, settlement.settlementLevel, settlement.prisonerList.Count()), delegate
                {
                    //disappear prisoner
                    FactionColonies.sendPrisoner(prisoner, settlement);

                    foreach (var bed in Find.Maps.Where(map => map.IsPlayerHome).SelectMany(map => map.listerBuildings.allBuildingsColonist).OfType <Building_Bed>().Where(bed => bed.OwnersForReading.Any(bedPawn => bedPawn == prisoner)))
                    {
                        bed.ForPrisoners = false;
                        bed.ForPrisoners = true;
                    }
                })).ToList();

                Find.WindowStack.Add(new FloatMenu(settlementList));
            }
        };