コード例 #1
0
 public virtual void Notify_LastPosture(PawnPosture posture, LayingDownState layingDown)
 {
 }
コード例 #2
0
 public override void Notify_LastPosture(PawnPosture posture, LayingDownState layingDown)
 {
     this.lastPosture = posture;
     base.layingDown  = layingDown;
 }
コード例 #3
0
 public void StartJob(Job newJob, JobCondition lastJobEndCondition = JobCondition.None, ThinkNode jobGiver = null, bool resumeCurJobAfterwards = false, bool cancelBusyStances = true, ThinkTreeDef thinkTree = null, JobTag?tag = null, bool fromQueue = false)
 {
     this.startingNewJob = true;
     try
     {
         if (!fromQueue && (!Find.TickManager.Paused || this.lastJobGivenAtFrame == RealTime.frameCount))
         {
             this.jobsGivenThisTick++;
             this.jobsGivenThisTickTextual = this.jobsGivenThisTickTextual + "(" + newJob.ToString() + ") ";
         }
         this.lastJobGivenAtFrame = RealTime.frameCount;
         if (this.jobsGivenThisTick > 10)
         {
             string text = this.jobsGivenThisTickTextual;
             this.jobsGivenThisTick        = 0;
             this.jobsGivenThisTickTextual = string.Empty;
             this.startingNewJob           = false;
             this.pawn.ClearReservationsForJob(newJob);
             this.StartErrorRecoverJob(string.Concat(new object[]
             {
                 this.pawn,
                 " started 10 jobs in one tick. newJob=",
                 newJob,
                 " jobGiver=",
                 jobGiver,
                 " jobList=",
                 text
             }));
         }
         else
         {
             PawnPosture     posture    = this.pawn.GetPosture();
             LayingDownState layingDown = (this.pawn.jobs == null || this.pawn.jobs.curDriver == null) ? LayingDownState.NotLaying : this.pawn.jobs.curDriver.layingDown;
             if (this.debugLog)
             {
                 this.DebugLogEvent(string.Concat(new object[]
                 {
                     "StartJob [",
                     newJob,
                     "] lastJobEndCondition=",
                     lastJobEndCondition,
                     ", jobGiver=",
                     jobGiver,
                     ", cancelBusyStances=",
                     cancelBusyStances
                 }));
             }
             if (cancelBusyStances && this.pawn.stances.FullBodyBusy)
             {
                 this.pawn.stances.CancelBusyStanceHard();
             }
             if (this.curJob != null)
             {
                 if (lastJobEndCondition == JobCondition.None)
                 {
                     Log.Warning(string.Concat(new object[]
                     {
                         this.pawn,
                         " starting job ",
                         newJob,
                         " from JobGiver ",
                         this.pawn.mindState.lastJobGiver,
                         " while already having job ",
                         this.curJob,
                         " without a specific job end condition."
                     }));
                     lastJobEndCondition = JobCondition.InterruptForced;
                 }
                 if (resumeCurJobAfterwards && this.curJob.def.suspendable)
                 {
                     this.jobQueue.EnqueueFirst(this.curJob, null);
                     if (this.debugLog)
                     {
                         this.DebugLogEvent("   JobQueue EnqueueFirst curJob: " + this.curJob);
                     }
                     this.CleanupCurrentJob(lastJobEndCondition, false, cancelBusyStances);
                 }
                 else
                 {
                     this.CleanupCurrentJob(lastJobEndCondition, true, cancelBusyStances);
                 }
             }
             if (newJob == null)
             {
                 Log.Warning(this.pawn + " tried to start doing a null job.");
             }
             else
             {
                 newJob.startTick = Find.TickManager.TicksGame;
                 if (this.pawn.Drafted || newJob.playerForced)
                 {
                     newJob.ignoreForbidden    = true;
                     newJob.ignoreDesignations = true;
                 }
                 this.curJob = newJob;
                 this.pawn.mindState.lastJobGiver          = jobGiver;
                 this.pawn.mindState.lastJobGiverThinkTree = thinkTree;
                 this.curDriver = this.curJob.MakeDriver(this.pawn);
                 if (this.curDriver.TryMakePreToilReservations())
                 {
                     if (tag.HasValue)
                     {
                         this.pawn.mindState.lastJobTag = tag.Value;
                     }
                     this.curDriver.Notify_Starting();
                     this.curDriver.Notify_LastPosture(posture, layingDown);
                     this.curDriver.SetupToils();
                     this.curDriver.ReadyForNextToil();
                 }
                 else if (fromQueue)
                 {
                     this.EndCurrentJob(JobCondition.QueuedNoLongerValid, true);
                 }
                 else
                 {
                     Log.Warning("TryMakePreToilReservations() returned false for a non-queued job right after StartJob(). This should have been checked before. curJob=" + this.curJob.ToStringSafe <Job>());
                     this.EndCurrentJob(JobCondition.Errored, true);
                 }
             }
         }
     }
     finally
     {
         this.startingNewJob = false;
     }
 }