private void CleanupCurrentJob(JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft = true) { if (this.debugLog) { this.DebugLogEvent("CleanupCurrentJob " + ((this.curJob == null) ? "null" : this.curJob.def.ToString()) + " condition " + condition); } if (this.curJob != null) { if (releaseReservations) { this.pawn.ClearReservationsForJob(this.curJob); } this.curDriver.ended = true; this.curDriver.Cleanup(condition); this.curDriver = null; this.curJob = null; this.pawn.VerifyReservations(); if (cancelBusyStancesSoft) { this.pawn.stances.CancelBusyStanceSoft(); } if (!this.pawn.Destroyed && this.pawn.carryTracker != null && this.pawn.carryTracker.CarriedThing != null) { Thing thing = default(Thing); this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Near, out thing, (Action <Thing, int>)null); } } }
private void CleanupCurrentJob(JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft = true) { if (this.debugLog) { this.DebugLogEvent(string.Concat(new object[] { "CleanupCurrentJob ", (this.curJob == null) ? "null" : this.curJob.def.ToString(), " condition ", condition })); } if (this.curJob == null) { return; } if (releaseReservations) { this.pawn.ClearReservationsForJob(this.curJob); } this.curDriver.ended = true; this.curDriver.Cleanup(condition); this.curDriver = null; this.curJob = null; this.pawn.VerifyReservations(); if (cancelBusyStancesSoft) { this.pawn.stances.CancelBusyStanceSoft(); } if (!this.pawn.Destroyed && this.pawn.carryTracker != null && this.pawn.carryTracker.CarriedThing != null) { Thing thing; this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Near, out thing, null); } }
private static bool on_cleanup_driver(JobDriver __instance, JobCondition condition) { if (__instance == null) { return(true); } var lov = __instance as JobDriver_Lovin; //Edited by nizhuan-jjr: The PostFix method cannot do this. if ((lov != null) && (condition == JobCondition.Succeeded)) { //--Log.Message("[RJW]patches_lovin::on_cleanup_driver is called0"); var par = find_partner(lov); xxx.aftersex(lov.pawn, par, false, true); // note that JobDriver_Lovin will be called for both pawns //lov.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(lov.pawn); //if (par != null) // par.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(par); } else if (xxx.RomanceDiversifiedIsActive && condition == JobCondition.Succeeded && __instance.GetType() == JobDriverDoLovinCasual) { //--Log.Message("[RJW]patches_lovin::on_cleanup_driver is called1"); var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; var casuallovin_par = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null)); if (casuallovin_par != null) { xxx.aftersex(__instance.pawn, casuallovin_par, false, true); // note that JobDriver_DoLovinCasual will be called for both pawns //lov.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(lov.pawn); //casuallovin_par.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(casuallovin_par); } } return(true); }
public void Cleanup(JobCondition condition) { for (int i = 0; i < this.globalFinishActions.Count; i++) { try { this.globalFinishActions[i](); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Pawn ", this.pawn, " threw exception while executing a global finish action (", i, "), jobDriver=", base.GetType(), ": ", ex })); } } if (this.HaveCurToil) { this.CurToil.Cleanup(); } }
public void EndCurrentJob(JobCondition condition, bool startNewJob = true) { if (debugLog) { DebugLogEvent(string.Concat("EndCurrentJob ", curJob == null ? "null" : curJob.ToString(), " condition=", condition, " curToil=", curDriver == null ? "null_driver" : curDriver.CurToilIndex.ToString())); } var job = curJob; CleanupCurrentJob(condition, true, true); if (startNewJob) { if (condition == JobCondition.ErroredPather || condition == JobCondition.Errored) { return; } if (condition == JobCondition.Succeeded && job != null && !caravan.pather.Moving ) //&& job.def != JobDefOf.WaitMaintainPosture ) { //this.StartJob(new CaravanJob(JobDefOf.WaitMaintainPosture, 1, false), JobCondition.None, null, false, false, null, null); } else { TryFindAndStartJob(); } } }
static void UnmarkDesignation(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft, bool canReturnToPool) { if (__instance?.curJob?.bill == null || __instance.curJob.bill.billStack != null || condition != JobCondition.Succeeded) { return; } if (__instance.curJob.targetB != null && __instance.curJob.targetB.HasThing && !__instance.curJob.targetB.ThingDestroyed) { RecipeDef rec = __instance.curJob.bill.recipe; Thing thing = __instance.curJob.targetB.Thing; DesignationDef dDef = DefDatabase <DesignationDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == rec.defName + "Designation"); if (dDef == null) { return; } Designation d = thing.Map.designationManager.DesignationOn(__instance.curJob.targetB.Thing, dDef); if (d == null) { return; } thing.Map.designationManager.RemoveDesignation(d); } }
//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); //} }
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(); }
public void Cleanup(JobCondition condition) { for (int i = 0; i < this.globalFinishActions.Count; i++) { try { this.globalFinishActions[i](); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Pawn ", this.pawn.ToStringSafe <Pawn>(), " threw exception while executing a global finish action (", i, "), jobDriver=", this.ToStringSafe <JobDriver>(), ", job=", this.job.ToStringSafe <Job>(), ": ", ex }), false); } } if (this.HaveCurToil) { this.CurToil.Cleanup(this.curToilIndex, this); } }
public void EndCurrentJob(JobCondition condition, bool startNewJob = true) { DebugLogEvent($"EndCurrentJob {curJob?.ToString() ?? "null"} condition={condition} " + $"curToil={curDriver?.CurToilIndex.ToString() ?? "null_driver"}"); var job = curJob; //CleanupCurrentJob(condition, true, true); CleanupCurrentJob(condition); if (startNewJob) { switch (condition) { case JobCondition.Errored: case JobCondition.ErroredPather: //StartJob(JobMaker.MakeJob(JobDefOf.Wait, 250)); return; case JobCondition.Succeeded: if (job != null && !caravan.pather.Moving) //&& job.def != JobDefOf.WaitMaintainPosture { //StartJob(JobMaker.MakeJob(JobDefOf.WaitMaintainPosture, 1), JobCondition.None, null, false, false); return; } break; } TryFindAndStartJob(); } }
static bool Prefix(Pawn_JobTracker_Crutch __instance, JobCondition condition, bool startNewJob) { if (__instance == null || __instance.curJob == null) { return(true); } if (Settings.fun_police && __instance._pawn.needs.joy != null && __instance._pawn.needs.joy.CurLevel > 0.95f) { CompJoyToppedOff c = __instance._pawn.TryGetComp <CompJoyToppedOff>(); if (c != null) { c.JoyToppedOff = true; } } if (Settings.clean_after_tanding && condition == JobCondition.Succeeded && __instance.curJob.def == JobDefOf.TendPatient && __instance.jobQueue != null && __instance.jobQueue.Count == 0 && __instance.curJob.targetA != null && __instance.curJob.targetA.Thing != null && __instance.curJob.targetA.Thing != __instance._pawn) { Job job = MakeCleaningJob(__instance._pawn, __instance.curJob.targetA, int.MaxValue); if (job != null) { __instance.jobQueue.EnqueueFirst(job); } } return(true); }
private void CleanupCurrentJob(JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft = true, bool canReturnToPool = false) { if (debugLog) { DebugLogEvent("CleanupCurrentJob " + ((curJob != null) ? curJob.def.ToString() : "null") + " condition " + condition); } if (curJob != null) { if (releaseReservations) { pawn.ClearReservationsForJob(curJob); } if (curDriver != null) { curDriver.ended = true; curDriver.Cleanup(condition); } curDriver = null; Job job = curJob; curJob = null; pawn.VerifyReservations(); if (cancelBusyStancesSoft) { pawn.stances.CancelBusyStanceSoft(); } if (!pawn.Destroyed && pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null) { pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out var _); } if (releaseReservations && canReturnToPool) { JobMaker.ReturnToPool(job); } } }
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); //} }
public void EndJobWith(JobCondition condition) { if (!pawn.Destroyed && job != null && pawn.CurJob == job) { pawn.jobs.EndCurrentJob(condition); } }
public void EndJobWith(JobCondition condition) { if (!this.pawn.Destroyed && this.pawn.CurJob == this.job) { this.pawn.jobs.EndCurrentJob(condition, true); } }
private bool CheckCurrentToilEndOrFail() { CaravanToil curToil = this.CurToil; if (this.globalFailConditions != null) { for (int i = 0; i < this.globalFailConditions.Count; i++) { JobCondition jobCondition = this.globalFailConditions[i](); if (jobCondition != JobCondition.Ongoing) { this.EndJobWith(jobCondition); return(true); } } } if (curToil != null && curToil.endConditions != null) { for (int j = 0; j < curToil.endConditions.Count; j++) { JobCondition jobCondition2 = curToil.endConditions[j](); if (jobCondition2 != JobCondition.Ongoing) { this.EndJobWith(jobCondition2); return(true); } } } return(false); }
private static bool Prefix(Pawn ___pawn, Job newJob, JobCondition lastJobEndCondition) { if (newJob.def == JobDefOf.Vomit && ___pawn.HasTrait(VTEDefOf.VTE_IronStomach)) { return(false); } return(true); }
public async Task <ListResult <Jobs> > GetDataList(JobCondition condition) { Expression <Func <Jobs, bool> > exp = w => string.IsNullOrEmpty(condition.Name) || w.Name.Contains(condition.Name); var data = await base.GetPageAsync(exp, w => w.CreateTime, condition.PageIndex, condition.PageSize); return(new ListResult <Jobs>(condition.PageIndex, condition.PageSize, data.Item1, data.Item2)); }
public static bool CleanupCurrentJob(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft = true) { if (QOLTweaksPack.PickupDropOrders.Value == false) { return(true); } if (!FloatMenuMakerMap_AddHumanLikeOrders_Postfix.forceKeep) { return(true); } if (!(__instance.curDriver is JobDriver_PickupObject)) { return(true); } if (__instance.curJob == null) { return(true); } if (__instance.debugLog) { __instance.DebugLogEvent(string.Concat(new object[] { "CleanupCurrentJob ", (__instance.curJob == null) ? "null" : __instance.curJob.def.ToString(), " condition ", condition })); } Pawn pawn = (Pawn)Reflection.GetFieldValue(__instance, "pawn"); __instance.curDriver.ended = true; __instance.curDriver.Cleanup(condition); __instance.curDriver = null; __instance.curJob = null; if (releaseReservations) { pawn.ClearReservations(false); } if (cancelBusyStancesSoft) { pawn.stances.CancelBusyStanceSoft(); } if (!pawn.Destroyed && pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null) { //Thing thing; //pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out thing, null); //Do not do this thing } return(false); }
private bool CheckCurrentToilEndOrFail() { Toil curToil = this.CurToil; if (this.globalFailConditions != null) { for (int i = 0; i < this.globalFailConditions.Count; i++) { JobCondition jobCondition = this.globalFailConditions[i](); if (jobCondition != JobCondition.Ongoing) { if (this.pawn.jobs.debugLog) { this.pawn.jobs.DebugLogEvent(string.Concat(new object[] { base.GetType().Name, " ends current job ", this.job.ToStringSafe <Job>(), " because of globalFailConditions[", i, "]" })); } this.EndJobWith(jobCondition); return(true); } } } if (curToil != null && curToil.endConditions != null) { for (int j = 0; j < curToil.endConditions.Count; j++) { JobCondition jobCondition2 = curToil.endConditions[j](); if (jobCondition2 != JobCondition.Ongoing) { if (this.pawn.jobs.debugLog) { this.pawn.jobs.DebugLogEvent(string.Concat(new object[] { base.GetType().Name, " ends current job ", this.job.ToStringSafe <Job>(), " because of toils[", this.curToilIndex, "].endConditions[", j, "]" })); } this.EndJobWith(jobCondition2); return(true); } } } return(false); }
public void EndJobWith(JobCondition condition) { if (condition == JobCondition.Ongoing) { Log.Warning("Ending a job with Ongoing as the condition. This makes no sense."); } if (this.caravan.Spawned) { Find.World.GetComponent <CaravanJobGiver>().Tracker(caravan).EndCurrentJob(condition, true); } }
private static bool on_cleanup_driver(JobDriver __instance, JobCondition condition) { if (__instance == null) { return(true); } if (condition == JobCondition.Succeeded) { Pawn pawn = __instance.pawn; //Log.Message("[RJW]patches_DubsBadHygiene::on_cleanup_driver" + xxx.get_pawnname(pawn)); if (xxx.DubsBadHygieneIsActive) { //clear one instance of s***n if ( __instance.GetType() == JobDriver_useWashBucket // || //__instance.GetType() == JobDriver_washAtCell ) { Hediff hediff = pawn.health.hediffSet.hediffs.Find(x => (x.def == RJW_SemenoOverlayHediffDefOf.Hediff_Semen || x.def == RJW_SemenoOverlayHediffDefOf.Hediff_InsectSpunk || x.def == RJW_SemenoOverlayHediffDefOf.Hediff_MechaFluids )); if (hediff != null) { //Log.Message("[RJW]patches_DubsBadHygiene::" + __instance.GetType() + " clear => " + hediff.Label); hediff.Severity -= 1f; } } //clear all instance of s***n else if ( __instance.GetType() == JobDriver_UseHotTub || __instance.GetType() == JobDriver_takeShower || __instance.GetType() == JobDriver_takeBath ) { foreach (Hediff hediff in pawn.health.hediffSet.hediffs) { if (hediff.def == RJW_SemenoOverlayHediffDefOf.Hediff_Semen || hediff.def == RJW_SemenoOverlayHediffDefOf.Hediff_InsectSpunk || hediff.def == RJW_SemenoOverlayHediffDefOf.Hediff_MechaFluids ) { //Log.Message("[RJW]patches_DubsBadHygiene::" + __instance.GetType() + " clear => " + hediff.Label); hediff.Severity -= 1f; } } } } } return(true); }
private static bool ModIncompatibilityCheck(Pawn ___pawn, JobCondition condition) { if (ModCompatibility.SmarterDeconstructionIsActive && condition == JobCondition.InterruptForced) { var curJobDef = ___pawn.CurJobDef; if (curJobDef == JobDefOf.Deconstruct || curJobDef == JobDefOf.Mine) { return(true); } } return(false); }
public void GizmoStuff() { pawnHolding = pwaninve.pawn; pwaninve = this.ParentHolder as Pawn_InventoryTracker; ThinkNode jobGiver = null; Pawn_JobTracker jobs = pawnHolding.jobs; Job job = this.TryMakeBipodJobComp(); Job newJob = job; JobCondition lastJobEndCondition = JobCondition.InterruptForced; Job curJob = pawnHolding.CurJob; jobs.StartJob(newJob, lastJobEndCondition, jobGiver, ((curJob != null) ? curJob.def : null) != job.def, true, null, null, false, false); }
public static bool CheckCurrentToilEndOrFail2(JobDriver __instance) { try { Toil curToil = get_CurToil2(__instance); List <Func <JobCondition> > listFuncJobConditions = __instance.globalFailConditions; if (listFuncJobConditions != null) { for (int i = 0; i < listFuncJobConditions.Count; i++) { JobCondition jobCondition = listFuncJobConditions[i](); if (jobCondition != JobCondition.Ongoing) { if (__instance.pawn.jobs.debugLog) { __instance.pawn.jobs.DebugLogEvent(__instance.GetType().Name + " ends current job " + __instance.job.ToStringSafe() + " because of globalFailConditions[" + i + "]"); } __instance.EndJobWith(jobCondition); return(true); } } } if (curToil != null && curToil.endConditions != null) { for (int j = 0; j < curToil.endConditions.Count; j++) { JobCondition jobCondition2 = curToil.endConditions[j](); if (jobCondition2 != JobCondition.Ongoing) { if (__instance.pawn.jobs.debugLog) { __instance.pawn.jobs.DebugLogEvent(__instance.GetType().Name + " ends current job " + __instance.job.ToStringSafe() + " because of toils[" + curToilIndex + "].endConditions[" + j + "]"); } __instance.EndJobWith(jobCondition2); return(true); } } } return(false); } catch (Exception exception) { JobUtility.TryStartErrorRecoverJob(__instance.pawn, "Exception in CheckCurrentToilEndOrFail for pawn " + __instance.pawn.ToStringSafe(), exception, __instance); return(true); } }
public static void Prefix(Pawn_JobTracker __instance, JobCondition condition, Pawn ___pawn) { //Logger.MessageFormat(__instance, "EndCurrentJob Prefix"); if (___pawn != null) { CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>(); if (compMeeseeksMemory != null) { compMeeseeksMemory.EndCurrentJob(__instance.curJob, __instance.curDriver, condition); } } }
public static bool CheckCurrentJob(this Pawn p, JobCondition jc) { if (p.CurJob == null) { return(false); } if (jc.currentJob.Contains(p.CurJobDef)) { return(true); } return(false); }
public static T EndOnDespawnedOrNull <T>(this T f, TargetIndex ind, JobCondition endCondition = JobCondition.Incompletable) where T : IJobEndable { f.AddEndCondition(delegate { LocalTargetInfo target = f.GetActor().jobs.curJob.GetTarget(ind); Thing thing = target.Thing; if (thing == null && target.IsValid) { return(JobCondition.Ongoing); } return((thing != null && thing.Spawned && thing.Map == f.GetActor().Map) ? JobCondition.Ongoing : endCondition); }); return(f); }
static void UnmarkDesignation(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft, bool canReturnToPool) { if (__instance?.curJob?.bill == null || __instance.curJob.bill.billStack != null /*|| condition != JobCondition.Succeeded*/) { return; } if (__instance.curJob.targetB != null && __instance.curJob.targetB.HasThing && !__instance.curJob.targetB.ThingDestroyed) { RecipeDef rec = __instance.curJob.bill.recipe; ThingWithComps thing = __instance.curJob.targetB.Thing as ThingWithComps; if (thing == null) { return; } // DesignationDef dDef = DefDatabase <DesignationDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == rec.defName + "Designation"); if (dDef == null) { return; } Designation d = thing.Map.designationManager.DesignationOn(__instance.curJob.targetB.Thing, dDef); if (d == null) { return; } thing.Map.designationManager.RemoveDesignation(d); if (condition != JobCondition.Succeeded) { Settings.ResetSelectTick(); var comp = thing.AllComps?.FirstOrDefault(x => x is ApplicableDesignationThingComp && (x as ApplicableDesignationThingComp).Props.designationDef == dDef) as ApplicableDesignationThingComp; if (comp != null) { comp.Allowed = null; } var ds = Find.ReverseDesignatorDatabase.AllDesignators.FirstOrDefault(x => (x as Designator_MicroRecipe) != null && (x as Designator_MicroRecipe).designationDef == dDef); if (ds == null || !ds.CanDesignateThing(thing)) { return; } // thing.Map.designationManager.AddDesignation(new Designation(thing, dDef)); } } }
static bool Prefix(Pawn_JobTracker_Crutch __instance, JobCondition condition) { if (__instance == null || __instance._pawn == null || !__instance._pawn.IsColonistPlayerControlled || __instance.curJob == null) { return(true); } if (Settings.fun_police && __instance._pawn.needs.joy != null && __instance._pawn.needs.joy.CurLevel > 0.95f) { CompJoyToppedOff c = __instance._pawn.TryGetComp <CompJoyToppedOff>(); if (c != null) { c.JoyToppedOff = true; } } Job job = null; if (Settings.clean_before_work && condition == JobCondition.Succeeded && __instance.jobQueue != null && __instance.jobQueue.Count == 0 && __instance.curJob != null && ProperJob(__instance.curJob, __instance._pawn, JobDefOf.DeliverFood)) { job = MakeCleaningJob(__instance._pawn, __instance.curJob.targetA, Settings.op_clean_num); } if (Settings.clean_after_tending && condition == JobCondition.Succeeded && __instance.jobQueue != null && __instance.jobQueue.Count == 0 && ProperJob(__instance.curJob, __instance._pawn, JobDefOf.TendPatient)) { ThinkTreeDef thinkTree = null; MethodInfo mi = AccessTools.Method(typeof(Pawn_JobTracker), "DetermineNextJob"); ThinkResult thinkResult = (ThinkResult)mi.Invoke(__instance, new object[] { thinkTree }); if (ProperJob(thinkResult.Job, __instance._pawn, JobDefOf.TendPatient)) { Pawn pawn = (Pawn)thinkResult.Job.targetA.Thing; if (pawn.GetRoom() == __instance.curJob.targetA.Thing.GetRoom() || ((float)HealthUtility.TicksUntilDeathDueToBloodLoss(pawn) / 2500f) < 6) { return(true); } } job = MakeCleaningJob(__instance._pawn, __instance.curJob.targetA, Settings.doc_clean_num); } // if (job != null) { __instance.jobQueue.EnqueueFirst(job); } // return(true); }