public static Toil SetTargetToIngredientPlaceCell(TargetIndex billGiverInd, TargetIndex carryItemInd, TargetIndex cellTargetInd) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing thing = curJob.GetTarget(carryItemInd).Thing; IBillGiver billGiver = curJob.GetTarget(billGiverInd).Thing as IBillGiver; IntVec3 c = IntVec3.Invalid; foreach (IntVec3 item in Toils_JobTransforms.IngredientPlaceCellsInOrder(billGiver)) { if (!c.IsValid) { c = item; } bool flag = false; List <Thing> list = actor.Map.thingGrid.ThingsListAt(item); int num = 0; while (num < list.Count) { if (list[num].def.category != ThingCategory.Item || (list[num].def == thing.def && list[num].stackCount != list[num].def.stackLimit)) { num++; continue; } flag = true; break; } if (!flag) { curJob.SetTarget(cellTargetInd, item); return; } } curJob.SetTarget(cellTargetInd, c); }; return(toil); }
public static Toil SetTargetToIngredientPlaceCell(TargetIndex billGiverInd, TargetIndex carryItemInd, TargetIndex cellTargetInd) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Thing thing = curJob.GetTarget(carryItemInd).Thing; IBillGiver billGiver = curJob.GetTarget(billGiverInd).Thing as IBillGiver; IntVec3 c = IntVec3.Invalid; foreach (IntVec3 current in Toils_JobTransforms.IngredientPlaceCellsInOrder(billGiver)) { if (!c.IsValid) { c = current; } bool flag = false; List <Thing> list = actor.Map.thingGrid.ThingsListAt(current); for (int i = 0; i < list.Count; i++) { if (list[i].def.category == ThingCategory.Item && (list[i].def != thing.def || list[i].stackCount == list[i].def.stackLimit)) { flag = true; break; } } if (!flag) { curJob.SetTarget(cellTargetInd, current); return; } } curJob.SetTarget(cellTargetInd, c); }; return(toil); }