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);
        }
Esempio n. 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
            });
        }
Esempio n. 3
0
        public static Danger ResolveMaxDanger(Pawn pawn, Danger secondPriority, Danger thirdPriority)
        {
            Danger danger = PawnUtility.ResolveMaxDanger(pawn, secondPriority);

            if (danger != Danger.Unspecified)
            {
                return(danger);
            }
            return(thirdPriority);
        }
        public static Danger ResolveMaxDanger(Pawn pawn, Danger secondPriority, Danger thirdPriority)
        {
            Danger danger = PawnUtility.ResolveMaxDanger(pawn, secondPriority);
            Danger result;

            if (danger != Danger.Unspecified)
            {
                result = danger;
            }
            else
            {
                result = thirdPriority;
            }
            return(result);
        }