public bool TryTakeOrderedJob(Job job, JobTag tag = JobTag.Misc) { if (this.debugLog) { this.DebugLogEvent("TryTakeOrderedJob " + job); } job.playerForced = true; bool result; if (this.curJob != null && this.curJob.JobIsSameAs(job)) { result = true; } else { bool flag = this.pawn.jobs.IsCurrentJobPlayerInterruptible(); bool flag2 = this.pawn.mindState.IsIdle || this.pawn.CurJob == null || this.pawn.CurJob.def.isIdle; bool isDownEvent = KeyBindingDefOf.QueueOrder.IsDownEvent; if (isDownEvent) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.QueueOrders, KnowledgeAmount.NoteTaught); } if (flag && (!isDownEvent || flag2)) { this.pawn.stances.CancelBusyStanceSoft(); if (this.debugLog) { this.DebugLogEvent(" Queueing job"); } this.ClearQueuedJobs(); if (job.TryMakePreToilReservations(this.pawn)) { this.jobQueue.EnqueueFirst(job, new JobTag?(tag)); if (this.curJob != null) { this.curDriver.EndJobWith(JobCondition.InterruptForced); } else { this.CheckForJobOverride(); } result = true; } else { Log.Warning("TryMakePreToilReservations() returned false right after TryTakeOrderedJob(). This should have been checked before. job=" + job.ToStringSafe <Job>(), false); this.pawn.ClearReservationsForJob(job); result = false; } } else if (isDownEvent) { if (job.TryMakePreToilReservations(this.pawn)) { this.jobQueue.EnqueueLast(job, new JobTag?(tag)); result = true; } else { Log.Warning("TryMakePreToilReservations() returned false right after TryTakeOrderedJob(). This should have been checked before. job=" + job.ToStringSafe <Job>(), false); this.pawn.ClearReservationsForJob(job); result = false; } } else { this.ClearQueuedJobs(); if (job.TryMakePreToilReservations(this.pawn)) { this.jobQueue.EnqueueLast(job, new JobTag?(tag)); result = true; } else { Log.Warning("TryMakePreToilReservations() returned false right after TryTakeOrderedJob(). This should have been checked before. job=" + job.ToStringSafe <Job>(), false); this.pawn.ClearReservationsForJob(job); result = false; } } } return(result); }
public bool TryTakeOrderedJob_NewTemp(Job job, JobTag?tag = JobTag.Misc, bool requestQueueing = false) { if (debugLog) { DebugLogEvent("TryTakeOrderedJob " + job); } job.playerForced = true; if (curJob != null && curJob.JobIsSameAs(job)) { return(true); } bool num = pawn.jobs.IsCurrentJobPlayerInterruptible(); bool flag = pawn.mindState.IsIdle || pawn.CurJob == null || pawn.CurJob.def.isIdle; bool isDownEvent = KeyBindingDefOf.QueueOrder.IsDownEvent; if (isDownEvent) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.QueueOrders, KnowledgeAmount.NoteTaught); } isDownEvent = isDownEvent || requestQueueing; if (num && (!isDownEvent || flag)) { pawn.stances.CancelBusyStanceSoft(); if (debugLog) { DebugLogEvent(" Queueing job"); } ClearQueuedJobs(); if (job.TryMakePreToilReservations(pawn, errorOnFailed: true)) { jobQueue.EnqueueFirst(job, tag); if (curJob != null) { curDriver.EndJobWith(JobCondition.InterruptForced); } else { CheckForJobOverride(); } return(true); } Log.Warning("TryMakePreToilReservations() returned false right after TryTakeOrderedJob(). This should have been checked before. job=" + job.ToStringSafe()); pawn.ClearReservationsForJob(job); return(false); } if (isDownEvent) { if (job.TryMakePreToilReservations(pawn, errorOnFailed: true)) { jobQueue.EnqueueLast(job, tag); return(true); } Log.Warning("TryMakePreToilReservations() returned false right after TryTakeOrderedJob(). This should have been checked before. job=" + job.ToStringSafe()); pawn.ClearReservationsForJob(job); return(false); } ClearQueuedJobs(); if (job.TryMakePreToilReservations(pawn, errorOnFailed: true)) { jobQueue.EnqueueLast(job, tag); return(true); } Log.Warning("TryMakePreToilReservations() returned false right after TryTakeOrderedJob(). This should have been checked before. job=" + job.ToStringSafe()); pawn.ClearReservationsForJob(job); return(false); }