protected override Job TryGiveJob(Pawn pawn) { IntVec3 position = pawn.Position; bool flag = !pawn.Map.fogGrid.IsFogged(position); bool flag2 = flag; Job result; if (flag2) { TraverseParms traverseParams = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, true); JobDef named = DefDatabase <JobDef> .GetNamed("MO_Kill", true); bool flag3 = pawn.jobs.curJob == null || (pawn.jobs.curJob.def != named && pawn.jobs.curJob.checkOverrideOnExpire); bool flag4 = flag3; if (flag4) { Pawn pawn2 = JobGiver_Kill.FindMeatyPrey(pawn, traverseParams); bool flag5 = pawn2 != null; bool flag6 = flag5; if (flag6) { PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, pawn2, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), PathEndMode.OnCell); IntVec3 intVec = new IntVec3(); Building_Door building_Door = PawnPathUtility.FirstBlockingBuilding(pawnPath, out intVec, pawn) as Building_Door; pawnPath.ReleaseToPool(); bool flag7 = building_Door != null; bool flag8 = flag7; if (flag8) { bool flag9 = !building_Door.Open; bool flag10 = flag9; if (flag10) { return(new Job(DefDatabase <JobDef> .GetNamed("MO_CrushDoor", true), intVec, building_Door) { maxNumMeleeAttacks = 4, expiryInterval = 500 }); } } // error return(new Job(named) { targetA = pawn2, maxNumMeleeAttacks = 4, killIncappedTarget = true, expiryInterval = 500 }); } } result = null; } else { result = null; } return(result); }
public static Pawn FindMeatyPrey(Pawn pawn, TraverseParms traverseParams) { ThingRequest thingRequest = ThingRequest.ForGroup(ThingRequestGroup.Pawn); Predicate <Thing> predicate = delegate(Thing p) { Pawn prey = p as Pawn; return(JobGiver_Kill.isPossiblePrey(prey, pawn)); }; return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, thingRequest, PathEndMode.Touch, traverseParams, 100f, predicate, null, -1) as Pawn); }
private static bool isPossiblePrey(Pawn prey, Pawn hunter) { return(hunter != prey && !prey.Dead && !prey.Downed && JobGiver_Kill.isHumanlike(hunter, prey) && !JobGiver_Kill.isFriendly(hunter, prey) && !JobGiver_Kill.isAlly(hunter, prey) && !JobGiver_Kill.isMech(hunter, prey) && !JobGiver_Kill.isOwnRace(hunter, prey) && JobGiver_Kill.isNearby(hunter, prey)); }