public static Toil MakeUnfinishedThingIfNeeded() { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; if (!curJob.RecipeDef.UsesUnfinishedThing) { return; } if (curJob.GetTarget(TargetIndex.B).Thing is UnfinishedThing) { return; } List <Thing> list = Toils_Recipe.CalculateIngredients(curJob, actor); Thing thing = Toils_Recipe.CalculateDominantIngredient(curJob, list); for (int i = 0; i < list.Count; i++) { Thing thing2 = list[i]; actor.Map.designationManager.RemoveAllDesignationsOn(thing2, false); if (thing2.Spawned) { thing2.DeSpawn(DestroyMode.Vanish); } } ThingDef stuff = (!curJob.RecipeDef.unfinishedThingDef.MadeFromStuff) ? null : thing.def; UnfinishedThing unfinishedThing = (UnfinishedThing)ThingMaker.MakeThing(curJob.RecipeDef.unfinishedThingDef, stuff); unfinishedThing.Creator = actor; unfinishedThing.BoundBill = (Bill_ProductionWithUft)curJob.bill; unfinishedThing.ingredients = list; CompColorable compColorable = unfinishedThing.TryGetComp <CompColorable>(); if (compColorable != null) { compColorable.Color = thing.DrawColor; } GenSpawn.Spawn(unfinishedThing, curJob.GetTarget(TargetIndex.A).Cell, actor.Map, WipeMode.Vanish); curJob.SetTarget(TargetIndex.B, unfinishedThing); actor.Reserve(unfinishedThing, curJob, 1, -1, null, true); }; return(toil); }
public static Toil FinishRecipeAndStartStoringProduct() { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; if (curJob.RecipeDef.workSkill != null && !curJob.RecipeDef.UsesUnfinishedThing) { float xp = (float)jobDriver_DoBill.ticksSpentDoingRecipeWork * 0.1f * curJob.RecipeDef.workSkillLearnFactor; actor.skills.GetSkill(curJob.RecipeDef.workSkill).Learn(xp, false); } List <Thing> ingredients = Toils_Recipe.CalculateIngredients(curJob, actor); Thing dominantIngredient = Toils_Recipe.CalculateDominantIngredient(curJob, ingredients); List <Thing> list = GenRecipe.MakeRecipeProducts(curJob.RecipeDef, actor, ingredients, dominantIngredient, jobDriver_DoBill.BillGiver).ToList <Thing>(); Toils_Recipe.ConsumeIngredients(ingredients, curJob.RecipeDef, actor.Map); curJob.bill.Notify_IterationCompleted(actor, ingredients); RecordsUtility.Notify_BillDone(actor, list); UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; if (curJob.bill.recipe.WorkAmountTotal((unfinishedThing == null) ? null : unfinishedThing.Stuff) >= 10000f && list.Count > 0) { TaleRecorder.RecordTale(TaleDefOf.CompletedLongCraftingProject, new object[] { actor, list[0].def }); } if (list.Count == 0) { actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); return; } if (curJob.bill.GetStoreMode() == BillStoreModeDefOf.DropOnFloor) { for (int i = 0; i < list.Count; i++) { if (!GenPlace.TryPlaceThing(list[i], actor.Position, actor.Map, ThingPlaceMode.Near, null, null)) { Log.Error(string.Concat(new object[] { actor, " could not drop recipe product ", list[i], " near ", actor.Position }), false); } } actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); return; } if (list.Count > 1) { for (int j = 1; j < list.Count; j++) { if (!GenPlace.TryPlaceThing(list[j], actor.Position, actor.Map, ThingPlaceMode.Near, null, null)) { Log.Error(string.Concat(new object[] { actor, " could not drop recipe product ", list[j], " near ", actor.Position }), false); } } } IntVec3 invalid = IntVec3.Invalid; if (curJob.bill.GetStoreMode() == BillStoreModeDefOf.BestStockpile) { StoreUtility.TryFindBestBetterStoreCellFor(list[0], actor, actor.Map, StoragePriority.Unstored, actor.Faction, out invalid, true); } else if (curJob.bill.GetStoreMode() == BillStoreModeDefOf.SpecificStockpile) { StoreUtility.TryFindBestBetterStoreCellForIn(list[0], actor, actor.Map, StoragePriority.Unstored, actor.Faction, curJob.bill.GetStoreZone().slotGroup, out invalid, true); } else { Log.ErrorOnce("Unknown store mode", 9158246, false); } if (invalid.IsValid) { actor.carryTracker.TryStartCarry(list[0]); curJob.targetB = invalid; curJob.targetA = list[0]; curJob.count = 99999; return; } if (!GenPlace.TryPlaceThing(list[0], actor.Position, actor.Map, ThingPlaceMode.Near, null, null)) { Log.Error(string.Concat(new object[] { "Bill doer could not drop product ", list[0], " near ", actor.Position }), false); } actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); }; return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { base.AddEndCondition(delegate { Thing thing = this.$this.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate { IBillGiver billGiver = this.$this.job.GetTarget(TargetIndex.A).Thing as IBillGiver; if (billGiver != null) { if (this.$this.job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } } return(false); }); Toil gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); yield return(new Toil { initAction = delegate { if (this.$this.job.targetQueueB != null && this.$this.job.targetQueueB.Count == 1) { UnfinishedThing unfinishedThing = this.$this.job.targetQueueB[0].Thing as UnfinishedThing; if (unfinishedThing != null) { unfinishedThing.BoundBill = (Bill_ProductionWithUft)this.$this.job.bill; } } } }); yield return(Toils_Jump.JumpIf(gotoBillGiver, () => this.$this.job.GetTargetQueue(TargetIndex.B).NullOrEmpty <LocalTargetInfo>())); Toil extract = Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B, true); yield return(extract); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B); yield return(getToHaulTarget); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, true, false, true)); yield return(JobDriver_DoBill.JumpToCollectNextIntoHandsForBill(getToHaulTarget, TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnDestroyedOrNull(TargetIndex.B)); Toil findPlaceTarget = Toils_JobTransforms.SetTargetToIngredientPlaceCell(TargetIndex.A, TargetIndex.B, TargetIndex.C); yield return(findPlaceTarget); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, findPlaceTarget, false)); yield return(Toils_Jump.JumpIfHaveTargetInQueue(TargetIndex.B, extract)); yield return(gotoBillGiver); yield return(Toils_Recipe.MakeUnfinishedThingIfNeeded()); yield return(Toils_Recipe.DoRecipeWork().FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell)); yield return(Toils_Recipe.FinishRecipeAndStartStoringProduct()); if (!this.job.RecipeDef.products.NullOrEmpty <ThingCountClass>() || !this.job.RecipeDef.specialProducts.NullOrEmpty <SpecialProductType>()) { yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null)); Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(carryToCell); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true)); Toil recount = new Toil(); recount.initAction = delegate { Bill_Production bill_Production = recount.actor.jobs.curJob.bill as Bill_Production; if (bill_Production != null && bill_Production.repeatMode == BillRepeatModeDefOf.TargetCount) { this.$this.Map.resourceCounter.UpdateResourceCounts(); } }; yield return(recount); } }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: { base.AddEndCondition(delegate { Thing thing = base.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate() { IBillGiver billGiver = this.job.GetTarget(TargetIndex.A).Thing as IBillGiver; if (billGiver != null) { if (this.job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } } return(false); }); gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); Toil bind = new Toil(); bind.initAction = delegate() { if (this.job.targetQueueB != null && this.job.targetQueueB.Count == 1) { UnfinishedThing unfinishedThing = this.job.targetQueueB[0].Thing as UnfinishedThing; if (unfinishedThing != null) { unfinishedThing.BoundBill = (Bill_ProductionWithUft)this.job.bill; } } }; this.$current = bind; if (!this.$disposing) { this.$PC = 1; } return(true); } case 1u: this.$current = Toils_Jump.JumpIf(gotoBillGiver, () => this.job.GetTargetQueue(TargetIndex.B).NullOrEmpty <LocalTargetInfo>()); if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: extract = Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B, true); this.$current = extract; if (!this.$disposing) { this.$PC = 3; } return(true); case 3u: getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B); this.$current = getToHaulTarget; if (!this.$disposing) { this.$PC = 4; } return(true); case 4u: this.$current = Toils_Haul.StartCarryThing(TargetIndex.B, true, false, true); if (!this.$disposing) { this.$PC = 5; } return(true); case 5u: this.$current = JobDriver_DoBill.JumpToCollectNextIntoHandsForBill(getToHaulTarget, TargetIndex.B); if (!this.$disposing) { this.$PC = 6; } return(true); case 6u: this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnDestroyedOrNull(TargetIndex.B); if (!this.$disposing) { this.$PC = 7; } return(true); case 7u: findPlaceTarget = Toils_JobTransforms.SetTargetToIngredientPlaceCell(TargetIndex.A, TargetIndex.B, TargetIndex.C); this.$current = findPlaceTarget; if (!this.$disposing) { this.$PC = 8; } return(true); case 8u: this.$current = Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, findPlaceTarget, false); if (!this.$disposing) { this.$PC = 9; } return(true); case 9u: this.$current = Toils_Jump.JumpIfHaveTargetInQueue(TargetIndex.B, extract); if (!this.$disposing) { this.$PC = 10; } return(true); case 10u: this.$current = gotoBillGiver; if (!this.$disposing) { this.$PC = 11; } return(true); case 11u: this.$current = Toils_Recipe.MakeUnfinishedThingIfNeeded(); if (!this.$disposing) { this.$PC = 12; } return(true); case 12u: this.$current = Toils_Recipe.DoRecipeWork().FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); if (!this.$disposing) { this.$PC = 13; } return(true); case 13u: this.$current = Toils_Recipe.FinishRecipeAndStartStoringProduct(); if (!this.$disposing) { this.$PC = 14; } return(true); case 14u: if (!this.job.RecipeDef.products.NullOrEmpty <ThingDefCountClass>() || !this.job.RecipeDef.specialProducts.NullOrEmpty <SpecialProductType>()) { this.$current = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null); if (!this.$disposing) { this.$PC = 15; } return(true); } break; case 15u: carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); this.$current = carryToCell; if (!this.$disposing) { this.$PC = 16; } return(true); case 16u: this.$current = Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true); if (!this.$disposing) { this.$PC = 17; } return(true); case 17u: < MakeNewToils > c__AnonStorey.recount = new Toil(); < MakeNewToils > c__AnonStorey.recount.initAction = delegate() { Bill_Production bill_Production = < MakeNewToils > c__AnonStorey.recount.actor.jobs.curJob.bill as Bill_Production; if (bill_Production != null && bill_Production.repeatMode == BillRepeatModeDefOf.TargetCount) { < MakeNewToils > c__AnonStorey.< > f__ref$0.$this.Map.resourceCounter.UpdateResourceCounts(); }
protected override IEnumerable <Toil> MakeNewToils() { //Bill giver destroyed (only in bill using phase! Not in carry phase) this.AddEndCondition(() => { var targ = this.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (targ is Building && !targ.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(TargetIndex.A); //Bill giver, or product burning in carry phase this.FailOn(() => { IBillGiver billGiver = job.GetTarget(BillGiverInd).Thing as IBillGiver; //conditions only apply during the billgiver-use phase if (billGiver != null) { if (job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } } return(false); }); //This toil is yielded later Toil gotoBillGiver = Toils_Goto.GotoThing(BillGiverInd, PathEndMode.InteractionCell); //Bind to bill if it should Toil bind = new Toil(); bind.initAction = () => { if (job.targetQueueB != null && job.targetQueueB.Count == 1) { UnfinishedThing uft = job.targetQueueB[0].Thing as UnfinishedThing; if (uft != null) { uft.BoundBill = (Bill_ProductionWithUft)job.bill; } } }; yield return(bind); //Jump over ingredient gathering if there are no ingredients needed yield return(Toils_Jump.JumpIf(gotoBillGiver, () => job.GetTargetQueue(IngredientInd).NullOrEmpty())); //Gather ingredients { //Extract an ingredient into IngredientInd target Toil extract = Toils_JobTransforms.ExtractNextTargetFromQueue(IngredientInd); yield return(extract); //Get to ingredient and pick it up //Note that these fail cases must be on these toils, otherwise the recipe work fails if you stacked // your targetB into another object on the bill giver square. var getToHaulTarget = Toils_Goto.GotoThing(IngredientInd, GotoIngredientPathEndMode) .FailOnDespawnedNullOrForbidden(IngredientInd) .FailOnSomeonePhysicallyInteracting(IngredientInd); yield return(getToHaulTarget); yield return(Toils_Haul.StartCarryThing(IngredientInd, putRemainderInQueue: true, failIfStackCountLessThanJobCount: true)); //Jump to pick up more in this run if we're collecting from multiple stacks at once yield return(JumpToCollectNextIntoHandsForBill(getToHaulTarget, TargetIndex.B)); //Carry ingredient to the bill giver yield return(Toils_Goto.GotoThing(BillGiverInd, PathEndMode.InteractionCell) .FailOnDestroyedOrNull(IngredientInd)); //Place ingredient on the appropriate cell Toil findPlaceTarget = Toils_JobTransforms.SetTargetToIngredientPlaceCell(BillGiverInd, IngredientInd, IngredientPlaceCellInd); yield return(findPlaceTarget); yield return(Toils_Haul.PlaceHauledThingInCell(IngredientPlaceCellInd, nextToilOnPlaceFailOrIncomplete: findPlaceTarget, storageMode: false)); //Jump back if another ingredient is queued, or you didn't finish carrying your current ingredient target yield return(Toils_Jump.JumpIfHaveTargetInQueue(IngredientInd, extract)); } //For it no ingredients needed, just go to the bill giver //This will do nothing if we took ingredients and are thus already at the bill giver yield return(gotoBillGiver); //If the recipe calls for the use of an UnfinishedThing //Create that and convert our job to be a job about working on it yield return(Toils_Recipe.MakeUnfinishedThingIfNeeded()); //Do the recipe //This puts the first product (if any) in targetC yield return(Toils_Recipe.DoRecipeWork() .FailOnDespawnedNullOrForbiddenPlacedThings() .FailOnCannotTouch(BillGiverInd, PathEndMode.InteractionCell)); //Finish doing this recipe //Generate the products //Modify the job to store them yield return(Toils_Recipe.FinishRecipeAndStartStoringProduct()); //If recipe has any products, store the first one if (!job.RecipeDef.products.NullOrEmpty() || !job.RecipeDef.specialProducts.NullOrEmpty()) { //Reserve the storage cell yield return(Toils_Reserve.Reserve(TargetIndex.B)); Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(carryToCell); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, storageMode: true)); //Bit of a hack here //This makes the worker use a count including the one they just dropped //When determining whether to make the next item if the bill has "make until you have" marked. Toil recount = new Toil(); recount.initAction = () => { Bill_Production bill = recount.actor.jobs.curJob.bill as Bill_Production; if (bill != null && bill.repeatMode == BillRepeatModeDefOf.TargetCount) { Map.resourceCounter.UpdateResourceCounts(); } }; yield return(recount); } }
protected override IEnumerable <Toil> MakeNewToils() { AddEndCondition(delegate { Thing thing = GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; return((!(thing is Building) || thing.Spawned) ? JobCondition.Ongoing : JobCondition.Incompletable); }); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate { IBillGiver billGiver = job.GetTarget(TargetIndex.A).Thing as IBillGiver; if (billGiver != null) { if (job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } } return(false); }); Toil gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); Toil toil = new Toil(); toil.initAction = delegate { if (job.targetQueueB != null && job.targetQueueB.Count == 1) { UnfinishedThing unfinishedThing = job.targetQueueB[0].Thing as UnfinishedThing; if (unfinishedThing != null) { unfinishedThing.BoundBill = (Bill_ProductionWithUft)job.bill; } } }; yield return(toil); yield return(Toils_Jump.JumpIf(gotoBillGiver, () => job.GetTargetQueue(TargetIndex.B).NullOrEmpty())); Toil extract = Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B); yield return(extract); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B); yield return(getToHaulTarget); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, putRemainderInQueue: true, subtractNumTakenFromJobCount: false, failIfStackCountLessThanJobCount: true)); yield return(JumpToCollectNextIntoHandsForBill(getToHaulTarget, TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnDestroyedOrNull(TargetIndex.B)); Toil findPlaceTarget2 = Toils_JobTransforms.SetTargetToIngredientPlaceCell(TargetIndex.A, TargetIndex.B, TargetIndex.C); yield return(findPlaceTarget2); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, findPlaceTarget2, storageMode: false)); yield return(Toils_Jump.JumpIfHaveTargetInQueue(TargetIndex.B, extract)); yield return(gotoBillGiver); yield return(Toils_Recipe.MakeUnfinishedThingIfNeeded()); yield return(Toils_Recipe.DoRecipeWork().FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell)); yield return(Toils_Recipe.FinishRecipeAndStartStoringProduct()); if (!job.RecipeDef.products.NullOrEmpty() || !job.RecipeDef.specialProducts.NullOrEmpty()) { yield return(Toils_Reserve.Reserve(TargetIndex.B)); findPlaceTarget2 = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(findPlaceTarget2); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, findPlaceTarget2, storageMode: true, tryStoreInSameStorageIfSpotCantHoldWholeStack: true)); Toil recount = new Toil(); recount.initAction = delegate { Bill_Production bill_Production = recount.actor.jobs.curJob.bill as Bill_Production; if (bill_Production != null && bill_Production.repeatMode == BillRepeatModeDefOf.TargetCount) { base.Map.resourceCounter.UpdateResourceCounts(); } }; yield return(recount); } }
public static Toil FinishRecipeAndStartStoringProduct() { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; if (curJob.RecipeDef.workSkill != null && !curJob.RecipeDef.UsesUnfinishedThing) { float xp = (float)((float)jobDriver_DoBill.ticksSpentDoingRecipeWork * 0.10999999940395355 * curJob.RecipeDef.workSkillLearnFactor); actor.skills.GetSkill(curJob.RecipeDef.workSkill).Learn(xp, false); } List <Thing> ingredients = Toils_Recipe.CalculateIngredients(curJob, actor); Thing dominantIngredient = Toils_Recipe.CalculateDominantIngredient(curJob, ingredients); List <Thing> list = GenRecipe.MakeRecipeProducts(curJob.RecipeDef, actor, ingredients, dominantIngredient).ToList(); Toils_Recipe.ConsumeIngredients(ingredients, curJob.RecipeDef, actor.Map); curJob.bill.Notify_IterationCompleted(actor, ingredients); RecordsUtility.Notify_BillDone(actor, list); UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; if (curJob.bill.recipe.WorkAmountTotal((unfinishedThing == null) ? null : unfinishedThing.Stuff) >= 20000.0 && list.Count > 0) { TaleRecorder.RecordTale(TaleDefOf.CompletedLongCraftingProject, actor, list[0].def); } if (list.Count == 0) { actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); } else if (curJob.bill.GetStoreMode() == BillStoreModeDefOf.DropOnFloor) { for (int i = 0; i < list.Count; i++) { if (!GenPlace.TryPlaceThing(list[i], actor.Position, actor.Map, ThingPlaceMode.Near, null)) { Log.Error(actor + " could not drop recipe product " + list[i] + " near " + actor.Position); } } actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); } else { if (list.Count > 1) { for (int j = 1; j < list.Count; j++) { if (!GenPlace.TryPlaceThing(list[j], actor.Position, actor.Map, ThingPlaceMode.Near, null)) { Log.Error(actor + " could not drop recipe product " + list[j] + " near " + actor.Position); } } } list[0].SetPositionDirect(actor.Position); IntVec3 c = default(IntVec3); if (StoreUtility.TryFindBestBetterStoreCellFor(list[0], actor, actor.Map, StoragePriority.Unstored, actor.Faction, out c, true)) { actor.carryTracker.TryStartCarry(list[0]); curJob.targetB = c; curJob.targetA = list[0]; curJob.count = 99999; } else { if (!GenPlace.TryPlaceThing(list[0], actor.Position, actor.Map, ThingPlaceMode.Near, null)) { Log.Error("Bill doer could not drop product " + list[0] + " near " + actor.Position); } actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); } } }; return(toil); }