protected override Job TryGiveJob(Pawn pawn)
        {
            PawnDuty duty = pawn.mindState.duty;

            if (duty == null)
            {
                return(null);
            }
            float curLevelPercentage = pawn.needs.food.CurLevelPercentage;

            if ((double)curLevelPercentage > 0.9)
            {
                return(null);
            }
            IntVec3 cell  = duty.focus.Cell;
            Thing   thing = this.FindFood(pawn, cell);

            if (thing == null)
            {
                return(null);
            }
            Job job = new Job(JobDefOf.Ingest, thing);

            job.count = FoodUtility.WillIngestStackCountOf(pawn, thing.def);
            return(job);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            PawnDuty duty = pawn.mindState.duty;

            if (duty == null)
            {
                return(null);
            }
            float curLevelPercentage = pawn.needs.food.CurLevelPercentage;

            if ((double)curLevelPercentage > 0.9)
            {
                return(null);
            }
            IntVec3 cell  = duty.focus.Cell;
            Thing   thing = this.FindFood(pawn, cell);

            if (thing == null)
            {
                return(null);
            }
            return(new Job(JobDefOf.Ingest, thing)
            {
                count = FoodUtility.WillIngestStackCountOf(pawn, thing.def, thing.def.GetStatValueAbstract(StatDefOf.Nutrition, null))
            });
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!base.ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            Thing    thing;
            ThingDef thingDef;

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out thingDef, false, true, false, false, false, false, false))
            {
                JobFailReason.Is("NoFood".Translate(), null);
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(thing, thingDef);

            return(new Job(JobDefOf.FeedPatient, thing, pawn2)
            {
                count = FoodUtility.WillIngestStackCountOf(pawn2, thingDef, nutrition)
            });
        }
Пример #4
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!base.ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.019999999552965164)
            {
                return(null);
            }
            Thing    t2  = default(Thing);
            ThingDef def = default(ThingDef);

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out t2, out def, false, true, false, false, false, false))
            {
                JobFailReason.Is("NoFood".Translate());
                return(null);
            }
            Job job = new Job(JobDefOf.FeedPatient, t2, pawn2);

            job.count = FoodUtility.WillIngestStackCountOf(pawn2, def);
            return(job);
        }
Пример #5
0
        private Toil ReserveFoodIfWillIngestWholeStack()
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                if (pawn.Faction != null)
                {
                    Thing thing = job.GetTarget(TargetIndex.A).Thing;
                    if (pawn.carryTracker.CarriedThing != thing)
                    {
                        int num = FoodUtility.WillIngestStackCountOf(pawn, thing.def, thing.GetStatValue(StatDefOf.Nutrition));
                        if (num >= thing.stackCount)
                        {
                            if (!thing.Spawned)
                            {
                                pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                            }
                            else
                            {
                                pawn.Reserve(thing, job);
                            }
                        }
                    }
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            toil.atomicWithPrevious  = true;
            return(toil);
        }
Пример #6
0
        public static Toil ReserveFoodFromStackForIngesting(TargetIndex ind, Pawn ingester = null)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                if (ingester == null)
                {
                    ingester = toil.actor;
                }
                int             stackCount = -1;
                LocalTargetInfo target     = toil.actor.jobs.curJob.GetTarget(ind);
                if (target.HasThing && target.Thing.Spawned && target.Thing.IngestibleNow)
                {
                    int b = FoodUtility.WillIngestStackCountOf(ingester, target.Thing.def, target.Thing.GetStatValue(StatDefOf.Nutrition));
                    stackCount = Mathf.Min(target.Thing.stackCount, b);
                }
                if (!toil.actor.Reserve(target, toil.actor.CurJob, 10, stackCount))
                {
                    toil.actor.jobs.EndCurrentJob(JobCondition.Incompletable);
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            toil.atomicWithPrevious  = true;
            return(toil);
        }
Пример #7
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out Thing foodSource, out ThingDef foodDef, canRefillDispenser: false, canUseInventory: true, allowForbidden: false, allowCorpse: false))
            {
                JobFailReason.Is("NoFood".Translate());
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
            Job   job       = new Job(JobDefOf.FeedPatient, foodSource, pawn2);

            job.count = FoodUtility.WillIngestStackCountOf(pawn2, foodDef, nutrition);
            return(job);
        }
 private Toil ReserveFoodIfWillIngestWholeStack()
 {
     return(new Toil
     {
         initAction = delegate()
         {
             if (this.pawn.Faction != null)
             {
                 Thing thing = this.job.GetTarget(TargetIndex.A).Thing;
                 if (this.pawn.carryTracker.CarriedThing != thing)
                 {
                     int num = FoodUtility.WillIngestStackCountOf(this.pawn, thing.def, thing.GetStatValue(StatDefOf.Nutrition, true));
                     if (num >= thing.stackCount)
                     {
                         if (!thing.Spawned)
                         {
                             this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                         }
                         else
                         {
                             this.pawn.Reserve(thing, this.job, 1, -1, null);
                         }
                     }
                 }
             }
         },
         defaultCompleteMode = ToilCompleteMode.Instant,
         atomicWithPrevious = true
     });
 }
Пример #9
0
        private void InterfaceIngest(Thing t)
        {
            Job job = new Job(JobDefOf.Ingest, t);

            job.count = Mathf.Min(t.stackCount, t.def.ingestible.maxNumToIngestAtOnce);
            job.count = Mathf.Min(job.count, FoodUtility.WillIngestStackCountOf(this.SelPawnForGear, t.def, t.GetStatValue(StatDefOf.Nutrition, true)));
            this.SelPawnForGear.jobs.TryTakeOrderedJob(job, JobTag.Misc);
        }
Пример #10
0
        private void InterfaceIngest(Thing t)
        {
            Job job = JobMaker.MakeJob(JobDefOf.Ingest, t);

            job.count = Mathf.Min(t.stackCount, t.def.ingestible.maxNumToIngestAtOnce);
            job.count = Mathf.Min(job.count, FoodUtility.WillIngestStackCountOf(SelPawnForGear, t.def, t.GetStatValue(StatDefOf.Nutrition)));
            SelPawnForGear.jobs.TryTakeOrderedJob(job);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Job result;

            if (!base.ShouldTakeCareOfPrisoner(pawn, t))
            {
                result = null;
            }
            else
            {
                Pawn     pawn2 = (Pawn)t;
                Thing    thing;
                ThingDef thingDef;
                if (!pawn2.guest.CanBeBroughtFood)
                {
                    result = null;
                }
                else if (!pawn2.Position.IsInPrisonCell(pawn2.Map))
                {
                    result = null;
                }
                else if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
                {
                    result = null;
                }
                else if (WardenFeedUtility.ShouldBeFed(pawn2))
                {
                    result = null;
                }
                else if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out thingDef, false, true, false, false, false, false, false))
                {
                    result = null;
                }
                else if (thing.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable))
                {
                    result = null;
                }
                else if (WorkGiver_Warden_DeliverFood.FoodAvailableInRoomTo(pawn2))
                {
                    result = null;
                }
                else
                {
                    float nutrition = FoodUtility.GetNutrition(thing, thingDef);
                    result = new Job(JobDefOf.DeliverFood, thing, pawn2)
                    {
                        count   = FoodUtility.WillIngestStackCountOf(pawn2, thingDef, nutrition),
                        targetC = RCellFinder.SpotToChewStandingNear(pawn2, thing)
                    };
                }
            }
            return(result);
        }
 public override bool TryMakePreToilReservations()
 {
     if (base.pawn.Faction != null && !(this.IngestibleSource is Building_NutrientPasteDispenser))
     {
         Thing ingestibleSource = this.IngestibleSource;
         int   num = FoodUtility.WillIngestStackCountOf(base.pawn, ingestibleSource.def);
         if (num >= ingestibleSource.stackCount && ingestibleSource.Spawned && !base.pawn.Reserve(ingestibleSource, base.job, 1, -1, null))
         {
             return(false);
         }
     }
     return(true);
 }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = (Pawn)t;

            if (FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out var foodSource, out var foodDef, canRefillDispenser: false))
            {
                float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
                Job   job       = JobMaker.MakeJob(JobDefOf.FeedPatient);
                job.targetA = foodSource;
                job.targetB = pawn2;
                job.count   = FoodUtility.WillIngestStackCountOf(pawn2, foodDef, nutrition);
                return(job);
            }
            return(null);
        }
Пример #14
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn     pawn2 = (Pawn)t;
            Thing    t2    = default(Thing);
            ThingDef def   = default(ThingDef);

            if (FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out t2, out def, false, true, false, true, false, false))
            {
                Job job = new Job(JobDefOf.FeedPatient);
                job.targetA = t2;
                job.targetB = pawn2;
                job.count   = FoodUtility.WillIngestStackCountOf(pawn2, def);
                return(job);
            }
            return(null);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!base.ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!pawn2.guest.CanBeBroughtFood)
            {
                return(null);
            }
            if (!pawn2.Position.IsInPrisonCell(pawn2.Map))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.019999999552965164)
            {
                return(null);
            }
            if (WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            Thing    thing = default(Thing);
            ThingDef def   = default(ThingDef);

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out def, false, true, false, false, false, false))
            {
                return(null);
            }
            if (thing.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable))
            {
                return(null);
            }
            if (WorkGiver_Warden_DeliverFood.FoodAvailableInRoomTo(pawn2))
            {
                return(null);
            }
            Job job = new Job(JobDefOf.DeliverFood, thing, pawn2);

            job.count   = FoodUtility.WillIngestStackCountOf(pawn2, def);
            job.targetC = RCellFinder.SpotToChewStandingNear(pawn2, thing);
            return(job);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn     pawn2 = (Pawn)t;
            Thing    thing;
            ThingDef thingDef;

            if (FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out thingDef, false, true, false, true, false, false, false))
            {
                float nutrition = FoodUtility.GetNutrition(thing, thingDef);
                return(new Job(JobDefOf.FeedPatient)
                {
                    targetA = thing,
                    targetB = pawn2,
                    count = FoodUtility.WillIngestStackCountOf(pawn2, thingDef, nutrition)
                });
            }
            return(null);
        }
Пример #17
0
 public override bool TryMakePreToilReservations(bool errorOnFailed)
 {
     if (this.pawn.Faction != null && !(this.IngestibleSource is Building_NutrientPasteDispenser))
     {
         Thing ingestibleSource = this.IngestibleSource;
         int   num = FoodUtility.WillIngestStackCountOf(this.pawn, ingestibleSource.def, ingestibleSource.GetStatValue(StatDefOf.Nutrition, true));
         if (num >= ingestibleSource.stackCount && ingestibleSource.Spawned)
         {
             Pawn            pawn   = this.pawn;
             LocalTargetInfo target = ingestibleSource;
             Job             job    = this.job;
             if (!pawn.Reserve(target, job, 1, -1, null, errorOnFailed))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #18
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!pawn2.guest.CanBeBroughtFood)
            {
                return(null);
            }
            if (!pawn2.Position.IsInPrisonCell(pawn2.Map))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            if (WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out Thing foodSource, out ThingDef foodDef, canRefillDispenser: false, canUseInventory: true, allowForbidden: false, allowCorpse: false))
            {
                return(null);
            }
            if (foodSource.GetRoom() == pawn2.GetRoom())
            {
                return(null);
            }
            if (FoodAvailableInRoomTo(pawn2))
            {
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
            Job   job       = new Job(JobDefOf.DeliverFood, foodSource, pawn2);

            job.count   = FoodUtility.WillIngestStackCountOf(pawn2, foodDef, nutrition);
            job.targetC = RCellFinder.SpotToChewStandingNear(pawn2, foodSource);
            return(job);
        }
        // Token: 0x0600009A RID: 154 RVA: 0x0000580C File Offset: 0x00003A0C
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = (Pawn)t;
            Predicate <Thing> predicate = (Thing t3) => t3.def.category == ThingCategory.Item && t3.IngestibleNow && pawn.RaceProps.CanEverEat(t3) && pawn.CanReserve(t3, 1, -1, null, false) && !t3.IsForbidden(pawn.Faction) && !t3.IsNotFresh() && t3.def.IsNutritionGivingIngestible;
            bool flag = predicate == null;
            Job  result;

            if (flag)
            {
                result = null;
            }
            else
            {
                Thing thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.HaulableAlways), PathEndMode.OnCell, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 10f, predicate, null, 0, -1, false, RegionType.Set_Passable, false);
                bool  flag2 = thing == null;
                if (flag2)
                {
                    result = null;
                }
                else
                {
                    bool flag3 = predicate != null && thing != null && pawn2 != null;
                    if (flag3)
                    {
                        ThingDef def       = thing.def;
                        float    nutrition = FoodUtility.GetNutrition(thing, def);
                        result = new Job(WPJobDefOf.WPFeedPatient)
                        {
                            targetA = thing,
                            targetB = pawn2,
                            count   = FoodUtility.WillIngestStackCountOf(pawn2, def, nutrition)
                        };
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
 private void <ReserveFoodIfWillIngestWholeStack> m__0()
 {
     if (this.pawn.Faction != null)
     {
         Thing thing = this.job.GetTarget(TargetIndex.A).Thing;
         if (this.pawn.carryTracker.CarriedThing != thing)
         {
             int num = FoodUtility.WillIngestStackCountOf(this.pawn, thing.def, thing.GetStatValue(StatDefOf.Nutrition, true));
             if (num >= thing.stackCount)
             {
                 if (!thing.Spawned)
                 {
                     this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                 }
                 else
                 {
                     this.pawn.Reserve(thing, this.job, 1, -1, null);
                 }
             }
         }
     }
 }
        // Token: 0x060003E2 RID: 994 RVA: 0x000280A0 File Offset: 0x000264A0
        public override bool TryMakePreToilReservations(bool errorOnFailed)
        {
            if (this.pawn.Faction != null && !(this.IngestibleSource is Building_NutrientPasteDispenser))
            {
                Thing ingestibleSource = this.IngestibleSource;
                if (ingestibleSource == null)
                {
                    return(false);
                }
                if (ingestibleSource.def == null)
                {
                    return(false);
                }

                try
                {
                    int num = FoodUtility.WillIngestStackCountOf(this.pawn, ingestibleSource.def, ingestibleSource.GetStatValue(StatDefOf.Nutrition, true) + 1);
                    if (num >= ingestibleSource.stackCount && ingestibleSource.Spawned)
                    {
                        Pawn            pawn   = this.pawn;
                        LocalTargetInfo target = ingestibleSource;
                        Job             job    = this.job;
                        if (!pawn.Reserve(target, job, 1, -1, null, errorOnFailed))
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception)
                {
                    //    Log.Message(string.Format("pawn: {0}", pawn));
                    //    Log.Message(string.Format("ingestibleSource.def: {0}", ingestibleSource.def));
                    //    Log.Message(string.Format("Nutrition: {0}", ingestibleSource.GetStatValue(StatDefOf.Nutrition, true)));
                    return(false);
                }
            }
            return(true);
        }
Пример #22
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            PawnDuty duty = pawn.mindState.duty;

            if (duty == null)
            {
                return(null);
            }
            if ((double)pawn.needs.food.CurLevelPercentage > 0.9)
            {
                return(null);
            }
            IntVec3 cell  = duty.focus.Cell;
            Thing   thing = FindFood(pawn, cell);

            if (thing == null)
            {
                return(null);
            }
            Job job = JobMaker.MakeJob(JobDefOf.Ingest, thing);

            job.count = FoodUtility.WillIngestStackCountOf(pawn, thing.def, thing.def.GetStatValueAbstract(StatDefOf.Nutrition));
            return(job);
        }
Пример #23
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);
                }
            }
        }
Пример #24
0
        // Token: 0x060004FD RID: 1277 RVA: 0x000321F8 File Offset: 0x000305F8
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Food    food  = pawn.needs.food;
            LifeStageDef stage = pawn.ageTracker.CurLifeStage;

            if (stage == pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def)
            {
                return(null);
            }

            bool flag;

            if (pawn.AnimalOrWildMan())
            {
                flag = true;
            }
            else
            {
                Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition, false);
                flag = (firstHediffOfDef != null && firstHediffOfDef.Severity > 0.4f);
            }
            bool     flag2     = pawn.needs.food.CurCategory == HungerCategory.Starving;
            bool     desperate = flag2;
            Thing    thing;
            ThingDef thingDef;
            bool     canRefillDispenser = false;
            bool     canUseInventory    = false;
            bool     allowCorpse        = true;
            bool     flag3 = false;

            if (pawn.GetLord() != null && pawn.GetLord() is Lord L)
            {
                if (L.CurLordToil is LordToil_DefendAndExpandHiveLike Hivelord)
                {
                    if (Hivelord.Data.assignedHiveLikes.TryGetValue(pawn) != null)
                    {
                        if (!Hivelord.Data.assignedHiveLikes.TryGetValue(pawn).active)
                        {
                            return(null);
                        }
                    }
                }
            }
            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn, desperate, out thing, out thingDef, canRefillDispenser, canUseInventory, true, allowCorpse, true, pawn.IsWildMan(), flag3))
            {
                return(null);
            }
            if (thing.GetType() != typeof(Corpse))
            {
                return(null);
            }
            Pawn pawn2 = thing as Pawn;

            if (pawn2 != null && pawn.CanSee(pawn2) && pawn.isXenomorph())
            {
                return(new Job(JobDefOf.PredatorHunt, pawn2)
                {
                    killIncappedTarget = true
                });
            }
            float nutrition = FoodUtility.GetNutrition(thing, thingDef);

            return(new Job(XenomorphDefOf.RRY_Neomorph_Ingest, thing)
            {
                count = FoodUtility.WillIngestStackCountOf(pawn, thingDef, nutrition)
            });
        }
Пример #25
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Food food = pawn.needs.food;

            if (food == null || (int)food.CurCategory < (int)minCategory)
            {
                return(null);
            }
            bool flag;

            if (pawn.AnimalOrWildMan())
            {
                flag = true;
            }
            else
            {
                Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition);
                flag = (firstHediffOfDef != null && firstHediffOfDef.Severity > 0.4f);
            }
            bool     flag2              = pawn.needs.food.CurCategory == HungerCategory.Starving;
            bool     desperate          = flag2;
            bool     canRefillDispenser = true;
            bool     canUseInventory    = true;
            bool     allowCorpse        = flag;
            bool     flag3              = forceScanWholeMap;
            Thing    foodSource         = default(Thing);
            ThingDef foodDef            = default(ThingDef);

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn, desperate, out foodSource, out foodDef, canRefillDispenser, canUseInventory, allowForbidden: false, allowCorpse, allowSociallyImproper: false, pawn.IsWildMan(), flag3))
            {
                return(null);
            }
            Pawn pawn2 = foodSource as Pawn;

            if (pawn2 != null)
            {
                Job job = new Job(JobDefOf.PredatorHunt, pawn2);
                job.killIncappedTarget = true;
                return(job);
            }
            if (foodSource is Plant && foodSource.def.plant.harvestedThingDef == foodDef)
            {
                return(new Job(JobDefOf.Harvest, foodSource));
            }
            Building_NutrientPasteDispenser building_NutrientPasteDispenser = foodSource as Building_NutrientPasteDispenser;

            if (building_NutrientPasteDispenser != null && !building_NutrientPasteDispenser.HasEnoughFeedstockInHoppers())
            {
                Building building = building_NutrientPasteDispenser.AdjacentReachableHopper(pawn);
                if (building != null)
                {
                    ISlotGroupParent hopperSgp = building as ISlotGroupParent;
                    Job job2 = WorkGiver_CookFillHopper.HopperFillFoodJob(pawn, hopperSgp);
                    if (job2 != null)
                    {
                        return(job2);
                    }
                }
                foodSource = FoodUtility.BestFoodSourceOnMap(pawn, pawn, flag2, out foodDef, FoodPreferability.MealLavish, allowPlant: false, !pawn.IsTeetotaler(), allowCorpse: false, allowDispenserFull: false, allowDispenserEmpty: false, allowForbidden: false, allowSociallyImproper: false, allowHarvest: false, forceScanWholeMap);
                if (foodSource == null)
                {
                    return(null);
                }
            }
            float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
            Job   job3      = new Job(JobDefOf.Ingest, foodSource);

            job3.count = FoodUtility.WillIngestStackCountOf(pawn, foodDef, nutrition);
            return(job3);
        }
        // Token: 0x060004FD RID: 1277 RVA: 0x000321F8 File Offset: 0x000305F8
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool         selected           = Find.Selector.SelectedObjects.Contains(pawn) && Prefs.DevMode;
            Need_Food    food               = pawn.needs.food;
            LifeStageDef stage              = pawn.ageTracker.CurLifeStage;
            bool         desperate          = food.CurCategory >= HungerCategory.Starving;
            bool         canRefillDispenser = false;
            bool         canUseInventory    = false;
            bool         allowCorpse        = true;
            bool         flag3              = this.forceScanWholeMap;

            if (stage == pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def)
            {
                if (selected)
                {
                    Log.Message(string.Format("adult {0} @ {1}", pawn, pawn.Position));
                }
                if (food.CurCategory == HungerCategory.Fed)
                {
                    return(null);
                }
            }
            else
            {
                if (selected)
                {
                    Log.Message(string.Format("young {0} @ {1}", pawn, pawn.Position));
                }

                /*
                 * if (food.CurCategory == HungerCategory.Fed)
                 * {
                 *  return null;
                 * }
                 */
            }

            float nutrition;

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn, desperate, out Thing thing, out ThingDef thingDef, canRefillDispenser, canUseInventory, true, allowCorpse, true, pawn.IsWildMan(), flag3))
            {
                return(null);
            }
            if (thing is Corpse corpse)
            {
                if (selected)
                {
                    Log.Message(string.Format("{0} is corpse @ {1}", thing, thing.Position));
                }
                nutrition = FoodUtility.GetNutrition(thing, thingDef);
                return(new Job(XenomorphDefOf.RRY_Neomorph_Ingest, thing)
                {
                    count = FoodUtility.WillIngestStackCountOf(pawn, thingDef, nutrition)
                });
            }
            if (thing is Pawn pawn2)
            {
                if (selected)
                {
                    Log.Message(string.Format("{0} is pawn @ {1}", thing, thing.Position));
                }
                if (pawn2 != null)
                {
                    return(new Job(JobDefOf.PredatorHunt, pawn2)
                    {
                        killIncappedTarget = true
                    });
                }
            }
            nutrition = FoodUtility.GetNutrition(thing, thingDef);
            if (selected)
            {
                Log.Message(string.Format("{0} is thing @ {1}", thing, thing.Position));
            }
            return(new Job(XenomorphDefOf.RRY_Neomorph_Ingest, thing)
            {
                count = FoodUtility.WillIngestStackCountOf(pawn, thingDef, nutrition)
            });
        }
Пример #27
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Food food = pawn.needs.food;

            if (food == null || food.CurCategory < this.minCategory)
            {
                return(null);
            }
            bool flag;

            if (pawn.AnimalOrWildMan())
            {
                flag = true;
            }
            else
            {
                Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition, false);
                flag = (firstHediffOfDef != null && firstHediffOfDef.Severity > 0.4f);
            }
            bool     flag2              = pawn.needs.food.CurCategory == HungerCategory.Starving;
            bool     desperate          = flag2;
            bool     canRefillDispenser = true;
            bool     canUseInventory    = true;
            bool     allowCorpse        = flag;
            bool     flag3              = this.forceScanWholeMap;
            Thing    thing;
            ThingDef thingDef;

            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn, desperate, out thing, out thingDef, canRefillDispenser, canUseInventory, false, allowCorpse, false, pawn.IsWildMan(), flag3))
            {
                return(null);
            }
            Pawn pawn2 = thing as Pawn;

            if (pawn2 != null)
            {
                return(new Job(JobDefOf.PredatorHunt, pawn2)
                {
                    killIncappedTarget = true
                });
            }
            if (thing is Plant && thing.def.plant.harvestedThingDef == thingDef)
            {
                return(new Job(JobDefOf.Harvest, thing));
            }
            Building_NutrientPasteDispenser building_NutrientPasteDispenser = thing as Building_NutrientPasteDispenser;

            if (building_NutrientPasteDispenser != null && !building_NutrientPasteDispenser.HasEnoughFeedstockInHoppers())
            {
                Building building = building_NutrientPasteDispenser.AdjacentReachableHopper(pawn);
                if (building != null)
                {
                    ISlotGroupParent hopperSgp = building as ISlotGroupParent;
                    Job job = WorkGiver_CookFillHopper.HopperFillFoodJob(pawn, hopperSgp);
                    if (job != null)
                    {
                        return(job);
                    }
                }
                thing = FoodUtility.BestFoodSourceOnMap(pawn, pawn, flag2, out thingDef, FoodPreferability.MealLavish, false, !pawn.IsTeetotaler(), false, false, false, false, false, false, this.forceScanWholeMap);
                if (thing == null)
                {
                    return(null);
                }
            }
            float nutrition = FoodUtility.GetNutrition(thing, thingDef);

            return(new Job(JobDefOf.Ingest, thing)
            {
                count = FoodUtility.WillIngestStackCountOf(pawn, thingDef, nutrition)
            });
        }