protected override IEnumerable <Toil> MakeNewToils() { yield return(this.ReserveFood()); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A)); yield return(Toils_Ingest.PickupIngestible(TargetIndex.A, this.pawn)); Toil empty = new Toil(); yield return(Toils_Jump.JumpIf(empty, delegate() { LocalTargetInfo food = this.job.GetTarget(TargetIndex.A); CompDFoodTemperature comp = food.Thing.TryGetComp <CompDFoodTemperature>(); if (comp == null) { return true; } if (comp.PropsTemp.likesHeat) { return comp.curTemp >= comp.targetCookingTemp; } return comp.curTemp > 0; })); if (!HotMealsSettings.multipleHeat) { yield return(Toils_Reserve.Reserve(TargetIndex.C)); yield return(Toils_Goto.GotoThing(TargetIndex.C, PathEndMode.InteractionCell).FailOnDestroyedOrNull(TargetIndex.C)); yield return(Toils_HeatMeal.HeatMeal().FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.C, PathEndMode.InteractionCell)); yield return(Toils_Reserve.Release(TargetIndex.C)); } else { yield return(Toils_Goto.GotoThing(TargetIndex.C, PathEndMode.Touch).FailOnDestroyedOrNull(TargetIndex.C)); yield return(Toils_HeatMeal.HeatMeal().FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.C, PathEndMode.Touch)); } yield return(empty); yield break; }
public static IEnumerable <Toil> Heat(JobDriver jd, TargetIndex foodIndex = TargetIndex.A, TargetIndex finalLocation = TargetIndex.C, TargetIndex tableIndex = TargetIndex.None) { LocalTargetInfo oldFinal = jd.job.GetTarget(finalLocation); Toil empty = new Toil(); yield return(Toils_Jump.JumpIf(empty, delegate() { Pawn actor = empty.actor; Job curJob = actor.jobs.curJob; LocalTargetInfo food = curJob.GetTarget(foodIndex).Thing; if (food.Thing == null) { return true; } CompDFoodTemperature comp = food.Thing.TryGetComp <CompDFoodTemperature>(); if (comp == null) { return true; } if (comp.PropsTemp.likesHeat) { return comp.curTemp >= comp.PropsTemp.tempLevels.goodTemp; } else if (HotMealsSettings.thawIt && !comp.PropsTemp.okFrozen) { return comp.curTemp > 0; } return true; })); Toil getHeater = new Toil(); getHeater.initAction = delegate() { Pawn actor = getHeater.actor; Job curJob = actor.jobs.curJob; Thing foodToHeat = curJob.GetTarget(foodIndex).Thing; Thing table = null; if (tableIndex != TargetIndex.None) { table = curJob.GetTarget(tableIndex).Thing; } Thing heater = Toils_HeatMeal.FindPlaceToHeatFood(foodToHeat, actor, searchNear: table); if (heater != null) { curJob.SetTarget(finalLocation, heater); } }; yield return(getHeater); yield return(Toils_Jump.JumpIf(empty, delegate() { Pawn actor = getHeater.actor; Job curJob = actor.jobs.curJob; Thing heater = curJob.GetTarget(finalLocation).Thing; return (heater == null); })); if (!HotMealsSettings.multipleHeat) { yield return(Toils_Reserve.Reserve(finalLocation)); yield return(Toils_Goto.GotoThing(finalLocation, PathEndMode.InteractionCell)); yield return(Toils_HeatMeal.HeatMeal(foodIndex, finalLocation).FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(finalLocation, PathEndMode.InteractionCell)); yield return(Toils_Reserve.Release(finalLocation)); } else { yield return(Toils_Goto.GotoThing(finalLocation, PathEndMode.Touch)); yield return(Toils_HeatMeal.HeatMeal(foodIndex, finalLocation).FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(finalLocation, PathEndMode.Touch)); } yield return(empty); if (oldFinal != LocalTargetInfo.Invalid) { Toil resetC = new Toil(); resetC.initAction = delegate() { Pawn actor = resetC.actor; Job curJob = actor.jobs.curJob; curJob.SetTarget(finalLocation, oldFinal); }; yield return(resetC); } }