Ejemplo n.º 1
0
        private static void ForceReform(MapParent mapParent)
        {
            if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist))
            {
                Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent);
                Current.Game.CurrentMap = mapParent.Map;
                Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate
                {
                    if (mapParent.HasMap)
                    {
                        mapParent.Destroy();
                    }
                }, mapAboutToBeRemoved: true);
                Find.WindowStack.Add(window);
                return;
            }
            List <Pawn> tmpPawns = new List <Pawn>();

            tmpPawns.AddRange(mapParent.Map.mapPawns.AllPawns.Where((Pawn x) => x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer));
            if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1);
            }
            tmpPawns.Clear();
            mapParent.Destroy();
        }
Ejemplo n.º 2
0
        public static void ForceReform(MapParent mapParent)
        {
            if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return;
            }

            if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist))
            {
                Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent);
                Current.Game.CurrentMap = mapParent.Map;
                Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate
                {
                    if (mapParent.HasMap)
                    {
                        Find.WorldObjects.Remove(mapParent);
                    }
                }, mapAboutToBeRemoved: true);
                Find.WindowStack.Add(window);
                return;
            }
            List <Pawn> tmpPawns = new List <Pawn>();

            tmpPawns.Clear();
            tmpPawns.AddRange(from x in mapParent.Map.mapPawns.AllPawns
                              where x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer
                              select x);
            if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1);
            }
            tmpPawns.Clear();
            Find.WorldObjects.Remove(mapParent);
        }
        public static void ApplyThoughts(Pawn listener, JoyKindDef joyKindDef)
        {
            if (joyKindDef != JoyKindDefOf_Music.Music)
            {
                return;
            }

            ThoughtDef thought = PerformanceManager.GetThoughtDef(MusicQuality);

            if (thought == null)
            {
                return;
            }

            Caravan caravan = CaravanUtility.GetCaravan(listener);

            List <Pawn> audience = new List <Pawn>();

            foreach (Pawn pawn in caravan.pawns)
            {
                if (!pawn.NonHumanlikeOrWildMan() && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Hearing) && pawn.Awake())
                {
                    audience.Add(pawn);
                }
            }
#if DEBUG
            Verse.Log.Message(String.Format("Giving memory of {0} to {1} pawns (caravan)", thought.stages[0].label, audience.Count()));
#endif

            foreach (Pawn audienceMember in audience)
            {
                audienceMember.needs.mood.thoughts.memories.TryGainMemory(thought);
            }
        }
        public static Pawn GetPawnToFollow(Pawn forPawn)
        {
            if (!forPawn.RaceProps.packAnimal || forPawn.inventory.UnloadEverything || MassUtility.IsOverEncumbered(forPawn))
            {
                return(null);
            }
            Lord lord = forPawn.GetLord();

            if (lord == null)
            {
                return(null);
            }
            List <Pawn> ownedPawns = lord.ownedPawns;

            for (int i = 0; i < ownedPawns.Count; i++)
            {
                Pawn pawn = ownedPawns[i];
                if (pawn != forPawn && CaravanUtility.IsOwner(pawn, forPawn.Faction) && pawn.CurJob != null && pawn.CurJob.def == JobDefOf.PrepareCaravan_GatherItems && forPawn.CanReach(pawn, PathEndMode.Touch, Danger.Deadly) && ((JobDriver_PrepareCaravan_GatherItems)pawn.jobs.curDriver).Carrier == forPawn)
                {
                    return(pawn);
                }
            }
            Pawn pawn2 = null;

            for (int j = 0; j < ownedPawns.Count; j++)
            {
                Pawn pawn3 = ownedPawns[j];
                if (pawn3 != forPawn && CaravanUtility.IsOwner(pawn3, forPawn.Faction) && pawn3.CurJob != null && pawn3.CurJob.def == JobDefOf.PrepareCaravan_GatherItems && forPawn.CanReach(pawn3, PathEndMode.Touch, Danger.Deadly) && (pawn2 == null || forPawn.Position.DistanceToSquared(pawn3.Position) < forPawn.Position.DistanceToSquared(pawn2.Position)))
                {
                    pawn2 = pawn3;
                }
            }
            return(pawn2);
        }
Ejemplo n.º 5
0
 private bool CheckForErrors(List <Pawn> pawns)
 {
     if (!pawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
     {
         Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), this.caravan, MessageTypeDefOf.RejectInput, false);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 6
0
        private void AddPawnsToTransferables()
        {
            List <Pawn> list = AllSendablePawns(map, reform);

            for (int i = 0; i < list.Count; i++)
            {
                bool setToTransferMax = (reform || mapAboutToBeRemoved) && !CaravanUtility.ShouldAutoCapture(list[i], Faction.OfPlayer);
                AddToTransferables(list[i], setToTransferMax);
            }
        }
Ejemplo n.º 7
0
 // Token: 0x0600007C RID: 124 RVA: 0x00006F04 File Offset: 0x00005104
 public static void CheckCaravanPainResponse(Pawn pawn)
 {
     if (CaravanUtility.IsCaravanMember(pawn))
     {
         Caravan car = CaravanUtility.GetCaravan(pawn);
         if (car != null && (pawn.IsColonist || (pawn.IsPrisoner && DRSettings.DoIfPrisoner)) && MSPainlessData.IsPainManager(pawn) && MSPainUtility.IsInPain(pawn) && !pawn.InMentalState && !car.NightResting)
         {
             MSPainResponse.DoCaravanPainReliefResponse(car, pawn);
         }
     }
 }
Ejemplo n.º 8
0
 public static bool AnyPotentialCaravanOwner(IEnumerable <IThingHolder> pods, Faction faction)
 {
     foreach (IThingHolder thingHolder in pods)
     {
         ThingOwner directlyHeldThings = thingHolder.GetDirectlyHeldThings();
         for (int i = 0; i < directlyHeldThings.Count; i++)
         {
             Pawn pawn = directlyHeldThings[i] as Pawn;
             if (pawn != null && CaravanUtility.IsOwner(pawn, faction))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
        public override void ForceReform(MapParent mapParent)
        {
            if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist))
            {
                Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent);
                Current.Game.CurrentMap = mapParent.Map;
                Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate
                {
                    if (RemoveAfterLeave && mapParent.HasMap)
                    {
                        Find.WorldObjects.Remove(mapParent);
                    }
                }, mapAboutToBeRemoved: true);
                Find.WindowStack.Add(window);
                for (int i = window.transferables.Count - 1; i >= 0; i--)
                {
                    TransferableOneWay t = window.transferables[i];
                    if (t != null)
                    {
                        if (t.AnyThing != null)
                        {
                            if (t.AnyThing.Faction != null && t.AnyThing.Faction == Faction)
                            {
                                window.transferables.Remove(t);
                            }
                        }
                    }
                }
                return;
            }
            List <Pawn> tmpPawns = new List <Pawn>();

            tmpPawns.Clear();
            tmpPawns.AddRange(from x in mapParent.Map.mapPawns.AllPawns
                              where x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer
                              select x);
            if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1);
            }
            tmpPawns.Clear();

            if (RemoveAfterLeave)
            {
                Find.WorldObjects.Remove(mapParent);
            }
        }
Ejemplo n.º 10
0
        public override void CompTick()
        {
            if (parent.IsHashIntervalTick(interval))
            {
                Pawn pawn = parent as Pawn;

                if (CaravanUtility.IsCaravanMember(pawn))
                {
                    StaticCollectionsClass.AddManffaloAndExperience((Pawn)parent);

                    if (xp <= 2)
                    {
                        xp += 0.01f;
                        StaticCollectionsClass.SetManffaloExperience((Pawn)parent, xp);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private bool DebugTryFormCaravanInstantly()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageSound.RejectInput);
                return(false);
            }
            this.AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            int currentTile = this.startingTile;

            if (currentTile < 0)
            {
                currentTile = this.CurrentTile;
            }
            CaravanFormingUtility.FormAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, this.CurrentTile, currentTile);
            return(true);
        }
Ejemplo n.º 12
0
 // Token: 0x0600004A RID: 74 RVA: 0x000050B8 File Offset: 0x000032B8
 public static bool IsValidPawnMod(Pawn pawn, bool painmode)
 {
     if (pawn.IsPrisoner)
     {
         if (painmode)
         {
             if (!DRSettings.DoIfPrisoner)
             {
                 return(false);
             }
         }
         else if (!DRSettings.DoDRIfPrisoner)
         {
             return(false);
         }
     }
     else if (!pawn.IsColonist)
     {
         return(false);
     }
     return((pawn.Spawned || CaravanUtility.IsCaravanMember(pawn)) && !pawn.Dead && !pawn.InMentalState);
 }
Ejemplo n.º 13
0
        public static bool CanSetSail(List <Pawn> caravan)
        {
            int  seats  = 0;
            int  pawns  = 0;
            int  prereq = 0;
            bool flag   = caravan.Any(x => !(x.GetComp <CompShips>() is null)); //Ships or No Ships

            if (flag)
            {
                foreach (Pawn p in caravan)
                {
                    if (IsShip(p))
                    {
                        seats  += p.GetComp <CompShips>().SeatsAvailable;
                        prereq += p.GetComp <CompShips>().PawnCountToOperate - p.GetComp <CompShips>().AllCrewAboard.Count;
                    }
                    else if (p.IsColonistPlayerControlled && !p.Downed && !p.Dead)
                    {
                        pawns++;
                    }
                }
            }
            bool flag2 = flag ? pawns > seats : false;  //Not Enough Room
            bool flag3 = flag ? pawns < prereq : false; //Not Enough Pawns to Sail

            if (flag2)
            {
                Messages.Message("CaravanMustHaveEnoughSpaceOnShip".Translate(), MessageTypeDefOf.RejectInput, false);
            }
            if (!caravan.Any(x => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
            {
                Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false);
            }
            if (flag3)
            {
                Messages.Message("CaravanMustHaveEnoughPawnsToOperate".Translate(prereq), MessageTypeDefOf.RejectInput, false);
            }
            return(!flag2 && !flag3);
        }
Ejemplo n.º 14
0
        private bool DebugTryFormCaravanInstantly()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            this.AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            int num = this.startingTile;

            if (num < 0)
            {
                num = CaravanExitMapUtility.RandomBestExitTileFrom(this.map);
            }
            if (num < 0)
            {
                num = this.CurrentTile;
            }
            CaravanFormingUtility.FormAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, this.CurrentTile, num, this.destinationTile);
            return(true);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Create sections in VehicleCaravan dialog for proper listing
        /// </summary>
        /// <param name="pawnWidget"></param>
        /// <param name="vehicleWidget"></param>
        /// <param name="transferables"></param>
        public static void AddVehicleAndPawnSections(TransferableOneWayWidget pawnWidget, TransferableVehicleWidget vehicleWidget, List <TransferableOneWay> transferables)
        {
            IEnumerable <TransferableOneWay> source = from x in transferables
                                                      where x.ThingDef.category == ThingCategory.Pawn
                                                      select x;

            vehicleWidget.AddSection("VehiclesTab".Translate(), from x in source
                                     where x.AnyThing is VehiclePawn vehicle && vehicle.CanMove
                                     select x);
            pawnWidget.AddSection("ColonistsSection".Translate(), from x in source
                                  where ((Pawn)x.AnyThing).IsFreeColonist
                                  select x);
            pawnWidget.AddSection("PrisonersSection".Translate(), from x in source
                                  where ((Pawn)x.AnyThing).IsPrisoner
                                  select x);
            pawnWidget.AddSection("CaptureSection".Translate(), from x in source
                                  where ((Pawn)x.AnyThing).Downed && CaravanUtility.ShouldAutoCapture((Pawn)x.AnyThing, Faction.OfPlayer)
                                  select x);
            pawnWidget.AddSection("AnimalsSection".Translate(), from x in source
                                  where ((Pawn)x.AnyThing).RaceProps.Animal
                                  select x);
            vehicleWidget.AvailablePawns = source.Where(x => x.AnyThing is Pawn pawn && !(pawn is VehiclePawn) && pawn.IsColonistPlayerControlled).ToList();
        }
Ejemplo n.º 16
0
        private bool CheckForErrors(List <Pawn> pawns)
        {
            if (this.MustChooseRoute && this.destinationTile < 0)
            {
                Messages.Message("MessageMustChooseRouteFirst".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            if (!this.reform && this.startingTile < 0)
            {
                Messages.Message("MessageNoValidExitTile".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            if (!pawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
            {
                Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            if (!this.reform && this.MassUsage > this.MassCapacity)
            {
                this.FlashMass();
                Messages.Message("TooBigCaravanMassUsage".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            Pawn pawn = pawns.Find((Pawn x) => !x.IsColonist && !pawns.Any((Pawn y) => y.IsColonist && y.CanReach(x, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)));

            if (pawn != null)
            {
                Messages.Message("CaravanPawnIsUnreachable".Translate(pawn.LabelShort, pawn).CapitalizeFirst(), pawn, MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            for (int i = 0; i < this.transferables.Count; i++)
            {
                if (this.transferables[i].ThingDef.category == ThingCategory.Item)
                {
                    int countToTransfer = this.transferables[i].CountToTransfer;
                    int num             = 0;
                    if (countToTransfer > 0)
                    {
                        for (int j = 0; j < this.transferables[i].things.Count; j++)
                        {
                            Thing t = this.transferables[i].things[j];
                            if (!t.Spawned || pawns.Any((Pawn x) => x.IsColonist && x.CanReach(t, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)))
                            {
                                num += t.stackCount;
                                if (num >= countToTransfer)
                                {
                                    break;
                                }
                            }
                        }
                        if (num < countToTransfer)
                        {
                            if (countToTransfer == 1)
                            {
                                Messages.Message("CaravanItemIsUnreachableSingle".Translate(this.transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, false);
                            }
                            else
                            {
                                Messages.Message("CaravanItemIsUnreachableMulti".Translate(countToTransfer, this.transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, false);
                            }
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 17
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f - 17f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.reform)
                {
                    if (this.TryReformCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        list.Add((daysWorthOfFood.First >= 0.1f) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (this.MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(this.transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                        {
                            string text = string.Concat((from str in list
                                                         select str + "\n\n").ToArray <string>()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (this.TryFormAndSendCaravan())
                                {
                                    this.Close(false);
                                }
                            }, false, null));
                        }
                    }
                    else if (this.TryFormAndSendCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            if (this.ShowCancelButton)
            {
                Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
                {
                    this.Close(true);
                }
            }
            if (this.canChooseRoute)
            {
                Rect rect5 = new Rect(rect.width - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect5, "ChooseRouteButton".Translate(), true, false, true))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
                if (this.destinationTile != -1)
                {
                    Rect rect6 = rect5;
                    rect6.y     += rect5.height + 4f;
                    rect6.height = 200f;
                    rect6.xMin  -= 200f;
                    Text.Anchor  = TextAnchor.UpperRight;
                    Widgets.Label(rect6, "CaravanEstimatedDaysToDestination".Translate(((float)this.TicksToArrive / 60000f).ToString("0.#")));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = this.BottomButtonSize.y / 2f;
                Rect  rect7 = new Rect(0f, rect.height - 55f - 17f, width, num);
                if (Widgets.ButtonText(rect7, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect8 = new Rect(0f, rect.height - 55f - 17f + num, width, num);
                if (Widgets.ButtonText(rect8, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.SetToSendEverything();
                }
            }
        }
Ejemplo n.º 18
0
        public static bool AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 c = IntVec3.FromVector3(clickPos);

            foreach (Thing thing in c.GetThingList(pawn.Map))
            {
                Pawn pawn2;
                if ((pawn2 = (thing as Pawn)) != null)
                {
                    Lord lord = pawn2.GetLord();
                    if (lord != null && lord.CurLordToil != null)
                    {
                        IEnumerable <FloatMenuOption> enumerable = lord.CurLordToil.ExtraFloatMenuOptions(pawn2, pawn);
                        if (enumerable != null)
                        {
                            foreach (FloatMenuOption item8 in enumerable)
                            {
                                opts.Add(item8);
                            }
                        }
                    }
                }
            }

            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo item9 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForArrest(pawn), thingsOnly: true))
                {
                    bool flag = item9.HasThing && item9.Thing is Pawn && ((Pawn)item9.Thing).IsWildMan();
                    if (pawn.Drafted || flag)
                    {
                        if (item9.Thing is Pawn && (pawn.InSameExtraFaction((Pawn)item9.Thing, ExtraFactionType.HomeFaction) || pawn.InSameExtraFaction((Pawn)item9.Thing, ExtraFactionType.MiniFaction)))
                        {
                            opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "SameFaction".Translate((Pawn)item9.Thing), null));
                        }
                        else if (!pawn.CanReach(item9, PathEndMode.OnCell, Danger.Deadly))
                        {
                            opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                        }
                        else
                        {
                            Pawn   pTarg2 = (Pawn)item9.Thing;
                            Action action = delegate
                            {
                                Building_Bed building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false);
                                if (building_Bed3 == null)
                                {
                                    building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true);
                                }

                                if (building_Bed3 == null)
                                {
                                    Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg2, MessageTypeDefOf.RejectInput, historical: false);
                                }
                                else
                                {
                                    Job job19 = JobMaker.MakeJob(JobDefOf.Arrest, pTarg2, building_Bed3);
                                    job19.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job19);
                                    if (pTarg2.Faction != null && ((pTarg2.Faction != Faction.OfPlayer && !pTarg2.Faction.Hidden) || pTarg2.IsQuestLodger()))
                                    {
                                        TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent());
                                    }
                                }
                            };
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("TryToArrest".Translate(item9.Thing.LabelCap, item9.Thing, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()), action, MenuOptionPriority.High, null, item9.Thing), pawn, pTarg2));
                        }
                    }
                }
            }

            foreach (Thing thing2 in c.GetThingList(pawn.Map))
            {
                Thing t = thing2;
                if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow)
                {
                    string text = (!t.def.ingestible.ingestCommandString.NullOrEmpty()) ? string.Format(t.def.ingestible.ingestCommandString, t.LabelShort) : ((string)"ConsumeThing".Translate(t.LabelShort, t));
                    if (!t.IsSociallyProper(pawn))
                    {
                        text = text + ": " + "ReservedForPrisoners".Translate().CapitalizeFirst();
                    }

                    FloatMenuOption floatMenuOption;
                    if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler())
                    {
                        floatMenuOption = new FloatMenuOption(text + ": " + TraitDefOf.DrugDesire.DataAtDegree(-1).GetLabelCapFor(pawn), null);
                    }
                    else if (FoodUtility.InappropriateForTitle(t.def, pawn, allowIfStarving: true))
                    {
                        floatMenuOption = new FloatMenuOption(text + ": " + "FoodBelowTitleRequirements".Translate(pawn.royalty.MostSeniorTitle.def.GetLabelFor(pawn)), null);
                    }
                    else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly))
                    {
                        floatMenuOption = new FloatMenuOption(text + ": " + "NoPath".Translate().CapitalizeFirst(), null);
                    }
                    else
                    {
                        MenuOptionPriority priority = (t is Corpse) ? MenuOptionPriority.Low : MenuOptionPriority.Default;
                        int maxAmountToPickup       = FoodUtility.GetMaxAmountToPickup(t, pawn, FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition)));
                        floatMenuOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate
                        {
                            int maxAmountToPickup2 = FoodUtility.GetMaxAmountToPickup(t, pawn, FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition)));
                            if (maxAmountToPickup2 != 0)
                            {
                                t.SetForbidden(value: false);
                                Job job18   = JobMaker.MakeJob(JobDefOf.Ingest, t);
                                job18.count = maxAmountToPickup2;
                                pawn.jobs.TryTakeOrderedJob(job18);
                            }
                        }, priority), pawn, t);
                        if (maxAmountToPickup == 0)
                        {
                            floatMenuOption.action = null;
                        }
                    }

                    opts.Add(floatMenuOption);
                }
            }

            foreach (LocalTargetInfo item10 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForQuestPawnsWhoWillJoinColony(pawn), thingsOnly: true))
            {
                Pawn            toHelpPawn = (Pawn)item10.Thing;
                FloatMenuOption item4      = pawn.CanReach(item10, PathEndMode.Touch, Danger.Deadly) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(toHelpPawn.IsPrisoner ? "FreePrisoner".Translate() : "OfferHelp".Translate(), delegate
                {
                    pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.OfferHelp, toHelpPawn));
                }, MenuOptionPriority.RescueOrCapture, null, toHelpPawn), pawn, toHelpPawn) : new FloatMenuOption("CannotGoNoPath".Translate(), null);
                opts.Add(item4);
            }

            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (Thing thing3 in c.GetThingList(pawn.Map))
                {
                    Corpse corpse = thing3 as Corpse;
                    if (corpse != null && corpse.IsInValidStorage())
                    {
                        StoragePriority priority2 = StoreUtility.CurrentHaulDestinationOf(corpse).GetStoreSettings().Priority;
                        if (StoreUtility.TryFindBestBetterNonSlotGroupStorageFor(corpse, pawn, pawn.Map, priority2, Faction.OfPlayer, out IHaulDestination haulDestination, acceptSamePriority: true) && haulDestination.GetStoreSettings().Priority == priority2 && haulDestination is Building_Grave)
                        {
                            Building_Grave grave = haulDestination as Building_Grave;
                            string         label = "PrioritizeGeneric".Translate("Burying".Translate(), corpse.Label);
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, delegate
                            {
                                pawn.jobs.TryTakeOrderedJob(HaulAIUtility.HaulToContainerJob(pawn, corpse, grave));
                            }), pawn, new LocalTargetInfo(corpse)));
                        }
                    }
                }

                foreach (LocalTargetInfo item11 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true))
                {
                    Pawn victim3 = (Pawn)item11.Thing;
                    if (!victim3.InBed() && pawn.CanReserveAndReach(victim3, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && !victim3.mindState.WillJoinColonyIfRescued)
                    {
                        if (!victim3.IsPrisonerOfColony && (!victim3.InMentalState || victim3.health.hediffSet.HasHediff(HediffDefOf.Scaria)) && (victim3.Faction == Faction.OfPlayer || victim3.Faction == null || !victim3.Faction.HostileTo(Faction.OfPlayer)))
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Rescue".Translate(victim3.LabelCap, victim3), delegate
                            {
                                Building_Bed building_Bed2 = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false);
                                if (building_Bed2 == null)
                                {
                                    building_Bed2 = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false, ignoreOtherReservations: true);
                                }

                                if (building_Bed2 == null)
                                {
                                    string t3 = (!victim3.RaceProps.Animal) ? ((string)"NoNonPrisonerBed".Translate()) : ((string)"NoAnimalBed".Translate());
                                    Messages.Message("CannotRescue".Translate() + ": " + t3, victim3, MessageTypeDefOf.RejectInput, historical: false);
                                }
                                else
                                {
                                    Job job17   = JobMaker.MakeJob(JobDefOf.Rescue, victim3, building_Bed2);
                                    job17.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job17);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total);
                                }
                            }, MenuOptionPriority.RescueOrCapture, null, victim3), pawn, victim3));
                        }

                        if (victim3.RaceProps.Humanlike && (victim3.InMentalState || victim3.Faction != Faction.OfPlayer || (victim3.Downed && (victim3.guilt.IsGuilty || victim3.IsPrisonerOfColony))))
                        {
                            TaggedString taggedString = "Capture".Translate(victim3.LabelCap, victim3);
                            if (victim3.Faction != null && victim3.Faction != Faction.OfPlayer && !victim3.Faction.Hidden && !victim3.Faction.HostileTo(Faction.OfPlayer) && !victim3.IsPrisonerOfColony)
                            {
                                taggedString += ": " + "AngersFaction".Translate().CapitalizeFirst();
                            }

                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(taggedString, delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false);
                                if (building_Bed == null)
                                {
                                    building_Bed = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true);
                                }

                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim3, MessageTypeDefOf.RejectInput, historical: false);
                                }
                                else
                                {
                                    Job job16   = JobMaker.MakeJob(JobDefOf.Capture, victim3, building_Bed);
                                    job16.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job16);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total);
                                    if (victim3.Faction != null && victim3.Faction != Faction.OfPlayer && !victim3.Faction.Hidden && !victim3.Faction.HostileTo(Faction.OfPlayer) && !victim3.IsPrisonerOfColony)
                                    {
                                        Messages.Message("MessageCapturingWillAngerFaction".Translate(victim3.Named("PAWN")).AdjustedFor(victim3), victim3, MessageTypeDefOf.CautionInput, historical: false);
                                    }
                                }
                            }, MenuOptionPriority.RescueOrCapture, null, victim3), pawn, victim3));
                        }
                    }
                }

                foreach (LocalTargetInfo item12 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true))
                {
                    LocalTargetInfo localTargetInfo = item12;
                    Pawn            victim2         = (Pawn)localTargetInfo.Thing;
                    if (victim2.Downed && pawn.CanReserveAndReach(victim2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, ignoreOtherReservations: true) != null)
                    {
                        string text2   = "CarryToCryptosleepCasket".Translate(localTargetInfo.Thing.LabelCap, localTargetInfo.Thing);
                        JobDef jDef    = JobDefOf.CarryToCryptosleepCasket;
                        Action action2 = delegate
                        {
                            Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn);
                            if (building_CryptosleepCasket == null)
                            {
                                building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, ignoreOtherReservations: true);
                            }

                            if (building_CryptosleepCasket == null)
                            {
                                Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim2, MessageTypeDefOf.RejectInput, historical: false);
                            }
                            else
                            {
                                Job job15 = JobMaker.MakeJob(jDef, victim2, building_CryptosleepCasket);
                                job15.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job15);
                            }
                        };
                        if (victim2.IsQuestLodger())
                        {
                            text2 += " (" + "CryptosleepCasketGuestsNotAllowed".Translate() + ")";
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, null, MenuOptionPriority.Default, null, victim2), pawn, victim2));
                        }
                        else if (victim2.GetExtraHostFaction() != null)
                        {
                            text2 += " (" + "CryptosleepCasketGuestPrisonersNotAllowed".Translate() + ")";
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, null, MenuOptionPriority.Default, null, victim2), pawn, victim2));
                        }
                        else
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, action2, MenuOptionPriority.Default, null, victim2), pawn, victim2));
                        }
                    }
                }

                if (ModsConfig.RoyaltyActive)
                {
                    foreach (LocalTargetInfo item13 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForShuttle(pawn), thingsOnly: true))
                    {
                        LocalTargetInfo   localTargetInfo2 = item13;
                        Pawn              victim           = (Pawn)localTargetInfo2.Thing;
                        Predicate <Thing> validator        = (Thing thing) => thing.TryGetComp <CompShuttle>()?.IsAllowedNow(victim) ?? false;
                        Thing             shuttleThing     = GenClosest.ClosestThingReachable(victim.Position, victim.Map, ThingRequest.ForDef(ThingDefOf.Shuttle), PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999f, validator);
                        if (shuttleThing != null && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Hauling))
                        {
                            string label2  = "CarryToShuttle".Translate(localTargetInfo2.Thing);
                            Action action3 = delegate
                            {
                                CompShuttle compShuttle = shuttleThing.TryGetComp <CompShuttle>();
                                if (!compShuttle.LoadingInProgressOrReadyToLaunch)
                                {
                                    TransporterUtility.InitiateLoading(Gen.YieldSingle(compShuttle.Transporter));
                                }

                                Job job14 = JobMaker.MakeJob(JobDefOf.HaulToTransporter, victim, shuttleThing);
                                job14.ignoreForbidden = true;
                                job14.count           = 1;
                                pawn.jobs.TryTakeOrderedJob(job14);
                            };
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label2, action3), pawn, victim));
                        }
                    }
                }
            }

            foreach (LocalTargetInfo item14 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForStrip(pawn), thingsOnly: true))
            {
                LocalTargetInfo stripTarg = item14;
                FloatMenuOption item5     = pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly) ? ((stripTarg.Pawn == null || !stripTarg.Pawn.HasExtraHomeFaction()) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Strip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing), delegate
                {
                    stripTarg.Thing.SetForbidden(value: false, warnOnFail: false);
                    pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Strip, stripTarg));
                    StrippableUtility.CheckSendStrippingImpactsGoodwillMessage(stripTarg.Thing);
                }), pawn, stripTarg) : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null)) : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing) + ": " + "NoPath".Translate().CapitalizeFirst(), null);
                opts.Add(item5);
            }

            ThingWithComps equipment;

            if (pawn.equipment != null)
            {
                equipment = null;
                List <Thing> thingList = c.GetThingList(pawn.Map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    if (thingList[i].TryGetComp <CompEquippable>() != null)
                    {
                        equipment = (ThingWithComps)thingList[i];
                        break;
                    }
                }

                if (equipment != null)
                {
                    string          labelShort = equipment.LabelShort;
                    FloatMenuOption item6;
                    string          cantReason;
                    if (equipment.def.IsWeapon && pawn.WorkTagIsDisabled(WorkTags.Violent))
                    {
                        item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort, pawn), null);
                    }
                    else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly))
                    {
                        item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "NoPath".Translate().CapitalizeFirst(), null);
                    }
                    else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                    {
                        item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "Incapable".Translate(), null);
                    }
                    else if (equipment.IsBurning())
                    {
                        item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "BurningLower".Translate(), null);
                    }
                    else if (pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(equipment, pawn))
                    {
                        item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null);
                    }
                    else if (!EquipmentUtility.CanEquip_NewTmp(equipment, pawn, out cantReason, checkBonded: false))
                    {
                        item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + cantReason.CapitalizeFirst(), null);
                    }
                    else
                    {
                        string text3 = "Equip".Translate(labelShort);
                        if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                        {
                            text3 += " " + "EquipWarningBrawler".Translate();
                        }

                        if (EquipmentUtility.AlreadyBondedToWeapon(equipment, pawn))
                        {
                            text3 += " " + "BladelinkAlreadyBonded".Translate();
                            TaggedString dialogText = "BladelinkAlreadyBondedDialog".Translate(pawn.Named("PAWN"), equipment.Named("WEAPON"), pawn.equipment.bondedWeapon.Named("BONDEDWEAPON"));
                            item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate
                            {
                                Find.WindowStack.Add(new Dialog_MessageBox(dialogText));
                            }, MenuOptionPriority.High), pawn, equipment);
                        }
                        else
                        {
                            item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate
                            {
                                string personaWeaponConfirmationText = EquipmentUtility.GetPersonaWeaponConfirmationText(equipment, pawn);
                                if (!personaWeaponConfirmationText.NullOrEmpty())
                                {
                                    Find.WindowStack.Add(new Dialog_MessageBox(personaWeaponConfirmationText, "Yes".Translate(), delegate
                                    {
                                        Equip();
                                    }, "No".Translate()));
                                }
                                else
                                {
                                    Equip();
                                }
                            }, MenuOptionPriority.High), pawn, equipment);
                        }
                    }

                    opts.Add(item6);
                }
            }

            foreach (Pair <CompReloadable, Thing> item15 in ReloadableUtility.FindPotentiallyReloadableGear(pawn, c.GetThingList(pawn.Map)))
            {
                CompReloadable comp   = item15.First;
                Thing          second = item15.Second;
                string         text4  = "Reload".Translate(comp.parent.Named("GEAR"), NamedArgumentUtility.Named(comp.AmmoDef, "AMMO")) + " (" + comp.LabelRemaining + ")";
                List <Thing>   chosenAmmo;
                if (!pawn.CanReach(second, PathEndMode.ClosestTouch, Danger.Deadly))
                {
                    opts.Add(new FloatMenuOption(text4 + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                }
                else if (!comp.NeedsReload(allowForcedReload: true))
                {
                    opts.Add(new FloatMenuOption(text4 + ": " + "ReloadFull".Translate(), null));
                }
                else if ((chosenAmmo = ReloadableUtility.FindEnoughAmmo(pawn, second.Position, comp, forceReload: true)) == null)
                {
                    opts.Add(new FloatMenuOption(text4 + ": " + "ReloadNotEnough".Translate(), null));
                }
                else
                {
                    Action action4 = delegate
                    {
                        pawn.jobs.TryTakeOrderedJob(JobGiver_Reload.MakeReloadJob(comp, chosenAmmo));
                    };
                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, action4), pawn, second));
                }
            }

            if (pawn.apparel != null)
            {
                if (pawn.Map.thingGrid.ThingAt(c, ThingCategory.Item) is Apparel apparel)
                {
                    string key  = "CannotWear";
                    string key2 = "ForceWear";
                    if (apparel.def.apparel.LastLayer.IsUtilityLayer)
                    {
                        key  = "CannotEquipApparel";
                        key2 = "ForceEquipApparel";
                    }

                    string          cantReason2;
                    FloatMenuOption item7 = (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly)) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "NoPath".Translate().CapitalizeFirst(), null) : (apparel.IsBurning() ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "Burning".Translate(), null) : (pawn.apparel.WouldReplaceLockedApparel(apparel) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "WouldReplaceLockedApparel".Translate().CapitalizeFirst(), null) : ((!ApparelUtility.HasPartsToWear(pawn, apparel.def)) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "CannotWearBecauseOfMissingBodyParts".Translate(), null) : (EquipmentUtility.CanEquip_NewTmp(apparel, pawn, out cantReason2) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(key2.Translate(apparel.LabelShort, apparel), delegate
                    {
                        apparel.SetForbidden(value: false);
                        Job job13 = JobMaker.MakeJob(JobDefOf.Wear, apparel);
                        pawn.jobs.TryTakeOrderedJob(job13);
                    }, MenuOptionPriority.High), pawn, apparel) : new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + cantReason2, null)))));
                    opts.Add(item7);
                }
            }

            if (pawn.IsFormingCaravan())
            {
                Thing item3 = c.GetFirstItem(pawn.Map);
                if (item3 != null && item3.def.EverHaulable && item3.def.canLoadIntoCaravan)
                {
                    Pawn   packTarget = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn) ?? pawn;
                    JobDef jobDef     = (packTarget == pawn) ? JobDefOf.TakeInventory : JobDefOf.GiveToPackAnimal;
                    if (!pawn.CanReach(item3, PathEndMode.ClosestTouch, Danger.Deadly))
                    {
                        opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(item3.Label, item3) + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                    }
                    else if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, item3, 1))
                    {
                        opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(item3.Label, item3) + ": " + "TooHeavy".Translate(), null));
                    }
                    else
                    {
                        LordJob_FormAndSendCaravan lordJob = (LordJob_FormAndSendCaravan)pawn.GetLord().LordJob;
                        float capacityLeft = CaravanFormingUtility.CapacityLeft(lordJob);
                        if (item3.stackCount == 1)
                        {
                            float capacityLeft2 = capacityLeft - item3.GetStatValue(StatDefOf.Mass);
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravan".Translate(item3.Label, item3), capacityLeft2), delegate
                            {
                                item3.SetForbidden(value: false, warnOnFail: false);
                                Job job12              = JobMaker.MakeJob(jobDef, item3);
                                job12.count            = 1;
                                job12.checkEncumbrance = (packTarget == pawn);
                                pawn.jobs.TryTakeOrderedJob(job12);
                            }, MenuOptionPriority.High), pawn, item3));
                        }
                        else
                        {
                            if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, item3, item3.stackCount))
                            {
                                opts.Add(new FloatMenuOption("CannotLoadIntoCaravanAll".Translate(item3.Label, item3) + ": " + "TooHeavy".Translate(), null));
                            }
                            else
                            {
                                float capacityLeft3 = capacityLeft - (float)item3.stackCount * item3.GetStatValue(StatDefOf.Mass);
                                opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravanAll".Translate(item3.Label, item3), capacityLeft3), delegate
                                {
                                    item3.SetForbidden(value: false, warnOnFail: false);
                                    Job job11              = JobMaker.MakeJob(jobDef, item3);
                                    job11.count            = item3.stackCount;
                                    job11.checkEncumbrance = (packTarget == pawn);
                                    pawn.jobs.TryTakeOrderedJob(job11);
                                }, MenuOptionPriority.High), pawn, item3));
                            }

                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("LoadIntoCaravanSome".Translate(item3.LabelNoCount, item3), delegate
                            {
                                int to3 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(packTarget, item3), item3.stackCount);
                                Dialog_Slider window3 = new Dialog_Slider(delegate(int val)
                                {
                                    float capacityLeft4 = capacityLeft - (float)val * item3.GetStatValue(StatDefOf.Mass);
                                    return(CaravanFormingUtility.AppendOverweightInfo(string.Format("LoadIntoCaravanCount".Translate(item3.LabelNoCount, item3), val), capacityLeft4));
                                }, 1, to3, delegate(int count)
                                {
                                    item3.SetForbidden(value: false, warnOnFail: false);
                                    Job job10              = JobMaker.MakeJob(jobDef, item3);
                                    job10.count            = count;
                                    job10.checkEncumbrance = (packTarget == pawn);
                                    pawn.jobs.TryTakeOrderedJob(job10);
                                });
                                Find.WindowStack.Add(window3);
                            }, MenuOptionPriority.High), pawn, item3));
                        }
                    }
                }
            }

            if (!pawn.Map.IsPlayerHome && !pawn.IsFormingCaravan())
            {
                Thing item2 = c.GetFirstItem(pawn.Map);
                if (item2 != null && item2.def.EverHaulable)
                {
                    if (!pawn.CanReach(item2, PathEndMode.ClosestTouch, Danger.Deadly))
                    {
                        opts.Add(new FloatMenuOption("CannotPickUp".Translate(item2.Label, item2) + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                    }
                    else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item2, 1))
                    {
                        opts.Add(new FloatMenuOption("CannotPickUp".Translate(item2.Label, item2) + ": " + "TooHeavy".Translate(), null));
                    }
                    else if (item2.stackCount == 1)
                    {
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item2.Label, item2), delegate
                        {
                            item2.SetForbidden(value: false, warnOnFail: false);
                            Job job9              = JobMaker.MakeJob(JobDefOf.TakeInventory, item2);
                            job9.count            = 1;
                            job9.checkEncumbrance = true;
                            pawn.jobs.TryTakeOrderedJob(job9);
                        }, MenuOptionPriority.High), pawn, item2));
                    }
                    else
                    {
                        if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item2, item2.stackCount))
                        {
                            opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item2.Label, item2) + ": " + "TooHeavy".Translate(), null));
                        }
                        else
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item2.Label, item2), delegate
                            {
                                item2.SetForbidden(value: false, warnOnFail: false);
                                Job job8              = JobMaker.MakeJob(JobDefOf.TakeInventory, item2);
                                job8.count            = item2.stackCount;
                                job8.checkEncumbrance = true;
                                pawn.jobs.TryTakeOrderedJob(job8);
                            }, MenuOptionPriority.High), pawn, item2));
                        }

                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item2.LabelNoCount, item2), delegate
                        {
                            int to2 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item2), item2.stackCount);
                            Dialog_Slider window2 = new Dialog_Slider("PickUpCount".Translate(item2.LabelNoCount, item2), 1, to2, delegate(int count)
                            {
                                item2.SetForbidden(value: false, warnOnFail: false);
                                Job job7              = JobMaker.MakeJob(JobDefOf.TakeInventory, item2);
                                job7.count            = count;
                                job7.checkEncumbrance = true;
                                pawn.jobs.TryTakeOrderedJob(job7);
                            });
                            Find.WindowStack.Add(window2);
                        }, MenuOptionPriority.High), pawn, item2));
                    }
                }
            }

            if (!pawn.Map.IsPlayerHome && !pawn.IsFormingCaravan())
            {
                Thing item = c.GetFirstItem(pawn.Map);
                if (item != null && item.def.EverHaulable)
                {
                    Pawn bestPackAnimal = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn);
                    if (bestPackAnimal != null)
                    {
                        if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly))
                        {
                            opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item.Label, item) + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                        }
                        else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, 1))
                        {
                            opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item.Label, item) + ": " + "TooHeavy".Translate(), null));
                        }
                        else if (item.stackCount == 1)
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimal".Translate(item.Label, item), delegate
                            {
                                item.SetForbidden(value: false, warnOnFail: false);
                                Job job6   = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item);
                                job6.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job6);
                            }, MenuOptionPriority.High), pawn, item));
                        }
                        else
                        {
                            if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, item.stackCount))
                            {
                                opts.Add(new FloatMenuOption("CannotGiveToPackAnimalAll".Translate(item.Label, item) + ": " + "TooHeavy".Translate(), null));
                            }
                            else
                            {
                                opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalAll".Translate(item.Label, item), delegate
                                {
                                    item.SetForbidden(value: false, warnOnFail: false);
                                    Job job5   = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item);
                                    job5.count = item.stackCount;
                                    pawn.jobs.TryTakeOrderedJob(job5);
                                }, MenuOptionPriority.High), pawn, item));
                            }

                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalSome".Translate(item.LabelNoCount, item), delegate
                            {
                                int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item), item.stackCount);
                                Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(item.LabelNoCount, item), 1, to, delegate(int count)
                                {
                                    item.SetForbidden(value: false, warnOnFail: false);
                                    Job job4   = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item);
                                    job4.count = count;
                                    pawn.jobs.TryTakeOrderedJob(job4);
                                });
                                Find.WindowStack.Add(window);
                            }, MenuOptionPriority.High), pawn, item));
                        }
                    }
                }
            }

            if (!pawn.Map.IsPlayerHome && pawn.Map.exitMapGrid.MapUsesExitGrid)
            {
                foreach (LocalTargetInfo item16 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true))
                {
                    Pawn p = (Pawn)item16.Thing;
                    if (p.Faction == Faction.OfPlayer || p.IsPrisonerOfColony || CaravanUtility.ShouldAutoCapture(p, Faction.OfPlayer))
                    {
                        IntVec3 exitSpot;
                        if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly))
                        {
                            opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label, p) + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                        }
                        else if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot))
                        {
                            opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label, p) + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                        }
                        else
                        {
                            TaggedString taggedString2 = (p.Faction == Faction.OfPlayer || p.IsPrisonerOfColony) ? "CarryToExit".Translate(p.Label, p) : "CarryToExitAndCapture".Translate(p.Label, p);
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(taggedString2, delegate
                            {
                                Job job3   = JobMaker.MakeJob(JobDefOf.CarryDownedPawnToExit, p, exitSpot);
                                job3.count = 1;
                                job3.failIfCantJoinOrCreateCaravan = true;
                                pawn.jobs.TryTakeOrderedJob(job3);
                            }, MenuOptionPriority.High), pawn, item16));
                        }
                    }
                }
            }

            if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForSelf(pawn), thingsOnly: true).Any())
            {
                if (pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanUnequip(pawn.equipment.Primary, pawn))
                {
                    opts.Add(new FloatMenuOption("CannotDrop".Translate(pawn.equipment.Primary.Label, pawn.equipment.Primary) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null));
                }
                else
                {
                    Action action5 = delegate
                    {
                        pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.DropEquipment, pawn.equipment.Primary));
                    };
                    opts.Add(new FloatMenuOption("Drop".Translate(pawn.equipment.Primary.Label, pawn.equipment.Primary), action5, MenuOptionPriority.Default, null, pawn));
                }
            }

            foreach (LocalTargetInfo item17 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForTrade(), thingsOnly: true))
            {
                if (!pawn.CanReach(item17, PathEndMode.OnCell, Danger.Deadly))
                {
                    opts.Add(new FloatMenuOption("CannotTrade".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                }
                else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
                {
                    opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null));
                }
                else if (!pawn.CanTradeWith(((Pawn)item17.Thing).Faction, ((Pawn)item17.Thing).TraderKind))
                {
                    opts.Add(new FloatMenuOption("CannotTradeMissingTitleAbility".Translate(), null));
                }
                else
                {
                    Pawn   pTarg   = (Pawn)item17.Thing;
                    Action action6 = delegate
                    {
                        Job job2 = JobMaker.MakeJob(JobDefOf.TradeWithPawn, pTarg);
                        job2.playerForced = true;
                        pawn.jobs.TryTakeOrderedJob(job2);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total);
                    };
                    string t2 = "";
                    if (pTarg.Faction != null)
                    {
                        t2 = " (" + pTarg.Faction.Name + ")";
                    }

                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("TradeWith".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + t2, action6, MenuOptionPriority.InitiateSocial, null, item17.Thing), pawn, pTarg));
                }
            }

            foreach (LocalTargetInfo casket in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForOpen(pawn), thingsOnly: true))
            {
                if (!pawn.CanReach(casket, PathEndMode.OnCell, Danger.Deadly))
                {
                    opts.Add(new FloatMenuOption("CannotOpen".Translate(casket.Thing) + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                }
                else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                {
                    opts.Add(new FloatMenuOption("CannotOpen".Translate(casket.Thing) + ": " + "Incapable".Translate(), null));
                }
                else if (casket.Thing.Map.designationManager.DesignationOn(casket.Thing, DesignationDefOf.Open) == null)
                {
                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Open".Translate(casket.Thing), delegate
                    {
                        Job job = JobMaker.MakeJob(JobDefOf.Open, casket.Thing);
                        job.ignoreDesignations = true;
                        pawn.jobs.TryTakeOrderedJob(job);
                    }, MenuOptionPriority.High), pawn, casket.Thing));
                }
            }

            foreach (Thing item18 in pawn.Map.thingGrid.ThingsAt(c))
            {
                foreach (FloatMenuOption floatMenuOption2 in item18.GetFloatMenuOptions(pawn))
                {
                    opts.Add(floatMenuOption2);
                }
            }

            void Equip()
            {
                equipment.SetForbidden(value: false);
                pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Equip, equipment));
                MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
            }

            return(false);
        }
 private static bool <DoBottomButtons> m__2(Pawn pawn)
 {
     return(CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled);
 }
 private static bool <CheckForErrors> m__B(Pawn x)
 {
     return(CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed);
 }
 private static bool <DoBottomButtons> m__5(Pawn x)
 {
     return(CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed);
 }
Ejemplo n.º 22
0
        // Token: 0x0600006A RID: 106 RVA: 0x000062D4 File Offset: 0x000044D4
        public override void CompTick()
        {
            int responseTicks = 150;

            if (DRSettings.UsePainManagement && MSDrugUtility.IsValidPawnMod(this.Pawn, true) && Gen.IsHashIntervalTick(this.Pawn, responseTicks))
            {
                Pawn pawn = this.Pawn;
                if ((pawn?.Map) != null)
                {
                    Pawn pawn2 = this.Pawn;
                    if ((pawn2?.CurJob) != null && this.Pawn.CurJob.def != JobDefOf.Ingest)
                    {
                        MSPainResponse.CheckPainResponse(this.Pawn);
                    }
                }
                else if (CaravanUtility.IsCaravanMember(this.Pawn))
                {
                    MSPainResponse.CheckCaravanPainResponse(this.Pawn);
                }
            }
            if (DRSettings.UseDrugResponse && MSDrugUtility.IsValidPawnMod(this.Pawn, false) && Gen.IsHashIntervalTick(this.Pawn, responseTicks + 50))
            {
                Pawn pawn3 = this.Pawn;
                if ((pawn3?.Map) != null)
                {
                    Pawn pawn4 = this.Pawn;
                    if ((pawn4?.CurJob) == null || this.Pawn.CurJob.def == JobDefOf.Ingest)
                    {
                        return;
                    }
                    Pawn      pawn5 = this.Pawn;
                    HediffSet hediffSet;
                    if (pawn5 == null)
                    {
                        hediffSet = null;
                    }
                    else
                    {
                        Pawn_HealthTracker health = pawn5.health;
                        hediffSet = (health?.hediffSet);
                    }
                    HediffSet hedSet = hediffSet;
                    if (hedSet == null || hedSet == null || hedSet.hediffs.Count <= 0)
                    {
                        return;
                    }
                    using (List <Hediff> .Enumerator enumerator = hedSet.hediffs.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff hediff = enumerator.Current;
                            if (hediff.Visible && !MSPainlessData.IsProsthetic(hediff) && MSDRUtility.MaladyUsed(hediff.def.defName))
                            {
                                for (int i = 1; i <= 2; i++)
                                {
                                    if (MSPainlessData.CheckIfResponse(this.Pawn, hediff.def.defName, this.DRResponse, i, out ThingDef drugdef) && MSDrugUtility.IsOKtoAdmin(this.Pawn, hediff.def, drugdef) && !MSDrugUtility.IsViolation(this.Pawn, drugdef))
                                    {
                                        Thing drug = MSDrugUtility.FindDrugFor(this.Pawn, drugdef);
                                        if (drug != null)
                                        {
                                            if ((i < 2 && MSDRUtility.GetValueDRBills(hediff.def.defName, DRSettings.MSDRValues)) || (i > 1 && MSDRUtility.GetValueDRBills(hediff.def.defName, DRSettings.MSDRValues2)) || (this.Pawn.IsPrisoner && DRSettings.DoDRIfPrisoner))
                                            {
                                                if ((i < 2 && MSAddDrugBill.GenDrugResponse(true, this.Pawn, hediff.def, drugdef, null, DRSettings.MSDRValues, i)) || (i > 1 && MSAddDrugBill.GenDrugResponse(true, this.Pawn, hediff.def, drugdef, null, DRSettings.MSDRValues2, i)))
                                                {
                                                    MSPainlessData.SetDRResponseData(this.Pawn, hediff.def.defName, drugdef.defName, Find.TickManager.TicksGame, this.DRResponse, i, out List <string> newDRResponse);
                                                    this.DRResponse = newDRResponse;
                                                    MSPainlessData.DoDRResponseMsg(this.Pawn, hediff.def, drugdef);
                                                }
                                            }
                                            else if (MSPainlessData.IsDRCapable(this.Pawn))
                                            {
                                                Job job = new Job(JobDefOf.Ingest, drug)
                                                {
                                                    count = Mathf.Min(new int[]
                                                    {
                                                        drug.stackCount,
                                                        drug.def.ingestible.maxNumToIngestAtOnce,
                                                        1
                                                    })
                                                };
                                                if (drug.Spawned && this.Pawn.drugs != null && !this.Pawn.inventory.innerContainer.Contains(drug.def))
                                                {
                                                    DrugPolicyEntry drugPolicyEntry = this.Pawn.drugs.CurrentPolicy[drug.def];
                                                    if (drugPolicyEntry.takeToInventory > 0)
                                                    {
                                                        job.takeExtraIngestibles = drugPolicyEntry.takeToInventory;
                                                    }
                                                }
                                                if (this.Pawn.jobs != null && this.Pawn.jobs.curJob != null)
                                                {
                                                    this.Pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true, true);
                                                    this.Pawn.jobs.ClearQueuedJobs(true);
                                                }
                                                MSPainlessData.SetDRResponseData(this.Pawn, hediff.def.defName, drugdef.defName, Find.TickManager.TicksGame, this.DRResponse, i, out List <string> newDRResponse2);
                                                this.DRResponse = newDRResponse2;
                                                MSPainlessData.DoDRResponseMsg(this.Pawn, hediff.def, drugdef);
                                                this.Pawn.jobs.TryTakeOrderedJob(job, 0);
                                            }
                                        }
                                    }
                                }
                                Pawn_JobTracker jobs = this.Pawn.jobs;
                                if ((jobs?.curJob) != null && this.Pawn.jobs.curJob.def == JobDefOf.Ingest)
                                {
                                    break;
                                }
                            }
                        }
                        return;
                    }
                }
                if (CaravanUtility.IsCaravanMember(this.Pawn))
                {
                    Pawn      pawn6 = this.Pawn;
                    HediffSet hediffSet2;
                    if (pawn6 == null)
                    {
                        hediffSet2 = null;
                    }
                    else
                    {
                        Pawn_HealthTracker health2 = pawn6.health;
                        hediffSet2 = (health2?.hediffSet);
                    }
                    HediffSet hedSet2 = hediffSet2;
                    if (hedSet2 != null && hedSet2 != null && hedSet2.hediffs.Count > 0)
                    {
                        foreach (Hediff hediff2 in hedSet2.hediffs)
                        {
                            if (hediff2.Visible && !MSPainlessData.IsProsthetic(hediff2) && MSDRUtility.MaladyUsed(hediff2.def.defName))
                            {
                                for (int j = 1; j <= 2; j++)
                                {
                                    if (MSPainlessData.CheckIfResponse(this.Pawn, hediff2.def.defName, this.DRResponse, j, out ThingDef drugdef2) && MSDrugUtility.IsOKtoAdmin(this.Pawn, hediff2.def, drugdef2) && !MSDrugUtility.IsViolation(this.Pawn, drugdef2))
                                    {
                                        Caravan car = CaravanUtility.GetCaravan(this.Pawn);
                                        if (car != null && MSCaravanUtility.CaravanHasDrug(car, drugdef2, out Thing drug2, out Pawn owner))
                                        {
                                            MSPainlessData.SetDRResponseData(this.Pawn, hediff2.def.defName, drugdef2.defName, Find.TickManager.TicksGame, this.DRResponse, j, out List <string> newDRResponse3);
                                            this.DRResponse = newDRResponse3;
                                            MSCaravanUtility.PawnOnCaravanTakeDrug(car, this.Pawn, drug2, owner);
                                            MSPainlessData.DoDRResponseMsg(this.Pawn, hediff2.def, drugdef2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
        private static List <Pawn> PawnsInCurrentSections; // For Giddy-up! Caravan compatibility
        public static bool AddPawnsSections(TransferableOneWayWidget widget, List <TransferableOneWay> transferables)
        {
            PawnsInCurrentSections = new List <Pawn>(); // For Giddy-up! Caravan compatibility

            // Get all pawns from the list of transferables
            List <Pawn> pawns = new List <Pawn>();
            Dictionary <Pawn, TransferableOneWay> pawnThing = new Dictionary <Pawn, TransferableOneWay>();

            foreach (TransferableOneWay thing in transferables)
            {
                if (thing.ThingDef.category == ThingCategory.Pawn)
                {
                    Pawn pawn = (Pawn)thing.AnyThing;
                    pawns.Add(pawn);
                    pawnThing[pawn] = thing;
                }
            }

            List <PawnGroup> pawnGroups = TacticUtils.AllPawnGroups;

            pawnGroups.Reverse(); // Reverse the list because it iterates in the wrong direction

            // Create a HashSet to sort out all the ungrouped pawns
            HashSet <Pawn> ungroupedPawns = new HashSet <Pawn>(pawns);

            foreach (PawnGroup pawnGroup in pawnGroups)
            {
                if (pawnGroup.pawns != null && pawnGroup.pawns.Count > 0)
                {
                    // Remove grouped pawns from the ungroupedPawns HashSet
                    ungroupedPawns.ExceptWith(from pawn in pawnGroup.pawns select pawn);

                    // Get only the group's pawns that are in the current list of transferables
                    List <TransferableOneWay> sectionTranferables = new List <TransferableOneWay>();
                    foreach (Pawn pawn in pawnGroup.pawns)
                    {
                        if (pawns.Contains(pawn) && pawnThing.ContainsKey(pawn) && pawn.IsFreeColonist)
                        {
                            sectionTranferables.Add(pawnThing[pawn]);
                            if (!PawnsInCurrentSections.Contains(pawn))
                            {
                                PawnsInCurrentSections.Add(pawn); // For Giddy-up! Caravan compatibility
                            }
                        }
                    }

                    if (sectionTranferables.Count > 0)
                    {
                        // Add a new section containing all pawns within the group
                        widget.AddSection(pawnGroup.curGroupName ?? "", from pawn in sectionTranferables select pawn);
                    }
                }
            }

            if (ungroupedPawns.Count > 0)
            {
                // Create a section containing all the ungrouped pawns
                widget.AddSection("Ungrouped " + "ColonistsSection".Translate().ToLower(), from pawn in ungroupedPawns
                                  where pawn.IsFreeColonist
                                  select pawnThing[pawn]);
                foreach (Pawn pawn in ungroupedPawns)
                {
                    if (pawn.IsFreeColonist && !PawnsInCurrentSections.Contains(pawn))
                    {
                        PawnsInCurrentSections.Add(pawn); // For Giddy-up! Caravan compatibility
                    }
                }
            }

            // We then return to vanilla code (slightly tweaked), commenting out the Colonists section of course

            /*
             * widget.AddSection("ColonistsSection".Translate(), from pawn in pawns
             *                                                where pawn.IsFreeColonist
             *                                                select pawnThing[pawn]);
             */

            widget.AddSection("PrisonersSection".Translate(), from pawn in pawns
                              where pawn.IsPrisoner
                              select pawnThing[pawn]);

            widget.AddSection("CaptureSection".Translate(), from pawn in pawns
                              where pawn.Downed && CaravanUtility.ShouldAutoCapture(pawn, Faction.OfPlayer)
                              select pawnThing[pawn]);

            widget.AddSection("AnimalsSection".Translate(), from pawn in pawns
                              where pawn.RaceProps.Animal
                              select pawnThing[pawn]);
            return(false);
        }
Ejemplo n.º 24
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.reform)
                {
                    if (this.TryReformCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
                else
                {
                    string text = null;
                    Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        text = ((daysWorthOfFood.First >= 0.1f) ? "DaysWorthOfFoodWarningDialog".Translate(new object[]
                        {
                            daysWorthOfFood.First.ToString("0.#")
                        }) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (this.MostFoodWillRotSoon)
                    {
                        text = "CaravanFoodWillRotSoonWarningDialog".Translate();
                    }
                    if (!text.NullOrEmpty())
                    {
                        if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                        {
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (this.TryFormAndSendCaravan())
                                {
                                    this.Close(false);
                                }
                            }, false, null));
                        }
                    }
                    else if (this.TryFormAndSendCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
            if (this.showEstTimeToDestinationButton)
            {
                Rect rect5 = new Rect(rect.width - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect5, "EstimatedTimeToDestinationButton".Translate(), true, false, true))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageSound.RejectInput);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = this.BottomButtonSize.y / 2f;
                Rect  rect6 = new Rect(0f, rect.height - 55f, width, num);
                if (Widgets.ButtonText(rect6, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect7 = new Rect(0f, rect.height - 55f + num, width, num);
                if (Widgets.ButtonText(rect7, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.SetToSendEverything();
                }
            }
        }
        public static bool AddPawnsSections(TransferableOneWayWidget widget, List <TransferableOneWay> transferables)
        {
            if (ModCompatibility.GiddyUpCaravanIsActive)
            {
                PawnsInCurrentSections = new List <Pawn>();
            }

            // Get all pawns from the list of transferables
            List <Pawn> pawns = new List <Pawn>();
            Dictionary <Pawn, TransferableOneWay> pawnTransferable = new Dictionary <Pawn, TransferableOneWay>();

            foreach (TransferableOneWay transferable in transferables)
            {
                if (transferable.ThingDef.category == ThingCategory.Pawn)
                {
                    Pawn pawn = (Pawn)transferable.AnyThing;
                    pawns.Add(pawn);
                    pawnTransferable[pawn] = transferable;
                }
            }

            List <PawnGroup> pawnGroups = TacticUtils.AllPawnGroups;

            pawnGroups.Reverse(); // Reverse the list because it iterates in the wrong direction

            // Create a HashSet to sort out all the ungrouped pawns
            HashSet <Pawn> ungroupedPawns = new HashSet <Pawn>(pawns);

            foreach (PawnGroup pawnGroup in pawnGroups)
            {
                if (!(pawnGroup.pawns is null) && pawnGroup.pawns.Count > 0)
                {
                    // Remove grouped pawns from the ungroupedPawns HashSet
                    ungroupedPawns.ExceptWith(from pawn in pawnGroup.pawns select pawn);

                    // Get only the group's pawns that are in the current list of transferables
                    List <Pawn> sectionPawns = new List <Pawn>();
                    sectionPawns.AddRange(from pawn in pawnGroup.pawns
                                          where pawns.Contains(pawn)
                                          select pawn);

                    if (ModCompatibility.GiddyUpCaravanIsActive)
                    {
                        PawnsInCurrentSections.AddRange(from pawn in sectionPawns.Except(PawnsInCurrentSections)
                                                        where pawn.IsFreeNonSlaveColonist
                                                        select pawn);
                    }

                    // Add a new section containing all pawns within the group
                    if (sectionPawns.Any(pawn => pawn.IsFreeNonSlaveColonist))
                    {
                        widget.AddSection(pawnGroup.curGroupName, from pawn in sectionPawns
                                          where pawn.IsFreeNonSlaveColonist
                                          select pawnTransferable[pawn]);
                    }

                    // Add a new section containing all slave pawns within the group
                    if (ModsConfig.IdeologyActive && sectionPawns.Any(pawn => pawn.IsSlave))
                    {
                        widget.AddSection("TG.GroupSlavesSection".Translate(pawnGroup.curGroupName), from pawn in sectionPawns
                                          where pawn.IsSlave
                                          select pawnTransferable[pawn]);
                    }
                }
            }

            // Create a section containing all the ungrouped pawns
            if (ungroupedPawns.Any(pawn => pawn.IsFreeNonSlaveColonist))
            {
                widget.AddSection("TG.UngroupedColonistsSection".Translate(), from pawn in ungroupedPawns
                                  where pawn.IsFreeNonSlaveColonist
                                  select pawnTransferable[pawn]);

                if (ModCompatibility.GiddyUpCaravanIsActive)
                {
                    PawnsInCurrentSections.AddRange(from pawn in ungroupedPawns.Except(PawnsInCurrentSections)
                                                    where pawn.IsFreeNonSlaveColonist
                                                    select pawn);
                }
            }

            // Create a section containing all the ungrouped slave pawns
            if (ModsConfig.IdeologyActive && ungroupedPawns.Any(pawn => pawn.IsSlave))
            {
                widget.AddSection("TG.UngroupedSlavesSection".Translate(), from pawn in ungroupedPawns
                                  where pawn.IsSlave
                                  select pawnTransferable[pawn]);
            }


            // We then return to vanilla code

            /*
             * widget.AddSection("ColonistsSection".Translate(), from pawn in pawns
             *                                                where pawn.IsFreeNonSlaveColonist
             *                                                select pawnTransferable[pawn]);
             *
             * if (ModsConfig.IdeologyActive)
             * {
             *  widget.AddSection("SlavesSection".Translate(), from pawn in pawns
             *                                                 where pawn.IsSlave
             *                                                 select pawnTransferable[pawn]);
             * }
             */

            widget.AddSection("PrisonersSection".Translate(), from pawn in pawns
                              where pawn.IsPrisoner
                              select pawnTransferable[pawn]);

            widget.AddSection("CaptureSection".Translate(), from pawn in pawns
                              where pawn.Downed && CaravanUtility.ShouldAutoCapture(pawn, Faction.OfPlayer)
                              select pawnTransferable[pawn]);

            widget.AddSection("AnimalsSection".Translate(), from pawn in pawns
                              where pawn.RaceProps.Animal
                              select pawnTransferable[pawn]);
            return(false);
        }
Ejemplo n.º 26
0
        private void DoBottomButtons(Rect rect)
        {
            float   num = rect.width / 2f;
            Vector2 bottomButtonSize = BottomButtonSize;
            float   x2 = num - bottomButtonSize.x / 2f;
            float   y  = rect.height - 55f - 17f;
            Vector2 bottomButtonSize2 = BottomButtonSize;
            float   x3 = bottomButtonSize2.x;
            Vector2 bottomButtonSize3 = BottomButtonSize;
            Rect    rect2             = new Rect(x2, y, x3, bottomButtonSize3.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate()))
            {
                if (reform)
                {
                    if (TryReformCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        list.Add((!(daysWorthOfFood.First < 0.1f)) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                        {
                            string text = string.Concat((from str in list
                                                         select str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (TryFormAndSendCaravan())
                                {
                                    Close(doCloseSound: false);
                                }
                            }));
                        }
                    }
                    else if (TryFormAndSendCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
            }
            float   num2 = rect2.x - 10f;
            Vector2 bottomButtonSize4 = BottomButtonSize;
            float   x4 = num2 - bottomButtonSize4.x;
            float   y2 = rect2.y;
            Vector2 bottomButtonSize5 = BottomButtonSize;
            float   x5 = bottomButtonSize5.x;
            Vector2 bottomButtonSize6 = BottomButtonSize;
            Rect    rect3             = new Rect(x4, y2, x5, bottomButtonSize6.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            if (ShowCancelButton)
            {
                float   x6 = rect2.xMax + 10f;
                float   y3 = rect2.y;
                Vector2 bottomButtonSize7 = BottomButtonSize;
                float   x7 = bottomButtonSize7.x;
                Vector2 bottomButtonSize8 = BottomButtonSize;
                Rect    rect4             = new Rect(x6, y3, x7, bottomButtonSize8.y);
                if (Widgets.ButtonText(rect4, "CancelButton".Translate()))
                {
                    Close();
                }
            }
            if (canChooseRoute)
            {
                float   width             = rect.width;
                Vector2 bottomButtonSize9 = BottomButtonSize;
                float   x8 = width - bottomButtonSize9.x;
                float   y4 = rect2.y;
                Vector2 bottomButtonSize10 = BottomButtonSize;
                float   x9 = bottomButtonSize10.x;
                Vector2 bottomButtonSize11 = BottomButtonSize;
                Rect    rect5 = new Rect(x8, y4, x9, bottomButtonSize11.y);
                if (Widgets.ButtonText(rect5, "ChooseRouteButton".Translate()))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
                if (destinationTile != -1)
                {
                    Rect rect6 = rect5;
                    rect6.y     += rect5.height + 4f;
                    rect6.height = 200f;
                    rect6.xMin  -= 200f;
                    Text.Anchor  = TextAnchor.UpperRight;
                    Widgets.Label(rect6, "CaravanEstimatedDaysToDestination".Translate(((float)TicksToArrive / 60000f).ToString("0.#")));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (Prefs.DevMode)
            {
                float   width2             = 200f;
                Vector2 bottomButtonSize12 = BottomButtonSize;
                float   num3  = bottomButtonSize12.y / 2f;
                Rect    rect7 = new Rect(0f, rect.height - 55f - 17f, width2, num3);
                if (Widgets.ButtonText(rect7, "Dev: Send instantly") && DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                Rect rect8 = new Rect(0f, rect.height - 55f - 17f + num3, width2, num3);
                if (Widgets.ButtonText(rect8, "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToSendEverything();
                }
            }
        }
Ejemplo n.º 27
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width - BottomButtonSize.x, rect.height - 55f - 17f, BottomButtonSize.x, BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "Send".Translate()))
            {
                if (reform)
                {
                    if (TryReformCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        list.Add((daysWorthOfFood.First < 0.1f) ? "DaysWorthOfFoodWarningDialog_NoFood".Translate() : "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")));
                    }
                    else if (MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                        {
                            string str2 = string.Concat(list.Select((string str) => str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(str2, delegate
                            {
                                if (TryFormAndSendCaravan())
                                {
                                    Close(doCloseSound: false);
                                }
                            }));
                        }
                    }
                    else if (TryFormAndSendCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
            }
            if (ShowCancelButton && Widgets.ButtonText(new Rect(0f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "CancelButton".Translate()))
            {
                Close();
            }
            if (Widgets.ButtonText(new Rect(rect.width / 2f - BottomButtonSize.x - 8.5f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            if (canChooseRoute)
            {
                if (Widgets.ButtonText(new Rect(rect.width / 2f + 8.5f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "ChangeRouteButton".Translate()))
                {
                    soundClose.PlayOneShotOnCamera();
                    Find.WorldRoutePlanner.Start(this);
                }
                if (destinationTile != -1)
                {
                    Rect rect3 = rect2;
                    rect3.y     += rect2.height + 4f;
                    rect3.height = 200f;
                    rect3.xMin  -= 200f;
                    Text.Anchor  = TextAnchor.UpperRight;
                    Widgets.Label(rect3, "CaravanEstimatedDaysToDestination".Translate(((float)TicksToArrive / 60000f).ToString("0.#")));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (Prefs.DevMode)
            {
                float width  = 200f;
                float height = BottomButtonSize.y / 2f;
                if (Widgets.ButtonText(new Rect(0f, rect2.yMax + 4f, width, height), "Dev: Send instantly") && DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                if (Widgets.ButtonText(new Rect(204f, rect2.yMax + 4f, width, height), "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToSendEverything();
                }
            }
        }
 private static bool <DebugTryFormCaravanInstantly> m__7(Pawn x)
 {
     return(CaravanUtility.IsOwner(x, Faction.OfPlayer));
 }
        private void CloseMapImmediate()
        {
            MapParent mapParent = this.parent as MapParent;

            if (mapParent != null)
            {
                if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, true).Any((Pawn x) => x.IsColonist || x.IsPrisonerOfColony || x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer))
                {
                    foreach (Pawn pawn in mapParent.Map.mapPawns.AllPawnsSpawned)
                    {
                        if (pawn.RaceProps.Humanlike)
                        {
                            Lord lord = pawn.GetLord();
                            if (lord != null)
                            {
                                lord.Notify_PawnLost(pawn, PawnLostCondition.ExitedMap);
                                pawn.ClearMind(false);
                            }
                        }
                    }
                    Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent);
                    Current.Game.CurrentMap = mapParent.Map;
                    Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, true, delegate()
                    {
                        if (mapParent.HasMap)
                        {
                            Find.WorldObjects.Remove(mapParent);
                        }
                    }, false);
                    List <Pawn> list = mapParent.Map.mapPawns.AllPawnsSpawned.ToList <Pawn>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        Pawn pawn2 = list[i];
                        if (!pawn2.HostileTo(Faction.OfPlayer) && (pawn2.Faction == Faction.OfPlayer || pawn2.IsPrisonerOfColony))
                        {
                            Log.Message(pawn2.Label + " Meets criteria in CaravanUtility.");
                        }
                        else
                        {
                            Log.Message(pawn2.Label + " NOT ALLOWED by in CaravanUtility.");
                        }
                    }
                    Find.WindowStack.Add(window);
                }
                else
                {
                    List <Pawn> list2 = new List <Pawn>();
                    list2.AddRange(from x in mapParent.Map.mapPawns.AllPawns
                                   where x.IsColonist || x.IsPrisonerOfColony || x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer
                                   select x);
                    if (list2.Any <Pawn>())
                    {
                        if (list2.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
                        {
                            //TODO: check if it works
                            CaravanExitMapUtility.ExitMapAndCreateCaravan(list2, Faction.OfPlayer,
                                                                          mapParent.Tile, mapParent.Tile, mapParent.Tile, false);
                            Messages.Message("MessageReformedCaravan".Translate(),
                                             MessageTypeDefOf.PositiveEvent);
                        }
                        else
                        {
                            StringBuilder stringBuilder = new StringBuilder();
                            for (int j = 0; j < list2.Count; j++)
                            {
                                stringBuilder.AppendLine("    " + list2[j].LabelCap);
                            }
                            Find.LetterStack.ReceiveLetter("RD_LetterLabelPawnsLostDueToMapCountdown".Translate(),
                                                           TranslatorFormattedStringExtensions.Translate("RD_LetterPawnsLostDueToMapCountdown",
                                                                                                         new NamedArgument[]
                            {
                                stringBuilder.ToString().TrimEndNewlines()
                            }), LetterDefOf.ThreatSmall, new GlobalTargetInfo(mapParent.Tile), null);
                        }
                        list2.Clear();
                    }
                    Find.WorldObjects.Remove(mapParent);
                }
            }
        }
Ejemplo n.º 30
0
        private void DoBottomButtons(Rect rect)
        {
            double  num = rect.width / 2.0;
            Vector2 bottomButtonSize = this.BottomButtonSize;
            double  x2 = num - bottomButtonSize.x / 2.0;
            double  y  = rect.height - 55.0;
            Vector2 bottomButtonSize2 = this.BottomButtonSize;
            float   x3 = bottomButtonSize2.x;
            Vector2 bottomButtonSize3 = this.BottomButtonSize;
            Rect    rect2             = new Rect((float)x2, (float)y, x3, bottomButtonSize3.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.reform)
                {
                    if (this.TryReformCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5.0)
                    {
                        list.Add((!(daysWorthOfFood.First < 0.10000000149011612)) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (this.MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(this.transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                        {
                            string text = string.Concat((from str in list
                                                         select str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (this.TryFormAndSendCaravan())
                                {
                                    this.Close(false);
                                }
                            }, false, null));
                        }
                    }
                    else if (this.TryFormAndSendCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
            }
            double  num2 = rect2.x - 10.0;
            Vector2 bottomButtonSize4 = this.BottomButtonSize;
            double  x4 = num2 - bottomButtonSize4.x;
            float   y2 = rect2.y;
            Vector2 bottomButtonSize5 = this.BottomButtonSize;
            float   x5 = bottomButtonSize5.x;
            Vector2 bottomButtonSize6 = this.BottomButtonSize;
            Rect    rect3             = new Rect((float)x4, y2, x5, bottomButtonSize6.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            double  x6 = rect2.xMax + 10.0;
            float   y3 = rect2.y;
            Vector2 bottomButtonSize7 = this.BottomButtonSize;
            float   x7 = bottomButtonSize7.x;
            Vector2 bottomButtonSize8 = this.BottomButtonSize;
            Rect    rect4             = new Rect((float)x6, y3, x7, bottomButtonSize8.y);

            if (Widgets.ButtonText(rect4, (!this.cancellingWillAbandon) ? "CancelButton".Translate() : "AbandonButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
            if (this.showEstTimeToDestinationButton)
            {
                float   width             = rect.width;
                Vector2 bottomButtonSize9 = this.BottomButtonSize;
                float   x8 = width - bottomButtonSize9.x;
                float   y4 = rect2.y;
                Vector2 bottomButtonSize10 = this.BottomButtonSize;
                float   x9 = bottomButtonSize10.x;
                Vector2 bottomButtonSize11 = this.BottomButtonSize;
                Rect    rect5 = new Rect(x8, y4, x9, bottomButtonSize11.y);
                if (Widgets.ButtonText(rect5, "EstimatedTimeToDestinationButton".Translate(), true, false, true))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                float   width2             = 200f;
                Vector2 bottomButtonSize12 = this.BottomButtonSize;
                float   num3  = (float)(bottomButtonSize12.y / 2.0);
                Rect    rect6 = new Rect(0f, (float)(rect.height - 55.0), width2, num3);
                if (Widgets.ButtonText(rect6, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect7 = new Rect(0f, (float)(rect.height - 55.0 + num3), width2, num3);
                if (Widgets.ButtonText(rect7, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.SetToSendEverything();
                }
            }
        }