示例#1
0
        private static void TryOpenComms(Pawn actor)
        {
            var curJobCommTarget = actor.jobs.curJob.commTarget;

            if (curJobCommTarget is Faction f)
            {
                var dialog_Negotiation = new Dialog_Negotiation(actor, f,
                                                                JecsToolsFactionDialogMaker.FactionDialogFor(actor, f), true);
                dialog_Negotiation.soundAmbient = SoundDefOf.RadioComms_Ambience;
                Find.WindowStack.Add(dialog_Negotiation);
                return;
            }
            if (!(curJobCommTarget is TradeShip ts))
            {
                return;
            }
            if (!ts.CanTradeNow)
            {
                return;
            }
            Find.WindowStack.Add(new Dialog_Trade(actor, ts));
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.BuildOrbitalTradeBeacon, OpportunityType.Critical);
            var empty  = string.Empty;
            var empty2 = string.Empty;

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(
                ts.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradeShip".Translate());
            if (!empty2.NullOrEmpty())
            {
                Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.PositiveEvent, null);
            }
            TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradeGoodsMustBeNearBeacon);
        }
示例#2
0
        public static void UpdateExtinguishDesignation(Thing t)
        {
            bool flag = false;

            if (t is ThingWithComps thingWithComps)
            {
                for (int i = 0; i < thingWithComps.AllComps.Count; i++)
                {
                    if (thingWithComps.AllComps[i] is CompExtinguishable compExtinguishable && compExtinguishable.WantsFlick())
                    {
                        Tools.Warn("wants to be extinguished", true);
                        flag = true;
                        break;
                    }
                }
            }
            Designation designation = t.Map.designationManager.DesignationOn(t, DesignationDefOf.Flick);

            if (flag && designation == null)
            {
                t.Map.designationManager.AddDesignation(new Designation(t, DesignationDefOf.Flick));
            }
            else if (!flag && designation != null)
            {
                designation.Delete();
            }
            TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.SwitchFlickingDesignation);
        }
示例#3
0
        //public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff)
        public static void Prefix(ref Blueprint_Build __result, BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff)
        {
            if (faction != Faction.OfPlayer)
            {
                return;
            }

            foreach (IntVec3 cell in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size))
            {
                if (map.designationManager.DesignationAt(cell, DesignationDefOf.Mine) != null)
                {
                    continue;
                }

                if (sourceDef is ThingDef thingDef)
                {
                    foreach (Thing mineThing in map.thingGrid.ThingsAt(cell).Where(t => t.IsMineableRock()))
                    {
                        if (!DontMineSmoothingRock.ToBeSmoothed(mineThing, thingDef))
                        {
                            map.designationManager.AddDesignation(new Designation(mineThing, DesignationDefOf.Mine));

                            if (mineThing.def.building?.mineableYieldWasteable ?? false)
                            {
                                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.BuildersTryMine);
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        private void UpdateDesignation()
        {
            if (!JobPatched)
            {
                FlickSwitches();
                return;
            }

            var designationManager = parent?.Map?.designationManager;

            if (designationManager != null)
            {
                var flickDesignation = parent.Map.designationManager.DesignationOn(parent, DesignationDefOf.Flick);
                if (WantFlick)
                {
                    if (flickDesignation == null)
                    {
                        designationManager.AddDesignation(new Designation((LocalTargetInfo)parent, DesignationDefOf.Flick));
                    }
                }
                else
                {
                    flickDesignation?.Delete();
                }
                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.SwitchFlickingDesignation, Array.Empty <string>());
            }
        }
示例#5
0
        public static void AddArrestOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            //TODO this is some copy-pasted example, refactor it so it should add arrest option
            IntVec3 c = IntVec3.FromVector3(clickPos);

            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, ForArrest(pawn), true))
                {
                    LocalTargetInfo dest = current;
                    bool            flag = dest.HasThing && dest.Thing is Pawn && ((Pawn)dest.Thing).IsWildMan();
                    if (!pawn.Drafted || flag)
                    {
                        if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            Pawn   pTarg  = (Pawn)dest.Thing;
                            Action action = delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, true);
                                }
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageTypeDefOf.RejectInput, false);
                                    return;
                                }
                                Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed);
                                job.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                                if (pTarg.Faction != null && pTarg.Faction != Faction.OfPlayer && !pTarg.Faction.def.hidden)
                                {
                                    TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies);
                                }
                            };
                            string             label    = "TryToArrest".Translate(dest.Thing.LabelCap, dest.Thing);
                            Action             action2  = action;
                            MenuOptionPriority priority = MenuOptionPriority.High;
                            Thing thing = dest.Thing;
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action2, priority, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy"));
                        }
                    }
                }
            }
        }
示例#6
0
        //For Multiplayer Compatibility
        public static void ArrestPrisoner(Pawn pTarg, Pawn pawn)
        {
            Building_Bed building_Bed = FindBed(pTarg, pawn);

            if (building_Bed == null)
            {
                Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageTypeDefOf.RejectInput, false);
                return;
            }
            Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed);

            job.count = 1;
            pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
            if (pTarg.Faction != null && pTarg.Faction != Faction.OfPlayer && !pTarg.Faction.def.hidden)
            {
                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies);
            }
        }
示例#7
0
 public override IEnumerable <Gizmo> GetGizmos()
 {
     foreach (Gizmo gizmo in base.GetGizmos())
     {
         yield return(gizmo);
     }
     if (TraderKind != null)
     {
         Command_Action command_Action = new Command_Action();
         command_Action.defaultLabel = "CommandShowSellableItems".Translate();
         command_Action.defaultDesc  = "CommandShowSellableItemsDesc".Translate();
         command_Action.icon         = ShowSellableItemsCommand;
         command_Action.action       = delegate
         {
             Find.WindowStack.Add(new Dialog_SellableItems(this));
             RoyalTitleDef titleRequiredToTrade = TraderKind.TitleRequiredToTrade;
             if (titleRequiredToTrade != null)
             {
                 TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradingRequiresPermit, titleRequiredToTrade.GetLabelCapForBothGenders());
             }
         };
         yield return(command_Action);
     }
     if (base.Faction != Faction.OfPlayer && !PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.FormCaravan))
     {
         Command_Action command_Action2 = new Command_Action();
         command_Action2.defaultLabel = "CommandFormCaravan".Translate();
         command_Action2.defaultDesc  = "CommandFormCaravanDesc".Translate();
         command_Action2.icon         = FormCaravanCommand;
         command_Action2.action       = delegate
         {
             Find.Tutor.learningReadout.TryActivateConcept(ConceptDefOf.FormCaravan);
             Messages.Message("MessageSelectOwnBaseToFormCaravan".Translate(), MessageTypeDefOf.RejectInput, historical: false);
         };
         yield return(command_Action2);
     }
 }
示例#8
0
        public void DoWindowContents(Rect canvas)
        {
            Listing_Standard list = new Listing_Standard();

            list.ColumnWidth = (canvas.width - 17) / 2; // Subtract 17 for gap between columns
            list.Begin(canvas);

            // Do general settings
            Text.Font = GameFont.Medium;
            list.Label("CE_Settings_HeaderGeneral".Translate());
            Text.Font = GameFont.Small;
            list.Gap();

            list.CheckboxLabeled("CE_Settings_ShowCasings_Title".Translate(), ref showCasings, "CE_Settings_ShowCasings_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_ShowTaunts_Title".Translate(), ref showTaunts, "CE_Settings_ShowTaunts_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_AllowMeleeHunting_Title".Translate(), ref allowMeleeHunting, "CE_Settings_AllowMeleeHunting_Desc".Translate());

#if DEBUG
            // Do Debug settings
            list.GapLine();
            Text.Font = GameFont.Medium;
            list.Label("Debug");
            Text.Font = GameFont.Small;
            list.Gap();

            list.CheckboxLabeled("Draw partial LoS checks", ref debugDrawPartialLoSChecks, "Displays line of sight checks against partial cover.");
            list.CheckboxLabeled("Draw target cover checks", ref debugDrawTargetCoverChecks, "Displays highest cover of target as it is selected.");
            list.CheckboxLabeled("Enable inventory validation", ref debugEnableInventoryValidation, "Inventory will refresh its cache every tick and log any discrepancies.");
            list.CheckboxLabeled("Display tree collision chances", ref debugShowTreeCollisionChance, "Projectiles will display chances of coliding with trees as they pass by.");
            list.CheckboxLabeled("Display suppression buildup", ref debugShowSuppressionBuildup, "Pawns will display buildup numbers when taking suppression.");
#endif

            // Do ammo settings
            list.NewColumn();

            Text.Font = GameFont.Medium;
            list.Label("CE_Settings_HeaderAmmo".Translate());
            Text.Font = GameFont.Small;
            list.Gap();

            list.CheckboxLabeled("CE_Settings_EnableAmmoSystem_Title".Translate(), ref enableAmmoSystem, "CE_Settings_EnableAmmoSystem_Desc".Translate());
            list.GapLine();
            if (enableAmmoSystem)
            {
                list.CheckboxLabeled("CE_Settings_RightClickAmmoSelect_Title".Translate(), ref rightClickAmmoSelect, "CE_Settings_RightClickAmmoSelect_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_AutoReloadOnChangeAmmo_Title".Translate(), ref autoReloadOnChangeAmmo, "CE_Settings_AutoReloadOnChangeAmmo_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_AutoTakeAmmo_Title".Translate(), ref autoTakeAmmo, "CE_Settings_AutoTakeAmmo_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_ShowCaliberOnGuns_Title".Translate(), ref showCaliberOnGuns, "CE_Settings_ShowCaliberOnGuns_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_ReuseNeolithicProjectiles_Title".Translate(), ref reuseNeolithicProjectiles, "CE_Settings_ReuseNeolithicProjectiles_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_RealisticCookOff_Title".Translate(), ref realisticCookOff, "CE_Settings_RealisticCookOff_Desc".Translate());
            }
            else
            {
                GUI.contentColor = Color.gray;
                list.Label("CE_Settings_RightClickAmmoSelect_Title".Translate());
                list.Label("CE_Settings_AutoReloadOnChangeAmmo_Title".Translate());
                list.Label("CE_Settings_AutoTakeAmmo_Title".Translate());
                list.Label("CE_Settings_ShowCaliberOnGuns_Title".Translate());
                list.Label("CE_Settings_ReuseNeolithicProjectiles_Title".Translate());
                list.Label("CE_Settings_RealisticCookOff_Title".Translate());
                GUI.contentColor = Color.white;
            }

            list.End();

            // Update ammo if setting changes
            if (lastAmmoSystemStatus != enableAmmoSystem)
            {
                AmmoInjector.Inject();
                lastAmmoSystemStatus = enableAmmoSystem;
                TutorUtility.DoModalDialogIfNotKnown(CE_ConceptDefOf.CE_AmmoSettings);
            }
        }
示例#9
0
        public void DoWindowContents(Rect canvas)
        {
            Listing_Standard list = new Listing_Standard();

            list.ColumnWidth = (canvas.width - 17) / 2; // Subtract 17 for gap between columns
            list.Begin(canvas);

            // Do general settings
            Text.Font = GameFont.Medium;
            list.Label("CE_Settings_HeaderGeneral".Translate());
            Text.Font = GameFont.Small;
            list.Gap();

            list.CheckboxLabeled("CE_Settings_ShowCasings_Title".Translate(), ref showCasings, "CE_Settings_ShowCasings_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_ShowTaunts_Title".Translate(), ref showTaunts, "CE_Settings_ShowTaunts_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_AllowMeleeHunting_Title".Translate(), ref allowMeleeHunting, "CE_Settings_AllowMeleeHunting_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_SmokeEffects_Title".Translate(), ref smokeEffects, "CE_Settings_SmokeEffects_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_MergeExplosions_Title".Translate(), ref mergeExplosions, "CE_Settings_MergeExplosions_Desc".Translate());
            list.CheckboxLabeled("CE_Settings_TurretsBreakShields_Title".Translate(), ref turretsBreakShields, "CE_Settings_TurretsBreakShields_Desc".Translate());

            // Only Allow these settings to be changed in the main menu since doing while a
            // map is loaded will result in rendering issues.
            if (Current.Game == null)
            {
                list.CheckboxLabeled("CE_Settings_ShowBackpacks_Title".Translate(), ref showBackpacks, "CE_Settings_ShowBackpacks_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_ShowWebbing_Title".Translate(), ref showTacticalVests, "CE_Settings_ShowWebbing_Desc".Translate());
            }
            else
            {
                // tell the user that he can only change these settings from main menu
                list.GapLine();
                Text.Font = GameFont.Medium;
                list.Label("CE_Settings_MainMenuOnly_Title".Translate(), tooltip: "CE_Settings_MainMenuOnly_Desc".Translate());
                Text.Font = GameFont.Small;

                list.Gap();
                list.Label("CE_Settings_ShowBackpacks_Title".Translate(), tooltip: "CE_Settings_ShowBackpacks_Desc".Translate());
                list.Label("CE_Settings_ShowWebbing_Title".Translate(), tooltip: "CE_Settings_ShowWebbing_Desc".Translate());
                list.Gap();
            }

#if DEBUG
            // Do Debug settings
            list.GapLine();
            Text.Font = GameFont.Medium;
            list.Label("Debug");
            list.Gap();
            Text.Font = GameFont.Small;
            list.CheckboxLabeled("Enable debugging", ref debuggingMode, "This will enable all debugging features.");
            if (debuggingMode)
            {
                list.GapLine();
                list.CheckboxLabeled("Verbose", ref debugVerbose, "Enable logging for internel states and many other things.");
                list.CheckboxLabeled("Draw intercept checks", ref debugDrawInterceptChecks, "Displays projectile checks for intercept.");
                list.CheckboxLabeled("Draw partial LoS checks", ref debugDrawPartialLoSChecks, "Displays line of sight checks against partial cover.");
                list.CheckboxLabeled("Draw debug things in range", ref debugGenClosetPawn);
                list.CheckboxLabeled("Draw target cover checks", ref debugDrawTargetCoverChecks, "Displays highest cover of target as it is selected.");
                list.CheckboxLabeled("Enable inventory validation", ref debugEnableInventoryValidation, "Inventory will refresh its cache every tick and log any discrepancies.");
                list.CheckboxLabeled("Display tree collision chances", ref debugShowTreeCollisionChance, "Projectiles will display chances of coliding with trees as they pass by.");
                list.CheckboxLabeled("Display suppression buildup", ref debugShowSuppressionBuildup, "Pawns will display buildup numbers when taking suppression.");
                list.CheckboxLabeled("Display light intensity affected by muzzle flash", ref debugMuzzleFlash);
            }
            else
            {
                list.Gap();
            }
#endif

            // Do ammo settings
            list.NewColumn();

            Text.Font = GameFont.Medium;
            list.Label("CE_Settings_HeaderAmmo".Translate());
            Text.Font = GameFont.Small;
            list.Gap();

            list.CheckboxLabeled("CE_Settings_EnableAmmoSystem_Title".Translate(), ref enableAmmoSystem, "CE_Settings_EnableAmmoSystem_Desc".Translate());
            list.GapLine();
            if (enableAmmoSystem)
            {
                list.CheckboxLabeled("CE_Settings_RightClickAmmoSelect_Title".Translate(), ref rightClickAmmoSelect, "CE_Settings_RightClickAmmoSelect_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_AutoReloadOnChangeAmmo_Title".Translate(), ref autoReloadOnChangeAmmo, "CE_Settings_AutoReloadOnChangeAmmo_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_AutoTakeAmmo_Title".Translate(), ref autoTakeAmmo, "CE_Settings_AutoTakeAmmo_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_ShowCaliberOnGuns_Title".Translate(), ref showCaliberOnGuns, "CE_Settings_ShowCaliberOnGuns_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_ReuseNeolithicProjectiles_Title".Translate(), ref reuseNeolithicProjectiles, "CE_Settings_ReuseNeolithicProjectiles_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_RealisticCookOff_Title".Translate(), ref realisticCookOff, "CE_Settings_RealisticCookOff_Desc".Translate());
                list.CheckboxLabeled("CE_Settings_EnableSimplifiedAmmo_Title".Translate(), ref enableSimplifiedAmmo, "CE_Settings_EnableSimplifiedAmmo_Desc".Translate());;
            }
            else
            {
                GUI.contentColor = Color.gray;
                list.Label("CE_Settings_RightClickAmmoSelect_Title".Translate());
                list.Label("CE_Settings_AutoReloadOnChangeAmmo_Title".Translate());
                list.Label("CE_Settings_AutoTakeAmmo_Title".Translate());
                list.Label("CE_Settings_ShowCaliberOnGuns_Title".Translate());
                list.Label("CE_Settings_ReuseNeolithicProjectiles_Title".Translate());
                list.Label("CE_Settings_RealisticCookOff_Title".Translate());
                list.Label("CE_Settings_EnableSimplifiedAmmo_Title".Translate());

                GUI.contentColor = Color.white;
            }

            list.End();

            // Update ammo if setting changes
            if (lastAmmoSystemStatus != enableAmmoSystem)
            {
                AmmoInjector.Inject();
                AmmoInjector.AddRemoveCaliberFromGunRecipes();  //Ensure the labels are _removed_ when the ammo system gets disabled
                lastAmmoSystemStatus = enableAmmoSystem;
                TutorUtility.DoModalDialogIfNotKnown(CE_ConceptDefOf.CE_AmmoSettings);
            }
            else if (AmmoInjector.gunRecipesShowCaliber != showCaliberOnGuns)
            {
                AmmoInjector.AddRemoveCaliberFromGunRecipes();
            }
        }
示例#10
0
            public static FloatMenuOption AddArrestOption(Pawn pawn, Pawn victim)
            {
                if (!pawn.CanReach(victim, PathEndMode.OnCell, Danger.Deadly))
                {
                    return(new FloatMenuOption(
                               "CannotArrest".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null));
                }
                else
                {
                    Pawn   pTarg2 = victim;
                    Action action = delegate
                    {
                        var  ZTracker     = ZUtils.ZTracker;
                        var  oldMap       = pawn.Map;
                        var  oldPosition1 = pawn.Position;
                        var  oldPosition2 = victim.Position;
                        bool select       = false;
                        if (Find.Selector.SelectedObjects.Contains(pawn))
                        {
                            select = true;
                        }

                        Building building_Bed3 = null;
                        foreach (var otherMap in ZUtils.GetAllMapsInClosestOrderForTwoThings(pawn, oldMap,
                                                                                             oldPosition1, victim, oldMap, oldPosition2))
                        {
                            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)
                            {
                                break;
                            }
                        }

                        ZUtils.TeleportThing(pawn, oldMap, oldPosition1);
                        ZUtils.TeleportThing(victim, oldMap, oldPosition2);

                        if (select)
                        {
                            Find.Selector.Select(pawn);
                        }

                        if (building_Bed3 == null)
                        {
                            Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(),
                                             pTarg2, MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else
                        {
                            Job job = JobMaker.MakeJob(JobDefOf.Arrest, pTarg2, building_Bed3);
                            job.count = 1;
                            ZTracker.BuildJobListFor(pawn, pawn.Map, job);
                            ZLogger.Message(pawn + " taking first job 3");
                            pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, false);

                            if (pTarg2.Faction != null &&
                                ((pTarg2.Faction != Faction.OfPlayer && !pTarg2.Faction.def.hidden) ||
                                 pTarg2.IsQuestLodger()))
                            {
                                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies);
                            }
                        }
                    };
                    return(FloatMenuUtility.DecoratePrioritizedTask(
                               new FloatMenuOption(
                                   "TryToArrest".Translate(victim.LabelCap, victim,
                                                           pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()), action,
                                   MenuOptionPriority.High, null, victim), pawn, pTarg2));
                }
            }
示例#11
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);
        }
示例#12
0
        internal static void AddDraftedOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 b = IntVec3.FromVector3(clickPos);

            foreach (TargetInfo attackTarg in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true))
            {
                if (pawn.equipment.Primary != null && !pawn.equipment.PrimaryEq.PrimaryVerb.verbProps.MeleeRange)
                {
                    string str;
                    Action rangedAct = FloatMenuUtility.GetRangedAttackAction(pawn, attackTarg, out str);
                    string text      = "FireAt".Translate(new object[]
                    {
                        attackTarg.Thing.LabelCap
                    });
                    FloatMenuOption floatMenuOption = new FloatMenuOption();
                    floatMenuOption.priority = MenuOptionPriority.High;
                    if (rangedAct == null)
                    {
                        text = text + " (" + str + ")";
                    }
                    else
                    {
                        floatMenuOption.autoTakeable = true;
                        floatMenuOption.action       = new Action(delegate
                        {
                            MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f);
                            rangedAct();
                        });
                    }
                    floatMenuOption.Label = text;
                    opts.Add(floatMenuOption);
                }
                string str2;
                Action meleeAct = FloatMenuUtility.GetMeleeAttackAction(pawn, attackTarg, out str2);
                Pawn   pawn2    = attackTarg.Thing as Pawn;
                string text2;
                if (pawn2 != null && pawn2.Downed)
                {
                    text2 = "MeleeAttackToDeath".Translate(new object[]
                    {
                        attackTarg.Thing.LabelCap
                    });
                }
                else
                {
                    text2 = "MeleeAttack".Translate(new object[]
                    {
                        attackTarg.Thing.LabelCap
                    });
                }
                Thing           thing            = attackTarg.Thing;
                FloatMenuOption floatMenuOption2 = new FloatMenuOption(string.Empty, null, MenuOptionPriority.High, null, thing, 0f, null);
                if (meleeAct == null)
                {
                    text2 = text2 + " (" + str2 + ")";
                }
                else
                {
                    floatMenuOption2.action = delegate
                    {
                        MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f);
                        meleeAct();
                    };
                }
                floatMenuOption2.Label = text2;
                opts.Add(floatMenuOption2);
            }
            if (pawn.RaceProps.Humanlike && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForArrest(pawn), true))
                {
                    TargetInfo dest = current2;
                    if (!((Pawn)dest.Thing).Downed)
                    {
                        if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null));
                        }
                        else if (!pawn.CanReserve(dest.Thing, 1))
                        {
                            opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Medium, null, null, 0f, null));
                        }
                        else
                        {
                            Pawn   pTarg  = (Pawn)dest.Thing;
                            Action action = delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageSound.RejectInput);
                                    return;
                                }
                                Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed);
                                job.playerForced  = true;
                                job.maxNumToCarry = 1;
                                pawn.drafter.TakeOrderedJob(job);
                                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies);
                            };
                            Thing thing = dest.Thing;
                            opts.Add(new FloatMenuOption("TryToArrest".Translate(new object[]
                            {
                                dest.Thing.LabelCap
                            }), action, MenuOptionPriority.Medium, null, thing, 0f, null));
                        }
                    }
                }
            }
            int     num = GenRadial.NumCellsInRadius(2.9f);
            IntVec3 curLoc;

            for (int i = 0; i < num; i++)
            {
                curLoc = GenRadial.RadialPattern[i] + b;
                if (curLoc.Standable())
                {
                    if (curLoc != pawn.Position)
                    {
                        if (!pawn.CanReach(curLoc, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            FloatMenuOption item = new FloatMenuOption("CannotGoNoPath".Translate(), null, MenuOptionPriority.Low, null, null, 0f, null);
                            opts.Add(item);
                        }
                        else
                        {
                            Action action2 = delegate
                            {
                                IntVec3 intVec = Pawn_DraftController.BestGotoDestNear(curLoc, pawn);
                                Job     job    = new Job(JobDefOf.Goto, intVec);
                                job.playerForced = true;
                                pawn.drafter.TakeOrderedJob(job);
                                MoteThrower.ThrowStatic(intVec, ThingDefOf.Mote_FeedbackGoto, 1f);
                            };
                            opts.Add(new FloatMenuOption("GoHere".Translate(), action2, MenuOptionPriority.Low, null, null, 0f, null)
                            {
                                autoTakeable = true
                            });
                        }
                    }
                    break;
                }
            }
        }
示例#13
0
        internal static List <FloatMenuOption> ChoicesAtFor(Vector3 clickPos, Pawn pawn)
        {
            IntVec3 clickCell = IntVec3.FromVector3(clickPos);

            DangerUtility.NotifyDirectOrderingThisFrame(pawn);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (!clickCell.InBounds())
            {
                return(list);
            }

            // ***** Beginning of drafted options *****

            if (pawn.Drafted)
            {
                foreach (TargetInfo attackTarg in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true))
                {
                    // *** Fire at option ***

                    if (pawn.equipment.Primary != null && !pawn.equipment.PrimaryEq.PrimaryVerb.verbProps.MeleeRange)
                    {
                        string str;
                        Action rangedAct = FloatMenuUtility.GetRangedAttackAction(pawn, attackTarg, out str);
                        string text      = "FireAt".Translate(new object[]
                        {
                            attackTarg.Thing.LabelCap
                        });
                        FloatMenuOption floatMenuOption = new FloatMenuOption();
                        floatMenuOption.priority = MenuOptionPriority.High;
                        if (rangedAct == null)
                        {
                            text = text + " (" + str + ")";
                        }
                        else
                        {
                            floatMenuOption.autoTakeable = true;
                            floatMenuOption.action       = new Action(delegate
                            {
                                MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f);
                                rangedAct();
                            });
                        }
                        floatMenuOption.label = text;
                        list.Add(floatMenuOption);
                    }

                    // *** Melee attack option ***

                    string str2;
                    Action meleeAct = FloatMenuUtility.GetMeleeAttackAction(pawn, attackTarg, out str2);
                    Pawn   pawn2    = attackTarg.Thing as Pawn;
                    string text2;
                    if (pawn2 != null && pawn2.Downed)
                    {
                        text2 = "MeleeAttackToDeath".Translate(new object[]
                        {
                            attackTarg.Thing.LabelCap
                        });
                    }
                    else
                    {
                        text2 = "MeleeAttack".Translate(new object[]
                        {
                            attackTarg.Thing.LabelCap
                        });
                    }
                    Thing           thing            = attackTarg.Thing;
                    FloatMenuOption floatMenuOption2 = new FloatMenuOption(string.Empty, null, MenuOptionPriority.High, null, thing);
                    if (meleeAct == null)
                    {
                        text2 = text2 + " (" + str2 + ")";
                    }
                    else
                    {
                        floatMenuOption2.action = new Action(delegate
                        {
                            MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f);
                            meleeAct();
                        });
                    }
                    floatMenuOption2.label = text2;
                    list.Add(floatMenuOption2);
                }

                // *** Arrest option ***

                if (pawn.RaceProps.Humanlike && !pawn.Downed)
                {
                    foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForArrest(pawn), true))
                    {
                        TargetInfo dest = current2;
                        if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            list.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null));
                        }
                        else if (!pawn.CanReserve(dest.Thing, 1))
                        {
                            list.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Medium, null, null));
                        }
                        else
                        {
                            Pawn   pTarg  = (Pawn)dest.Thing;
                            Action action = new Action(delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageSound.RejectInput);
                                    return;
                                }
                                Job job           = new Job(JobDefOf.Arrest, pTarg, building_Bed);
                                job.playerForced  = true;
                                job.maxNumToCarry = 1;
                                pawn.drafter.TakeOrderedJob(job);
                                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies);
                            });
                            List <FloatMenuOption> arg_3F1_0 = list;
                            Thing thing = dest.Thing;
                            arg_3F1_0.Add(new FloatMenuOption("TryToArrest".Translate(new object[]
                            {
                                dest.Thing.LabelCap
                            }), action, MenuOptionPriority.Medium, null, thing));
                        }
                    }
                }

                // *** Goto option ***

                int num = GenRadial.NumCellsInRadius(2.9f);
                for (int i = 0; i < num; i++)
                {
                    IntVec3 curLoc = GenRadial.RadialPattern[i] + clickCell;
                    if (curLoc.Standable())
                    {
                        if (curLoc != pawn.Position)
                        {
                            if (!pawn.CanReach(curLoc, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                            {
                                FloatMenuOption item = new FloatMenuOption("CannotGoNoPath".Translate(), null, MenuOptionPriority.Low, null, null);
                                list.Add(item);
                            }
                            else
                            {
                                Action action2 = new Action(delegate
                                {
                                    IntVec3 dest     = Pawn_DraftController.BestGotoDestNear(curLoc, pawn);
                                    Job job          = new Job(JobDefOf.Goto, dest);
                                    job.playerForced = true;
                                    pawn.drafter.TakeOrderedJob(job);
                                    MoteThrower.ThrowStatic(dest, ThingDefOf.Mote_FeedbackGoto, 1f);
                                });
                                list.Add(new FloatMenuOption("GoHere".Translate(), action2, MenuOptionPriority.Low, null, null)
                                {
                                    autoTakeable = true
                                });
                            }
                        }
                        break;
                    }
                }
            }

            // *** End of drafted options ***

            // *** Beginning of humanlike options ***

            if (pawn.RaceProps.Humanlike)
            {
                int num2 = 0;
                if (pawn.story != null)
                {
                    num2 = pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire);
                }

                // *** Consume option ***

                foreach (Thing current3 in clickCell.GetThingList())
                {
                    Thing t = current3;
                    if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow)
                    {
                        FloatMenuOption item2;
                        if (t.def.ingestible.isPleasureDrug && num2 < 0)
                        {
                            item2 = new FloatMenuOption("ConsumeThing".Translate(new object[]
                            {
                                t.LabelBaseShort
                            }) + " (" + "Teetotaler".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            item2 = new FloatMenuOption("ConsumeThing".Translate(new object[]
                            {
                                t.LabelBaseShort
                            }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else if (!pawn.CanReserve(t, 1))
                        {
                            item2 = new FloatMenuOption("ConsumeThing".Translate(new object[]
                            {
                                t.LabelBaseShort
                            }) + " (" + "ReservedBy".Translate(new object[]
                            {
                                Find.Reservations.FirstReserverOf(t, pawn.Faction).LabelBaseShort
                            }) + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else
                        {
                            item2 = new FloatMenuOption("ConsumeThing".Translate(new object[]
                            {
                                t.LabelBaseShort
                            }), new Action(delegate
                            {
                                t.SetForbidden(false, true);
                                Job job           = new Job(JobDefOf.Ingest, t);
                                job.maxNumToCarry = t.def.ingestible.maxNumToIngestAtOnce;
                                pawn.drafter.TakeOrderedJob(job);
                            }), MenuOptionPriority.Medium, null, null);
                        }
                        list.Add(item2);
                    }
                }

                // *** Rescue/Capture downed option ***

                foreach (TargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    Pawn victim = (Pawn)current4.Thing;
                    if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && !victim.IsPrisonerOfColony)
                    {
                        if ((victim.Faction == Faction.OfColony && victim.MentalStateDef == null) || (victim.Faction != Faction.OfColony && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfColony))))
                        {
                            List <FloatMenuOption> arg_8E1_0 = list;
                            Pawn victim2 = victim;
                            arg_8E1_0.Add(new FloatMenuOption("Rescue".Translate(new object[]
                            {
                                victim2.LabelCap
                            }), new Action(delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false);
                                if (building_Bed == null)
                                {
                                    string str;
                                    if (victim.RaceProps.Animal)
                                    {
                                        str = "NoAnimalBed".Translate();
                                    }
                                    else
                                    {
                                        str = "NoNonPrisonerBed".Translate();
                                    }
                                    Messages.Message("CannotRescue".Translate() + ": " + str, victim, MessageSound.RejectInput);
                                    return;
                                }
                                Job job           = new Job(JobDefOf.Rescue, victim, building_Bed);
                                job.maxNumToCarry = 1;
                                job.playerForced  = true;
                                pawn.drafter.TakeOrderedJob(job);
                                ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total);
                            }), MenuOptionPriority.Medium, null, victim2));
                        }
                        if (victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfColony))
                        {
                            List <FloatMenuOption> arg_962_0 = list;
                            Pawn victim2 = victim;
                            arg_962_0.Add(new FloatMenuOption("Capture".Translate(new object[]
                            {
                                victim2.LabelCap
                            }), new Action(delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput);
                                    return;
                                }
                                Job job           = new Job(JobDefOf.Capture, victim, building_Bed);
                                job.maxNumToCarry = 1;
                                job.playerForced  = true;
                                pawn.drafter.TakeOrderedJob(job);
                                ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total);
                            }), MenuOptionPriority.Medium, null, victim2));
                        }
                    }
                }

                // *** Carry to cryosleep option ***

                foreach (TargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    TargetInfo targetInfo = current5;
                    Pawn       victim     = (Pawn)targetInfo.Thing;
                    if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null)
                    {
                        string label = "CarryToCryptosleepCasket".Translate(new object[]
                        {
                            targetInfo.Thing.LabelCap
                        });
                        JobDef jDef    = JobDefOf.CarryToCryptosleepCasket;
                        Action action3 = new Action(delegate
                        {
                            Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn);
                            if (building_CryptosleepCasket == null)
                            {
                                Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput);
                                return;
                            }
                            Job job           = new Job(jDef, victim, building_CryptosleepCasket);
                            job.maxNumToCarry = 1;
                            job.playerForced  = true;
                            pawn.drafter.TakeOrderedJob(job);
                        });
                        List <FloatMenuOption> arg_A80_0 = list;
                        Pawn victim2 = victim;
                        arg_A80_0.Add(new FloatMenuOption(label, action3, MenuOptionPriority.Medium, null, victim2));
                    }
                }

                // *** Strip option ***

                foreach (TargetInfo current6 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true))
                {
                    TargetInfo      stripTarg = current6;
                    FloatMenuOption item3;
                    if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item3 = new FloatMenuOption("CannotStrip".Translate(new object[]
                        {
                            stripTarg.Thing.LabelCap
                        }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                    }
                    else if (!pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1))
                    {
                        item3 = new FloatMenuOption("CannotStrip".Translate(new object[]
                        {
                            stripTarg.Thing.LabelCap
                        }) + " (" + "ReservedBy".Translate(new object[]
                        {
                            Find.Reservations.FirstReserverOf(stripTarg, pawn.Faction).LabelBaseShort
                        }) + ")", null, MenuOptionPriority.Medium, null, null);
                    }
                    else
                    {
                        item3 = new FloatMenuOption("Strip".Translate(new object[]
                        {
                            stripTarg.Thing.LabelCap
                        }), new Action(delegate
                        {
                            stripTarg.Thing.SetForbidden(false, false);
                            Job job          = new Job(JobDefOf.Strip, stripTarg);
                            job.playerForced = true;
                            pawn.drafter.TakeOrderedJob(job);
                        }), MenuOptionPriority.Medium, null, null);
                    }
                    list.Add(item3);
                }

                // *** Equip option ***

                CompInventory compInventory = pawn.TryGetComp <CompInventory>();      // Need compInventory here for equip and wear options

                if (pawn.equipment != null)
                {
                    ThingWithComps equipment = null;
                    List <Thing>   thingList = clickCell.GetThingList();
                    for (int j = 0; j < thingList.Count; j++)
                    {
                        if (thingList[j].TryGetComp <CompEquippable>() != null)
                        {
                            equipment = (ThingWithComps)thingList[j];
                            break;
                        }
                    }
                    if (equipment != null)
                    {
                        string          eqLabel = GenLabel.ThingLabel(equipment.def, equipment.Stuff, 1);
                        FloatMenuOption equipOption;
                        if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            equipOption = new FloatMenuOption("CannotEquip".Translate(new object[]
                            {
                                eqLabel
                            }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else if (!pawn.CanReserve(equipment, 1))
                        {
                            equipOption = new FloatMenuOption("CannotEquip".Translate(new object[]
                            {
                                eqLabel
                            }) + " (" + "ReservedBy".Translate(new object[]
                            {
                                Find.Reservations.FirstReserverOf(equipment, pawn.Faction).LabelBaseShort
                            }) + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                        {
                            equipOption = new FloatMenuOption("CannotEquip".Translate(new object[]
                            {
                                eqLabel
                            }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else
                        {
                            // Added check for inventory space here
                            int count;
                            if (compInventory != null && !compInventory.CanFitInInventory(equipment, out count, true))
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "CR_InventoryFull".Translate() + ")", null);
                            }
                            else
                            {
                                string equipOptionLabel = "Equip".Translate(new object[]
                                {
                                    eqLabel
                                });
                                if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                                {
                                    equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate();
                                }
                                equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate
                                {
                                    equipment.SetForbidden(false, true);
                                    Job job          = new Job(JobDefOf.Equip, equipment);
                                    job.playerForced = true;
                                    pawn.drafter.TakeOrderedJob(job);
                                    MoteThrower.ThrowStatic(equipment.DrawPos, ThingDefOf.Mote_FeedbackEquip, 1f);
                                    ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
                                }), MenuOptionPriority.Medium, null, null);
                            }
                        }
                        list.Add(equipOption);
                    }
                }

                // *** Wear option ***

                if (pawn.apparel != null)
                {
                    Apparel apparel = Find.ThingGrid.ThingAt <Apparel>(clickCell);
                    if (apparel != null)
                    {
                        FloatMenuOption wearOption;
                        if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            wearOption = new FloatMenuOption("CannotWear".Translate(new object[]
                            {
                                apparel.Label
                            }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else if (!pawn.CanReserve(apparel, 1))
                        {
                            Pawn pawn3 = Find.Reservations.FirstReserverOf(apparel, pawn.Faction);
                            wearOption = new FloatMenuOption("CannotWear".Translate(new object[]
                            {
                                apparel.Label
                            }) + " (" + "ReservedBy".Translate(new object[]
                            {
                                pawn3.LabelBaseShort
                            }) + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def))
                        {
                            wearOption = new FloatMenuOption("CannotWear".Translate(new object[]
                            {
                                apparel.Label
                            }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Medium, null, null);
                        }
                        else
                        {
                            // Added check for inventory capacity
                            int count;
                            if (compInventory != null && !compInventory.CanFitInInventory(apparel, out count, false, true))
                            {
                                wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CR_InventoryFull".Translate() + ")", null);
                            }
                            else
                            {
                                wearOption = new FloatMenuOption("ForceWear".Translate(new object[] { apparel.LabelBaseShort }),
                                                                 new Action(delegate
                                {
                                    apparel.SetForbidden(false, true);
                                    Job job          = new Job(JobDefOf.Wear, apparel);
                                    job.playerForced = true;
                                    pawn.drafter.TakeOrderedJob(job);
                                }),
                                                                 MenuOptionPriority.Medium, null, null);
                            }
                        }
                        list.Add(wearOption);
                    }
                }

                // *** NEW: Pick up option ***

                if (compInventory != null)
                {
                    List <Thing> thingList = clickCell.GetThingList();
                    if (!thingList.NullOrEmpty <Thing>())
                    {
                        Thing item = thingList.FirstOrDefault(thing => thing.def.alwaysHaulable && !(thing is Corpse));
                        if (item != null)
                        {
                            FloatMenuOption pickUpOption;
                            int             count = 0;
                            if (!pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly))
                            {
                                pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "NoPath".Translate() + ")", null);
                            }
                            else if (!pawn.CanReserve(item))
                            {
                                pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(item, pawn.Faction) }), null);
                            }
                            else if (!compInventory.CanFitInInventory(item, out count))
                            {
                                pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "CR_InventoryFull".Translate() + ")", null);
                            }
                            else
                            {
                                pickUpOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelBaseShort,
                                                                   new Action(delegate
                                {
                                    item.SetForbidden(false);
                                    Job job = new Job(JobDefOf.TakeInventory, item)
                                    {
                                        maxNumToCarry = 1
                                    };
                                    job.playerForced = true;
                                    pawn.drafter.TakeOrderedJob(job);
                                }));
                            }
                            list.Add(pickUpOption);
                            if (count > 1 && item.stackCount > 1)
                            {
                                int             numToCarry        = Math.Min(count, item.stackCount);
                                FloatMenuOption pickUpStackOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelBaseShort + " x" + numToCarry.ToString(),
                                                                                        new Action(delegate
                                {
                                    item.SetForbidden(false);
                                    Job job = new Job(JobDefOf.TakeInventory, item)
                                    {
                                        maxNumToCarry = numToCarry
                                    };
                                    job.playerForced = true;
                                    pawn.drafter.TakeOrderedJob(job);
                                }));
                                list.Add(pickUpStackOption);
                            }
                        }
                    }
                }

                // *** Deposit/drop equipment options ***

                if (pawn.equipment != null && pawn.equipment.Primary != null)
                {
                    Thing thing2 = Find.ThingGrid.ThingAt(clickCell, ThingDefOf.EquipmentRack);
                    if (thing2 != null)
                    {
                        if (!pawn.CanReach(thing2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            list.Add(new FloatMenuOption("CannotDeposit".Translate(new object[]
                            {
                                pawn.equipment.Primary.LabelCap,
                                thing2.def.label
                            }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null));
                        }
                        else
                        {
                            using (IEnumerator <IntVec3> enumerator7 = GenAdj.CellsOccupiedBy(thing2).GetEnumerator())
                            {
                                while (enumerator7.MoveNext())
                                {
                                    IntVec3 c = enumerator7.Current;
                                    if (c.GetStorable() == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1))
                                    {
                                        Action action4 = new Action(delegate
                                        {
                                            ThingWithComps t;
                                            if (pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true))
                                            {
                                                t.SetForbidden(false, true);
                                                Job job           = new Job(JobDefOf.HaulToCell, t, c);
                                                job.haulMode      = HaulMode.ToCellStorage;
                                                job.maxNumToCarry = 1;
                                                job.playerForced  = true;
                                                pawn.drafter.TakeOrderedJob(job);
                                            }
                                        });
                                        list.Add(new FloatMenuOption("Deposit".Translate(new object[]
                                        {
                                            pawn.equipment.Primary.LabelCap,
                                            thing2.def.label
                                        }), action4, MenuOptionPriority.Medium, null, null));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <TargetInfo>())
                    {
                        Action action5 = new Action(delegate
                        {
                            ThingWithComps thingWithComps;
                            pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true);
                            pawn.drafter.TakeOrderedJob(new Job(JobDefOf.Wait, 20, false));
                        }
                                                    );
                        list.Add(new FloatMenuOption("Drop".Translate(new object[]
                        {
                            pawn.equipment.Primary.LabelCap
                        }), action5, MenuOptionPriority.Medium, null, null));
                    }
                }

                // *** Trade with option ***

                foreach (TargetInfo current7 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true))
                {
                    TargetInfo dest2 = current7;
                    if (!pawn.CanReach(dest2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        list.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null));
                    }
                    else if (!pawn.CanReserve(dest2.Thing, 1))
                    {
                        list.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Medium, null, null));
                    }
                    else
                    {
                        Pawn   pTarg   = (Pawn)dest2.Thing;
                        Action action6 = new Action(delegate
                        {
                            Job job          = new Job(JobDefOf.TradeWithPawn, pTarg);
                            job.playerForced = true;
                            pawn.drafter.TakeOrderedJob(job);
                            ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total);
                        });
                        string str3 = string.Empty;
                        if (pTarg.Faction != null)
                        {
                            str3 = " (" + pTarg.Faction.name + ")";
                        }
                        List <FloatMenuOption> arg_142E_0 = list;
                        Thing thing = dest2.Thing;
                        arg_142E_0.Add(new FloatMenuOption("TradeWith".Translate(new object[]
                        {
                            pTarg.LabelBaseShort
                        }) + str3, action6, MenuOptionPriority.Medium, null, thing));
                    }
                }
                foreach (Thing current8 in Find.ThingGrid.ThingsAt(clickCell))
                {
                    foreach (FloatMenuOption current9 in current8.GetFloatMenuOptions(pawn))
                    {
                        list.Add(current9);
                    }
                }
            }

            // *** End of humanlike options ***

            // *** Beginning of non-drafted options ***

            if (!pawn.Drafted)
            {
                bool flag  = false;
                bool flag2 = false;
                foreach (Thing current10 in Find.ThingGrid.ThingsAt(clickCell))
                {
                    flag2 = true;
                    if (pawn.CanReach(current10, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag2 && !flag)
                {
                    list.Add(new FloatMenuOption("(" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null));
                    return(list);
                }
                foreach (Thing current11 in Find.ThingGrid.ThingsAt(clickCell))
                {
                    Pawn pawn4 = Find.Reservations.FirstReserverOf(current11, pawn.Faction);
                    if (pawn4 != null && pawn4 != pawn)
                    {
                        list.Add(new FloatMenuOption("IsReservedBy".Translate(new object[]
                        {
                            current11.LabelBaseShort.CapitalizeFirst(),
                            pawn4.LabelBaseShort
                        }), null, MenuOptionPriority.Medium, null, null));
                    }
                    else
                    {
                        JobGiver_Work jobGiver_Work = pawn.thinker.TryGetMainTreeThinkNode <JobGiver_Work>();
                        if (jobGiver_Work != null)
                        {
                            foreach (WorkTypeDef current12 in DefDatabase <WorkTypeDef> .AllDefsListForReading)
                            {
                                for (int k = 0; k < current12.workGiversByPriority.Count; k++)
                                {
                                    WorkGiver_Scanner workGiver_Scanner = current12.workGiversByPriority[k].Worker as WorkGiver_Scanner;
                                    if (workGiver_Scanner != null)
                                    {
                                        if (workGiver_Scanner.def.directOrderable)
                                        {
                                            if (!workGiver_Scanner.ShouldSkip(pawn))
                                            {
                                                JobFailReason.Clear();
                                                Job job;
                                                if (!workGiver_Scanner.HasJobOnThingForced(pawn, current11))
                                                {
                                                    job = null;
                                                }
                                                else
                                                {
                                                    job = workGiver_Scanner.JobOnThingForced(pawn, current11);
                                                }
                                                if (workGiver_Scanner.PotentialWorkThingRequest.Accepts(current11) || (workGiver_Scanner.PotentialWorkThingsGlobal(pawn) != null && workGiver_Scanner.PotentialWorkThingsGlobal(pawn).Contains(current11)))
                                                {
                                                    if (job == null)
                                                    {
                                                        if (JobFailReason.HaveReason)
                                                        {
                                                            string label2 = "CannotGenericWork".Translate(new object[]
                                                            {
                                                                workGiver_Scanner.def.verb,
                                                                current11.LabelBaseShort
                                                            }) + " (" + JobFailReason.Reason + ")";
                                                            list.Add(new FloatMenuOption(label2, null, MenuOptionPriority.Medium, null, null));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        string          label;
                                                        WorkTypeDef     workType        = workGiver_Scanner.def.workType;
                                                        Action          action7         = null;
                                                        PawnCapacityDef pawnCapacityDef = workGiver_Scanner.MissingRequiredCapacity(pawn);
                                                        if (pawnCapacityDef != null)
                                                        {
                                                            label = "CannotMissingHealthActivities".Translate(new object[]
                                                            {
                                                                pawnCapacityDef.label
                                                            });
                                                        }
                                                        else if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job))
                                                        {
                                                            label = "CannotGenericAlreadyAm".Translate(new object[]
                                                            {
                                                                workType.gerundLabel,
                                                                current11.LabelBaseShort
                                                            });
                                                        }
                                                        else if (pawn.workSettings.GetPriority(workType) == 0)
                                                        {
                                                            label = "CannotPrioritizeIsNotA".Translate(new object[]
                                                            {
                                                                pawn.NameStringShort,
                                                                workType.pawnLabel
                                                            });
                                                        }
                                                        else if (job.def == JobDefOf.Research && current11 is Building_ResearchBench)
                                                        {
                                                            label = "CannotPrioritizeResearch".Translate();
                                                        }
                                                        else if (current11.IsForbidden(pawn))
                                                        {
                                                            label = "CannotPrioritizeForbidden".Translate(new object[]
                                                            {
                                                                current11.Label
                                                            });
                                                        }
                                                        else if (!pawn.CanReach(current11, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))
                                                        {
                                                            label = current11.Label + ": " + "NoPath".Translate();
                                                        }
                                                        else
                                                        {
                                                            label = "PrioritizeGeneric".Translate(new object[]
                                                            {
                                                                workGiver_Scanner.def.gerund,
                                                                current11.Label
                                                            });
                                                            Job         localJob         = job;
                                                            WorkTypeDef localWorkTypeDef = workType;
                                                            action7 = new Action(delegate { pawn.thinker.GetMainTreeThinkNode <JobGiver_Work>().TryStartPrioritizedWorkOn(pawn, localJob, localWorkTypeDef); });
                                                        }
                                                        if (!list.Any(op => op.label == label))
                                                        {
                                                            list.Add(new FloatMenuOption(label, action7, MenuOptionPriority.Medium, null, null));
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // *** End of non-drafted options ***

            foreach (FloatMenuOption current13 in pawn.GetExtraFloatMenuOptionsFor(clickCell))
            {
                list.Add(current13);
            }
            DangerUtility.DoneDirectOrdering();
            return(list);
        }
        // well this is a dumpster fire of a decompilation job
        public static void AddDraftedOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 b = IntVec3.FromVector3(clickPos);

            foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true))
            {
                LocalTargetInfo attackTarg = current;
                if (pawn.equipment.Primary != null && !pawn.equipment.PrimaryEq.PrimaryVerb.verbProps.MeleeRange)
                {
                    string str;
                    Action rangedAct = FloatMenuUtility.GetRangedAttackAction(pawn, attackTarg, out str);
                    string text      = "FireAt".Translate(new object[]
                    {
                        attackTarg.Thing.LabelCap
                    });
                    FloatMenuOption floatMenuOption = new FloatMenuOption(MenuOptionPriority.High);
                    if (rangedAct == null)
                    {
                        text = text + " (" + str + ")";
                    }
                    else
                    {
                        floatMenuOption.autoTakeable = true;
                        floatMenuOption.action       = delegate
                        {
                            MoteMaker.MakeStaticMote(attackTarg.Thing.DrawPos, attackTarg.Thing.Map, ThingDefOf.Mote_FeedbackAttack, 1f);
                            rangedAct();
                        };
                    }
                    floatMenuOption.Label = text;
                    opts.Add(floatMenuOption);
                }
                string str2;
                Action meleeAct = FloatMenuUtility.GetMeleeAttackAction(pawn, attackTarg, out str2);
                Pawn   pawn2    = attackTarg.Thing as Pawn;
                string text2;
                if (pawn2 != null && pawn2.Downed)
                {
                    text2 = "MeleeAttackToDeath".Translate(new object[]
                    {
                        attackTarg.Thing.LabelCap
                    });
                }
                else
                {
                    text2 = "MeleeAttack".Translate(new object[]
                    {
                        attackTarg.Thing.LabelCap
                    });
                }
                MenuOptionPriority priority      = (!attackTarg.HasThing || !pawn.HostileTo(attackTarg.Thing)) ? MenuOptionPriority.VeryLow : MenuOptionPriority.AttackEnemy;
                Thing           thing            = attackTarg.Thing;
                FloatMenuOption floatMenuOption2 = new FloatMenuOption(string.Empty, null, priority, null, thing, 0f, null, null);
                if (meleeAct == null)
                {
                    text2 = text2 + " (" + str2 + ")";
                }
                else
                {
                    floatMenuOption2.action = delegate
                    {
                        MoteMaker.MakeStaticMote(attackTarg.Thing.DrawPos, attackTarg.Thing.Map, ThingDefOf.Mote_FeedbackAttack, 1f);
                        meleeAct();
                    };
                }
                floatMenuOption2.Label = text2;
                opts.Add(floatMenuOption2);
            }
            if (pawn.RaceProps.Humanlike && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForArrest(pawn), true))
                {
                    LocalTargetInfo dest = current2;
                    if (!((Pawn)dest.Thing).Downed)
                    {
                        if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null));
                        }
                        else
                        {
                            Pawn   pTarg  = (Pawn)dest.Thing;
                            Action action = delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageSound.RejectInput);
                                    return;
                                }
                                Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed);
                                job.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job);
                                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies);
                            };
                            Thing thing = dest.Thing;
                            ITWN.PostMenuOption(opts,
                                                pawn,
                                                dest.Thing,
                                                "TryToArrest".Translate(new object[] { dest.Thing.LabelCap }),
                                                action,
                                                revalidateClickTarget: thing,
                                                priority: MenuOptionPriority.High);
                        }
                    }
                }
            }
            int     num = GenRadial.NumCellsInRadius(2.9f);
            IntVec3 curLoc;

            for (int i = 0; i < num; i++)
            {
                curLoc = GenRadial.RadialPattern[i] + b;
                if (curLoc.Standable(pawn.Map))
                {
                    if (curLoc != pawn.Position)
                    {
                        if (!pawn.CanReach(curLoc, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            FloatMenuOption item = new FloatMenuOption("CannotGoNoPath".Translate(), null, MenuOptionPriority.Low, null, null, 0f, null);
                            opts.Add(item);
                        }
                        else
                        {
                            Action action2 = delegate
                            {
                                IntVec3 intVec = RCellFinder.BestOrderedGotoDestNear(curLoc, pawn);
                                Job     job    = new Job(JobDefOf.Goto, intVec);
                                if (pawn.Map.exitMapGrid.IsExitCell(UI.MouseCell()))
                                {
                                    job.exitMapOnArrival = true;
                                }
                                if (pawn.jobs.TryTakeOrderedJob(job))
                                {
                                    MoteMaker.MakeStaticMote(intVec, pawn.Map, ThingDefOf.Mote_FeedbackGoto, 1f);
                                }
                            };
                            opts.Add(new FloatMenuOption("GoHere".Translate(), action2, MenuOptionPriority.GoHere, null, null, 0f, null, null)
                            {
                                autoTakeable = true
                            });
                        }
                    }
                    break;
                }
            }
        }
示例#15
0
        public void TryOpenComms(Pawn negotiator)
        {
            if (!this.CanTradeNow)
            {
                return;
            }
            ModelPlaceOrder modelPlaceOrder = new ModelPlaceOrder(this);

            //maybe a grid or a dialog featuring my own flow components.
            Dictionary <string, PageRenderer> pages = new Dictionary <string, PageRenderer>();

            pages.Add("menu", new PageRenderer((f => GetCallLabel()), null, null)
                      .AddChild(new RowLayoutRenderer()
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new ButtonTextRenderer("Trade", (f => Find.WindowStack.Add(new Dialog_Trade(negotiator, this)))))
                                          //Placing an order requires selecting stuff for the item to make(could be a stuff category or fixed ingredients) more complicated things have filters
                                          //Maybe using the workbench interface to define the possible materials? But then we need to pick from storage etc.. simulating the whole chain.
                                          //Only allow recipes with category item.
                                          .AddChild(new ButtonTextRenderer("Place order", (f => { modelPlaceOrder.resources = ColonyThingsWillingToBuy(negotiator); f.navigate("placeOrder"); })))
                                          //.AddChild(new ButtonTextRenderer("Claim order", (f => f.navigate("statistics"))))
                                          .AddChild(new ButtonTextRenderer("Statistics", (f => f.navigate("statistics"))))
                                          .AddChild(new ButtonTextRenderer("Rename colony", (f => f.navigate("renameColony"))))
                                          .AddChild(new ButtonTextRenderer("Remove colony", (f => Find.WindowStack.Add(new Dialog_MessageBox("This is irreversible! Are you sure?", "Remove", delegate {
                Find.WorldObjects.Remove(this);
                //TODO When removing a colony we have the option to remove the housed pawns for good(including their relations) or we keep them around.
            }, "Cancel", null, "Remove Remnant Colony", true)))))
                                          )));

            pages.Add("statistics", new PageRenderer((f => "Statistics"), null, () => "menu")
                      .AddChild(new RowLayoutRenderer()
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Inhabitants")))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new ListRenderer(pawnNames, 200f + QOLMod.VerticalScrollbarWidth(), QOLMod.LineHeight(GameFont.Small) * 5)
                                                    .AddChild(new LabelRenderer((f => ((string)((IterationItem)f.pageScope["curItem"]).curItem)), 200f))))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Max skill levels")))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new ListRenderer(maxSkillLevels, 400f + QOLMod.VerticalScrollbarWidth(), QOLMod.LineHeight(GameFont.Small) * 5)
                                                    .AddChild(new LabelRenderer((f => ((SkillLevel)((IterationItem)f.pageScope["curItem"]).curItem).def.label), 200f))
                                                    .AddChild(new LabelRenderer((f => ((SkillLevel)((IterationItem)f.pageScope["curItem"]).curItem).level.ToString()), 200f))))));

            pages.Add("renameColony", new PageRenderer((f => "Rename colony"), null, () => "menu")
                      .AddChild(new RowLayoutRenderer()
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Name", 200f))
                                          .AddChild(new EditTextRenderer((f => settlementName), (f, v) => settlementName = v, 200f)))
                                ));

            pages.Add("placeOrder", new PageRenderer((f => "Place order"), null, () => "menu")
                      .AddChild(new RowLayoutRenderer()
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Recipe", 200f))
                                          .AddChild(new ButtonTextRenderer(f => modelPlaceOrder.recipe == null ? "Choose" : modelPlaceOrder.recipe.label,
                                                                           f => Find.WindowStack.Add(
                                                                               new Dialog_Select <RecipeDef>(def => { modelPlaceOrder.recipe = def; return(true); },
                                                                                                             DefDatabase <RecipeDef> .AllDefsListForReading
                                                                                                             //only recipes that produce something and only recipes that can be crafted with the tradeable resources(e.g. chunks arent launchable and cannot be used)
                                                                                                             .Where(d => !d.products.NullOrEmpty() /*&&modelPlaceOrder.HasIngredients(d)*/)
                                                                                                             .OrderBy(d => d.label),
                                                                                                             d => d.label)
                                                                               ), GameFont.Small, 200f)))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Ingredient", 200f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter))
                                          .AddChild(new LabelRenderer("Amount", 100f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter))
                                          .AddChild(new LabelRenderer("In Stock", 100f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter)))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new ListRenderer(modelPlaceOrder.ingredients, 400f + QOLMod.VerticalScrollbarWidth(), QOLMod.LineHeight(GameFont.Small) * 5)
                                                    .AddChild(new ButtonTextRenderer(f => ((Pair <ThingDef, IngredientCount>)((IterationItem)f.pageScope["curItem"]).curItem).Key.label,
                                                                                     (f => { f.pageScope["selectItem"] = ((IterationItem)f.pageScope["curItem"]).curItem; Find.WindowStack.Add(new Dialog_SelectDef <ThingDef>(def => {
                    ((Pair <ThingDef, IngredientCount>)f.pageScope["selectItem"]).Key = def; modelPlaceOrder.updateStuff(); return(true);
                }, ((Pair <ThingDef, IngredientCount>)f.pageScope["selectItem"]).Value.filter.AllowedThingDefs)); }), GameFont.Small, 200f))
                                                    .AddChild(new LabelRenderer((f => {
                Pair <ThingDef, IngredientCount> p = ((Pair <ThingDef, IngredientCount>)((IterationItem)f.pageScope["curItem"]).curItem);
                return(p.Value.CountRequiredOfFor(p.Key, modelPlaceOrder.recipe).ToString());
            }), 100f, GameFont.Small, UnityEngine.TextAnchor.MiddleRight))
                                                    .AddChild(new LabelRenderer((f => modelPlaceOrder.stockCount(((Pair <ThingDef, IngredientCount>)((IterationItem)f.pageScope["curItem"]).curItem).Key).ToString()), 100f, GameFont.Small, UnityEngine.TextAnchor.MiddleRight))))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Quality", 100f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter))
                                          .AddChild(new LabelRenderer("Material", 150f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter))
                                          .AddChild(new LabelRenderer("Product", 150f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter)))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new ListRenderer(modelPlaceOrder.products, 400f + QOLMod.VerticalScrollbarWidth(), QOLMod.LineHeight(GameFont.Small) * 5)
                                                    .AddChild(new HideRenderer(f => !((ProductConfig)((IterationItem)f.pageScope["curItem"]).curItem).HasQuality(),
                                                                               new ButtonTextRenderer(f => ((ProductConfig)((IterationItem)f.pageScope["curItem"]).curItem).quality.GetLabel(),
                                                                                                      (f => { f.pageScope["selectItem"] = ((IterationItem)f.pageScope["curItem"]).curItem; Find.WindowStack.Add(new Dialog_Select <QualityCategory>(q => {
                    ((ProductConfig)f.pageScope["selectItem"]).quality = q; modelPlaceOrder.updateStuff(); return(true);
                }, modelPlaceOrder.allowedQualityCategories, d => Enum.GetName(typeof(QualityCategory), d))); }), GameFont.Small, 100f)))

                                                    .AddChild(new LabelRenderer(f => { ThingDef stuff = ((ProductConfig)((IterationItem)f.pageScope["curItem"]).curItem).stuff; return(stuff != null ? stuff.label : ""); }, 150f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter))

                                                    .AddChild(new LabelRenderer((f => {
                ProductConfig p = ((ProductConfig)((IterationItem)f.pageScope["curItem"]).curItem);
                return(p.countClass.thingDef.label + (p.countClass.count > 1 ? "(" + p.countClass.count.ToString() + ")" : ""));
            }), 150f, GameFont.Small, UnityEngine.TextAnchor.MiddleCenter))))
                                //Display the currency count from the stock
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new LabelRenderer("Cost", 200f))
                                          .AddChild(new LabelRenderer(f => ((ModelPlaceOrder)f.flowScope["model"]).cost().ToString() + " (" + modelPlaceOrder.stockCount(ThingDefOf.Silver) + ")", 200f)))
                                .AddChild(new ColumnLayoutRenderer()
                                          .AddChild(new ButtonTextRenderer("Buy", f => modelPlaceOrder.buy(negotiator), GameFont.Small, 400f)))
                                ));
            //A Button to place the order


            Flow flow = new Flow(pages, "menu"); Enum.GetValues(typeof(QualityCategory));

            flow.flowScope["model"] = modelPlaceOrder;

            Find.WindowStack.Add(new Dialog_Flow(flow));
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.BuildOrbitalTradeBeacon, OpportunityType.Critical);
            TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradeGoodsMustBeNearBeacon);
        }