public static void RemoveWeaponTrait(this CompBladelinkWeapon compBladelink, WeaponTraitDef traitDef)
        {
            List <WeaponTraitDef> curTraits = compBladelink.TraitsListForReading;

            curTraits.Remove(traitDef);
            typeof(CompBladelinkWeapon).GetField("traits", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(compBladelink, curTraits);
        }
        private static void EquipWeaponDialog(Pawn pawn, Thing equipment)
        {
            TaggedString        equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn);
            CompBladelinkWeapon compBladelinkWeapon = equipment.TryGetComp <CompBladelinkWeapon>();

            if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn)
            {
                if (!equipWeaponConfirmationDialogText.NullOrEmpty())
                {
                    equipWeaponConfirmationDialogText += "\n\n";
                }

                equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate();
            }

            if (!equipWeaponConfirmationDialogText.NullOrEmpty())
            {
                equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate();
                Find.WindowStack.Add(
                    new Dialog_MessageBox(
                        equipWeaponConfirmationDialogText,
                        "Yes".Translate(),
                        () =>
                {
                    EquipWeapon(pawn, equipment);
                },
                        "No".Translate()));
            }
            else
            {
                EquipWeapon(pawn, equipment);
            }
        }
Пример #3
0
        public static bool canCarrySidearmInstance(ThingWithComps sidearmThing, Pawn pawn, out string errString)
        {
            //nicked from EquipmentUtility.CanEquip
            CompBladelinkWeapon compBladelinkWeapon = sidearmThing.TryGetComp <CompBladelinkWeapon>();

            if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != null && compBladelinkWeapon.bondedPawn != pawn)
            {
                errString = "BladelinkBondedToSomeoneElse".Translate();
                return(false);
            }
            if (EquipmentUtility.IsBiocoded(sidearmThing) && pawn != sidearmThing.TryGetComp <CompBiocodableWeapon>().CodedPawn)
            {
                errString = "BiocodedCodedForSomeoneElse".Translate();
                return(false);
            }
            if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn == null)
            {
                errString = "SidearmPickupFail_NotYetBladelinkBonded".Translate();
                return(false);
            }

            ThingDefStuffDefPair sidearm = sidearmThing.toThingDefStuffDefPair();

            return(canCarrySidearmType(sidearm, pawn, out errString));
        }
Пример #4
0
 static bool IsBiocodedOrLinked(Pawn pawn, Thing thing, bool inventory)
 {
     if (pawn.IsQuestLodger())
     {
         if (inventory)
         {
             return(true);
         }
         else
         {
             CompBiocodable compBiocodable = thing.TryGetComp <CompBiocodable>();
             if (compBiocodable != null && compBiocodable.Biocoded)
             {
                 return(true);
             }
             else
             {
                 CompBladelinkWeapon compBladelinkWeapon = thing.TryGetComp <CompBladelinkWeapon>();
                 return(compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn == pawn);
             }
         }
     }
     else
     {
         return(false);
     }
 }
Пример #5
0
        public static bool canCarrySidearmInstance(ThingWithComps sidearmThing, Pawn pawn, out string errString)
        {
            //nicked from EquipmentUtility.CanEquip
            CompBladelinkWeapon compBladelinkWeapon = sidearmThing.TryGetComp <CompBladelinkWeapon>();

            if (compBladelinkWeapon != null && compBladelinkWeapon.Biocodable && compBladelinkWeapon.CodedPawn != null && compBladelinkWeapon.CodedPawn != pawn)
            {
                errString = "BladelinkBondedToSomeoneElse".Translate();
                return(false);
            }
            if (CompBiocodable.IsBiocoded(sidearmThing) && !CompBiocodable.IsBiocodedFor(sidearmThing, pawn))
            {
                errString = "BiocodedCodedForSomeoneElse".Translate();
                return(false);
            }
            if (EquipmentUtility.AlreadyBondedToWeapon(sidearmThing, pawn))
            {
                errString = "BladelinkAlreadyBondedMessage".Translate(pawn.Named("PAWN"), pawn.equipment.bondedWeapon.Named("BONDEDWEAPON"));
                return(false);
            }
            if (compBladelinkWeapon != null && !compBladelinkWeapon.Biocoded && !compBladelinkWeapon.TraitsListForReading.Any(t => t.neverBond == true))
            {
                errString = "SidearmPickupFail_NotYetBladelinkBonded".Translate();
                return(false);
            }
            if (EquipmentUtility.RolePreventsFromUsing(pawn, sidearmThing, out string roleReason))
            {
                errString = roleReason;
                return(false);
            }

            ThingDefStuffDefPair sidearm = sidearmThing.toThingDefStuffDefPair();

            return(canCarrySidearmType(sidearm, pawn, out errString));
        }
 public static bool IsBladelinkWeapon(this Thing weapon, out CompBladelinkWeapon compBladelink)
 {
     compBladelink = weapon.TryGetComp <CompBladelinkWeapon>();
     if (compBladelink != null)
     {
         return(true);
     }
     return(false);
 }
Пример #7
0
 public override void Notify_OtherWeaponWielded(CompBladelinkWeapon weapon)
 {
     if (weapon.bondedPawn != null && !weapon.bondedPawn.Dead && weapon.bondedPawn.needs.mood != null)
     {
         Thought_WeaponTrait thought_WeaponTrait = (Thought_WeaponTrait)ThoughtMaker.MakeThought(ThoughtDefOf.JealousRage);
         thought_WeaponTrait.weapon = weapon.parent;
         weapon.bondedPawn.needs.mood.thoughts.memories.TryGainMemory(thought_WeaponTrait);
     }
 }
        public static void AddWeaponTrait(this CompBladelinkWeapon compBladelink, WeaponTraitDef traitDef)
        {
            List <WeaponTraitDef> curTraits = compBladelink.TraitsListForReading;

            if (!curTraits.Contains(traitDef))
            {
                curTraits.Add(traitDef);
            }
            typeof(CompBladelinkWeapon).GetField("traits", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(compBladelink, curTraits);
        }
        public static bool CanAddWeaponTrait(this CompBladelinkWeapon compBladelink, WeaponTraitDef traitDef)
        {
            List <WeaponTraitDef> curTraits = compBladelink.TraitsListForReading;

            if (curTraits.NullOrEmpty <WeaponTraitDef>())
            {
                return(true);
            }
            for (int i = 0; i < curTraits.Count; i++)
            {
                if (traitDef.Overlaps(curTraits[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #10
0
        public static bool DrawThingRow(Pawn SelPawn, bool CanControl, ref float y, ref float width, Thing thing, bool inventory)
        {
            Color hColor = new Color(1f, 0.8f, 0.8f, 1f);

            bool IsBiocodedOrLinked(Pawn pawn, Thing athing, bool ainventory)
            {
                if (pawn.IsQuestLodger())
                {
                    if (ainventory)
                    {
                        return(true);
                    }
                    else
                    {
                        CompBiocodable compBiocodable = athing.TryGetComp <CompBiocodable>();
                        if (compBiocodable != null && compBiocodable.Biocoded)
                        {
                            return(true);
                        }
                        else
                        {
                            CompBladelinkWeapon compBladelinkWeapon = athing.TryGetComp <CompBladelinkWeapon>();
                            return(compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn == pawn);
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }

            bool IsLocked(Pawn pawn, Thing athing)
            {
                Apparel apparel;

                return((apparel = (athing as Apparel)) != null && pawn.apparel != null && pawn.apparel.IsLocked(apparel));
            }

            if (!Settings.gui_manual_unload)
            {
                return(true);
            }

            Rect rect = new Rect(0f, y, width, 28f);

            if (CanControl &&
                (SelPawn.IsColonistPlayerControlled || SelPawn.Spawned && !SelPawn.Map.IsPlayerHome) &&
                (thing is ThingWithComps) &&
                !IsBiocodedOrLinked(SelPawn, thing, inventory) &&
                !IsLocked(SelPawn, thing))
            {
                Rect rect2          = new Rect(rect.width - 24f, y, 24f, 24f);
                CompUnloadChecker c = CompUnloadChecker.GetChecker(thing, false, true);
                if (c.ShouldUnload)
                {
                    TooltipHandler.TipRegion(rect2, "UnloadThingCancel".Translate());

                    //weird shenanigans with colors
                    var cl = GUI.color;
                    if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing_Cancel"), hColor))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        c.ShouldUnload = false;

                        if (MassUtility.Capacity(SelPawn, null) < MassUtility.GearAndInventoryMass(SelPawn) &&
                            thing.stackCount * thing.GetStatValue(StatDefOf.Mass, true) > 0 &&
                            !thing.def.destroyOnDrop)
                        {
                            Thing t;
                            SelPawn.inventory.innerContainer.TryDrop(thing, SelPawn.Position, SelPawn.Map, ThingPlaceMode.Near, out t, null, null);
                        }
                    }
                    GUI.color = cl;
                }
                else
                {
                    TooltipHandler.TipRegion(rect2, "UnloadThing".Translate());
                    if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing")))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        c.ShouldUnload = true;
                    }
                }
                width -= 24f;
            }
            return(true);
        }
        private void Recode()
        {
            //CompBiocodableWeapon biocodableWeapon = this.CodableThing.TryGetComp<CompBiocodableWeapon>();

            CompBiocodable      biocodableThing = this.CodableThing.TryGetComp <CompBiocodable>();
            CompBladelinkWeapon bladelinkWeapon = this.CodableThing.TryGetComp <CompBladelinkWeapon>();
            bool selfDestory = false;

            /*if (Rand.Value > this.SuccessChance)
             * {
             *      Messages.Message("PolarisDecoderFailedUsedForPawn".Translate(this.pawn.NameShortColored, this.CodableThing.Label), MessageTypeDefOf.NegativeEvent, true);
             *      if (Rand.Value < this.Configs.selfDestoryOnFailed)
             *      {
             *              Messages.Message("PolarisDecoderSelfDestroyed".Translate(), MessageTypeDefOf.NegativeEvent, true);
             *              this.Item.SplitOff(1).Destroy(DestroyMode.Vanish);
             *      }
             *      return;
             * }
             * Messages.Message("PolarisDecoderSuccessedUsedForPawn".Translate(this.pawn.NameShortColored, this.CodableThing.Label), this.pawn, MessageTypeDefOf.PositiveEvent, true);*/
            /*if (biocodableWeapon != null)
             * {
             *      if (biocodableWeapon.Biocoded)
             *      {
             *              biocodableWeapon.CodeFor(this.pawn);
             *              if (Rand.Value < this.Configs.selfDestoryOnSuccessed)
             *              {
             *                      selfDestory = true;
             *              }
             *      }
             *      else
             *      {
             *              biocodableWeapon.CodeFor(this.pawn);
             *
             *      }
             * }*/
            if (biocodableThing != null)
            {
                if (biocodableThing.Biocoded)
                {
                    if (this.CheckSuccessOnUsed())
                    {
                        biocodableThing.CodeFor(this.pawn);
                        if (Rand.Value < this.Configs.selfDestoryOnSuccessed)
                        {
                            selfDestory = true;
                        }
                    }
                }
                else
                {
                    biocodableThing.CodeFor(this.pawn);
                    Messages.Message("PolarisDecoderSuccessedUsedForPawn".Translate(this.pawn.NameShortColored, this.CodableThing.Label), this.pawn, MessageTypeDefOf.PositiveEvent, true);
                }
            }

            if (bladelinkWeapon != null)
            {
                if (bladelinkWeapon.bondedPawn != this.pawn)
                {
                    if (this.CheckSuccessOnUsed())
                    {
                        bladelinkWeapon.bondedPawn = null;
                        bladelinkWeapon.Notify_Equipped(this.pawn);
                        if (Rand.Value < this.Configs.selfDestoryOnSuccessed)
                        {
                            selfDestory = true;
                        }
                    }
                }
            }

            if (biocodableThing == null && bladelinkWeapon == null)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (selfDestory)
            {
                this.Item.SplitOff(1).Destroy(DestroyMode.Vanish);
                Messages.Message("PolarisDecoderSelfDestroyed".Translate(), MessageTypeDefOf.NegativeEvent, true);
            }
        }
Пример #12
0
        public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 position = IntVec3.FromVector3(clickPos);

            // Add options for equipment.
            if (pawn.equipment != null)
            {
                List <Thing> things = position.GetThingList(pawn.Map);
                foreach (Thing thing in things)
                {
                    if (thing.TryGetComp <CompEquippable>() != null)
                    {
                        ThingWithComps equipment = (ThingWithComps)thing;

                        if (equipment.def.IsWeapon &&
                            !pawn.WorkTagIsDisabled(WorkTags.Violent) &&
                            pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly) &&
                            pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) &&
                            !(pawn.IsQuestLodger() && (!equipment.def.IsWeapon || pawn.equipment.Primary != null)) &&
                            EquipmentUtility.CanEquip(equipment, pawn, out _))
                        {
                            string text3 = UIText.AIEquip.Translate(thing.LabelShort);
                            if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                            {
                                text3 += " " + UIText.EquipWarningBrawler.Translate();
                            }

                            var option = FloatMenuUtility.DecoratePrioritizedTask(
                                new FloatMenuOption(
                                    text3,
                                    () =>
                            {
                                TaggedString equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn);
                                CompBladelinkWeapon compBladelinkWeapon        = equipment.TryGetComp <CompBladelinkWeapon>();
                                if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn)
                                {
                                    if (!equipWeaponConfirmationDialogText.NullOrEmpty())
                                    {
                                        equipWeaponConfirmationDialogText += "\n\n";
                                    }

                                    equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate();
                                }

                                if (!equipWeaponConfirmationDialogText.NullOrEmpty())
                                {
                                    equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate();
                                    Find.WindowStack.Add(
                                        new Dialog_MessageBox(
                                            equipWeaponConfirmationDialogText,
                                            "Yes".Translate(),
                                            () =>
                                    {
                                        Equip();
                                    },
                                            "No".Translate()));
                                }
                                else
                                {
                                    Equip();
                                }
                            },
                                    MenuOptionPriority.High),
                                pawn,
                                equipment);
                            opts.Add(option);
                        }

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

            // Add options for apparel.
            if (pawn.apparel != null)
            {
                Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(position);
                if (apparel != null)
                {
                    if (pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly) &&
                        !apparel.IsBurning() &&
                        ApparelOptionUtility.CanWear(pawn, apparel))
                    {
                        FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask(
                            new FloatMenuOption(
                                UIText.AIForceWear.Translate(apparel.LabelShort),
                                () =>
                        {
                            DressJob dressJob  = SimplePool <DressJob> .Get();
                            dressJob.def       = AwesomeInventory_JobDefOf.AwesomeInventory_Dress;
                            dressJob.targetA   = apparel;
                            dressJob.ForceWear = true;

                            apparel.SetForbidden(value: false);
                            pawn.jobs.TryTakeOrderedJob(dressJob);
                        },
                                MenuOptionPriority.High),
                            pawn,
                            apparel);
                        opts.Add(option);

                        option = FloatMenuUtility.DecoratePrioritizedTask(
                            new FloatMenuOption(
                                UIText.AIWear.Translate(apparel.LabelShort),
                                () =>
                        {
                            DressJob dressJob  = SimplePool <DressJob> .Get();
                            dressJob.def       = AwesomeInventory_JobDefOf.AwesomeInventory_Dress;
                            dressJob.targetA   = apparel;
                            dressJob.ForceWear = false;

                            apparel.SetForbidden(value: false);
                            pawn.jobs.TryTakeOrderedJob(dressJob);
                        },
                                MenuOptionPriority.High),
                            pawn,
                            apparel);
                        opts.Add(option);
                    }
                }
            }
        }
Пример #13
0
        public static Job TryGiveJobStatic(Pawn pawn, bool inCombat)
        {
            if (!Settings.ReEquipOutOfCombat)
            {
                return(null);
            }
            if (!Settings.ReEquipInCombat && inCombat)
            {
                return(null);
            }
            if (RestraintsUtility.InRestraints(pawn))
            {
                return(null);
            }
            else
            {
                if (!pawn.IsValidSidearmsCarrier())
                {
                    return(null);
                }

                CompSidearmMemory pawnMemory = CompSidearmMemory.GetMemoryCompForPawn(pawn);
                if (pawnMemory == null)
                {
                    return(null);
                }

                //if (pawnMemory.IsUsingAutotool(true))
                //    return null;

                //WeaponAssingment.equipBestWeaponFromInventoryByPreference(pawn, Globals.DroppingModeEnum.Calm);

                if (pawnMemory.RememberedWeapons is null)
                {
                    Log.Warning("pawnMemory of " + pawn.Label + " is missing remembered weapons");
                }

                Dictionary <ThingDefStuffDefPair, int> dupeCounters = new Dictionary <ThingDefStuffDefPair, int>();

                foreach (ThingDefStuffDefPair weaponMemory in pawnMemory.RememberedWeapons)
                {
                    if (!dupeCounters.ContainsKey(weaponMemory))
                    {
                        dupeCounters[weaponMemory] = 0;
                    }

                    if (!pawn.hasWeaponType(weaponMemory, dupeCounters[weaponMemory]))
                    {
                        float maxDist = 1000f;
                        if (pawn.Faction != Faction.OfPlayer)
                        {
                            maxDist = 30f;
                        }
                        if (inCombat)
                        {
                            maxDist = 12f;
                        }

                        bool bladelinkable = weaponMemory.thing.HasComp(typeof(CompBladelinkWeapon));
                        bool biocodeable   = weaponMemory.thing.HasComp(typeof(CompBiocodable));

                        IEnumerable <ThingWithComps> matchingWeapons = pawn.Map.listerThings.ThingsOfDef(weaponMemory.thing).OfType <ThingWithComps>().Where(t => t.Stuff == weaponMemory.stuff);
                        if (bladelinkable)
                        {
                            matchingWeapons = matchingWeapons.Where(t =>
                            {
                                CompBladelinkWeapon bladelink = t.GetComp <CompBladelinkWeapon>();
                                return(bladelink != null && bladelink.Biocoded && bladelink.CodedPawn == pawn);
                            });
                        }
                        if (biocodeable)
                        {
                            matchingWeapons = matchingWeapons.Where(t =>
                            {
                                CompBiocodable biocode = t.GetComp <CompBiocodable>();
                                if (biocode == null)
                                {
                                    return(true); //not sure how this could ever happen...
                                }
                                if (biocode.Biocoded && biocode.CodedPawn != pawn)
                                {
                                    return(false);
                                }
                                return(true);
                            });
                        }

                        Thing thing = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, matchingWeapons, PathEndMode.OnCell, TraverseParms.For(pawn), maxDist,
                                                                               (Thing t) => !t.IsForbidden(pawn) && pawn.CanReserve(t),
                                                                               (Thing t) => Settings.ReEquipBest ? t.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS, false) : 0);
                        //this works properly because better ranged weapons also happen to be better at pistolwhipping
                        //okay past me, WHAT? Why?

                        if (thing == null)
                        {
                            continue;
                        }

                        if (!inCombat)
                        {
                            return(JobMaker.MakeJob(SidearmsDefOf.ReequipSecondary, thing));
                        }
                        else
                        {
                            return(JobMaker.MakeJob(SidearmsDefOf.ReequipSecondaryCombat, thing, pawn.Position));
                        }
                    }

                    dupeCounters[weaponMemory]++;
                }

                return(null);
            }
        }
        public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            if (!AwesomeInventoryServiceProvider.TryGetImplementation <IInventoryHelper>(out IInventoryHelper inventoryHelper))
            {
                Log.Error(string.Format(ErrorMessage.NotImplemented, typeof(IInventoryHelper).Name));
                return;
            }

            IntVec3 position = IntVec3.FromVector3(clickPos);

            // Add options for equipment.
            if (pawn.equipment != null)
            {
                List <Thing> things = position.GetThingList(pawn.Map);
                foreach (Thing thing in things)
                {
                    if (thing.TryGetComp <CompEquippable>() != null)
                    {
                        ThingWithComps equipment = (ThingWithComps)thing;

                        if (equipment.def.IsWeapon &&
                            !pawn.WorkTagIsDisabled(WorkTags.Violent) &&
                            pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly) &&
                            pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) &&
                            !(pawn.IsQuestLodger() && (!equipment.def.IsWeapon || pawn.equipment.Primary != null)) &&
                            EquipmentUtility.CanEquip(equipment, pawn, out _))
                        {
                            string text3 = UIText.AIEquip.Translate(thing.LabelShort);
                            if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                            {
                                text3 += " " + UIText.EquipWarningBrawler.Translate();
                            }

                            var option = FloatMenuUtility.DecoratePrioritizedTask(
                                new FloatMenuOption(
                                    text3,
                                    () =>
                            {
                                TaggedString equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn);
                                CompBladelinkWeapon compBladelinkWeapon        = equipment.TryGetComp <CompBladelinkWeapon>();
                                if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn)
                                {
                                    if (!equipWeaponConfirmationDialogText.NullOrEmpty())
                                    {
                                        equipWeaponConfirmationDialogText += "\n\n";
                                    }

                                    equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate();
                                }

                                if (!equipWeaponConfirmationDialogText.NullOrEmpty())
                                {
                                    equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate();
                                    Find.WindowStack.Add(
                                        new Dialog_MessageBox(
                                            equipWeaponConfirmationDialogText,
                                            "Yes".Translate(),
                                            () =>
                                    {
                                        Equip();
                                    },
                                            "No".Translate()));
                                }
                                else
                                {
                                    Equip();
                                }
                            },
                                    MenuOptionPriority.High),
                                pawn,
                                equipment);
                            opts.Add(option);
                        }

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

            // Add options for apparel.
            if (pawn.apparel != null)
            {
                Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(position);
                if (apparel != null)
                {
                    if (pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly) &&
                        !apparel.IsBurning() &&
                        !pawn.apparel.WouldReplaceLockedApparel(apparel) &&
                        ApparelUtility.HasPartsToWear(pawn, apparel.def))
                    {
                        FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask(
                            new FloatMenuOption(
                                UIText.AIForceWear.Translate(apparel.LabelShort),
                                () =>
                        {
                            DressJob dressJob  = SimplePool <DressJob> .Get();
                            dressJob.def       = AwesomeInventory_JobDefOf.AwesomeInventory_Dress;
                            dressJob.targetA   = apparel;
                            dressJob.ForceWear = true;

                            apparel.SetForbidden(value: false);
                            pawn.jobs.TryTakeOrderedJob(dressJob);
                        },
                                MenuOptionPriority.High),
                            pawn,
                            apparel);
                        opts.Add(option);

                        option = FloatMenuUtility.DecoratePrioritizedTask(
                            new FloatMenuOption(
                                UIText.AIWear.Translate(apparel.LabelShort),
                                () =>
                        {
                            DressJob dressJob  = SimplePool <DressJob> .Get();
                            dressJob.def       = AwesomeInventory_JobDefOf.AwesomeInventory_Dress;
                            dressJob.targetA   = apparel;
                            dressJob.ForceWear = false;

                            apparel.SetForbidden(value: false);
                            pawn.jobs.TryTakeOrderedJob(dressJob);
                        },
                                MenuOptionPriority.High),
                            pawn,
                            apparel);
                        opts.Add(option);
                    }
                }
            }

            List <Thing> items = position.GetThingList(pawn.Map);

            foreach (Thing item in items)
            {
                if (item.def.category == ThingCategory.Item)
                {
                    int count = MassUtility.CountToPickUpUntilOverEncumbered(pawn, item);
                    if (count == 0)
                    {
                        continue;
                    }

                    count = Math.Min(count, item.stackCount);

                    string displayText = UIText.Pickup.Translate(item.LabelNoCount + " x" + count);
                    var    option      = FloatMenuUtility.DecoratePrioritizedTask(
                        new FloatMenuOption(
                            displayText
                            , () =>
                    {
                        Job job   = JobMaker.MakeJob(JobDefOf.TakeInventory, item);
                        job.count = count;
                        pawn.jobs.TryTakeOrderedJob(job);
                    })
                        , pawn
                        , item);
                    opts.Add(option);
                }
            }
        }