Ejemplo n.º 1
0
 private void CleanupCurrentJob(JobCondition condition, bool releaseReservations,
                                bool cancelBusyStancesSoft = true)
 {
     if (debugLog)
     {
         DebugLogEvent(string.Concat("CleanupCurrentJob ", curJob == null ? "null" : curJob.def.ToString(),
                                     " condition ", condition));
     }
     if (curJob == null)
     {
         return;
     }
     curDriver.ended = true;
     curDriver.Cleanup(condition);
     curDriver = null;
     curJob    = null;
     //if (releaseReservations)
     //{
     //    this.caravan.ClearReservations(false);
     //}
     //if (cancelBusyStancesSoft)
     //{
     //    this.caravan.stances.CancelBusyStanceSoft();
     //}
     //if (!this.caravan.Destroyed && this.caravan.carryTracker != null && this.caravan.carryTracker.CarriedThing != null)
     //{
     //    Thing thing;
     //    this.caravan.carryTracker.TryDropCarriedThing(this.caravan.Position, ThingPlaceMode.Near, out thing, null);
     //}
 }
Ejemplo n.º 2
0
 //private void CleanupCurrentJob(JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft = true)
 private void CleanupCurrentJob(JobCondition condition)
 {
     DebugLogEvent($"CleanupCurrentJob {curJob?.def.ToString() ?? "null"} condition {condition}");
     if (curJob == null)
     {
         return;
     }
     curDriver.ended = true;
     curDriver.Cleanup(condition);
     curDriver = null;
     curJob    = null;
     //if (releaseReservations)
     //{
     //    caravan.ClearReservations(false);
     //}
     //if (cancelBusyStancesSoft)
     //{
     //    caravan.stances.CancelBusyStanceSoft();
     //}
     //if (!caravan.Destroyed && caravan.carryTracker != null && caravan.carryTracker.CarriedThing != null)
     //{
     //    Thing thing;
     //    caravan.carryTracker.TryDropCarriedThing(caravan.Position, ThingPlaceMode.Near, out thing, null);
     //}
 }
Ejemplo n.º 3
0
 public void StartJob(CaravanJob newJob, JobCondition lastJobEndCondition = JobCondition.None,
                      ThinkNode jobGiver     = null, bool resumeCurJobAfterwards = false, bool cancelBusyStances = true,
                      ThinkTreeDef thinkTree = null, JobTag?tag = null)
 {
     //Log.Message("JecsTools :: CaravanJobTracker :: JobTracker StartJob :: " + newJob.def.label);
     if (!Find.TickManager.Paused || lastJobGivenAtFrame == RealTime.frameCount)
     {
         jobsGivenThisTick++;
         jobsGivenThisTickTextual = jobsGivenThisTickTextual + "(" + newJob + ") ";
     }
     lastJobGivenAtFrame = RealTime.frameCount;
     if (jobsGivenThisTick > 10)
     {
         var text = jobsGivenThisTickTextual;
         jobsGivenThisTick        = 0;
         jobsGivenThisTickTextual = string.Empty;
         StartErrorRecoverJob(string.Concat(caravan, " started 10 jobs in one tick. newJob=", newJob,
                                            " jobGiver=", jobGiver, " jobList=", text));
         return;
     }
     if (debugLog)
     {
         DebugLogEvent(string.Concat("StartJob [", newJob, "] lastJobEndCondition=", lastJobEndCondition,
                                     ", jobGiver=", jobGiver, ", cancelBusyStances=", cancelBusyStances));
     }
     if (curJob != null)
     {
         if (lastJobEndCondition == JobCondition.None)
         {
             Log.Warning(string.Concat(caravan, " starting job ", newJob, " while already having job ", curJob,
                                       " without a specific job end condition."));
             lastJobEndCondition = JobCondition.InterruptForced;
         }
         if (resumeCurJobAfterwards && curJob.def.suspendable)
         {
             jobQueue.EnqueueFirst(curJob, null);
             if (debugLog)
             {
                 DebugLogEvent("   JobQueue EnqueueFirst curJob: " + curJob);
             }
         }
         CleanupCurrentJob(lastJobEndCondition, !resumeCurJobAfterwards, cancelBusyStances);
     }
     if (newJob == null)
     {
         Log.Warning(caravan + " tried to start doing a null job.");
         return;
     }
     newJob.startTick = Find.TickManager.TicksGame;
     if (newJob.playerForced)
     {
         newJob.ignoreForbidden    = true;
         newJob.ignoreDesignations = true;
     }
     curJob    = newJob;
     curDriver = curJob.MakeDriver(caravan);
     curDriver.Notify_Starting();
     curDriver.SetupToils();
     curDriver.ReadyForNextToil();
 }
Ejemplo n.º 4
0
        public CaravanJobDriver MakeDriver(Caravan driverCaravan)
        {
            CaravanJobDriver jobDriver = (CaravanJobDriver)Activator.CreateInstance(this.def.driverClass);

            jobDriver.caravan = driverCaravan;
            Log.Message("JecsTools :: MakeDriver Called :: " + this.def.driverClass.ToString());
            return(jobDriver);
        }