protected override Job TryGiveJob(Pawn pawn)
        {
            pawn.mindState.nextMoveOrderIsWait = !pawn.mindState.nextMoveOrderIsWait;

            if (!pawn.mindState.duty.focus.HasThing)
            {
                return(null);
            }

            Thing thing = pawn.mindState.duty.focus.Thing;

            IntVec3 cell = thing.InteractionCell;

            if (!pawn.CanReach(cell, PathEndMode.OnCell, PawnUtility.ResolveMaxDanger(pawn, maxDanger)))
            {
                return(null);
            }
            if (pawn.Position == cell)
            {
                return(null);
            }

            Job job2 = JobMaker.MakeJob(JobDefOf.Goto, cell);

            job2.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, locomotionUrgency);
            job2.expiryInterval    = jobMaxDuration;
            return(job2);
        }
Beispiel #2
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            pawn.drafter.Drafted = true;

            IntVec3 cell = pawn.mindState.duty.focus.Cell;

            if (pawn.IsBoat() && !ShipReachabilityUtility.CanReachShip(pawn, cell, PathEndMode.OnCell, PawnUtility.ResolveMaxDanger(pawn, maxDanger), false, TraverseMode.ByPawn))
            {
                return(null);
            }
            else if (!pawn.IsBoat() && pawn is VehiclePawn vehicle && !ReachabilityUtility.CanReach(vehicle, cell, PathEndMode.OnCell, PawnUtility.ResolveMaxDanger(vehicle, maxDanger), false))
            {
                return(null);
            }
            if (exactCell && pawn.Position == cell)
            {
                return(null);
            }

            return(new Job(JobDefOf.Goto, cell)
            {
                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, locomotionUrgency),
                expiryInterval = jobMaxDuration
            });
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            pawn.mindState.nextMoveOrderIsWait = !pawn.mindState.nextMoveOrderIsWait;
            if (pawn.mindState.nextMoveOrderIsWait && !this.exactCell)
            {
                return(new Job(JobDefOf_Ships.IdleShip)
                {
                    expiryInterval = this.WaitTicks.RandomInRange
                });
            }
            IntVec3 cell = pawn.mindState.duty.focus.Cell;

            if (!ShipReachabilityUtility.CanReachShip(pawn, cell, PathEndMode.OnCell, PawnUtility.ResolveMaxDanger(pawn, this.maxDanger), false, TraverseMode.ByPawn))
            {
                return(null);
            }
            if (this.exactCell && pawn.Position == cell)
            {
                return(null);
            }
            IntVec3 c = cell;

            return(new Job(JobDefOf.Goto, c)
            {
                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.locomotionUrgency),
                expiryInterval = this.jobMaxDuration
            });
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool flag = forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig && !pawn.CanReachMapEdge()) || (forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, countDormantPawnsAsHostile: true));

            if (!TryFindGoodExitDest(pawn, flag, out IntVec3 dest))
            {
                return(null);
            }
            if (flag)
            {
                using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, dest, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings)))
                {
                    IntVec3 cellBefore;
                    Thing   thing = path.FirstBlockingBuilding(out cellBefore, pawn);
                    if (thing != null)
                    {
                        Job job = DigUtility.PassBlockerJob(pawn, thing, cellBefore, canMineMineables: true, canMineNonMineables: true);
                        if (job != null)
                        {
                            return(job);
                        }
                    }
                }
            }
            Job job2 = JobMaker.MakeJob(JobDefOf.Goto, dest);

            job2.exitMapOnArrival = true;
            job2.failIfCantJoinOrCreateCaravan = failIfCantJoinOrCreateCaravan;
            job2.locomotionUrgency             = PawnUtility.ResolveLocomotion(pawn, defaultLocomotion, LocomotionUrgency.Jog);
            job2.expiryInterval = jobMaxDuration;
            job2.canBash        = canBash;
            return(job2);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(null);
            }
            if (pawn.GetRegion() == null)
            {
                return(null);
            }

            CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>();

            if (memory == null || !memory.guardPosition.IsValid)
            {
                return(null);
            }

            Job job = null;

            Thing target = this.FindAttackTarget(pawn);

            if (target == null)
            {
                return(null);
            }

            // Melee attack if it is adjacent
            job = TryMeleeAttackTargetJob(pawn, target);

            // Shoot it if we can
            if (job == null)
            {
                job = TryRangedAttackTargetJob(pawn, target);
            }

            // Otherwise approach
            if (job == null)
            {
                job = GoNearTarget(pawn, target);
            }

            if (job != null)
            {
                job.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, LocomotionUrgency.Sprint, LocomotionUrgency.Walk);
            }

            return(job);
        }
Beispiel #6
0
        protected Job ExitMapJob(Pawn meeseeks)
        {
            IntVec3 destination;

            if (!RCellFinder.TryFindBestExitSpot(meeseeks, out destination, TraverseMode.ByPawn))
            {
                return(null);
            }

            Job job2 = JobMaker.MakeJob(JobDefOf.Goto, destination);

            job2.exitMapOnArrival = true;
            job2.failIfCantJoinOrCreateCaravan = false;
            job2.locomotionUrgency             = PawnUtility.ResolveLocomotion(meeseeks, LocomotionUrgency.Walk, LocomotionUrgency.Jog);
            //job2.expiryInterval = jobMaxDuration;
            //job2.canBash = canBash;
            return(job2);
        }
Beispiel #7
0
        public static bool TryGiveJob(JobGiver_ExitMap __instance, ref Job __result, Pawn pawn)
        {
            Pawn_MindState mindState = pawn.mindState;
            bool           canDig    = __instance.forceCanDig ||
                                       (mindState != null && mindState.duty != null) &&
                                       mindState.duty.canDig &&
                                       !pawn.CanReachMapEdge() ||
                                       __instance.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge() ||
                                       __instance.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null &&
                                       GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, true);
            IntVec3 dest;

            if (!__instance.TryFindGoodExitDest(pawn, canDig, out dest))
            {
                __result = null;
                return(false);
            }
            if (canDig)
            {
                using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, (LocalTargetInfo)dest, TraverseParms.For(pawn, mode: TraverseMode.PassAllDestroyableThings)))
                {
                    IntVec3 cellBefore;
                    Thing   blocker = path.FirstBlockingBuilding(out cellBefore, pawn);
                    if (blocker != null)
                    {
                        Job job = DigUtility.PassBlockerJob(pawn, blocker, cellBefore, true, true);
                        if (job != null)
                        {
                            __result = job;
                            return(false);
                        }
                    }
                }
            }
            Job job1 = JobMaker.MakeJob(JobDefOf.Goto, (LocalTargetInfo)dest);

            job1.exitMapOnArrival = true;
            job1.failIfCantJoinOrCreateCaravan = __instance.failIfCantJoinOrCreateCaravan;
            job1.locomotionUrgency             = PawnUtility.ResolveLocomotion(pawn, __instance.defaultLocomotion, LocomotionUrgency.Jog);
            job1.expiryInterval = __instance.jobMaxDuration;
            job1.canBashDoors   = __instance.canBash;
            __result            = job1;
            return(false);
        }
Beispiel #8
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool flag = false;

            if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction)))
            {
                flag = true;
            }
            IntVec3 c;
            Job     result;

            if (!this.TryFindGoodExitDest(pawn, flag, out c))
            {
                result = null;
            }
            else
            {
                if (flag)
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                    {
                        IntVec3 cellBeforeBlocker;
                        Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                        if (thing != null)
                        {
                            Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                }
                result = new Job(JobDefOf.Goto, c)
                {
                    exitMapOnArrival = true,
                    failIfCantJoinOrCreateCaravan = this.failIfCantJoinOrCreateCaravan,
                    locomotionUrgency             = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog),
                    expiryInterval = this.jobMaxDuration,
                    canBash        = this.canBash
                };
            }
            return(result);
        }
Beispiel #9
0
        // Token: 0x06003EB7 RID: 16055 RVA: 0x001D76A8 File Offset: 0x001D5AA8
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool flag = false;

            if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction)))
            {
                flag = true;
            }
            IntVec3 c;

            if (pawn.xenomorph().HiveLoc == null)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} no hiveloc", pawn));
                }
                return(null);
            }
            if (!pawn.xenomorph().HiveLoc.IsValid)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} no hiveloc", pawn));
                }
                return(null);
            }
            if (pawn.xenomorph().HiveLoc == IntVec3.Zero)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} hiveloc zero", pawn));
                }
                return(null);
            }
            c = pawn.xenomorph().HiveLoc;

            if (!c.IsValid)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} no c", pawn));
                }
                return(null);
            }
            if (c == IntVec3.Zero)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} c zero", pawn));
                }
                return(null);
            }

            if (flag)
            {
                using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                {
                    IntVec3 cellBeforeBlocker;
                    Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                    if (thing != null)
                    {
                        if (!thing.def.defName.Contains("Xenomorph_Hive"))
                        {
                            Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                }
            }

            /*
             * //    Log.Message("TryGiveJob 6");
             * //    Log.Message(string.Format("TryGiveJob 6 {0}, {1}", pawn.Map, c));
             * if (c.GetFirstBuilding(pawn.Map)!=null)
             * {
             * //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == {2}", pawn.Map, c, c.GetFirstBuilding(pawn.Map)));
             *  if (c.GetFirstBuilding(pawn.Map).def == XenomorphDefOf.RRY_Xenomorph_Hive)
             *  {
             *  //    Log.Message("TryGiveJob 6 1");
             *      return null;
             *  }
             * }
             * else
             * {
             * //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == Null", pawn.Map, c));
             *  if (c.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive) != null)
             *  {
             *  //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == {2}", pawn.Map, c, c.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive)));
             *      if (c.GetFirstBuilding(pawn.Map).def == )
             *      {
             *      //    Log.Message("TryGiveJob 6 1");
             *          return null;
             *      }
             *  }
             *  else
             *  {
             *  //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == Null", pawn.Map, c));
             *  }
             * }
             * //    Log.Message("TryGiveJob 7");
             */
            return(new Job(JobDefOf.Goto, c)
            {
                exitMapOnArrival = false,
                failIfCantJoinOrCreateCaravan = this.failIfCantJoinOrCreateCaravan,
                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog),
                expiryInterval = this.jobMaxDuration,
                canBash = this.canBash
            });
        }
Beispiel #10
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Room room = pawn.GetRoom(RegionType.Set_Passable);

            if (room != null)
            {
                if (room.PsychologicallyOutdoors)
                {
                    Area area = pawn.MapHeld.areaManager.Home;
                    if (area != null)
                    {
                        if (area.ActiveCells.FirstOrDefault(x => x.Roofed(pawn.Map) && x.Walkable(pawn.Map)) is IntVec3 safePlace && !IsZero(safePlace) && safePlace.IsValid)
                        {
                            //Log.Message("Safe Place");
                            return(new Job(JobDefOf.Goto, safePlace)
                            {
                                locomotionUrgency = LocomotionUrgency.Sprint
                            });
                        }
                    }


                    Thing thing = GenClosest.ClosestThingReachable(pawn.PositionHeld, pawn.Map, ThingRequest.ForDef(ThingDefOf.Fire), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 23, null, null, 0, -1, false, RegionType.Set_Passable, false);
                    if (thing != null)
                    {
                        //Log.Message("Flee Place");

                        IntVec3 fleeLoc = CellFinderLoose.GetFleeDest(pawn, new List <Thing>()
                        {
                            thing
                        }, 23);
                        return(new Job(JobDefOf.FleeAndCower, thing));
                    }

                    Region region;
                    CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn), (x => !x.Room.PsychologicallyOutdoors), 9999, out region, RegionType.Set_All);   //.ClosestRegionIndoors(pawn.Position, pawn.Map, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), RegionType.Set_Passable);
                    if (region != null)
                    {
                        IntVec3 result;
                        if (region.TryFindRandomCellInRegion(x => !IsZero(x) && x.IsValid && x.InBounds(pawn.MapHeld) && x.GetDoor(pawn.MapHeld) == null, out result))
                        {
                            //Log.Message("Region Place");

                            return(new Job(JobDefOf.Goto, result)
                            {
                                locomotionUrgency = LocomotionUrgency.Sprint
                            });
                        }
                    }
                    IntVec3?cellResult = null;
                    cellResult = CellFinderLoose.RandomCellWith(x => !IsZero(x) && x.IsValid && x.InBounds(pawn.MapHeld) && x.Roofed(pawn.MapHeld) && x.Walkable(pawn.MapHeld) &&
                                                                pawn.Map.reachability.CanReach(pawn.PositionHeld, x, PathEndMode.OnCell, TraverseMode.ByPawn, Danger.Deadly), pawn.MapHeld, 1000);
                    if (cellResult != null && cellResult.Value.IsValid && !IsZero(cellResult.Value))
                    {
                        //Log.Message("Random Place");

                        return(new Job(JobDefOf.Goto, cellResult.Value)
                        {
                            locomotionUrgency = LocomotionUrgency.Sprint
                        });
                    }

                    if (pawn.Faction != pawn.Map.ParentFaction)
                    {
                        bool flag = false;
                        if (pawn.mindState.duty != null && pawn.mindState.duty.canDig)
                        {
                            flag = true;
                        }
                        IntVec3 c;
                        if (RCellFinder.TryFindBestExitSpot(pawn, out c, (!flag) ? TraverseMode.ByPawn : TraverseMode.PassAllDestroyableThings))
                        {
                            if (flag)
                            {
                                using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                                {
                                    IntVec3 cellBeforeBlocker;
                                    Thing   thingY = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                                    if (thingY != null)
                                    {
                                        Job job = DigUtility.PassBlockerJob(pawn, thingY, cellBeforeBlocker, true);
                                        if (job != null)
                                        {
                                            return(job);
                                        }
                                    }
                                }
                            }
                            return(new Job(JobDefOf.Goto, c)
                            {
                                exitMapOnArrival = true,
                                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, LocomotionUrgency.Sprint, LocomotionUrgency.Jog),
                                expiryInterval = 400,
                                canBash = true
                            });
                        }
                    }

                    IntVec3?hideyHoleResult = null;
                    hideyHoleResult = VampireUtility.FindHideyHoleSpot(VampDefOf.ROMV_HideyHole, Rot4.Random, pawn.PositionHeld, pawn.MapHeld);
                    if (hideyHoleResult != null && hideyHoleResult.Value.IsValid)
                    {
                        //Log.Message("Hidey Place");

                        return(new Job(VampDefOf.ROMV_DigAndHide, hideyHoleResult.Value)
                        {
                            locomotionUrgency = LocomotionUrgency.Sprint
                        });
                    }
                }
                //bool nextMoveOrderIsWait = pawn.mindState.nextMoveOrderIsWait;
                //pawn.mindState.nextMoveOrderIsWait = !pawn.mindState.nextMoveOrderIsWait;
                //if (nextMoveOrderIsWait)
                //{
                //    return new Job(JobDefOf.WaitWander)
                //    {
                //        expiryInterval = this.ticksBetweenWandersRange.RandomInRange
                //    };
                //}
                //IntVec3 exactWanderDest = this.GetExactWanderDest(pawn);
                //if (!exactWanderDest.IsValid)
                //{
                //    pawn.mindState.nextMoveOrderIsWait = false;
                //    return null;
                //}
                //pawn.Map.pawnDestinationManager.ReserveDestinationFor(pawn, exactWanderDest);
                //return new Job(JobDefOf.GotoWander, exactWanderDest)
                //{
                //    locomotionUrgency = this.locomotionUrgency
                //};
            }
            return(null);
        }
Beispiel #11
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            //if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            //{
            //    return null;
            //}
            //if (pawn.GetRegion() == null)
            //{
            //    return null;
            //}

            CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>();

            if (memory == null)
            {
                return(null);
            }

            //MentalState_MeeseeksKillCreator mentalState = pawn.MentalState as MentalState_MeeseeksKillCreator;
            //if (mentalState == null)
            //    return null;

            //Pawn creator = mentalState.target;

            Lord lord = pawn.GetLord();

            if (lord == null)
            {
                return(null);
            }

            LordJob_MeeseeksKillCreator killCreatorLordJob = lord.LordJob as LordJob_MeeseeksKillCreator;

            if (killCreatorLordJob == null)
            {
                return(null);
            }

            Pawn  creator = killCreatorLordJob.Target;
            Thing target  = creator.SpawnedParentOrMe;

            Job job = null;

            if (creator == null || creator.Dead || creator.Destroyed)
            {
                job = JobMaker.MakeJob(MeeseeksDefOf.CM_Meeseeks_Box_Job_EmbraceTheVoid);
            }

            if (creator.MapHeld != pawn.MapHeld)
            {
                job = ExitMap(pawn);
            }

            if (job == null)
            {
                job = TryMeleeAttackTargetJob(pawn, target);
            }

            if (job == null)
            {
                job = TryRangedAttackTargetJob(pawn, target);
            }

            if (job == null)
            {
                job = TryMeleeAttackAdjacentJob(pawn);
            }

            if (job == null)
            {
                job = TryGetEquipmentJob(pawn, target);
            }

            if (job == null)
            {
                if (pawn.CanReach(target, PathEndMode.Touch, Danger.Deadly, canBash: true))
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, target.Position, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassDoors)))
                    {
                        if (!pawnPath.Found)
                        {
                            Logger.MessageFormat("Somehow no path was found to {0}", target);
                            return(null);
                        }
                        IntVec3 cellBefore;
                        Thing   blocker = pawnPath.FirstBlockingBuilding(out cellBefore, pawn);
                        if (blocker != null)
                        {
                            job = TryMeleeAttackTargetJob(pawn, blocker);
                            if (job == null)
                            {
                                job = TryRangedAttackTargetJob(pawn, blocker);
                            }
                            if (job == null)
                            {
                                job = GoToTarget(pawn, cellBefore);
                            }
                        }
                    }
                }
            }

            if (job == null)
            {
                job = GoNearTarget(pawn, target);
            }

            if (job != null)
            {
                job.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, LocomotionUrgency.Sprint, LocomotionUrgency.Walk);
            }

            return(job);
        }
Beispiel #12
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            List <Thing> steelVehicle = new List <Thing>();

            foreach (Vehicle_Cart vehicle_Cart in ToolsForHaulUtility.Cart)
            {
                if (ToolsForHaulUtility.IsDriver(pawn))
                {
                    break;
                }
                if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders)
                {
                    break;
                }
                if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 20f) && !vehicle_Cart.mountableComp.IsMounted && (float)vehicle_Cart.HitPoints / vehicle_Cart.MaxHitPoints > 0.2f && vehicle_Cart.VehicleSpeed >= pawn.GetStatValue(StatDefOf.MoveSpeed) && pawn.CanReserveAndReach(vehicle_Cart, PathEndMode.InteractionCell, Danger.Deadly))
                {
                    steelVehicle.Add(vehicle_Cart);
                }
            }

            foreach (Vehicle_Turret vehicle_Cart in ToolsForHaulUtility.CartTurret)
            {
                if (ToolsForHaulUtility.IsDriver(pawn))
                {
                    break;
                }
                if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders)
                {
                    break;
                }
                if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 20f) && !vehicle_Cart.mountableComp.IsMounted && (float)vehicle_Cart.HitPoints / vehicle_Cart.MaxHitPoints > 0.2f && vehicle_Cart.VehicleSpeed >= pawn.GetStatValue(StatDefOf.MoveSpeed) && pawn.CanReserveAndReach(vehicle_Cart, PathEndMode.InteractionCell, Danger.Deadly))
                {
                    steelVehicle.Add(vehicle_Cart);
                }
            }

            if (steelVehicle.Any())
            {
                IOrderedEnumerable <Thing> orderedEnumerable = steelVehicle.OrderBy(x => x.Position.DistanceToSquared(pawn.Position));
                Job job = new Job(HaulJobDefOf.Mount);
                orderedEnumerable.First().SetFaction(null);
                job.targetA = orderedEnumerable.First();

                return(job);
            }

            bool flag = false;

            if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig))
            {
                flag = true;
            }
            IntVec3 vec;

            if (!this.TryFindGoodExitDest(pawn, flag, out vec))
            {
                return(null);
            }
            if (flag)
            {
                using (PawnPath pawnPath = PathFinder.FindPath(pawn.Position, vec, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAnything)))
                {
                    IntVec3 cellBeforeBlocker;
                    Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                    if (thing != null)
                    {
                        Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true);
                        if (job != null)
                        {
                            return(job);
                        }
                    }
                }
            }
            return(new Job(JobDefOf.Goto, vec)
            {
                exitMapOnArrival = true,
                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog),
                expiryInterval = this.jobMaxDuration,
                canBash = this.canBash
            });
        }