Пример #1
0
        // [ Apparel ] [ Melee ] [ Ranged ] [ Medical / Drugs ]
        public void DrawItemColumns(Rect r)
        {
            var topRect = r.TopPartPixels(ModGUIUtility.DEFAULT_HEIGHT);

            void DrawOptionButton(Texture2D tex, string tooltip, State state)
            {
                var optionRect = topRect.LeftPartPixels(ModGUIUtility.DEFAULT_HEIGHT);

                GUI.DrawTexture(topRect.LeftPartPixels(ModGUIUtility.DEFAULT_HEIGHT), tex, ScaleMode.ScaleToFit, true, 1f, Color.white, 0f, 0f);
                TooltipHandler.TipRegion(optionRect, tooltip);
                if (Widgets.ButtonInvisible(optionRect))
                {
                    curState  = state;
                    defFilter = string.Empty;
                }
                topRect.x += ModGUIUtility.SPACED_HEIGHT;
            }

            r.AdjVertBy(ModGUIUtility.DEFAULT_HEIGHT);

            DrawOptionButton(Textures.ApparelTex, "Apparel", State.Apparel);
            DrawOptionButton(Textures.MeleeTex, "Melee", State.Melee);
            DrawOptionButton(Textures.RangedTex, "Ranged", State.Ranged);
            DrawOptionButton(Textures.MedicalTex, "Medicine", State.Medicinal);
            DrawOptionButton(Textures.MiscItemsTex, "Items", State.Items);

            switch (curState)
            {
            case State.Apparel: DrawDefList(r, ApparelUtility.ApparelCanFitOnBody(BodyDefOf.Human, curTag.requiredItems.Select(s => s.Def).Where(def => def.IsApparel).ToList()).ToList());
                break;

            case State.Melee: DrawDefList(r, Utility.meleeWeapons);
                break;

            case State.Ranged: DrawDefList(r, Utility.rangedWeapons);
                break;

            case State.Medicinal: DrawDefList(r, Utility.medicinalDefs);
                break;

            case State.Items: DrawDefList(r, Utility.items);
                break;
            }
        }
Пример #2
0
            public void AddFreeWarmthAsNeeded(NeededWarmth warmth, float mapTemperature)
            {
                if (warmth == NeededWarmth.Any)
                {
                    return;
                }
                if (warmth == NeededWarmth.Cool)
                {
                    return;
                }
                if (DebugViewSettings.logApparelGeneration)
                {
                    PawnApparelGenerator.debugSb.AppendLine();
                    PawnApparelGenerator.debugSb.AppendLine("Trying to give free warm layer.");
                }
                for (int i = 0; i < 3; i++)
                {
                    if (!this.SatisfiesNeededWarmth(warmth, true, mapTemperature))
                    {
                        if (DebugViewSettings.logApparelGeneration)
                        {
                            PawnApparelGenerator.debugSb.AppendLine("Checking to give free torso-cover at max price " + PawnApparelGenerator.freeWarmParkaMaxPrice);
                        }
                        Predicate <ThingStuffPair> parkaPairValidator = delegate(ThingStuffPair pa)
                        {
                            if (pa.Price > PawnApparelGenerator.freeWarmParkaMaxPrice)
                            {
                                return(false);
                            }
                            if (pa.InsulationCold <= 0f)
                            {
                                return(false);
                            }
                            if (!pa.thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso))
                            {
                                return(false);
                            }
                            float replacedInsulationCold = this.GetReplacedInsulationCold(pa);
                            return(replacedInsulationCold < pa.InsulationCold);
                        };
                        int j = 0;
                        while (j < 2)
                        {
                            ThingStuffPair candidate;
                            if (j == 0)
                            {
                                if ((from pa in PawnApparelGenerator.allApparelPairs
                                     where parkaPairValidator(pa) && pa.InsulationCold < 40f
                                     select pa).TryRandomElementByWeight((ThingStuffPair pa) => pa.Commonality / (pa.Price * pa.Price), out candidate))
                                {
                                    goto IL_12F;
                                }
                            }
                            else if ((from pa in PawnApparelGenerator.allApparelPairs
                                      where parkaPairValidator(pa)
                                      select pa).TryMaxBy((ThingStuffPair x) => x.InsulationCold - this.GetReplacedInsulationCold(x), out candidate))
                            {
                                goto IL_12F;
                            }
                            j++;
                            continue;
IL_12F:
                            if (DebugViewSettings.logApparelGeneration)
                            {
                                PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                                {
                                    "Giving free torso-cover: ",
                                    candidate,
                                    " insulation=",
                                    candidate.InsulationCold
                                }));
                                foreach (ThingStuffPair current in from a in this.aps
                                         where !ApparelUtility.CanWearTogether(a.thing, candidate.thing, this.body)
                                         select a)
                                {
                                    PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                                    {
                                        "    -replaces ",
                                        current.ToString(),
                                        " InsulationCold=",
                                        current.InsulationCold
                                    }));
                                }
                            }
                            this.aps.RemoveAll((ThingStuffPair pa) => !ApparelUtility.CanWearTogether(pa.thing, candidate.thing, this.body));
                            this.aps.Add(candidate);
                            break;
                        }
                    }
                    if (GenTemperature.SafeTemperatureRange(this.raceDef, this.aps).Includes(mapTemperature))
                    {
                        break;
                    }
                }
                if (!this.SatisfiesNeededWarmth(warmth, true, mapTemperature))
                {
                    if (DebugViewSettings.logApparelGeneration)
                    {
                        PawnApparelGenerator.debugSb.AppendLine("Checking to give free hat at max price " + PawnApparelGenerator.freeWarmHatMaxPrice);
                    }
                    Predicate <ThingStuffPair> hatPairValidator = delegate(ThingStuffPair pa)
                    {
                        if (pa.Price > PawnApparelGenerator.freeWarmHatMaxPrice)
                        {
                            return(false);
                        }
                        if (pa.InsulationCold < 7f)
                        {
                            return(false);
                        }
                        if (!pa.thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.FullHead) && !pa.thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.UpperHead))
                        {
                            return(false);
                        }
                        float replacedInsulationCold = this.GetReplacedInsulationCold(pa);
                        return(replacedInsulationCold < pa.InsulationCold);
                    };
                    ThingStuffPair hatPair;
                    if ((from pa in PawnApparelGenerator.allApparelPairs
                         where hatPairValidator(pa)
                         select pa).TryRandomElementByWeight((ThingStuffPair pa) => pa.Commonality / (pa.Price * pa.Price), out hatPair))
                    {
                        if (DebugViewSettings.logApparelGeneration)
                        {
                            PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                            {
                                "Giving free hat: ",
                                hatPair,
                                " insulation=",
                                hatPair.InsulationCold
                            }));
                            foreach (ThingStuffPair current2 in from a in this.aps
                                     where !ApparelUtility.CanWearTogether(a.thing, hatPair.thing, this.body)
                                     select a)
                            {
                                PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                                {
                                    "    -replaces ",
                                    current2.ToString(),
                                    " InsulationCold=",
                                    current2.InsulationCold
                                }));
                            }
                        }
                        this.aps.RemoveAll((ThingStuffPair pa) => !ApparelUtility.CanWearTogether(pa.thing, hatPair.thing, this.body));
                        this.aps.Add(hatPair);
                    }
                }
                if (DebugViewSettings.logApparelGeneration)
                {
                    PawnApparelGenerator.debugSb.AppendLine("New TotalInsulationCold: " + this.TotalInsulationCold);
                }
            }
Пример #3
0
        private Apparel FindGarmentCoveringPart(Pawn pawn, BodyPartGroupDef bodyPartGroupDef)
        {
            Room room = pawn.GetRoom(RegionType.Set_Passable);

            if (room.isPrisonCell)
            {
                foreach (IntVec3 c in room.Cells)
                {
                    List <Thing> thingList = c.GetThingList(pawn.Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Apparel apparel = thingList[i] as Apparel;
                        if (apparel != null && apparel.def.apparel.bodyPartGroups.Contains(bodyPartGroupDef) && pawn.CanReserve(apparel, 1, -1, null, false) && ApparelUtility.HasPartsToWear(pawn, apparel.def))
                        {
                            return(apparel);
                        }
                    }
                }
            }
            return(null);
        }
Пример #4
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.outfits == null)
            {
                Log.ErrorOnce(string.Concat(pawn, " tried to run JobGiver_OptimizeApparel without an OutfitTracker"), 5643897);
                return(null);
            }
            if (pawn.Faction != Faction.OfPlayer)
            {
                Log.ErrorOnce(string.Concat("Non-colonist ", pawn, " tried to optimize apparel."), 764323);
                return(null);
            }
            if (pawn.IsQuestLodger())
            {
                return(null);
            }
            if (!DebugViewSettings.debugApparelOptimize)
            {
                if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick)
                {
                    return(null);
                }
            }
            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;
                    return(job);
                }
            }
            Thing        thing = null;
            float        num2  = 0f;
            List <Thing> list  = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            if (list.Count == 0)
            {
                SetNextOptimizeTick(pawn);
                return(null);
            }
            neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));
            wornApparelScores.Clear();
            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];
                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 = 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)
            {
                SetNextOptimizeTick(pawn);
                return(null);
            }
            return(JobMaker.MakeJob(JobDefOf.Wear, thing));
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.outfits == null)
            {
                Log.ErrorOnce(pawn + " tried to run JobGiver_OptimizeApparel without an OutfitTracker", 5643897, false);
                return(null);
            }
            if (pawn.Faction != Faction.OfPlayer)
            {
                Log.ErrorOnce("Non-colonist " + pawn + " tried to optimize apparel.", 764323, false);
                return(null);
            }
            if (!DebugViewSettings.debugApparelOptimize)
            {
                if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick)
                {
                    return(null);
                }
            }
            else
            {
                JobGiver_OptimizeApparel.debugSb = new StringBuilder();
                JobGiver_OptimizeApparel.debugSb.AppendLine(string.Concat(new object[]
                {
                    "Scanning for ",
                    pawn,
                    " at ",
                    pawn.Position
                }));
            }
            Outfit         currentOutfit = pawn.outfits.CurrentOutfit;
            List <Apparel> wornApparel   = pawn.apparel.WornApparel;

            for (int i = wornApparel.Count - 1; i >= 0; i--)
            {
                if (!currentOutfit.filter.Allows(wornApparel[i]) && pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(wornApparel[i]))
                {
                    return(new Job(JobDefOf.RemoveApparel, wornApparel[i])
                    {
                        haulDroppedApparel = true
                    });
                }
            }
            Thing        thing = null;
            float        num   = 0f;
            List <Thing> list  = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            if (list.Count == 0)
            {
                this.SetNextOptimizeTick(pawn);
                return(null);
            }
            JobGiver_OptimizeApparel.neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));
            for (int j = 0; j < list.Count; j++)
            {
                Apparel apparel = (Apparel)list[j];
                if (currentOutfit.filter.Allows(apparel))
                {
                    if (apparel.IsInAnyStorage())
                    {
                        if (!apparel.IsForbidden(pawn))
                        {
                            float num2 = JobGiver_OptimizeApparel.ApparelScoreGain(pawn, apparel);
                            if (DebugViewSettings.debugApparelOptimize)
                            {
                                JobGiver_OptimizeApparel.debugSb.AppendLine(apparel.LabelCap + ": " + num2.ToString("F2"));
                            }
                            if (num2 >= 0.05f && num2 >= num)
                            {
                                if (ApparelUtility.HasPartsToWear(pawn, apparel.def))
                                {
                                    if (pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger(), 1, -1, null, false))
                                    {
                                        thing = apparel;
                                        num   = num2;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (DebugViewSettings.debugApparelOptimize)
            {
                JobGiver_OptimizeApparel.debugSb.AppendLine("BEST: " + thing);
                Log.Message(JobGiver_OptimizeApparel.debugSb.ToString(), false);
                JobGiver_OptimizeApparel.debugSb = null;
            }
            if (thing == null)
            {
                this.SetNextOptimizeTick(pawn);
                return(null);
            }
            return(new Job(JobDefOf.Wear, thing));
        }
Пример #6
0
 public void AddFreeWarmthAsNeeded(NeededWarmth warmth)
 {
     if (warmth == NeededWarmth.Any)
     {
         return;
     }
     if (warmth == NeededWarmth.Cool)
     {
         return;
     }
     if (DebugViewSettings.logApparelGeneration)
     {
         PawnApparelGenerator.debugSb.AppendLine();
         PawnApparelGenerator.debugSb.AppendLine("Trying to give free warm layer.");
     }
     if (!this.SatisfiesNeededWarmth(warmth, false, 21f))
     {
         if (DebugViewSettings.logApparelGeneration)
         {
             PawnApparelGenerator.debugSb.AppendLine("Checking to give free torso-cover at max price " + PawnApparelGenerator.freeWarmParkaMaxPrice);
         }
         Predicate <ThingStuffPair> parkaPairValidator = (ThingStuffPair pa) => pa.Price <= PawnApparelGenerator.freeWarmParkaMaxPrice && pa.InsulationCold <= -40f;
         ThingStuffPair             parkaPair;
         if ((from pa in PawnApparelGenerator.allApparelPairs
              where parkaPairValidator(pa)
              select pa).TryRandomElementByWeight((ThingStuffPair pa) => pa.Commonality / (pa.Price * pa.Price), out parkaPair))
         {
             if (DebugViewSettings.logApparelGeneration)
             {
                 PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                 {
                     "Giving free torso-cover: ",
                     parkaPair,
                     " insulation=",
                     parkaPair.InsulationCold
                 }));
                 foreach (ThingStuffPair current in from a in this.aps
                          where !ApparelUtility.CanWearTogether(a.thing, parkaPair.thing, this.body)
                          select a)
                 {
                     PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                     {
                         "    -replaces ",
                         current.ToString(),
                         " InsulationCold=",
                         current.InsulationCold
                     }));
                 }
             }
             this.aps.RemoveAll((ThingStuffPair pa) => !ApparelUtility.CanWearTogether(pa.thing, parkaPair.thing, this.body));
             this.aps.Add(parkaPair);
         }
     }
     if (!this.SatisfiesNeededWarmth(warmth, false, 21f))
     {
         if (DebugViewSettings.logApparelGeneration)
         {
             PawnApparelGenerator.debugSb.AppendLine("Checking to give free hat at max price " + PawnApparelGenerator.freeWarmHatMaxPrice);
         }
         Predicate <ThingStuffPair> hatPairValidator = (ThingStuffPair pa) => pa.Price <= PawnApparelGenerator.freeWarmHatMaxPrice && pa.InsulationCold <= -7f && (pa.thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.FullHead) || pa.thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.UpperHead));
         ThingStuffPair             hatPair;
         if ((from pa in PawnApparelGenerator.allApparelPairs
              where hatPairValidator(pa)
              select pa).TryRandomElementByWeight((ThingStuffPair pa) => pa.Commonality / (pa.Price * pa.Price), out hatPair))
         {
             if (DebugViewSettings.logApparelGeneration)
             {
                 PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                 {
                     "Giving free hat: ",
                     hatPair,
                     " insulation=",
                     hatPair.InsulationCold
                 }));
                 foreach (ThingStuffPair current2 in from a in this.aps
                          where !ApparelUtility.CanWearTogether(a.thing, hatPair.thing, this.body)
                          select a)
                 {
                     PawnApparelGenerator.debugSb.AppendLine(string.Concat(new object[]
                     {
                         "    -replaces ",
                         current2.ToString(),
                         " InsulationCold=",
                         current2.InsulationCold
                     }));
                 }
             }
             this.aps.RemoveAll((ThingStuffPair pa) => !ApparelUtility.CanWearTogether(pa.thing, hatPair.thing, this.body));
             this.aps.Add(hatPair);
         }
     }
     if (DebugViewSettings.logApparelGeneration)
     {
         PawnApparelGenerator.debugSb.AppendLine("New TotalInsulationCold: " + this.TotalInsulationCold);
     }
 }
Пример #7
0
        private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 c = IntVec3.FromVector3(clickPos);

            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) : "ConsumeThing".Translate(t.LabelShort);
                    if (!t.IsSociallyProper(pawn))
                    {
                        text = text + " (" + "ReservedForPrisoners".Translate() + ")";
                    }
                    FloatMenuOption item3;
                    if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler())
                    {
                        item3 = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item3 = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else
                    {
                        MenuOptionPriority priority = (MenuOptionPriority)((!(t is Corpse)) ? 4 : 2);
                        item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate
                        {
                            t.SetForbidden(false, true);
                            Job job13   = new Job(JobDefOf.Ingest, t);
                            job13.count = FoodUtility.WillIngestStackCountOf(pawn, t.def);
                            pawn.jobs.TryTakeOrderedJob(job13, JobTag.Misc);
                        }, priority, null, null, 0f, null, null), pawn, t, "ReservedBy");
                    }
                    opts.Add(item3);
                }
            }
            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo item7 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    Pawn victim = (Pawn)item7.Thing;
                    if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true))
                    {
                        if (!victim.IsPrisonerOfColony && !victim.InMentalState && (victim.Faction == Faction.OfPlayer || victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer)))
                        {
                            string label  = "Rescue".Translate(victim.LabelCap);
                            Action action = delegate
                            {
                                Building_Bed building_Bed2 = RestUtility.FindBedFor(victim, pawn, false, false, false);
                                if (building_Bed2 == null)
                                {
                                    building_Bed2 = RestUtility.FindBedFor(victim, pawn, false, false, true);
                                }
                                if (building_Bed2 == null)
                                {
                                    string str2 = (!victim.RaceProps.Animal) ? "NoNonPrisonerBed".Translate() : "NoAnimalBed".Translate();
                                    Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageTypeDefOf.RejectInput);
                                }
                                else
                                {
                                    Job job12 = new Job(JobDefOf.Rescue, victim, building_Bed2);
                                    job12.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job12, JobTag.Misc);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total);
                                }
                            };
                            MenuOptionPriority priority2 = MenuOptionPriority.RescueOrCapture;
                            Pawn revalidateClickTarget   = victim;
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy"));
                        }
                        if (!victim.NonHumanlikeOrWildMan() && (victim.InMentalState || victim.Faction != Faction.OfPlayer || (victim.Downed && (victim.guilt.IsGuilty || victim.IsPrisonerOfColony))))
                        {
                            string label  = "Capture".Translate(victim.LabelCap);
                            Action action = delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, true);
                                }
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageTypeDefOf.RejectInput);
                                }
                                else
                                {
                                    Job job11 = new Job(JobDefOf.Capture, victim, building_Bed);
                                    job11.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job11, JobTag.Misc);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total);
                                }
                            };
                            MenuOptionPriority priority2 = MenuOptionPriority.RescueOrCapture;
                            Pawn revalidateClickTarget   = victim;
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy"));
                        }
                    }
                }
                foreach (LocalTargetInfo item8 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    LocalTargetInfo localTargetInfo = item8;
                    Pawn            victim2         = (Pawn)localTargetInfo.Thing;
                    if (victim2.Downed && pawn.CanReserveAndReach(victim2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, true) != null)
                    {
                        string text2   = "CarryToCryptosleepCasket".Translate(localTargetInfo.Thing.LabelCap);
                        JobDef jDef    = JobDefOf.CarryToCryptosleepCasket;
                        Action action2 = delegate
                        {
                            Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, false);
                            if (building_CryptosleepCasket == null)
                            {
                                building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, true);
                            }
                            if (building_CryptosleepCasket == null)
                            {
                                Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim2, MessageTypeDefOf.RejectInput);
                            }
                            else
                            {
                                Job job10 = new Job(jDef, victim2, building_CryptosleepCasket);
                                job10.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job10, JobTag.Misc);
                            }
                        };
                        string label  = text2;
                        Action action = action2;
                        Pawn   revalidateClickTarget = victim2;
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.Default, null, revalidateClickTarget, 0f, null, null), pawn, victim2, "ReservedBy"));
                    }
                }
            }
            foreach (LocalTargetInfo item9 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true))
            {
                LocalTargetInfo stripTarg = item9;
                FloatMenuOption item4     = pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Strip".Translate(stripTarg.Thing.LabelCap), delegate
                {
                    stripTarg.Thing.SetForbidden(false, false);
                    pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Strip, stripTarg), JobTag.Misc);
                }, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, stripTarg, "ReservedBy") : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                opts.Add(item4);
            }
            if (pawn.equipment != null)
            {
                ThingWithComps equipment = null;
                List <Thing>   thingList = c.GetThingList(pawn.Map);
                int            num       = 0;
                while (num < thingList.Count)
                {
                    if (thingList[num].TryGetComp <CompEquippable>() == null)
                    {
                        num++;
                        continue;
                    }
                    equipment = (ThingWithComps)thingList[num];
                    break;
                }
                if (equipment != null)
                {
                    string          labelShort = equipment.LabelShort;
                    FloatMenuOption item5;
                    if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                    {
                        item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                    {
                        item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else
                    {
                        string text3 = "Equip".Translate(labelShort);
                        if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                        {
                            text3 = text3 + " " + "EquipWarningBrawler".Translate();
                        }
                        item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate
                        {
                            equipment.SetForbidden(false, true);
                            pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Equip, equipment), JobTag.Misc);
                            MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f);
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy");
                    }
                    opts.Add(item5);
                }
            }
            if (pawn.apparel != null)
            {
                Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(c);
                if (apparel != null)
                {
                    FloatMenuOption item6 = pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) ? (ApparelUtility.HasPartsToWear(pawn, apparel.def) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("ForceWear".Translate(apparel.LabelShort), delegate
                    {
                        apparel.SetForbidden(false, true);
                        Job job9 = new Job(JobDefOf.Wear, apparel);
                        pawn.jobs.TryTakeOrderedJob(job9, JobTag.Misc);
                    }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, apparel, "ReservedBy") : new FloatMenuOption("CannotWear".Translate(apparel.Label) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)) : new FloatMenuOption("CannotWear".Translate(apparel.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    opts.Add(item6);
                }
            }
            if (!pawn.Map.IsPlayerHome)
            {
                Thing item = c.GetFirstItem(pawn.Map);
                if (item != null && item.def.EverHaulable)
                {
                    if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, 1))
                    {
                        opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else if (item.stackCount == 1)
                    {
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item.Label), delegate
                        {
                            item.SetForbidden(false, false);
                            Job job8   = new Job(JobDefOf.TakeInventory, item);
                            job8.count = 1;
                            pawn.jobs.TryTakeOrderedJob(job8, JobTag.Misc);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                    }
                    else
                    {
                        if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, item.stackCount))
                        {
                            opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item.Label), delegate
                            {
                                item.SetForbidden(false, false);
                                Job job7   = new Job(JobDefOf.TakeInventory, item);
                                job7.count = item.stackCount;
                                pawn.jobs.TryTakeOrderedJob(job7, JobTag.Misc);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                        }
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item.Label), delegate
                        {
                            int to2 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item), item.stackCount);
                            Dialog_Slider window2 = new Dialog_Slider("PickUpCount".Translate(item.LabelShort), 1, to2, delegate(int count)
                            {
                                item.SetForbidden(false, false);
                                Job job6   = new Job(JobDefOf.TakeInventory, item);
                                job6.count = count;
                                pawn.jobs.TryTakeOrderedJob(job6, JobTag.Misc);
                            }, -2147483648);
                            Find.WindowStack.Add(window2);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                    }
                }
            }
            if (!pawn.Map.IsPlayerHome)
            {
                Thing item2 = c.GetFirstItem(pawn.Map);
                if (item2 != null && item2.def.EverHaulable)
                {
                    Pawn bestPackAnimal = GiveToPackAnimalUtility.PackAnimalWithTheMostFreeSpace(pawn.Map, pawn.Faction);
                    if (bestPackAnimal != null)
                    {
                        if (!pawn.CanReach(item2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item2.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item2, 1))
                        {
                            opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item2.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else if (item2.stackCount == 1)
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimal".Translate(item2.Label), delegate
                            {
                                item2.SetForbidden(false, false);
                                Job job5   = new Job(JobDefOf.GiveToPackAnimal, item2);
                                job5.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job5, JobTag.Misc);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy"));
                        }
                        else
                        {
                            if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item2, item2.stackCount))
                            {
                                opts.Add(new FloatMenuOption("CannotGiveToPackAnimalAll".Translate(item2.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                            }
                            else
                            {
                                opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalAll".Translate(item2.Label), delegate
                                {
                                    item2.SetForbidden(false, false);
                                    Job job4   = new Job(JobDefOf.GiveToPackAnimal, item2);
                                    job4.count = item2.stackCount;
                                    pawn.jobs.TryTakeOrderedJob(job4, JobTag.Misc);
                                }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy"));
                            }
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalSome".Translate(item2.Label), delegate
                            {
                                int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item2), item2.stackCount);
                                Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(item2.LabelShort), 1, to, delegate(int count)
                                {
                                    item2.SetForbidden(false, false);
                                    Job job3   = new Job(JobDefOf.GiveToPackAnimal, item2);
                                    job3.count = count;
                                    pawn.jobs.TryTakeOrderedJob(job3, JobTag.Misc);
                                }, -2147483648);
                                Find.WindowStack.Add(window);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy"));
                        }
                    }
                }
            }
            if (!pawn.Map.IsPlayerHome && pawn.Map.exitMapGrid.MapUsesExitGrid)
            {
                foreach (LocalTargetInfo item10 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    Pawn p = (Pawn)item10.Thing;
                    if (p.Faction == Faction.OfPlayer || p.HostFaction == Faction.OfPlayer)
                    {
                        IntVec3 exitSpot;
                        if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("CarryToExit".Translate(p.Label), delegate
                            {
                                Job job2   = new Job(JobDefOf.CarryDownedPawnToExit, p, exitSpot);
                                job2.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job2, JobTag.Misc);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item10, "ReservedBy"));
                        }
                    }
                }
            }
            if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any())
            {
                Action action3 = delegate
                {
                    pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, pawn.equipment.Primary), JobTag.Misc);
                };
                opts.Add(new FloatMenuOption("Drop".Translate(pawn.equipment.Primary.Label), action3, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            foreach (LocalTargetInfo item11 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true))
            {
                LocalTargetInfo dest = item11;
                if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                {
                    opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
                {
                    opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else
                {
                    Pawn   pTarg   = (Pawn)dest.Thing;
                    Action action4 = delegate
                    {
                        Job job = new Job(JobDefOf.TradeWithPawn, pTarg);
                        job.playerForced = true;
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total);
                    };
                    string str = string.Empty;
                    if (pTarg.Faction != null)
                    {
                        str = " (" + pTarg.Faction.Name + ")";
                    }
                    string             label     = "TradeWith".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + str;
                    Action             action    = action4;
                    MenuOptionPriority priority2 = MenuOptionPriority.InitiateSocial;
                    Thing thing = dest.Thing;
                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy"));
                }
            }
            foreach (Thing item12 in pawn.Map.thingGrid.ThingsAt(c))
            {
                foreach (FloatMenuOption floatMenuOption in item12.GetFloatMenuOptions(pawn))
                {
                    opts.Add(floatMenuOption);
                }
            }
        }
Пример #8
0
        private Apparel FindGarmentSatisfyingTitleRequirement(Pawn pawn, RoyalTitleDef.ApparelRequirement req)
        {
            Room room = pawn.GetRoom();

            if (room.isPrisonCell)
            {
                foreach (IntVec3 cell in room.Cells)
                {
                    List <Thing> thingList = cell.GetThingList(pawn.Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Apparel apparel = thingList[i] as Apparel;
                        if (apparel != null && req.ApparelMeetsRequirement(thingList[i].def, allowUnmatched: false) && pawn.CanReserve(apparel) && !apparel.IsBurning() && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def))
                        {
                            return(apparel);
                        }
                    }
                }
            }
            return(null);
        }
Пример #9
0
        private Apparel FindGarmentCoveringPart(Pawn pawn, BodyPartGroupDef bodyPartGroupDef)
        {
            Room room = pawn.GetRoom();

            if (room.isPrisonCell)
            {
                foreach (IntVec3 cell in room.Cells)
                {
                    List <Thing> thingList = cell.GetThingList(pawn.Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Apparel apparel = thingList[i] as Apparel;
                        if (apparel != null && apparel.def.apparel.bodyPartGroups.Contains(bodyPartGroupDef) && pawn.CanReserve(apparel) && !apparel.IsBurning() && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def))
                        {
                            return(apparel);
                        }
                    }
                }
            }
            return(null);
        }