public override void TransformValue(StatRequest req, ref float val)
 {
     if (req.HasThing && EquipmentUtility.IsBiocoded(req.Thing))
     {
         val *= 0f;
     }
 }
        private static bool CanEquipThis(bool combat, Pawn pawn, CompMeeseeksMemory compMeeseeksMemory, Thing weapon, List <SkillDef> relevantSkills)
        {
            if (weapon.IsForbidden(pawn))
            {
                AddDebugLine("Forbidden: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (weapon.IsBurning())
            {
                AddDebugLine("Burning: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (EquipmentUtility.IsBiocoded(weapon))
            {
                AddDebugLine("Biocoded: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (!pawn.CanReserveAndReach(weapon, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                AddDebugLine("Can't touch this: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (!combat && !HasReleventStatModifiers(weapon, relevantSkills))
            {
                AddDebugLine("Irrelevant: " + weapon.GetUniqueLoadID());
                return(false);
            }

            return(true);
        }
        public void DrawEquipmentAiming(Thing eq, Vector3 drawLoc, float aimAngle)
        {
            Mesh  mesh = null;
            float num  = aimAngle - 90f;

            if (aimAngle > 20f && aimAngle < 160f)
            {
                mesh = MeshPool.plane10;
                num += eq.def.equippedAngleOffset;
            }
            else if (aimAngle > 200f && aimAngle < 340f)
            {
                mesh = MeshPool.plane10Flip;
                num -= 180f;
                num -= eq.def.equippedAngleOffset;
            }
            else
            {
                mesh = MeshPool.plane10;
                num += eq.def.equippedAngleOffset;
            }
            num %= 360f;
            CompEquippable compEquippable = eq.TryGetComp <CompEquippable>();

            if (compEquippable != null)
            {
                EquipmentUtility.Recoil(eq.def, EquipmentUtility.GetRecoilVerb(compEquippable.AllVerbs), out var drawOffset, out var angleOffset, aimAngle);
                drawLoc += drawOffset;
                num     += angleOffset;
            }
            Material           material           = null;
            Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount;

            Graphics.DrawMesh(material: (graphic_StackCount == null) ? eq.Graphic.MatSingle : graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle, mesh: mesh, position: drawLoc, rotation: Quaternion.AngleAxis(num, Vector3.up), layer: 0);
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 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.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));
        }
Exemplo n.º 6
0
 public override void Fill(EquipmentSortType type)
 {
     _type = type;
     mDMono.gameObject.SetActive(true);
     _chooseObj.SetActive(_type == LTPartnerEquipDataManager.Instance.CurSortType);
     _labName.text = EquipmentUtility.AttrTypeTrans(_type.ToString(), false);
 }
Exemplo n.º 7
0
 public static bool IsItemQuestLocked(this Pawn pawn, Thing thing)
 {
     if (pawn == null || thing == null)
     {
         return(false);
     }
     return((thing is Apparel eqApparel && (pawn.apparel?.IsLocked(eqApparel) ?? false)) ||
            (thing.def.IsWeapon && pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanUnequip(thing, pawn)));
 }
Exemplo n.º 8
0
 private bool ShouldEquipWeapon(Thing newWep, Pawn pawn)
 {
     if (newWep.def.IsRangedWeapon)
     {
         return(false);
     }
     if (EquipmentUtility.CanEquip(newWep, pawn) && GetWeaponScore(pawn, newWep) > GetWeaponScore(pawn, pawn.equipment.Primary))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 9
0
        public static Thing PickBestArmorFor(Pawn pawn)
        {
            if (pawn.outfits == null)
            {
                return(null);
            }
            if (pawn.Faction != Faction.OfPlayer)
            {
                return(null);
            }
            if (pawn.IsQuestLodger())
            {
                return(null);
            }

            Outfit       currentOutfit = pawn.outfits.CurrentOutfit;
            Thing        thing         = null;
            float        num2          = 0f;
            List <Thing> list          = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            if (list.Count == 0)
            {
                return(null);
            }
            neededWarmth      = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));
            wornApparelScores = new List <float>();
            List <Apparel> wornApparel = pawn.apparel.WornApparel;

            for (int i = 0; i < wornApparel.Count; i++)
            {
                wornApparelScores.Add(ApparelScoreRaw(pawn, wornApparel[i]));
            }
            for (int j = 0; j < list.Count; j++)
            {
                Apparel apparel = (Apparel)list[j];                 // && apparel.IsInAnyStorage()
                if (!apparel.IsBurning() && currentOutfit.filter.Allows(apparel) && !apparel.IsForbidden(pawn) &&
                    (apparel.def.apparel.gender == Gender.None || apparel.def.apparel.gender == pawn.gender))
                {
                    float num3 = ApparelScoreGain_NewTmp(pawn, apparel, wornApparelScores);
                    if (!(num3 < 0.05f) && !(num3 < num2) && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) &&
                        ApparelUtility.HasPartsToWear(pawn, apparel.def) &&
                        pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger()))
                    {
                        thing = apparel;
                        num2  = num3;
                    }
                }
            }
            return(thing);
        }
Exemplo n.º 10
0
        public void To(Data.PromotionTemplate info, Data.PromotionAttributeLevelTemplate attrInfo)
        {
            Reset();

            string attrName     = attrInfo.name;
            int    attrId       = attrInfo.id;
            bool   isPercentNum = attrInfo.attrValue.ToString().Contains(".");
            int    nextId       = Data.CharacterTemplateManager.Instance.GetNextPromotionId(info.id);
            string formatStr;

            if (PageId == 1)
            {
                formatStr = isPercentNum ? "{0}/{1}%" : "{0}/{1}";
            }
            else
            {
                formatStr = isPercentNum ? "{0}/{1}%({2})" : "{0}/{1}({2})";
            }
            Data.PromotionTemplate nextInfo = Data.CharacterTemplateManager.Instance.GetPromotionInfo(nextId);
            int    currentAttrLevel         = LTPromotionManager.Instance.GetCurrentAttrLevel(attrId);
            float  attrValue   = isPercentNum ? attrInfo.attrValue * 100 : attrInfo.attrValue;
            string deltaFormat = nextInfo == null ? "Max" : isPercentNum ? "+{0}%" : "+{0}";
            string deltaStr    = string.Format(deltaFormat, nextInfo == null ? "" : ((nextInfo.attributeLevelUpperLimit - info.attributeLevelUpperLimit) * attrValue).ToString());

            _labName.text = EquipmentUtility.AttrTypeTrans(attrName, false);
            int trainingAfterAttrLevel;

            if (!LTPromotionManager.Instance.GetTrainingAfterAttrLevel(attrId, out trainingAfterAttrLevel))
            {
                trainingAfterAttrLevel = currentAttrLevel;
            }
            PlayProgressfx(trainingAfterAttrLevel * attrValue - currentAttrLevel * attrValue > 0, false);
            DOTween.To(val =>
            {
                float targetValue   = info.attributeLevelUpperLimit * attrValue;
                string sign         = isPercentNum ? "%" : string.Empty;
                string currentValue = LT.Hotfix.Utility.ColorUtility.FormatColorByGreen(val, targetValue, sign, isPercentNum ? 1 : 0);
                _labProgress.text   = EB.StringUtil.Format(formatStr, currentValue, targetValue.ToString(isPercentNum ? "0.0" : "0"), deltaStr);
            }, currentAttrLevel * attrValue, trainingAfterAttrLevel * attrValue, dynamicEffectDuration);
            DOTween.To(val =>
            {
                _uiProgressBar.value = val;
                SetProgressBarForeground(val > 0.99f);
            }, currentAttrLevel / (float)info.attributeLevelUpperLimit, trainingAfterAttrLevel / (float)info.attributeLevelUpperLimit, dynamicEffectDuration).OnComplete(() =>
            {
                ShowIncrement(currentAttrLevel * attrValue, trainingAfterAttrLevel * attrValue, isPercentNum);
            });
        }
Exemplo n.º 11
0
        private bool ShouldEquipUtilityItem(Thing thing, Pawn pawn)
        {
            Apparel apparel;

            if ((apparel = thing as Apparel) == null)
            {
                return(false);
            }
            if (!apparel.def.apparel.ai_pickUpOpportunistically)
            {
                return(false);
            }
            if (EquipmentUtility.CanEquip(apparel, pawn) && ApparelUtility.HasPartsToWear(pawn, apparel.def))
            {
                return(!pawn.apparel.WouldReplaceLockedApparel(apparel));
            }
            return(false);
        }
Exemplo n.º 12
0
        private static bool CanWearApparel(Pawn pawn, Apparel apparel)
        {
            if (EquipmentUtility.IsBiocoded(apparel) && !EquipmentUtility.IsBiocodedFor(apparel, pawn))
            {
                return(false);
            }

            if (pawn.apparel.WouldReplaceLockedApparel(apparel))
            {
                return(false);
            }

            if (apparel.IsForbidden(pawn))
            {
                return(false);
            }

            return(true);
        }
        private bool WillDrop(Pawn pawn, Thing i)
        {
            // To prevent dropping ammo from CE or similar
            var ammoCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail("Ammo");

            if (ammoCategory != null && i.def.IsWithinCategory(ammoCategory))
            {
                return(false);
            }
            if (EquipmentUtility.IsBiocoded(i))
            {
                return(false);
            }
            if (i.TryGetComp <CompBladelinkWeapon>()?.bondedPawn != null)
            {
                return(false);
            }

            return(i.def != ThingDefOf.Silver && !i.IsMeal() && !pawn.Bought(i) && !BoughtOrSoldByPlayer(i) && !pawn.inventory.NotForSale(i));
        }
Exemplo n.º 14
0
        private void InitEquipShow(DetailedEquipmentInfo info)
        {
            MainAttr.GetChild(0).GetComponent <UILabel>().text = "[fff348]" + EquipmentUtility.AttrTypeTrans(info.MainAttributes.Name);
            MainAttr.GetChild(1).GetComponent <UILabel>().text = EquipmentUtility.AttrTypeValue(info.MainAttributes);
            int ExIndex = info.ExAttributes.Count - 1;

            for (int i = 0; i < 4; i++)
            {
                if (i > ExIndex)
                {
                    ExAttr[i].gameObject.CustomSetActive(false);
                }
                else
                {
                    string ExNameStr = EquipmentUtility.AttrTypeTrans(info.ExAttributes[i].Name);
                    ExAttr[i].GetChild(0).GetComponent <UILabel>().text = ExNameStr;
                    ExAttr[i].GetChild(1).GetComponent <UILabel>().text = EquipmentUtility.AttrTypeValue(info.ExAttributes[i]);
                    ExAttr[i].gameObject.CustomSetActive(true);
                }
            }
        }
Exemplo n.º 15
0
        private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false)
        {
            Rect rect = new Rect(0f, y, width, _thingRowHeight);

            Widgets.InfoCardButton(rect.width - 24f, y, thing);
            rect.width -= 24f;
            if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony))
            {
                var   dropForbidden  = IsItemDropForbidden(thing);
                Color color          = dropForbidden ? Color.grey : Color.white;
                Color mouseoverColor = dropForbidden ? Color.grey : GenUI.MouseoverColor;
                Rect  dropRect       = new Rect(rect.width - 24f, y, 24f, 24f);
                TooltipHandler.TipRegion(dropRect, dropForbidden ? "DropThingLocked".Translate() : "DropThing".Translate());
                if (Widgets.ButtonImage(dropRect, TexButton.Drop, color, mouseoverColor) && !dropForbidden)
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    InterfaceDrop(thing);
                }
                rect.width -= 24f;
            }
            if (CanControlColonist)
            {
                if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug))
                {
                    Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f);
                    TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing));
                    if (Widgets.ButtonImage(rect3, TexButton.Ingest))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        InterfaceIngest(thing);
                    }
                }
                rect.width -= 24f;
            }
            Rect rect4 = rect;

            rect4.xMin = rect4.xMax - 60f;
            CaravanThingsTabUtility.DrawMass(thing, rect4);
            rect.width -= 60f;
            if (Mouse.IsOver(rect))
            {
                GUI.color = _highlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }

            if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = ThingLabelColor;
            Rect   thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight);
            string thingLabel     = thing.LabelCap;

            if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) ||
                (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing)))
            {
                thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate();
            }

            Text.WordWrap = false;
            Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null));
            Text.WordWrap = true;
            string text2 = string.Concat(new object[]
            {
                thing.LabelCap,
                "\n",
                thing.DescriptionDetailed,
                "\n",
                thing.GetWeightAndBulkTip()
            });

            if (thing.def.useHitPoints)
            {
                string text3 = text2;
                text2 = string.Concat(new object[]
                {
                    text3,
                    "\n",
                    "HitPointsBasic".Translate().CapitalizeFirst(),
                    ": ",
                    thing.HitPoints,
                    " / ",
                    thing.MaxHitPoints
                });
            }
            TooltipHandler.TipRegion(thingLabelRect, text2);
            y += 28f;

            // RMB menu
            if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1)
            {
                List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>();
                floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Default, null, null));
                if (CanControl)
                {
                    // Equip option
                    ThingWithComps eq = thing as ThingWithComps;
                    if (eq != null && eq.TryGetComp <CompEquippable>() != null)
                    {
                        CompInventory  compInventory = SelPawnForGear.TryGetComp <CompInventory>();
                        CompBiocodable compBiocoded  = eq.TryGetComp <CompBiocodable>();
                        if (compInventory != null)
                        {
                            FloatMenuOption equipOption;
                            string          eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
                            if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear)
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null);
                            }
                            else if (SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear))
                            {
                                var forbiddenEquipOrPutAway = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(eqLabel) : "CannotEquip".Translate(eqLabel);
                                equipOption = new FloatMenuOption(forbiddenEquipOrPutAway + ": " + "CE_CannotChangeEquipment".Translate(), null);
                            }
                            else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null)
                            {
                                equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel),
                                                                  new Action(delegate
                                {
                                    SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer);
                                }));
                            }
                            else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null);
                            }
                            else
                            {
                                string equipOptionLabel = "Equip".Translate(eqLabel);
                                if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler))
                                {
                                    equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate();
                                }
                                equipOption = new FloatMenuOption(
                                    equipOptionLabel,
                                    (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent))
                                    ? null
                                    : new Action(delegate
                                {
                                    compInventory.TrySwitchToWeapon(eq);
                                }));
                            }
                            floatOptionList.Add(equipOption);
                        }
                    }
                    //Reload apparel option
                    IEnumerable <Apparel> worn_apparel = SelPawnForGear?.apparel?.WornApparel ?? Enumerable.Empty <Apparel>();
                    foreach (var apparel in worn_apparel)
                    {
                        var compReloadable = apparel.TryGetComp <CompReloadable>();
                        if (compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true))
                        {
                            if (!SelPawnForGear.Drafted)    //TODO-1.2 This should be doable for drafted pawns as well, but the job does nothing. Figure out what's wrong and remove this condition.
                            {
                                FloatMenuOption reloadApparelOption = new FloatMenuOption(
                                    "CE_ReloadApparel".Translate(apparel.Label, thing.Label),
                                    new Action(delegate
                                {
                                    //var reloadJob = JobMaker.MakeJob(JobDefOf.Reload, apparel, thing);
                                    //SelPawnForGear.jobs.StartJob(reloadJob, JobCondition.InterruptForced, null, SelPawnForGear.CurJob?.def != reloadJob.def, true);

                                    SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing));
                                })
                                    );
                                floatOptionList.Add(reloadApparelOption);
                            }
                        }
                    }
                    // Consume option
                    if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing))
                    {
                        Action eatFood = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceIngest(thing);
                        };
                        string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort);
                        if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug)
                        {
                            floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null));
                        }
                        else
                        {
                            floatOptionList.Add(new FloatMenuOption(label, eatFood));
                        }
                    }
                    // Drop, and drop&haul options
                    if (IsItemDropForbidden(eq))
                    {
                        floatOptionList.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null));
                        floatOptionList.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null));
                    }
                    else
                    {
                        floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), new Action(delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceDrop(thing);
                        })));
                        floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), new Action(delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceDropHaul(thing);
                        })));
                    }
                    // Stop holding in inventory option
                    if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing))
                    {
                        Action forgetHoldTracker = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            SelPawnForGear.HoldTrackerForget(thing);
                        };
                        floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker));
                    }
                }
                FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false);
                Find.WindowStack.Add(window);
            }
            // end menu
        }
Exemplo n.º 16
0
        /// <summary>
        /// Try to give a job to <paramref name="pawn"/>.
        /// </summary>
        /// <param name="pawn"> Pawn that will be assigned a job to. </param>
        /// <returns> A job assigned to <paramref name="pawn"/>. </returns>
        protected override Job TryGiveJob(Pawn pawn)
        {
#if DEBUG
            ValidateArg.NotNull(pawn, nameof(pawn));
            Log.Message(pawn.Name + "Looking for weapons");
#endif
            if (CombatExtendedUtility.IsActive)
            {
                return(null);
            }

            ValidateArg.NotNull(pawn, nameof(pawn));

            if (!pawn.Faction.IsPlayer)
            {
                return(null);
            }

            if (!pawn.RaceProps.Humanlike)
            {
                return(null);
            }

            if (pawn.Drafted)
            {
                return(null);
            }

            if (pawn.equipment == null)
            {
                return(null);
            }

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)
                ||
                pawn.WorkTagIsDisabled(WorkTags.Violent))
            {
                return(null);
            }

            if (pawn.Map == null)
            {
                return(null);
            }

            if (_parent == null)
            {
                if (parent is JobGiver_FindItemByRadius p)
                {
                    _parent = p;
                }
                else
                {
                    throw new InvalidOperationException(ErrorText.WrongTypeParentThinkNode);
                }
            }

            if (pawn.TryGetComp <CompAwesomeInventoryLoadout>() is CompAwesomeInventoryLoadout compLoadout)
            {
                if (compLoadout.NeedRestock)
                {
                    foreach (KeyValuePair <ThingGroupSelector, int> pair in compLoadout.ItemsToRestock)
                    {
                        // Exclude beer and other drugs that are also categoried as weapon
                        ThingDef thingDef = pair.Key.AllowedThing;
                        if (thingDef.IsWeapon && !thingDef.IsDrug && !thingDef.IsStuff)
                        {
                            Thing targetThingA =
                                _parent.FindItem(
                                    pawn
                                    , pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Weapon)
                                    , (thing) => pair.Key.Allows(thing, out _)
                                    &&
                                    !compLoadout.Loadout.IncludedInBlacklist(thing)
                                    &&
                                    EquipmentUtility.CanEquip(thing, pawn));

                            if (targetThingA != null)
                            {
                                Job job = JobMaker.MakeJob(AwesomeInventory_JobDefOf.AwesomeInventory_MapEquip, targetThingA);
                                if (pawn.Reserve(targetThingA, job, errorOnFailed: false))
                                {
                                    return(job);
                                }
                                else
                                {
                                    JobMaker.ReturnToPool(job);
                                    return(null);
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
        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 (!SimpleSidearmUtility.IsActive &&
                            equipment.def.IsWeapon &&
                            !MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, equipment, 1) &&
                            !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();
                            }

                            opts.Add(ContextMenuUtility.MakeDecoratedEquipOption(pawn, equipment, text3, () => AddToLoadoutDialog(equipment)));
                        }
                    }
                }
            }

            // 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() &&
                        !MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, apparel, apparel.stackCount) &&
                        ApparelOptionUtility.CanWear(pawn, apparel))
                    {
                        opts.Add(
                            ContextMenuUtility.MakeDecoratedWearApparelOption(
                                pawn, apparel, UIText.AIForceWear.Translate(apparel.LabelShort), true, () => AddToLoadoutDialog(apparel)));

                        opts.Add(
                            ContextMenuUtility.MakeDecoratedWearApparelOption(
                                pawn, apparel, UIText.AIWear.Translate(apparel.LabelShort), false, () => AddToLoadoutDialog(apparel)));
                    }
                }
            }

            void AddToLoadoutDialog(Thing thing1)
            {
                if (AwesomeInventoryMod.Settings.OpenLoadoutInContextMenu && pawn.UseLoadout(out Loadout.CompAwesomeInventoryLoadout comp))
                {
                    Find.WindowStack.Add(
                        new Dialog_InstantMessage(
                            UIText.AddToLoadout.Translate(comp.Loadout.label) + Environment.NewLine + $"({UIText.DisableWindowInModSetting.TranslateSimple()})"
                            , _size
                            , "Yes".TranslateSimple()
                            , () => ContextMenuUtility.AddToLoadoutDialog(pawn, comp, thing1)
                            , "No".TranslateSimple()));
                }
            }
        }
Exemplo n.º 18
0
        public static bool AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 c = IntVec3.FromVector3(clickPos);

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

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

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

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

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

                    opts.Add(floatMenuOption);
                }
            }

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

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

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

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

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

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

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

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

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

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

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

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

            ThingWithComps equipment;

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

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

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

                    opts.Add(item6);
                }
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            return(false);
        }
Exemplo n.º 19
0
 static bool IsBiocodedOrLinked(this Pawn pawn, Thing thing, bool?inventory = null)
 {
     return(pawn.IsQuestLodger() && (inventory == true || !EquipmentUtility.QuestLodgerCanUnequip(thing, pawn)));
 }
        private static bool CanWearThis(Pawn pawn, CompMeeseeksMemory compMeeseeksMemory, Thing apparel, List <SkillDef> relevantSkills)
        {
            if (apparel.IsForbidden(pawn))
            {
                return(false);
            }
            if (apparel.IsBurning())
            {
                return(false);
            }
            if (EquipmentUtility.IsBiocoded(apparel))
            {
                return(false);
            }
            if (!ApparelUtility.HasPartsToWear(pawn, apparel.def))
            {
                return(false);
            }
            if (!pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                return(false);
            }

            bool armor = false;

            foreach (ThingCategoryDef thingCategoryDef in apparel.def.thingCategories)
            {
                if (thingCategoryDef.defName.ToLower().Contains("armor".ToLower()))
                {
                    armor = true;
                    break;
                }
            }

            if (pawn.Drafted || compMeeseeksMemory.guardPosition.IsValid)
            {
                if (!armor)
                {
                    return(false);
                }
            }
            else
            {
                if (armor)
                {
                    return(false);
                }

                if (!HasReleventStatModifiers(apparel, relevantSkills))
                {
                    return(false);
                }
            }

            List <Apparel> wornApparel = pawn.apparel.WornApparel;

            for (int i = 0; i < wornApparel.Count; i++)
            {
                if (!ApparelUtility.CanWearTogether(wornApparel[i].def, apparel.def, pawn.RaceProps.body))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 21
0
        public static Thing PickBestWeaponFor(Pawn pawn)
        {
            if (pawn.Map == null || pawn.equipment == null || pawn.Faction != Faction.OfPlayer || pawn.IsQuestLodger() ||
                !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || pawn.WorkTagIsDisabled(WorkTags.Violent))
            {
                return(null);
            }

            bool isBrawler    = pawn.story?.traits?.HasTrait(TraitDefOf.Brawler) ?? false;
            bool preferRanged = !isBrawler && (!pawn.equipment.Primary?.def.IsMeleeWeapon ?? false || pawn.equipment.Primary == null);

            Predicate <Thing> validator = delegate(Thing t)
            {
                if (!t.def.IsWeapon)
                {
                    return(false);
                }
                if (t.IsForbidden(pawn))
                {
                    return(false);
                }
                if (isBrawler && t.def.IsRangedWeapon)
                {
                    return(false);
                }
                if (preferRanged && t.def.IsMeleeWeapon)
                {
                    return(false);
                }
                if (!preferRanged && t.def.IsRangedWeapon)
                {
                    return(false);
                }
                if (t.def.weaponTags != null && t.def.weaponTags.Where(x => x.ToLower().Contains("grenade")).Any())
                {
                    return(false);
                }
                if (t.def.IsRangedWeapon && t.def.Verbs.Where(x => x.verbClass == typeof(Verb_ShootOneUse)).Any())
                {
                    return(false);
                }
                return(true);
            };

            Thing        thing    = null;
            float        maxValue = 0f;
            List <Thing> list     = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Weapon).Where(x => validator(x)).ToList();

            List <Thing> weapons = pawn.inventory.innerContainer.InnerListForReading.Where(x => validator(x)).ToList();

            list.AddRange(weapons);
            if (pawn.equipment.Primary != null)
            {
                list.Add(pawn.equipment.Primary);
            }
            for (int j = 0; j < list.Count; j++)
            {
                Thing weapon = list[j];
                if (!weapon.IsBurning())
                {
                    float weaponScore = WeaponScoreGain(weapon, StatDefOf.AccuracyMedium);
                    if (!(weaponScore < 0.05f) && !(weaponScore < maxValue) && (!CompBiocodable.IsBiocoded(weapon) || CompBiocodable.IsBiocodedFor(weapon, pawn)) &&
                        EquipmentUtility.CanEquip(weapon, pawn) && pawn.CanReserveAndReach(weapon, PathEndMode.OnCell, pawn.NormalMaxDanger()))
                    {
                        thing    = weapon;
                        maxValue = weaponScore;
                    }
                }
            }
            return(thing);
        }
Exemplo n.º 22
0
        public static bool TryGiveJob(JobGiver_OptimizeApparel __instance, ref Job __result, Pawn pawn)
        {
            if (pawn.outfits == null)
            {
                Log.ErrorOnce(string.Concat(pawn, " tried to run JobGiver_OptimizeApparel without an OutfitTracker"), 5643897);
                __result = null;
                return(false);
            }

            if (pawn.Faction != Faction.OfPlayer)
            {
                Log.ErrorOnce(string.Concat("Non-colonist ", pawn, " tried to optimize apparel."), 764323);
                __result = null;
                return(false);
            }

            if (pawn.IsQuestLodger())
            {
                __result = null;
                return(false);
            }

            if (!DebugViewSettings.debugApparelOptimize)
            {
                if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick)
                {
                    __result = null;
                    return(false);
                }
            }
            else
            {
                debugSb = new StringBuilder();
                debugSb.AppendLine(string.Concat("Scanning for ", pawn, " at ", pawn.Position));
            }

            Outfit         currentOutfit = pawn.outfits.CurrentOutfit;
            List <Apparel> wornApparel   = pawn.apparel.WornApparel;

            for (int num = wornApparel.Count - 1; num >= 0; num--)
            {
                if (!currentOutfit.filter.Allows(wornApparel[num]) && pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(wornApparel[num]) && !pawn.apparel.IsLocked(wornApparel[num]))
                {
                    Job job = JobMaker.MakeJob(JobDefOf.RemoveApparel, wornApparel[num]);
                    job.haulDroppedApparel = true;
                    __result = job;
                    return(false);
                }
            }

            Thing        thing = null;
            float        num2  = 0f;
            List <Thing> list  = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            if (list.Count == 0)
            {
                SetNextOptimizeTick2(pawn);
                __result = null;
                return(false);
            }

            neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));
            //wornApparelScores.Clear();
            List <float> wornApparelScores = new List <float>();

            for (int i = 0; i < wornApparel.Count; i++)
            {
                wornApparelScores.Add(JobGiver_OptimizeApparel.ApparelScoreRaw(pawn, wornApparel[i]));
            }

            for (int j = 0; j < list.Count; j++)
            {
                Apparel apparel = (Apparel)list[j];
                if (currentOutfit.filter.Allows(apparel) && apparel.IsInAnyStorage() && !apparel.IsForbidden(pawn) && !apparel.IsBurning() && (apparel.def.apparel.gender == Gender.None || apparel.def.apparel.gender == pawn.gender))
                {
                    float num3 = JobGiver_OptimizeApparel.ApparelScoreGain_NewTmp(pawn, apparel, wornApparelScores);
                    if (DebugViewSettings.debugApparelOptimize)
                    {
                        debugSb.AppendLine(apparel.LabelCap + ": " + num3.ToString("F2"));
                    }

                    if (!(num3 < 0.05f) && !(num3 < num2) && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def) && pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger()))
                    {
                        thing = apparel;
                        num2  = num3;
                    }
                }
            }

            if (DebugViewSettings.debugApparelOptimize)
            {
                debugSb.AppendLine("BEST: " + thing);
                Log.Message(debugSb.ToString());
                debugSb = null;
            }

            if (thing == null)
            {
                SetNextOptimizeTick2(pawn);
                __result = null;
                return(false);
            }

            __result = JobMaker.MakeJob(JobDefOf.Wear, thing);
            return(false);
        }
        private void TryEquipDraggedItem(Pawn p)
        {
            droppedDraggedItem = false;
            if (!EquipmentUtility.CanEquip_NewTmp(draggedItem, p, out var cantReason))
            {
                Messages.Message("MessageCantEquipCustom".Translate(cantReason.CapitalizeFirst()), p, MessageTypeDefOf.RejectInput, historical: false);
                draggedItem = null;
                return;
            }
            if (draggedItem.def.IsWeapon)
            {
                if (p.guest.IsPrisoner)
                {
                    Messages.Message("MessageCantEquipCustom".Translate("MessagePrisonerCannotEquipWeapon".Translate(p.Named("PAWN"))), p, MessageTypeDefOf.RejectInput, historical: false);
                    draggedItem = null;
                    return;
                }
                if (p.WorkTagIsDisabled(WorkTags.Violent))
                {
                    Messages.Message("MessageCantEquipIncapableOfViolence".Translate(p.LabelShort, p), p, MessageTypeDefOf.RejectInput, historical: false);
                    draggedItem = null;
                    return;
                }
                if (!p.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                {
                    Messages.Message("MessageCantEquipIncapableOfManipulation".Translate(), p, MessageTypeDefOf.RejectInput, historical: false);
                    draggedItem = null;
                    return;
                }
            }
            Apparel        apparel        = draggedItem as Apparel;
            ThingWithComps thingWithComps = draggedItem as ThingWithComps;

            if (apparel != null && p.apparel != null)
            {
                if (!ApparelUtility.HasPartsToWear(p, apparel.def))
                {
                    Messages.Message("MessageCantWearApparelMissingBodyParts".Translate(p.LabelShort, p), p, MessageTypeDefOf.RejectInput, historical: false);
                    draggedItem = null;
                    return;
                }
                if (CurrentWearerOf(apparel) != null && CurrentWearerOf(apparel).apparel.IsLocked(apparel))
                {
                    Messages.Message("MessageCantUnequipLockedApparel".Translate(), p, MessageTypeDefOf.RejectInput, historical: false);
                    draggedItem = null;
                    return;
                }
                if (p.apparel.WouldReplaceLockedApparel(apparel))
                {
                    Messages.Message("MessageWouldReplaceLockedApparel".Translate(p.LabelShort, p), p, MessageTypeDefOf.RejectInput, historical: false);
                    draggedItem = null;
                    return;
                }
                tmpExistingApparel.Clear();
                tmpExistingApparel.AddRange(p.apparel.WornApparel);
                for (int i = 0; i < tmpExistingApparel.Count; i++)
                {
                    if (!ApparelUtility.CanWearTogether(apparel.def, tmpExistingApparel[i].def, p.RaceProps.body))
                    {
                        p.apparel.Remove(tmpExistingApparel[i]);
                        Pawn pawn = CaravanInventoryUtility.FindPawnToMoveInventoryTo(tmpExistingApparel[i], Pawns, null);
                        if (pawn != null)
                        {
                            pawn.inventory.innerContainer.TryAdd(tmpExistingApparel[i]);
                            continue;
                        }
                        Log.Warning(string.Concat("Could not find any pawn to move ", tmpExistingApparel[i], " to."));
                        tmpExistingApparel[i].Destroy();
                    }
                }
                p.apparel.Wear((Apparel)apparel.SplitOff(1), dropReplacedApparel: false);
                if (p.outfits != null)
                {
                    p.outfits.forcedHandler.SetForced(apparel, forced: true);
                }
            }
            else if (thingWithComps != null && p.equipment != null)
            {
                string personaWeaponConfirmationText = EquipmentUtility.GetPersonaWeaponConfirmationText(draggedItem, p);
                if (!personaWeaponConfirmationText.NullOrEmpty())
                {
                    _ = draggedItem;
                    Find.WindowStack.Add(new Dialog_MessageBox(personaWeaponConfirmationText, "Yes".Translate(), delegate
                    {
                        AddEquipment();
                    }, "No".Translate()));
                    draggedItem = null;
                    return;
                }
                AddEquipment();
            }
            else
            {
                Log.Warning(string.Concat("Could not make ", p, " equip or wear ", draggedItem));
            }
            draggedItem = null;
            void AddEquipment()
            {
                tmpExistingEquipment.Clear();
                tmpExistingEquipment.AddRange(p.equipment.AllEquipmentListForReading);
                for (int j = 0; j < tmpExistingEquipment.Count; j++)
                {
                    p.equipment.Remove(tmpExistingEquipment[j]);
                    Pawn pawn2 = CaravanInventoryUtility.FindPawnToMoveInventoryTo(tmpExistingEquipment[j], Pawns, null);
                    if (pawn2 != null)
                    {
                        pawn2.inventory.innerContainer.TryAdd(tmpExistingEquipment[j]);
                    }
                    else
                    {
                        Log.Warning(string.Concat("Could not find any pawn to move ", tmpExistingEquipment[j], " to."));
                        tmpExistingEquipment[j].Destroy();
                    }
                }
                p.equipment.AddEquipment((ThingWithComps)thingWithComps.SplitOff(1));
            }
        }
Exemplo n.º 24
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);
                    }
                }
            }
        }
Exemplo n.º 25
0
 private bool IsItemDropForbidden(Thing thing)
 {
     return((thing is Apparel eqApparel && (SelPawnForGear.apparel?.IsLocked(eqApparel) ?? false)) ||
            (thing.def.IsWeapon && SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanUnequip(thing, SelPawnForGear)));
 }
Exemplo n.º 26
0
        public void Show(int type, int eid)//0为装备背包栏,1为已装备栏,2为升级背包栏
        {
            m_type = type;
            Pdata  = LTPartnerEquipMainController.CurrentPartnerData;
            if (Pdata == null)
            {
                EB.Debug.LogError("LTEquipmentFirstInfo.Show Pdata == null");
            }
            data = LTPartnerEquipDataManager.Instance.GetEquipmentInfoByEID(eid);
            if (data == null)
            {
                EB.Debug.LogError("LTEquipmentFirstInfo.Show data == null");
                return;
            }
            if (type == 0)
            {
                LevelupBtn.transform.localPosition = new Vector3(-160, -985, 0);
                LevelupBtn.transform.localScale    = Vector3.one;
                LevelupBtn.CustomSetActive(true);
                GetOffBtn.CustomSetActive(false);
                hasEquipObj.CustomSetActive(false);
                EquipSynBtn.CustomSetActive(false);

                if (Pdata == null)
                {
                    return;
                }

                var equippedId = Pdata.GetEquipmentsInfo((int)data.Type - 1).Eid;

                if (LTPartnerEquipMainController.instance.CurrentEquipmentViewState == LTPartnerEquipMainController.EquipmentViewState.PresetEditView)
                {
                    equippedId = LTPartnerEquipmentInfoController.instance.Eids[(int)data.Type - 1];
                }

                if (equippedId == 0)//没装备
                {
                    ReplaceBtn.transform.GetChild(0).GetComponent <UILabel>().text = ReplaceBtn.transform.GetChild(0).GetChild(0).GetComponent <UILabel>().text = EB.Localizer.GetString("ID_EQUIP_TIPS_LOAD");
                    SecondInfoUI.mDMono.gameObject.CustomSetActive(false);
                }
                else//有装备
                {
                    ReplaceBtn.transform.GetChild(0).GetComponent <UILabel>().text = ReplaceBtn.transform.GetChild(0).GetChild(0).GetComponent <UILabel>().text = EB.Localizer.GetString("ID_REPLACE");
                    SecondInfoUI.Show();
                    SecondInfoUI.mDMono.gameObject.CustomSetActive(true);
                }

                ReplaceBtn.CustomSetActive(true);

                Effect_4Label.effectStyle = UILabel.Effect.None;
                Effect_4Label.transform.GetChild(1).GetComponent <UISprite>().color = new Color(0.75f, 0.75f, 0.75f);
                if (data.FirstSuitAttr != null)
                {
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_1924"), LTPartnerEquipConfig.HasEffectStrDic[false], data.FirstSuitAttr);
                }
                else if (data.SecondSuitAttr != null)
                {
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_2136"), LTPartnerEquipConfig.HasEffectStrDic[false], data.SecondSuitAttr);
                }
            }
            else if (type == 1)
            {
                LevelupBtn.transform.localPosition = new Vector3(-160, -985, 0);
                LevelupBtn.transform.localScale    = Vector3.one;
                LevelupBtn.CustomSetActive(true);
                GetOffBtn.CustomSetActive(true);
                hasEquipObj.CustomSetActive(true);
                ReplaceBtn.CustomSetActive(false);
                EquipSynBtn.CustomSetActive(false);
                SecondInfoUI.mDMono.gameObject.CustomSetActive(false);
                if (LTPartnerEquipMainController.m_Open && LTPartnerEquipMainController.instance.CurrentEquipmentViewState != LTPartnerEquipMainController.EquipmentViewState.PresetView)
                {
                    GetOffBtn.transform.GetChild(0).GetComponent <UILabel>().text = GetOffBtn.transform.GetChild(0).GetChild(0).GetComponent <UILabel>().text = EB.Localizer.GetString("ID_EQUIP_TIPS_UNLOAD");
                }
                else
                {
                    GetOffBtn.transform.GetChild(0).GetComponent <UILabel>().text = GetOffBtn.transform.GetChild(0).GetChild(0).GetComponent <UILabel>().text = EB.Localizer.GetString("ID_REPLACE");
                }
                if (Pdata == null)
                {
                    return;
                }
                List <SuitAttrsSuitTypeAndCount> SuitList = Pdata.EquipmentTotleAttr.SuitList;
                int Count = 0;
                for (int i = 0; i < SuitList.Count; i++)
                {
                    if (data.SuitType == SuitList[i].SuitType)
                    {
                        Count = SuitList[i].count;
                    }
                }

                int suitNeed = 6;
                if (data.FirstSuitAttr != null)
                {
                    suitNeed           = 2;
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_1924"), LTPartnerEquipConfig.HasEffectStrDic[Count >= suitNeed], data.FirstSuitAttr);
                }
                else if (data.SecondSuitAttr != null)
                {
                    suitNeed           = 4;
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_2136"), LTPartnerEquipConfig.HasEffectStrDic[Count >= suitNeed], data.SecondSuitAttr);
                }

                if (Count >= suitNeed)
                {
                    Effect_4Label.effectStyle = UILabel.Effect.Outline8;
                    Effect_4Label.transform.GetChild(1).GetComponent <UISprite>().color = new Color(0.74f, 1f, 0.85f);
                }
                else
                {
                    Effect_4Label.effectStyle = UILabel.Effect.None;
                    Effect_4Label.transform.GetChild(1).GetComponent <UISprite>().color = new Color(0.75f, 0.75f, 0.75f);
                }
            }
            else if (type == 2)
            {
                LevelupBtn.CustomSetActive(false);
                GetOffBtn.CustomSetActive(false);
                hasEquipObj.CustomSetActive(false);
                ReplaceBtn.CustomSetActive(false);
                EquipSynBtn.CustomSetActive(false);
                SecondInfoUI.mDMono.gameObject.CustomSetActive(false);

                Effect_4Label.effectStyle = UILabel.Effect.None;
                Effect_4Label.transform.GetChild(1).GetComponent <UISprite>().color = new Color(0.75f, 0.75f, 0.75f);
                if (data.FirstSuitAttr != null)
                {
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_1924"), LTPartnerEquipConfig.HasEffectStrDic[false], data.FirstSuitAttr);
                }
                else if (data.SecondSuitAttr != null)
                {
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_2136"), LTPartnerEquipConfig.HasEffectStrDic[false], data.SecondSuitAttr);
                }
            }
            else if (type == 3)
            {
                LevelupBtn.transform.localPosition = new Vector3(160, -985, 0);
                LevelupBtn.transform.localScale    = Vector3.one;
                LevelupBtn.CustomSetActive(true);
                GetOffBtn.CustomSetActive(false);
                hasEquipObj.CustomSetActive(false);
                ReplaceBtn.CustomSetActive(false);
                //判断显示取回还是放入
                BaseEquipmentInfo[] synArray = LTPartnerEquipMainController.EquipSynArray;
                bool tempisInList            = false;

                for (int i = 0; i < synArray.Length; i++)
                {
                    if (synArray[i] != null)
                    {
                        if (synArray[i].Eid == eid)
                        {
                            //取出
                            EquipSynConditionLabel.text = EquipSynConditionLabel.transform.GetChild(0).GetComponent <UILabel>().text = EB.Localizer.GetString("ID_EQUIP_SYN_OUTOFLIST");
                            EquipSynBtn.GetComponent <ConsecutiveClickCoolTrigger>().clickEvent[0] = new EventDelegate(delegate { SelectEquipEven.SelectSynEquipment(eid, false, delegate { InforUI.controller.Close(); }); });
                            tempisInList = true;
                        }
                    }
                }
                if (!tempisInList)
                {
                    //放入
                    EquipSynConditionLabel.text = EquipSynConditionLabel.transform.GetChild(0).GetComponent <UILabel>().text = EB.Localizer.GetString("ID_EQUIP_SYN_INTOLIST");
                    EquipSynBtn.GetComponent <ConsecutiveClickCoolTrigger>().clickEvent[0] = new EventDelegate(delegate { SelectEquipEven.SelectSynEquipment(eid, true, delegate { InforUI.controller.Close(); }); });
                }
                EquipSynBtn.CustomSetActive(true);
                SecondInfoUI.mDMono.gameObject.CustomSetActive(false);
                Effect_4Label.effectStyle = UILabel.Effect.None;
                Effect_4Label.transform.GetChild(1).GetComponent <UISprite>().color = new Color(0.75f, 0.75f, 0.75f);
                if (data.FirstSuitAttr != null)
                {
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_1924"), LTPartnerEquipConfig.HasEffectStrDic[false], data.FirstSuitAttr);
                }
                else if (data.SecondSuitAttr != null)
                {
                    Effect_4Label.text = string.Format(EB.Localizer.GetString("ID_codefont_in_LTEquipmentFirstInfo_2136"), LTPartnerEquipConfig.HasEffectStrDic[false], data.SecondSuitAttr);
                }
            }

            DataItem.Fill(data);
            NameLabel.applyGradient  = true;
            NameLabel.gradientTop    = LT.Hotfix.Utility.ColorUtility.QualityToGradientTopColor(data.QualityLevel);
            NameLabel.gradientBottom = LT.Hotfix.Utility.ColorUtility.QualityToGradientBottomColor(data.QualityLevel);
            NameLabel.text           = NameLabel.transform.GetChild(0).GetComponent <UILabel>().text = data.Name;

            string MainStr = EquipmentUtility.AttrTypeTrans(data.MainAttributes.Name);

            MainAttr.GetChild(0).GetComponent <UILabel>().text = "[fff348]" + MainStr;
            MainAttr.GetChild(1).GetComponent <UILabel>().text = EquipmentUtility.AttrTypeValue(data.MainAttributes);
            int ExIndex = data.ExAttributes.Count - 1;

            for (int i = 0; i < 4; i++)
            {
                if (i > ExIndex)
                {
                    ExAttr[i].gameObject.CustomSetActive(false);
                }
                else
                {
                    string ExNameStr = EquipmentUtility.AttrTypeTrans(data.ExAttributes[i].Name);
                    ExAttr[i].GetChild(0).GetComponent <UILabel>().text = ExNameStr;
                    ExAttr[i].GetChild(1).GetComponent <UILabel>().text = EquipmentUtility.AttrTypeValue(data.ExAttributes[i]);
                    ExAttr[i].gameObject.CustomSetActive(true);
                }
            }
            Effect_2Label.gameObject.CustomSetActive(false);

            int trans = 0;

            if (type == 2)
            {
                trans = 166;
                EffectTrans.SetParent(EffectPos[0]);
                EffectTrans.localPosition = Vector3.zero;
            }
            else
            {
                EffectTrans.SetParent(EffectPos[1]);
                EffectTrans.localPosition = Vector3.zero;
            }
            mDMono.transform.GetComponent <UIWidget>().height = 619 + 88 * data.ExAttributes.Count + ((Effect_2Label.gameObject.activeSelf) ? Effect_2Label.height : 0) + ((Effect_4Label.gameObject.activeSelf) ? Effect_4Label.height : 0) - trans;
            LockIcon.spriteName = data.isLock ? "Equipment_Icon_Suoding" : "Equipment_Icon_Jiesuo";
        }
        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);
                }
            }
        }
Exemplo n.º 28
0
            static void DropDownThingMenu(object tab, Thing thing)
            {
                Pawn SelPawnForGear         = (Pawn)LSelPawnForGear.GetValue(tab);
                Pawn SelPawn                = (Pawn)LSelPawn.GetValue(tab);
                bool canControl             = (bool)LCanControl.GetValue(tab);
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate()
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                //bool canControl = this.CanControl;
                if (canControl)
                {
                    ThingWithComps eq     = thing as ThingWithComps;
                    bool           flag10 = eq != null && eq.TryGetComp <CompEquippable>() != null;
                    if (flag10)
                    {
                        object         comp           = SelPawnForGear.getCompInventory();
                        CompBiocodable compBiocodable = eq.TryGetComp <CompBiocodable>();
                        bool           flag11         = comp != null;
                        if (flag11)
                        {
                            string          value  = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
                            bool            flag12 = compBiocodable != null && compBiocodable.Biocoded && compBiocodable.CodedPawn != SelPawnForGear;
                            FloatMenuOption item;
                            if (flag12)
                            {
                                item = new FloatMenuOption("CannotEquip".Translate(value) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                            }
                            else
                            {
                                bool flag13 = SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear);
                                if (flag13)
                                {
                                    TaggedString t = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(value) : "CannotEquip".Translate(value);
                                    item = new FloatMenuOption(t + ": " + "CE_CannotChangeEquipment".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                                }
                                else
                                {
                                    bool flag14 = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null;
                                    if (flag14)
                                    {
                                        item = new FloatMenuOption("CE_PutAway".Translate(value), delegate()
                                        {
                                            SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer);
                                        }, MenuOptionPriority.Default, null, null, 0f, null, null);
                                    }
                                    else
                                    {
                                        bool flag15 = !SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation);
                                        if (flag15)
                                        {
                                            item = new FloatMenuOption("CannotEquip".Translate(value), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                                        }
                                        else
                                        {
                                            string text4  = "Equip".Translate(value);
                                            bool   flag16 = eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler);
                                            if (flag16)
                                            {
                                                text4 = text4 + " " + "EquipWarningBrawler".Translate();
                                            }
                                            item = new FloatMenuOption(text4, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate()
                                            {
                                                CEAccess.trySwitchToWeapon(comp, eq);
                                            }), MenuOptionPriority.Default, null, null, 0f, null, null);
                                        }
                                    }
                                }
                            }
                            list.Add(item);
                        }
                    }
                    //Pawn selPawnForGear = SelPawnForGear;   //??
                    List <Apparel> list2;
                    if (SelPawnForGear == null)
                    {
                        list2 = null;
                    }
                    else
                    {
                        Pawn_ApparelTracker apparel2 = SelPawnForGear.apparel;
                        list2 = ((apparel2 != null) ? apparel2.WornApparel : null);
                    }
                    List <Apparel> list3 = list2;
                    using (List <Apparel> .Enumerator enumerator = list3.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Apparel        apparel        = enumerator.Current;
                            CompReloadable compReloadable = apparel.TryGetComp <CompReloadable>();
                            bool           flag17         = compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true);
                            if (flag17)
                            {
                                bool flag18 = !SelPawnForGear.Drafted;
                                if (flag18)
                                {
                                    FloatMenuOption item2 = new FloatMenuOption("CE_ReloadApparel".Translate(apparel.Label, thing.Label), delegate()
                                    {
                                        SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing), JobTag.Misc);
                                    }, MenuOptionPriority.Default, null, null, 0f, null, null);
                                    list.Add(item2);
                                }
                            }
                        }
                    }
                    bool flag19 = canControl && thing.IngestibleNow && SelPawn.RaceProps.CanEverEat(thing);
                    if (flag19)
                    {
                        Action action = delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            LInterfaceIngest.Invoke(tab, new object[] { thing });
                        };
                        string text5  = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort);
                        bool   flag20 = SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug;
                        if (flag20)
                        {
                            List <FloatMenuOption> list4    = list;
                            string          str             = text5;
                            string          str2            = ": ";
                            TraitDegreeData traitDegreeData = (from x in TraitDefOf.DrugDesire.degreeDatas
                                                               where x.degree == -1
                                                               select x).First <TraitDegreeData>();
                            list4.Add(new FloatMenuOption(str + str2 + ((traitDegreeData != null) ? traitDegreeData.label : null), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            list.Add(new FloatMenuOption(text5, action, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    bool flag21 = SelPawnForGear.isItemQuestLocked(eq);
                    if (flag21)
                    {
                        list.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        list.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else
                    {
                        list.Add(new FloatMenuOption("DropThing".Translate(), delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            LInterfaceDrop.Invoke(tab, new object[] { thing });
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        list.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            InterfaceDropHaul(SelPawnForGear, thing, SelPawn);
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    bool flag22 = canControl && (bool)LHoldTrackerIsHeld.Invoke(null, new object[] { SelPawnForGear, thing }); //SelPawnForGear.HoldTrackerIsHeld(thing);
                    if (flag22)
                    {
                        Action action2 = delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            LHoldTrackerForget.Invoke(null, new object[] { SelPawnForGear, thing }); //SelPawnForGear.HoldTrackerForget(thing);
                        };
                        list.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), action2, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                }
                FloatMenu window = new FloatMenu(list, thing.LabelCap, false);

                Find.WindowStack.Add(window);
            }
        public static void Postfix(ref List <FloatMenuOption> __result, Vector3 clickPos, Pawn pawn, bool suppressAutoTakeableGoto = false)
        {
            if (!pawn.RaceProps.Humanlike)
            {
                var compMachine = pawn.GetComp <CompMachine>();
                if (compMachine != null && compMachine.Props.canPickupWeapons)
                {
                    IntVec3        c          = IntVec3.FromVector3(clickPos);
                    ThingWithComps equipment  = null;
                    List <Thing>   thingList2 = c.GetThingList(pawn.Map);
                    for (int i = 0; i < thingList2.Count; i++)
                    {
                        if (thingList2[i].TryGetComp <CompEquippable>() != null)
                        {
                            equipment = (ThingWithComps)thingList2[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 (equipment.def.IsRangedWeapon && pawn.WorkTagIsDisabled(WorkTags.Shooting))
                        {
                            item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "IsIncapableOfShootingLower".Translate(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(equipment, pawn, out cantReason, checkBonded: false))
                        {
                            item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + cantReason.CapitalizeFirst(), null);
                        }
                        else
                        {
                            string text4 = "Equip".Translate(labelShort);
                            if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                            {
                                text4 += " " + "EquipWarningBrawler".Translate();
                            }
                            if (EquipmentUtility.AlreadyBondedToWeapon(equipment, pawn))
                            {
                                text4 += " " + "BladelinkAlreadyBonded".Translate();
                                TaggedString dialogText = "BladelinkAlreadyBondedDialog".Translate(pawn.Named("PAWN"), equipment.Named("WEAPON"), pawn.equipment.bondedWeapon.Named("BONDEDWEAPON"));
                                item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, delegate
                                {
                                    Find.WindowStack.Add(new Dialog_MessageBox(dialogText));
                                }, MenuOptionPriority.High), pawn, equipment);
                            }
                            else
                            {
                                item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, 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);
                            }
                        }
                        __result.Add(item6);
                        if (SimpleSidearmsPatch.SimpleSidearmsActive)
                        {
                            AppendSidearmsOptions(pawn, equipment, ref __result);
                        }
                    }

                    void Equip()
                    {
                        equipment.SetForbidden(value: false);
                        pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Equip, equipment), JobTag.Misc);
                        FleckMaker.Static(equipment.DrawPos, equipment.MapHeld, FleckDefOf.FeedbackEquip);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
                    }
                }
            }
        }
Exemplo n.º 30
0
        private static float Likey(Pawn pawn, Thing thing)
        {
            if (thing == null)
            {
                return(0);
            }

            // Health of object
            var hpFactor = thing.def.useHitPoints?(float)thing.HitPoints / thing.MaxHitPoints:1;

            // Apparel
            var appFactor = thing is Apparel apparel ? 1 + ApparelScoreGain(pawn, apparel) : 0.8f; // Not apparel, less likey
            //Log.Message(thing.Label + " - apparel score: " + appFactor);

            var hungerFactor = GetHungerFactor(pawn);

            // Food
            if (ItemUtility.IsFood(thing) && pawn.RaceProps.CanEverEat(thing))
            {
                appFactor = FoodUtility.FoodOptimality(pawn, thing, FoodUtility.GetFinalIngestibleDef(thing), 0, true) / 300f; // 300 = optimality max
                //Log.Message($"{pawn.LabelShort} looked at {thing.LabelShort} at {thing.Position} and scored it {appFactor}.");
                appFactor += hungerFactor;
                //Log.Message($"{pawn.LabelShort} added {hungerFactor} to the score for his hunger.");
                if (thing.def.IsWithinCategory(ThingCategoryDefOf.PlantFoodRaw))
                {
                    appFactor -= 0.25f;
                }
                if (thing.def.IsWithinCategory(ThingCategoryDefOf.MeatRaw))
                {
                    appFactor -= 0.5f;
                }
            }
            // Other consumables
            else if (ItemUtility.IsIngestible(thing) && thing.def.ingestible.joy > 0)
            {
                appFactor = 1 + thing.def.ingestible.joy * 0.5f;

                // Hungry? Care less about other stuff
                if (hungerFactor > 0)
                {
                    appFactor -= hungerFactor;
                }
            }
            else
            {
                // Hungry? Care less about other stuff
                if (hungerFactor > 0)
                {
                    appFactor -= hungerFactor;
                }
            }

            if (EquipmentUtility.IsBiocoded(thing) && !EquipmentUtility.IsBiocodedFor(thing, pawn))
            {
                return(0);
            }

            // Weapon
            if (thing.def.IsRangedWeapon)
            {
                if (pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                {
                    return(0);
                }
                if (pawn.apparel.WornApparel.OfType <ShieldBelt>().Any())
                {
                    return(0);
                }
            }
            if (thing.def.IsWeapon)
            {
                // Weapon is also good!
                appFactor = 1;
                if (pawn.RaceProps.Humanlike && pawn.WorkTagIsDisabled(WorkTags.Violent))
                {
                    return(0);
                }
                if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                {
                    return(0);
                }
                if (!ItemUtility.AlienFrameworkAllowsIt(pawn.def, thing.def, "CanEquip"))
                {
                    return(0);
                }
            }
            // Shield belt
            if (thing is ShieldBelt)
            {
                if (pawn.equipment.Primary?.def.IsRangedWeapon == true)
                {
                    return(0);
                }
                if (!ItemUtility.AlienFrameworkAllowsIt(pawn.def, thing.def, "CanEquip"))
                {
                    return(0);
                }
            }

            // Quality of object
            var qFactor = 0.7f;

            if (thing.TryGetQuality(out var cat))
            {
                qFactor  = (float)cat;
                qFactor -= (float)QualityCategory.Normal;
                qFactor /= (float)QualityCategory.Masterwork - (float)QualityCategory.Normal;
                qFactor += 1;
                //Log.Message(thing.Label+" - quality: "+cat+" = "+ qFactor);
            }
            // Tech level of object
            var tFactor = 0.8f;

            if (thing.def.techLevel != TechLevel.Undefined)
            {
                tFactor  = (float)thing.def.techLevel;
                tFactor -= (float)pawn.Faction.def.techLevel;
                tFactor /= (float)TechLevel.Spacer;
                tFactor += 1;
                //Log.Message(thing.Label + " - techlevel: " + thing.def.techLevel + " = " + tFactor);
            }
            var rFactor = Rand.RangeSeeded(0.5f, 1.7f, pawn.thingIDNumber * 60509 + thing.thingIDNumber * 33151);

            //if(hpFactor*hpFactor*qFactor*qFactor*tFactor*appFactor > 0.5)
            //    Log.Message($"{thing.LabelShort.Colorize(Color.yellow)} - score: {hpFactor * hpFactor * qFactor * qFactor * tFactor * appFactor}, random: {rFactor}");
            return(Mathf.Max(0, hpFactor * hpFactor * qFactor * qFactor * tFactor * appFactor * rFactor)); // <= 0.5 = don't buy
        }