protected override Job TryGiveJob(Pawn pawn)
        {
            pawn.mindState.nextMoveOrderIsWait = !pawn.mindState.nextMoveOrderIsWait;
            if (pawn.mindState.nextMoveOrderIsWait && !exactCell)
            {
                Job job = JobMaker.MakeJob(JobDefOf.Wait_Wander);
                job.expiryInterval = WaitTicks.RandomInRange;
                return(job);
            }
            IntVec3 cell = pawn.mindState.duty.focus.Cell;

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

            if (!exactCell)
            {
                c = CellFinder.RandomClosewalkCellNear(cell, pawn.Map, 6);
            }
            Job job2 = JobMaker.MakeJob(JobDefOf.Goto, c);

            job2.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, locomotionUrgency);
            job2.expiryInterval    = jobMaxDuration;
            return(job2);
        }
示例#2
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            pawn.mindState.nextMoveOrderIsWait = !pawn.mindState.nextMoveOrderIsWait;
            if (pawn.mindState.nextMoveOrderIsWait && !this.exactCell)
            {
                return(new Job(JobDefOf.Wait_Wander)
                {
                    expiryInterval = this.WaitTicks.RandomInRange
                });
            }
            IntVec3 cell = pawn.mindState.duty.focus.Cell;

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

            if (!this.exactCell)
            {
                c = CellFinder.RandomClosewalkCellNear(cell, pawn.Map, 6, null);
            }
            return(new Job(JobDefOf.Goto, c)
            {
                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.locomotionUrgency),
                expiryInterval = this.jobMaxDuration
            });
        }
示例#3
0
        public static LocomotionUrgency ResolveLocomotion(Pawn pawn, LocomotionUrgency secondPriority, LocomotionUrgency thirdPriority)
        {
            LocomotionUrgency locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, secondPriority);

            if (locomotionUrgency != LocomotionUrgency.None)
            {
                return(locomotionUrgency);
            }
            return(thirdPriority);
        }
        public static LocomotionUrgency ResolveLocomotion(Pawn pawn, LocomotionUrgency secondPriority, LocomotionUrgency thirdPriority)
        {
            LocomotionUrgency locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, secondPriority);
            LocomotionUrgency result;

            if (locomotionUrgency != LocomotionUrgency.None)
            {
                result = locomotionUrgency;
            }
            else
            {
                result = thirdPriority;
            }
            return(result);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            int transportersGroup = pawn.mindState.duty.transportersGroup;

            if (transportersGroup != -1)
            {
                List <Pawn> allPawnsSpawned = pawn.Map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    if (allPawnsSpawned[i] != pawn && allPawnsSpawned[i].CurJobDef == JobDefOf.HaulToTransporter)
                    {
                        CompTransporter transporter = ((JobDriver_HaulToTransporter)allPawnsSpawned[i].jobs.curDriver).Transporter;
                        if (transporter != null && transporter.groupID == transportersGroup)
                        {
                            return(null);
                        }
                    }
                }
                TransporterUtility.GetTransportersInGroup(transportersGroup, pawn.Map, tmpTransporters);
                CompTransporter compTransporter = FindMyTransporter(tmpTransporters, pawn);
                tmpTransporters.Clear();
                if (compTransporter == null || !pawn.CanReach(compTransporter.parent, PathEndMode.Touch, Danger.Deadly))
                {
                    return(null);
                }
                return(JobMaker.MakeJob(JobDefOf.EnterTransporter, compTransporter.parent));
            }
            Thing thing = pawn.mindState.duty.focus.Thing;

            if (thing == null || !pawn.CanReach(thing, PathEndMode.Touch, Danger.Deadly))
            {
                return(null);
            }
            Job job = JobMaker.MakeJob(JobDefOf.EnterTransporter, pawn.mindState.duty.focus.Thing);

            job.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, LocomotionUrgency.Walk);
            return(job);
        }