public override Job JobOnThing(Pawn pawn, Thing thing, bool forced = false) { ISlotGroupParent slotGroupParent = thing as ISlotGroupParent; if (slotGroupParent == null) { return(null); } if (!pawn.CanReserve(thing.Position, 1, -1, null, false)) { return(null); } int num = 0; List <Thing> list = pawn.Map.thingGrid.ThingsListAt(thing.Position); for (int i = 0; i < list.Count; i++) { Thing thing2 = list[i]; if (Building_NutrientPasteDispenser.IsAcceptableFeedstock(thing2.def)) { num += thing2.stackCount; } } if (num > 25) { JobFailReason.Is("AlreadyFilledLower".Translate()); return(null); } return(WorkGiver_CookFillHopper.HopperFillFoodJob(pawn, slotGroupParent)); }
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) }); }
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); }