public ThingRequest GetThingRequest() { if (HasThing) { return(ThingRequest.ForDef(thing.def)); } if (HasThingFilter) { return(thingFilter.BestThingRequest); } return(ThingRequest.ForUndefined()); }
// Token: 0x06000010 RID: 16 RVA: 0x000022BC File Offset: 0x000004BC public ThingRequest Request() { if (thingDef != null) { return(ThingRequest.ForDef(thingDef)); } if (nutrition) { return(ThingRequest.ForGroup(ThingRequestGroup.FoodSourceNotPlantOrTree)); } return(ThingRequest.ForUndefined()); }
internal static Thing _BestConsumeTarget(this JobGiver_BingeAlcohol obj, Pawn pawn) { // Set flag to let FoodUtility.GetFoodDef() know we are looking for alcohol, not food _FoodUtility._GetFoodDefAlcohol = true; return(GenClosest.ClosestThingReachable( pawn.Position, ThingRequest.ForUndefined(), PathEndMode.OnCell, TraverseParms.For( pawn, pawn.NormalMaxDanger(), TraverseMode.ByPawn, false), 9999f, (thing) => { if ( (obj.IgnoreForbid(pawn)) || (!thing.IsForbidden(pawn)) ) { return pawn.CanReserve(thing, 1); } return false; }, Find.ListerThings.AllThings .Where(thing => thing.def.IsAlcohol()) .Concat( (IEnumerable <Thing>)Find.ListerBuildings.AllBuildingsColonistOfClass <Building_AutomatedFactory>() .Where(factory => ( (factory.OutputToPawnsDirectly) && (factory.BestProduct(FoodSynthesis.IsAlcohol, FoodSynthesis.SortAlcohol) != null) )) ), -1, false )); }
// Token: 0x06000091 RID: 145 RVA: 0x00005838 File Offset: 0x00003A38 public ThingRequest Request() { bool flag = this.thingDef != null; ThingRequest result; if (flag) { result = ThingRequest.ForDef(this.thingDef); } else { bool flag2 = this.nutrition; if (flag2) { result = ThingRequest.ForGroup(ThingRequestGroup.FoodSourceNotPlantOrTree); } else { result = ThingRequest.ForUndefined(); } } return(result); }
internal static Job _DrinkAlcoholJob(Pawn pawn) { var JobGiver_Binge_DrinkAlchohol = new _JobGiver_Binge._DrinkAlchohol(); JobGiver_Binge_DrinkAlchohol.pawn = pawn; JobGiver_Binge_DrinkAlchohol.ignoreForbid = JobGiver_Binge_DrinkAlchohol.pawn.MentalStateDef != null; var validator = new Predicate <Thing>(JobGiver_Binge_DrinkAlchohol.CanBingeOn); var thing = GenClosest.ClosestThingReachable( pawn.Position, ThingRequest.ForUndefined(), PathEndMode.OnCell, TraverseParms.For( pawn, pawn.NormalMaxDanger()), 9999f, validator, Find.ListerThings.AllThings.Where(t => ( (t.def.IsAlcohol()) || (t is Building_AutomatedFactory) )), -1, true); if (thing == null) { return((Job)null); } Job job = new Job(JobDefOf.Ingest, thing, thing); job.maxNumToCarry = Mathf.Min( thing.stackCount, thing.def.ingestible.maxNumToIngestAtOnce); job.ignoreForbidden = JobGiver_Binge_DrinkAlchohol.ignoreForbid; return(job); }
internal static Thing _BestFoodSourceFor(Pawn getter, Pawn eater, bool fullDispensersOnly, out ThingDef foodDef) { var dispenserValidator = new DispenserValidator(); dispenserValidator.getter = getter; dispenserValidator.fullDispensersOnly = fullDispensersOnly; Thing bestFoodSpawnedFor = FoodUtility.BestFoodSpawnedFor(getter, eater, getter == eater); if ( (getter == eater) && (getter.RaceProps.predator) && (bestFoodSpawnedFor == null) ) { Pawn prey = BestPawnToHuntForPredator(getter); if (prey != null) { foodDef = prey.RaceProps.corpseDef; return((Thing)prey); } } if (getter.RaceProps.ToolUser) { // Try to find a working nutrient paste dispenser or food sythesizer var validatorPredicate = new Predicate <Thing>(dispenserValidator.Validate); var dispensers = Find.ListerThings.AllThings.Where(t => ( (t is Building_NutrientPasteDispenser) || ( (t is Building_AutomatedFactory) && (((Building_AutomatedFactory)t).CompAutomatedFactory.Properties.outputVector == FactoryOutputVector.DirectToPawn) ) )); if (dispensers.Any()) { // Check dispenses and synthesizers (automated factories) if (bestFoodSpawnedFor != null) { // Compare with best spawned meal float dist = (getter.Position - bestFoodSpawnedFor.Position).LengthManhattan; dispenserValidator.meal.thing = bestFoodSpawnedFor; dispenserValidator.meal.def = bestFoodSpawnedFor.def; dispenserValidator.meal.score = FoodOptimality(bestFoodSpawnedFor, dist); } else { // Nothing to compare to dispenserValidator.meal.thing = null; dispenserValidator.meal.def = null; dispenserValidator.meal.score = FoodOptimalityUnusable; } // Now find the best/closest dispenser var dispenser = GenClosest.ClosestThingReachable( getter.Position, ThingRequest.ForUndefined(), PathEndMode.InteractionCell, TraverseParms.For( dispenserValidator.getter, dispenserValidator.getter.NormalMaxDanger()), 9999f, validatorPredicate, dispensers, -1, true); if (dispenser != null) { // Found a dispenser/synthesizer and it's better than the spawned meal foodDef = dispenserValidator.meal.def; return(dispenser); } } } foodDef = bestFoodSpawnedFor == null ? null : bestFoodSpawnedFor.def; return(bestFoodSpawnedFor); }