public static Corpse FindClosestCorpseFor(Predicate<Thing> pred, Pawn getter) { Predicate<Thing> predicate1 = (Thing c) => !c.IsForbidden(Faction.OfColony) && getter.AwareOf(c) && getter.CanReserve(c); Predicate<Thing> predicate = (Thing t) => pred(t) && predicate1(t); ThingRequest thingReq = ThingRequest.ForGroup(ThingRequestGroup.Corpse); return (Corpse)GenClosest.ClosestThingReachable(getter.Position, thingReq, PathEndMode.ClosestTouch, TraverseParms.For(getter), 9999f, predicate, null); }
private Thing GetBestSeedThingForSowing( Pawn pawn, IntVec3 cell, ThingDef_PlantWithSeeds customPlantDef ) { Thing seedThing = null; Predicate<Thing> predicate = (Thing tempThing ) => !tempThing.IsForbidden( pawn.Faction ) && pawn.AwareOf( tempThing ) && pawn.CanReserve( tempThing); if ( customPlantDef.SeedDef != null ) { seedThing = GenClosest.ClosestThingReachable(cell, ThingRequest.ForDef(customPlantDef.SeedDef), PathEndMode.ClosestTouch, TraverseParms.For( pawn ), 9999f, predicate ); } return seedThing; }