protected override IEnumerable <Toil> MakeNewToils() { Building_AquacultureBasin aquacultureBasin = this.TargetThingA as Building_AquacultureBasin; yield return(Toils_Goto.GotoThing(aquacultureBasinIndex, PathEndMode.InteractionCell)); yield return(Toils_General.Wait(120).WithProgressBarToilDelay(aquacultureBasinIndex)); Toil getAquacultureBasinProduction = new Toil() { initAction = () => { Job curJob = this.pawn.jobs.curJob; Thing product = aquacultureBasin.GetProduction(); if (product == null) { this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } else { while (product.stackCount > product.def.stackLimit) { Thing meatStack = ThingMaker.MakeThing(product.def); meatStack.stackCount = product.def.stackLimit; GenPlace.TryPlaceThing(meatStack, this.GetActor().Position, this.Map, ThingPlaceMode.Near); product.stackCount -= product.def.stackLimit; } GenSpawn.Spawn(product, aquacultureBasin.InteractionCell, this.Map); IntVec3 storageCell; if (StoreUtility.TryFindBestBetterStoreCellFor(product, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true)) { this.pawn.Reserve(product, this.job); this.pawn.Reserve(storageCell, this.job, 1); this.pawn.CurJob.SetTarget(TargetIndex.B, storageCell); this.pawn.CurJob.SetTarget(TargetIndex.A, product); this.pawn.CurJob.count = 99999; this.pawn.CurJob.haulMode = HaulMode.ToCellStorage; } else { this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } } } }; yield return(getAquacultureBasinProduction); yield return(Toils_Reserve.Release(aquacultureBasinIndex)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A)); Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(carryToCell); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true)); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(aquacultureBasinIndex)); Building_AquacultureBasin aquacultureBasin = this.TargetThingA as Building_AquacultureBasin; yield return(Toils_Goto.GotoThing(aquacultureBasinIndex, PathEndMode.InteractionCell)); yield return(Toils_General.Wait(120).WithProgressBarToilDelay(aquacultureBasinIndex)); Toil getAquacultureBasinProduction = new Toil() { initAction = () => { Job curJob = this.pawn.jobs.curJob; Thing product = aquacultureBasin.GetProduction(); if (product == null) { this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } else { GenSpawn.Spawn(product, aquacultureBasin.InteractionCell, this.Map); IntVec3 storageCell; if (StoreUtility.TryFindBestBetterStoreCellFor(product, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true)) { this.pawn.carryTracker.TryStartCarry(product); curJob.targetB = storageCell; curJob.targetC = product; curJob.count = 99999; } else { this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } } } }; yield return(getAquacultureBasinProduction); // Reserve the product and storage cell. yield return(Toils_Reserve.Reserve(TargetIndex.B)); yield return(Toils_Reserve.Reserve(TargetIndex.C)); yield return(Toils_Reserve.Release(aquacultureBasinIndex)); Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(carryToCell); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true)); }