Beispiel #1
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            JobQueue jobQueue = pawn.jobs.jobQueue;
            bool     flag     = pawn.Downed || jobQueue.AnyCanBeginNow(pawn, this.inBedOnly);

            if (flag)
            {
                while (jobQueue.Count > 0 && !jobQueue.Peek().job.CanBeginNow(pawn, this.inBedOnly))
                {
                    QueuedJob queuedJob = jobQueue.Dequeue();
                    pawn.ClearReservationsForJob(queuedJob.job);
                    if (pawn.jobs.debugLog)
                    {
                        pawn.jobs.DebugLogEvent("   Throwing away queued job that I cannot begin now: " + queuedJob.job);
                    }
                }
            }
            ThinkResult result;

            if (jobQueue.Count > 0 && jobQueue.Peek().job.CanBeginNow(pawn, this.inBedOnly))
            {
                QueuedJob queuedJob2 = jobQueue.Dequeue();
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent("   Returning queued job: " + queuedJob2.job);
                }
                result = new ThinkResult(queuedJob2.job, this, queuedJob2.tag, true);
            }
            else
            {
                result = ThinkResult.NoJob;
            }
            return(result);
        }
Beispiel #2
0
        public void EndCurrentOrQueuedJob(Job job, JobCondition condition)
        {
            if (debugLog)
            {
                DebugLogEvent("EndJob [" + job + "] condition=" + condition);
            }
            QueuedJob queuedJob = jobQueue.Extract(job);

            if (queuedJob != null)
            {
                pawn.ClearReservationsForJob(queuedJob.job);
            }
            if (curJob == job)
            {
                EndCurrentJob(condition);
            }
        }
        public void EndJob(Job job, JobCondition condition)
        {
            if (this.debugLog)
            {
                this.DebugLogEvent("EndJob [" + job + "] condition=" + condition);
            }
            QueuedJob queuedJob = this.jobQueue.Extract(job);

            if (queuedJob != null)
            {
                this.pawn.ClearReservationsForJob(queuedJob.job);
            }
            if (this.curJob == job)
            {
                this.EndCurrentJob(condition, true);
            }
        }
Beispiel #4
0
        public void EndCurrentOrQueuedJob(Job job, JobCondition condition, bool canReturnToPool = true)
        {
            if (debugLog)
            {
                DebugLogEvent(string.Concat("EndJob [", job, "] condition=", condition));
            }
            QueuedJob queuedJob = jobQueue.Extract(job);

            if (queuedJob != null)
            {
                pawn.ClearReservationsForJob(queuedJob.job);
                if (canReturnToPool)
                {
                    JobMaker.ReturnToPool(queuedJob.job);
                }
            }
            if (curJob == job)
            {
                EndCurrentJob(condition, startNewJob: true, canReturnToPool);
            }
        }
        public void EndJob(Job job, JobCondition condition)
        {
            if (this.debugLog)
            {
                this.DebugLogEvent(string.Concat(new object[]
                {
                    "EndJob [",
                    job,
                    "] condition=",
                    condition
                }));
            }
            QueuedJob queuedJob = this.jobQueue.Extract(job);

            if (queuedJob != null)
            {
                this.pawn.ClearReservationsForJob(queuedJob.job);
            }
            if (this.curJob == job)
            {
                this.EndCurrentJob(condition, true);
            }
        }