// Token: 0x0600002F RID: 47 RVA: 0x00003958 File Offset: 0x00001B58 public static Toil FinishRecipeAndStartStoringProduct() { Log.Message("start finish recipe, store product.", false); Toil toil = new Toil(); toil.initAction = delegate() { Log.Message("in finishing", false); Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; string str = "curJob"; Job job = curJob; string str2 = (job != null) ? job.ToString() : null; string str3 = " actor "; Pawn pawn = actor; Log.Message(str + str2 + str3 + ((pawn != null) ? pawn.ToString() : null), false); JobDriver_WPDoBill jobDriver_WPDoBill = (JobDriver_WPDoBill)actor.jobs.curDriver; List <Thing> list = Toils_WPRecipe.CalculateIngredients(curJob, actor); for (int i = 0; i < list.Count; i++) { string str4 = "toils_wprecipe: ingredient[i] "; Thing thing = list[i]; Log.Message(str4 + ((thing != null) ? thing.ToString() : null), false); } Thing thing2 = Toils_WPRecipe.CalculateDominantIngredient(curJob, list); string[] array = new string[8]; array[0] = "finishing: curJob.RecipeDef "; int num = 1; RecipeDef recipeDef = curJob.RecipeDef; array[num] = ((recipeDef != null) ? recipeDef.ToString() : null); array[2] = " actor "; int num2 = 3; Pawn pawn2 = actor; array[num2] = ((pawn2 != null) ? pawn2.ToString() : null); array[4] = " ingredients "; int num3 = 5; List <Thing> list2 = list; array[num3] = ((list2 != null) ? list2.ToString() : null); array[6] = " dominantIngredient "; int num4 = 7; Thing thing3 = thing2; array[num4] = ((thing3 != null) ? thing3.ToString() : null); Log.Message(string.Concat(array), false); List <Thing> list3 = WPGenRecipe.MakeRecipeProducts(curJob.RecipeDef, actor, list, thing2).ToList <Thing>(); Toils_WPRecipe.ConsumeIngredients(list, curJob.RecipeDef, actor.Map); curJob.bill.Notify_IterationCompleted(actor, list); RecordsUtility.Notify_BillDone(actor, list3); UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; bool flag = list3.Count == 0; if (flag) { actor.jobs.EndCurrentJob(JobCondition.Succeeded, true, true); } else { bool flag2 = curJob.bill.GetStoreMode() == BillStoreModeDefOf.DropOnFloor; if (flag2) { for (int j = 0; j < list3.Count; j++) { bool flag3 = !GenPlace.TryPlaceThing(list3[j], actor.Position, actor.Map, ThingPlaceMode.Near, null, null, default(Rot4)); if (flag3) { Log.Error(string.Concat(new object[] { actor, " could not drop recipe product ", list3[j], " near ", actor.Position }), false); } } actor.jobs.EndCurrentJob(JobCondition.Succeeded, true, true); } else { bool flag4 = list3.Count > 1; if (flag4) { for (int k = 1; k < list3.Count; k++) { bool flag5 = !GenPlace.TryPlaceThing(list3[k], actor.Position, actor.Map, ThingPlaceMode.Near, null, null, default(Rot4)); if (flag5) { Log.Error(string.Concat(new object[] { actor, " could not drop recipe product ", list3[k], " near ", actor.Position }), false); } } } list3[0].SetPositionDirect(actor.Position); IntVec3 c; bool flag6 = StoreUtility.TryFindBestBetterStoreCellFor(list3[0], actor, actor.Map, StoragePriority.Unstored, actor.Faction, out c, true); if (flag6) { actor.carryTracker.TryStartCarry(list3[0]); curJob.targetB = c; curJob.targetA = list3[0]; curJob.count = 99999; } else { bool flag7 = !GenPlace.TryPlaceThing(list3[0], actor.Position, actor.Map, ThingPlaceMode.Near, null, null, default(Rot4)); if (flag7) { Log.Error(string.Concat(new object[] { "Bill doer could not drop product ", list3[0], " near ", actor.Position }), false); } actor.jobs.EndCurrentJob(JobCondition.Succeeded, true, true); } } } }; return(toil); }