protected override IEnumerable <Toil> MakeNewToils() { //Log.Message("I am inside the job now, with "+pawn.ToString(), false); Building_ItemProcessor building_processor = (Building_ItemProcessor)this.job.GetTarget(TargetIndex.A).Thing; this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); yield return(Toils_General.DoAtomic(delegate { if (building_processor.ExpectedAmountSecondIngredient != 0) { this.job.count = building_processor.ExpectedAmountSecondIngredient - building_processor.CurrentAmountSecondIngredient; } else { this.job.count = 1; } })); Toil reserveIngredient = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null); yield return(reserveIngredient); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, true, false).FailOnDestroyedNullOrForbidden(TargetIndex.B)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveIngredient, TargetIndex.B, TargetIndex.None, true, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); yield return(Toils_General.Wait(200, TargetIndex.None).FailOnDestroyedNullOrForbidden(TargetIndex.B).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f)); yield return(new Toil { initAction = delegate { if (building_processor.processorStage != ProcessorStage.Inactive) { if (building_processor.compItemProcessor.Props.transfersIngredientLists) { if (this.job.targetB.Thing.TryGetComp <CompIngredients>() is CompIngredients ingredientComp) { building_processor.ingredients.AddRange(ingredientComp.ingredients); } } building_processor.CurrentAmountSecondIngredient += this.job.targetB.Thing.stackCount; if (building_processor.ExpectedAmountSecondIngredient != 0) { if (building_processor.CurrentAmountSecondIngredient >= building_processor.ExpectedAmountSecondIngredient) { building_processor.secondIngredientComplete = true; } } building_processor.TryAcceptSecond(this.job.targetB.Thing, 0, true); building_processor.Notify_StartProcessing(); //this.job.targetB.Thing.Destroy(); } },