Example #1
0
        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);
        }