protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            base.AddEndCondition(() => (!this.$this.RefuelableComp.IsFull) ? JobCondition.Ongoing : JobCondition.Succeeded);
            base.AddFailCondition(() => !this.$this.job.playerForced && !this.$this.RefuelableComp.ShouldAutoRefuelNowIgnoringFuelPct);
            yield return(Toils_General.DoAtomic(delegate
            {
                this.$this.job.count = this.$this.RefuelableComp.GetFuelCountToFullyRefuel();
            }));

            Toil getNextIngredient = Toils_General.Label();

            yield return(getNextIngredient);

            yield return(Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B, true));

            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_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            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.JumpIf(getNextIngredient, () => !this.$this.job.GetTargetQueue(TargetIndex.B).NullOrEmpty <LocalTargetInfo>()));

            yield return(Toils_General.Wait(240, TargetIndex.None).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

            yield return(Toils_Refuel.FinalizeRefueling(TargetIndex.A, TargetIndex.None));
        }
示例#2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedNullOrForbidden(tableTI);
            this.FailOnBurningImmobile(objectTI);
            this.FailOnDestroyedNullOrForbidden(objectTI);
            this.FailOnBurningImmobile(objectTI);
            yield return(Toils_Reserve.Reserve(tableTI));

            yield return(Toils_Reserve.Reserve(objectTI));

            yield return(Toils_Goto.GotoThing(objectTI, PathEndMode.Touch));

            yield return(Toils_Haul.StartCarryThing(objectTI));

            yield return(Toils_Goto.GotoThing(tableTI, PathEndMode.InteractionCell));

            yield return(Toils_Haul.PlaceHauledThingInCell(tableTI, null, false));

            yield return(DoBill());

            yield return(Store());

            yield return(Toils_Reserve.Reserve(haulTI));

            yield return(Toils_Haul.CarryHauledThingToCell(haulTI));

            yield return(Toils_Haul.PlaceHauledThingInCell(haulTI, null, false));

            yield return(Toils_Reserve.Release(objectTI));

            yield return(Toils_Reserve.Release(haulTI));

            yield return(Toils_Reserve.Release(tableTI));
        }
示例#3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            // Set up fail conditions
            this.FailOn(delegate {
                return(Quarry == null || Quarry.IsForbidden(pawn) || Quarry.Depleted);
            });

            // Go to the quarry
            yield return(Toils_Goto.Goto(CellInd, PathEndMode.OnCell));

            // Mine at the quarry. This is only for the delay
            yield return(Mine());

            // Collect resources from the quarry
            yield return(Collect());

            // Reserve the resource
            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            // Reserve the storage cell
            yield return(Toils_Reserve.Reserve(TargetIndex.C));

            // Go to the resource
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            // Pick up the resource
            yield return(Toils_Haul.StartCarryThing(TargetIndex.B));

            // Carry the resource to the storage cell, then place it down
            Toil carry = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carry, true));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedNullOrForbidden(SlaveInd);
            this.FailOnBurningImmobile(SlaveInd);
            this.FailOn(() =>
            {
                var slave = (Pawn)this.GetActor().CurJob.GetTarget(SlaveInd).Thing;
                return(slave.guest.interactionMode != (PrisonerInteractionMode)Data.PIM_FreeSlave);
            });
            this.FailOnDowned(SlaveInd);
            this.FailOnAggroMentalState(SlaveInd);
            yield return(Toils_Reserve.Reserve(SlaveInd, 1));

            yield return(Toils_Goto.GotoThing(SlaveInd, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(SlaveInd));

            var gotoToil = Toils_Goto.GotoCell(ReleaseCellInd, PathEndMode.ClosestTouch);

            yield return(gotoToil);

            yield return(Toils_Haul.PlaceHauledThingInCell(ReleaseCellInd, gotoToil, false));

            yield return(Toils_Reserve.Release(SlaveInd));

            yield return(Toils_Prisoner.FreeSlave(SlaveInd, CollarInd));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedNullOrForbidden(PrisonerInd);
            this.FailOnDestroyedNullOrForbidden(CollarInd);
            this.FailOnBurningImmobile(CollarInd);
            yield return(Toils_Reserve.Reserve(PrisonerInd, 1));

            yield return(Toils_Reserve.Reserve(CollarInd, 1));

            yield return(Toils_Goto.GotoThing(CollarInd, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(CollarInd));

            var gotoToil = Toils_Goto.GotoThing(PrisonerInd, PathEndMode.ClosestTouch);

            yield return(gotoToil);

            yield return(Toils_Haul.PlaceHauledThingInCell(CollarCellInd, gotoToil, false));

            yield return(Toils_Reserve.Release(CollarInd));

            yield return(Toils_Prisoner.Enslave(PrisonerInd, CollarInd));

            yield return(Toils_Reserve.Release(PrisonerInd));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.B);
            this.FailOnDowned(TargetIndex.A);
            this.FailOnAggroMentalState(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, false));

            Toil setupIrradiation = new Toil()
            {
                initAction = delegate()
                {
                    pawn.ClearReservationsForJob(job);

                    Job prisonerJob = new Job(JobDefOf.RadiologyIrradiate, Chamber, 1500, true);
                    Prisoner.jobs.StartJob(prisonerJob);
                }
            };

            yield return(setupIrradiation);

            yield break;
        }
        /// <summary>
        /// Makes the new toils.
        /// </summary>
        /// <returns></returns>
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);
            yield return(Toils_General.DoAtomic(delegate { job.count = 1; }));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch)
                         .FailOnDespawnedNullOrForbidden(TargetIndex.B)
                         .FailOnSomeonePhysicallyInteracting(TargetIndex.B));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, true).FailOnDestroyedNullOrForbidden(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, null, false));

            yield return(Toils_General.Wait(600)
                         .FailOnDestroyedNullOrForbidden(TargetIndex.B)
                         .FailOnDestroyedNullOrForbidden(TargetIndex.A)
                         .FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell)
                         .WithProgressBarToilDelay(TargetIndex.A));

            var toil = new Toil
            {
                initAction          = ApplyGenome,
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(toil);
        }
示例#8
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(CorpseInd);
            Toil gotoCorpse = Toils_Goto.GotoThing(CorpseInd, PathEndMode.Touch).FailOnDespawnedOrNull(CorpseInd);

            yield return(Toils_Jump.JumpIfTargetInvalid(GraveInd, gotoCorpse));

            yield return(Toils_Goto.GotoThing(GraveInd, PathEndMode.InteractionCell).FailOnDespawnedOrNull(GraveInd));

            yield return(Toils_General.Wait(300).WithProgressBarToilDelay(GraveInd, false, -0.5f).FailOnDespawnedOrNull(GraveInd).FailOnCannotTouch(GraveInd, PathEndMode.InteractionCell));

            yield return(Toils_General.Open(GraveInd));

            yield return(Toils_Reserve.Reserve(CorpseInd, 1, -1, null));

            yield return(gotoCorpse);

            yield return(Toils_Haul.StartCarryThing(CorpseInd, false, false, false));

            yield return(this.FindCellToDropCorpseToil());

            yield return(Toils_Reserve.Reserve(CellInd, 1, -1, null));

            yield return(Toils_Goto.GotoCell(CellInd, PathEndMode.Touch));

            yield return(Toils_Haul.PlaceHauledThingInCell(CellInd, null, false));

            foreach (Toil t in this.Nibble())
            {
                yield return(t);
            }
            yield return(this.Forbid());
        }
示例#9
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.B);
            this.FailOn(() => ((Pawn)((Thing)GetActor().CurJob.GetTarget(TargetIndex.A))).guest.interactionMode != PrisonerInteractionModeDefOf.Release);
            this.FailOnDowned(TargetIndex.A);
            this.FailOnAggroMentalState(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, false));

            Toil setReleased = new Toil();

            setReleased.initAction = delegate
            {
                Pawn actor  = setReleased.actor;
                Job  curJob = actor.jobs.curJob;
                Pawn p      = curJob.targetA.Thing as Pawn;
                GenGuest.PrisonerRelease(p);
            };
            yield return(setReleased);
        }
示例#10
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            Toil gotoCorpse = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A);

            yield return(Toils_Jump.JumpIfTargetInvalid(TargetIndex.B, gotoCorpse));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.InteractionCell).FailOnDespawnedOrNull(TargetIndex.B));

            yield return(Toils_General.Wait(300, TargetIndex.None).WithProgressBarToilDelay(TargetIndex.B, false, -0.5f).FailOnDespawnedOrNull(TargetIndex.B).FailOnCannotTouch(TargetIndex.B, PathEndMode.InteractionCell));

            yield return(Toils_General.Open(TargetIndex.B));

            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null));

            yield return(gotoCorpse);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false));

            yield return(this.FindCellToDropCorpseToil());

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            yield return(Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.Touch));

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, null, false));

            yield return(this.ForbidAndNotifyMentalStateToil());

            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);
            yield return(Toils_General.DoAtomic(delegate
            {
                job.count = 1;
            }));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, putRemainderInQueue: false, subtractNumTakenFromJobCount: true).FailOnDestroyedNullOrForbidden(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, null, storageMode: false));

            yield return(Toils_General.Wait(600).FailOnDestroyedNullOrForbidden(TargetIndex.B).FailOnDestroyedNullOrForbidden(TargetIndex.A)
                         .FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell)
                         .WithProgressBarToilDelay(TargetIndex.A));

            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Find.ResearchManager.ApplyTechprint(TechprintComp.Props.project, pawn);
                Techprint.Destroy();
                SoundDefOf.TechprintApplied.PlayOneShotOnCamera();
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(toil);
        }
        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));
        }
        // Token: 0x06000053 RID: 83 RVA: 0x00004200 File Offset: 0x00002400
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(600, TargetIndex.None).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

            yield return(Toils_AQRemoving.FinalizeRemoving(TargetIndex.A));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null));

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false, false));

            Toil carry = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carry, true, false));

            yield break;
        }
示例#14
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            yield return(Toils_General.Wait(this.duration, TargetIndex.None).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

            yield return(Toils_General.Do(delegate
            {
                if (this.pawn.apparel.WornApparel.Contains(this.Apparel))
                {
                    Apparel apparel;
                    if (this.pawn.apparel.TryDrop(this.Apparel, out apparel))
                    {
                        this.job.targetA = apparel;
                        if (this.job.haulDroppedApparel)
                        {
                            apparel.SetForbidden(false, false);
                            StoragePriority currentPriority = StoreUtility.CurrentStoragePriorityOf(apparel);
                            IntVec3 c;
                            if (StoreUtility.TryFindBestBetterStoreCellFor(apparel, this.pawn, base.Map, currentPriority, this.pawn.Faction, out c, true))
                            {
                                this.job.count = apparel.stackCount;
                                this.job.targetB = c;
                            }
                            else
                            {
                                base.EndJobWith(JobCondition.Incompletable);
                            }
                        }
                        else
                        {
                            base.EndJobWith(JobCondition.Succeeded);
                        }
                    }
                    else
                    {
                        base.EndJobWith(JobCondition.Incompletable);
                    }
                }
                else
                {
                    base.EndJobWith(JobCondition.Incompletable);
                }
            }));

            if (this.job.haulDroppedApparel)
            {
                yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null));

                yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null));

                yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false).FailOn(() => !this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)));

                Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);
                yield return(carryToCell);

                yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));
            }
            yield break;
        }
        // Token: 0x0600000A RID: 10 RVA: 0x000029D9 File Offset: 0x00000BD9
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOn(delegate
            {
                if (job.ignoreDesignations)
                {
                    return(false);
                }

                var victim = Victim;
                if (victim != null && !victim.Dead &&
                    Map.designationManager.DesignationOn(victim, DesignationDefOf.Hunt) == null)
                {
                    return(true);
                }

                return(false);
            });
            yield return(new Toil
            {
                initAction = delegate { jobStartTick = Find.TickManager.TicksGame; }
            });

            yield return(Toils_Combat.TrySetJobToUseAttackVerb(TargetIndex.A));

            var startCollectCorpse = StartCollectCorpseToil();
            var gotoCastPos        = MarvsGotoCastPosition(TargetIndex.A, true)
                                     .JumpIfDespawnedOrNull(TargetIndex.A, startCollectCorpse)
                                     .FailOn(() => Find.TickManager.TicksGame > jobStartTick + 5000);

            yield return(gotoCastPos);

            var moveIfCannotHit = MarvsJumpIfTargetNotHittable(TargetIndex.A, gotoCastPos);

            yield return(moveIfCannotHit);

            yield return(MarvsJumpIfTargetDownedDistant(TargetIndex.A, gotoCastPos));

            yield return(Toils_Combat.CastVerb(TargetIndex.A, false)
                         .JumpIfDespawnedOrNull(TargetIndex.A, startCollectCorpse)
                         .FailOn(() => Find.TickManager.TicksGame > jobStartTick + 5000));

            yield return(Toils_Jump.JumpIfTargetDespawnedOrNull(TargetIndex.A, startCollectCorpse));

            yield return(Toils_Jump.Jump(moveIfCannotHit));

            yield return(startCollectCorpse);

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.ClosestTouch)
                         .FailOnDespawnedNullOrForbidden(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A));

            var carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));
        }
示例#16
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.B);
            if (!forbiddenInitially)
            {
                this.FailOnForbidden(TargetIndex.A);
            }
            Toil reserveTargetA = Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null);

            yield return(reserveTargetA);

            Toil toilGoto = null;

            toilGoto = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);
            toilGoto.AddFailCondition(delegate
            {
                Pawn actor = toilGoto.actor;
                Job curJob = actor.jobs.curJob;
                if (curJob.haulMode == HaulMode.ToCellStorage)
                {
                    Thing thing  = curJob.GetTarget(TargetIndex.A).Thing;
                    IntVec3 cell = actor.jobs.curJob.GetTarget(TargetIndex.B).Cell;
                    if (!cell.IsValidStorageFor(Map, thing))
                    {
                        return(true);
                    }
                }
                return(false);
            });
            yield return(toilGoto);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false));

            if (job.haulOpportunisticDuplicates)
            {
                yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveTargetA, TargetIndex.A, TargetIndex.B, false, null));
            }
            if (job.expiryInterval != -1)
            {
                yield return(CheckExpiry());
            }
            Insect insect = toilGoto.actor as Insect;

            if (insect != null && insect.targetColonyFood)
            {
                yield return(ResetTargetColonyFoodFlag(insect));
            }
            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));

            if (insect != null && insect.stealFood)
            {
                yield return(ResetStealFoodFlag(insect));
            }
        }
示例#17
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.A);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.A, carryToCell, true));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TakeeIndex);
            this.FailOnDestroyedOrNull(AlterIndex);
            this.FailOnAggroMentalStateAndHostile(TakeeIndex);

            yield return(Toils_Goto.GotoThing(TakeeIndex, PathEndMode.ClosestTouch)
                         .FailOnDespawnedNullOrForbidden(TakeeIndex)
                         .FailOnDespawnedNullOrForbidden(AlterIndex)
                         .FailOn(() => !pawn.CanReach(Alter, PathEndMode.OnCell, Danger.Deadly)));

            Toil toil2 = Toils_Haul.StartCarryThing(TakeeIndex);

            yield return(toil2);

            var carryToil = Toils_Haul.CarryHauledThingToCell(AlterIndex);

            yield return(carryToil);

            var eToil = Toils_Haul.PlaceHauledThingInCell(AlterIndex, carryToil, false);

            yield return(eToil);

            Toil toil4 = new Toil();

            void DropTarget()
            {
                IntVec3 position = Alter.Position;

                pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out Thing target);

                try
                {
                    var pTarget = (Pawn)target;
                    if (pTarget == null)
                    {
                        return;
                    }

                    var hediff = HediffMaker.MakeHediff(HediffDefOf.Anesthetic, pTarget);
                    //hacky, but will stop the target from moving around
                    pTarget.health.hediffSet.AddDirect(hediff);

                    //now add the transformation hediff
                    var tfHediff = HediffMaker.MakeHediff(PSHediffDefOf.SkavenRitualEffect, pTarget);
                    pTarget.health.hediffSet.AddDirect(tfHediff);
                }
                catch (Exception e)
                {
                    Log.Error($"caught {e.GetType().Name} while finishing TakeToAlter action!\n{e} ");
                }
            }

            toil4.initAction          = DropTarget;
            toil4.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(toil4);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOn(() => Patient == null || Medicine == null);
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            this.FailOnNotDowned(TargetIndex.A);
            this.AddEndCondition(delegate
            {
                if (Patient.health.hediffSet.GetHediffsTendable().Any(h => h.CanBeStabilized()))
                {
                    return(JobCondition.Ongoing);
                }
                Medicine.Destroy();
                return(JobCondition.Incompletable);
            });

            // Pick up medicine and haul to patient
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.A, null, false));

            // Stabilize patient
            int  duration = (int)(1f / this.pawn.GetStatValue(StatDefOf.MedicalTendSpeed, true) * baseTendDuration);
            Toil waitToil = Toils_General.Wait(duration).WithProgressBarToilDelay(TargetIndex.A).PlaySustainerOrSound(SoundDefOf.Interact_Tend);

            yield return(waitToil);

            Toil stabilizeToil = new Toil();

            stabilizeToil.initAction = delegate
            {
                float xp = (!Patient.RaceProps.Animal) ? 125f : 50f * Medicine.def.MedicineTendXpGainFactor;
                pawn.skills.Learn(SkillDefOf.Medicine, xp);
                foreach (Hediff curInjury in from x in Patient.health.hediffSet.GetHediffsTendable() orderby x.BleedRate descending select x)
                {
                    if (curInjury.CanBeStabilized())
                    {
                        HediffComp_Stabilize comp = curInjury.TryGetComp <HediffComp_Stabilize>();
                        comp.Stabilize(pawn, Medicine);
                        break;
                    }
                }
            };
            stabilizeToil.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(stabilizeToil);

            yield return(Toils_Jump.Jump(waitToil));
        }
        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));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (pawn.Faction != Faction.OfPlayer)
            {
                TargetThingB.SetForbidden(false, false);
                this.FailOnDestroyedOrNull(TargetIndex.A);
                this.FailOnDestroyedOrNull(TargetIndex.B);
            }
            else
            {
                this.FailOnDestroyedNullOrForbidden(TargetIndex.A);
                this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            }

            // Haul ammo
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.A, null, false));

            // Wait in place
            Toil waitToil = new Toil();

            waitToil.initAction = delegate
            {
                waitToil.actor.pather.StopDead();
                compReloader.TryStartReload();
            };
            waitToil.defaultCompleteMode = ToilCompleteMode.Delay;
            waitToil.defaultDuration     = Mathf.CeilToInt(compReloader.Props.reloadTicks / pawn.GetStatValue(CE_StatDefOf.ReloadSpeed));
            yield return(waitToil.WithProgressBarToilDelay(TargetIndex.A));

            //Actual reloader
            Toil reloadToil = new Toil();

            reloadToil.defaultCompleteMode = ToilCompleteMode.Instant;
            reloadToil.initAction          = delegate
            {
                Building_TurretGunCE turret = TargetThingA as Building_TurretGunCE;
                if (compReloader != null && turret.compAmmo != null)
                {
                    compReloader.LoadAmmo(TargetThingB);
                }
            };
            reloadToil.EndOnDespawnedOrNull(TargetIndex.B);
            yield return(reloadToil);
        }
示例#22
0
        // Token: 0x06000373 RID: 883 RVA: 0x0001EF58 File Offset: 0x0001D358
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnIncapable(PawnCapacityDefOf.Manipulation);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carryToCell);

            /*
             * yield return new Toil
             * {
             *  initAction = delegate ()
             *  {
             *      if (this.pawn.Position.OnEdge(this.pawn.Map) || this.pawn.Map.exitMapGrid.IsExitCell(this.pawn.Position))
             *      {
             *          this.pawn.ExitMap(true, CellRect.WholeMap(base.Map).GetClosestEdge(this.pawn.Position));
             *      }
             *  },
             *  defaultCompleteMode = ToilCompleteMode.Instant
             * };
             */
            //    yield return Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.OnCell);
            if (Takee == null || Takee.Dead)
            {
                yield break;
            }
            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, false));

            Toil prepare = Toils_General.Wait(this.useDuration, TargetIndex.A);

            prepare.NPCWithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            //    prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell);
            prepare.WithEffect(EffecterDefOf.Vomit, TargetIndex.A);
            prepare.PlaySustainerOrSound(() => SoundDefOf.Vomit);
            yield return(prepare);

            Toil use = new Toil();

            use.initAction = delegate()
            {
                Pawn actor      = use.actor;
                Pawn Infectable = (Pawn)actor.CurJob.targetA.Thing;
                Infectable.health.AddHediff(heCocDeff);
            };
            use.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(use);

            yield break;
        }
示例#23
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(10, TargetIndex.None));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    Pawn otherPawn = this.OtherPawn;
                    if (!otherPawn.inventory.UnloadEverything)
                    {
                        base.EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        ThingCount firstUnloadableThing = otherPawn.inventory.FirstUnloadableThing;
                        IntVec3 c;
                        if (!firstUnloadableThing.Thing.def.EverStorable(false) || !this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, this.pawn, out c))
                        {
                            Thing thing;
                            otherPawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                            base.EndJobWith(JobCondition.Succeeded);
                            if (thing != null)
                            {
                                thing.SetForbidden(false, false);
                            }
                        }
                        else
                        {
                            Thing thing2;
                            otherPawn.inventory.innerContainer.TryTransferToContainer(firstUnloadableThing.Thing, this.pawn.carryTracker.innerContainer, firstUnloadableThing.Count, out thing2, true);
                            this.job.count = thing2.stackCount;
                            this.job.SetTarget(TargetIndex.B, thing2);
                            this.job.SetTarget(TargetIndex.C, c);
                            firstUnloadableThing.Thing.SetForbidden(false, false);
                        }
                    }
                }
            });

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, true));

            yield break;
        }
示例#24
0
        // Token: 0x06000045 RID: 69 RVA: 0x0000409D File Offset: 0x0000229D
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(Feedable);
            AddEndCondition(delegate
            {
                if (AQComp.foodPct > 0.95f)
                {
                    return(JobCondition.Succeeded);
                }
                return(JobCondition.Ongoing);
            });
            yield return(Toils_General.DoAtomic(delegate
            {
                job.count = AQUtility.GetFoodNumToFullyFeed(AQComp);
            }));

            Toil reserveFood = Toils_Reserve.Reserve(Foodybits, 1, -1, null);

            yield return(reserveFood);

            yield return(Toils_Goto.GotoThing(Foodybits, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(Foodybits).FailOnSomeonePhysicallyInteracting(Foodybits));

            yield return(Toils_Haul.StartCarryThing(Foodybits, false, true, false).FailOnDestroyedNullOrForbidden(Foodybits));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveFood, Foodybits, TargetIndex.None, true, null));

            yield return(Toils_Goto.GotoThing(Feedable, PathEndMode.Touch));

            yield return(Toils_General.Wait(FeedDuration, TargetIndex.None).FailOnDestroyedNullOrForbidden(Foodybits).FailOnDestroyedNullOrForbidden(Feedable).FailOnCannotTouch(Feedable, PathEndMode.Touch).WithProgressBarToilDelay(Feedable, false, -0.5f));

            yield return(Toils_AQFeed.FinalizeFeeding(Feedable, Foodybits));

            if (!job.GetTarget(Foodybits).HasThing)
            {
                EndJobWith(JobCondition.Incompletable);
            }
            yield return(Toils_Reserve.Reserve(Foodybits, 1, -1, null));

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            yield return(Toils_Goto.GotoThing(Foodybits, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(Foodybits, false, false, false));

            Toil carry = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carry, true, false));

            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOn(delegate
            {
                return(DestType == HaulLocation.None ||
                       !Info.ShouldHaulTrash ||
                       Info.currentLord != pawn.GetLord() ||
                       !Info.AnyCarriersCanCarry(this.ThingToHaul));
            });

            Toil reserve = Toils_Reserve.Reserve(TargetIndex.A);

            yield return(reserve); // reserve if not already reserved by this pawn

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(this.DetermineNumToHaul());

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserve, TargetIndex.A, TargetIndex.None, false, t => Info.thingsToHaul.Contains(t)));

            if (DestType == HaulLocation.ToCarriers)
            {
                Toil findCarrier = FindCarrier();

                yield return(findCarrier);

                //yield return Toils_Reserve.Reserve(TargetIndex.B);

                yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch)
                             .JumpIf(() => !JobDriver_PrepareCaravan_GatherItems.IsUsableCarrier(this.Carrier, this.pawn, false), findCarrier));

                yield return(Toils_General.Wait(PlaceInInventoryDuration).WithProgressBarToilDelay(TargetIndex.B, false, -0.5f));

                yield return(PlaceTargetInCarrierInventory());
            }
            else if (DestType == HaulLocation.ToTrash || DestType == HaulLocation.ToColony)
            {
                Toil findTrashSpot = FindTrashSpot();

                yield return(findTrashSpot);

                yield return(Toils_Reserve.Reserve(TargetIndex.B));

                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.Touch));

                yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, findTrashSpot, false));
            }

            yield return(RemoveThingToHaulFromInfo());
        }
示例#26
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)
                         .FailOnDestroyedNullOrForbidden(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, null, storageMode: false));

            var repair = new Toil
            {
                initAction = () =>
                {
                    ticksToNextRepair = WarmupTicks;
                    workLeft          = TotalNeededWork;
                },
                tickAction = () =>
                {
                    if (InstallTarget is Pawn pawnTarget)
                    {
                        pawnTarget.pather.StopDead();
                    }
                    pawn.rotationTracker.FaceCell(TargetB.Cell);
                    var actor = pawn;
                    actor.skills.Learn(SkillDefOf.Construction, 0.275f, false);
                    var statValue = actor.GetStatValue(StatDefOf.ConstructionSpeed, true);
                    ticksToNextRepair -= statValue;
                    if (ticksToNextRepair <= 0f)
                    {
                        ticksToNextRepair += TicksBetweenRepairs;
                        workLeft          -= 20 + actor.GetStatValue(StatDefOf.ConstructionSpeed, true);
                        if (workLeft <= 0)
                        {
                            actor.records.Increment(RecordDefOf.ThingsInstalled);
                            InstallComp.Notify_Installed(actor, InstallTarget);
                            actor.jobs.EndCurrentJob(JobCondition.Succeeded, true);
                        }
                    }
                },
            };

            repair.FailOnCannotTouch(TargetIndex.B, PathEndMode.Touch);
            repair.WithEffect(InstallComp.Props.workEffect, TargetIndex.B);
            repair.WithProgressBar(TargetIndex.B, () => WorkDone / TotalNeededWork, false, -0.5f);
            repair.defaultCompleteMode = ToilCompleteMode.Never;
            yield return(repair);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.pawn.jobs.curJob.count = 1;
            this.FailOnDestroyedOrNull(TargetIndex.A);
            if (!base.TargetThingA.IsForbidden(this.pawn))
            {
                this.FailOnForbidden(TargetIndex.A);
            }
            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));

            Toil toil = Toils_Reserve.Reserve(TargetIndex.A, 1);

            yield return(toil);

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false));

            if (base.CurJob.haulOpportunisticDuplicates)
            {
                yield return(Toils_Haul.CheckForGetOpportunityDuplicate(toil, TargetIndex.A, TargetIndex.B, false, null));
            }
            Toil toil3 = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(toil3);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, toil3, true));



            Toil toil2 = new Toil();

            toil2.defaultCompleteMode = ToilCompleteMode.Delay;
            toil2.defaultDuration     = 100;
            toil2.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            toil2.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            yield return(toil2);

            yield return(new Toil
            {
                initAction = delegate
                {
                    Pawn actor = this.pawn;
                    CompUsable compUsable = actor.CurJob.targetA.Thing.TryGetComp <CompUsable>();
                    compUsable.UsedBy(actor);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
示例#28
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(240).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Building_Beehouse buildingbeehouse = (Building_Beehouse)this.job.GetTarget(TargetIndex.A).Thing;
                    buildingbeehouse.BeehouseIsFull = false;
                    Thing newComb = ThingMaker.MakeThing(DecideRandomComb());
                    GenSpawn.Spawn(newComb, buildingbeehouse.Position - GenAdj.CardinalDirections[0], buildingbeehouse.Map);

                    StoragePriority currentPriority = StoreUtility.CurrentStoragePriorityOf(newComb);
                    IntVec3 c;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(newComb, this.pawn, this.Map, currentPriority, this.pawn.Faction, out c, true))
                    {
                        this.job.SetTarget(TargetIndex.C, c);
                        this.job.SetTarget(TargetIndex.B, newComb);
                        this.job.count = newComb.stackCount;
                        buildingbeehouse.tickCounter = 0;
                    }
                    else
                    {
                        this.EndJobWith(JobCondition.Incompletable);
                        buildingbeehouse.BeehouseIsFull = false;
                        buildingbeehouse.tickCounter = 0;
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null));

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false, false));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, true));
        }
示例#29
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedNullOrForbidden(PrisonerInd);
            this.FailOnBurningImmobile(HaulToInd);
            if (!pawn.CurJob.GetTarget(PrisonerInd).Thing.IsForbidden(pawn))
            {
                this.FailOnForbidden(PrisonerInd);
            }
            this.AddEndCondition(() =>
            {
                // Cancel out if the prisoner enters the target room on their own
                var prisonerRoom = pawn.jobs.curJob.GetTarget(PrisonerInd).Thing.Position.GetRoom();
                var targetRoom   = pawn.jobs.curJob.GetTarget(HaulToInd).Cell.GetRoom();
                return(prisonerRoom == targetRoom ? JobCondition.Succeeded : JobCondition.Ongoing);
            });
            yield return(Toils_Reserve.Reserve(HaulToInd, 1));

            yield return(Toils_Reserve.Reserve(PrisonerInd, 1));

            var toilGoto = Toils_Goto.GotoThing(PrisonerInd, PathEndMode.ClosestTouch)
                           .FailOn(() =>
            {
                Job job = pawn.jobs.curJob;
                if (job.haulMode == HaulMode.ToCellStorage)
                {
                    Thing prisoner = job.GetTarget(PrisonerInd).Thing;
                    if (!pawn.jobs.curJob.GetTarget(HaulToInd).Cell.IsValidStorageFor(prisoner))
                    {
                        return(true);
                    }
                }
                return(false);
            });

            yield return(toilGoto);

            yield return(Toils_Haul.StartCarryThing(PrisonerInd));

            var carryToCell = Toils_Haul.CarryHauledThingToCell(HaulToInd);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(HaulToInd, carryToCell, true));

            yield return(Toils_Prisoner.NoLongerNeedsHauling(PrisonerInd));

            yield return(Toils_Reserve.Release(HaulToInd));

            yield return(Toils_Reserve.Release(PrisonerInd));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            AddEndCondition(delegate
            {
                Thing thing = GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing;
                if (thing is Building && !thing.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });
            this.FailOnBurningImmobile(TargetIndex.A);

            //send pawn to grower
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(Toils_General.WaitWith(TargetIndex.A, 200, true));

            //Try to drop the product on the floor, if specified by the active Bill. If successful, end Job.
            yield return(QEEToils.TryDropProductOnFloor(TargetThingA as Building_GrowerBase_WorkTable));

            //The product is going to a stockpile. Create product, decrement bill counter, and start carrying it.
            //If target stockpile full, drop on ground and end Job, as a fallback.
            yield return(QEEToils.StartCarryProductToStockpile(TargetThingA as Building_GrowerBase_WorkTable));

            //if we've reached this far, an output stockpile was specified in the Bill options and a valid cell was found
            //  in the toil above
            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));

            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)
                {
                    Map.resourceCounter.UpdateResourceCounts();
                }
            };
            yield return(recount);
        }