protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDespawnedOrNull(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, 1, null));

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

            //yield return Toils_Reserve.Reserve(TargetIndex.B, 10, 1, null);
            //yield return Toils_Reserve.ReserveQueue(TargetIndex.B, 10, 1, null);
            Toil toil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            //toil.AddFailCondition(() => ShipFull(ship));
            toil.tickAction += delegate
            {
                if (this.ShipFull(ship))
                {
                    this.EndJobWith(JobCondition.Incompletable);
                }
            };
            yield return(toil);

            yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            Toil toilPickup = Toils_Haul.StartCarryThing(TargetIndex.A, false, true);//.FailOn(() => this.ShipFull(ship));

            yield return(toilPickup);

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(toil, TargetIndex.A));

            Toil toil2 = Toils_Haul.CarryHauledThingToContainer();

            toil2.tickAction += delegate
            {
                if (this.ShipFull(ship, false))
                {
                    this.EndJobWith(JobCondition.Incompletable);
                }
            };
            yield return(toil2);

            yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B));

            yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B));

            Toil toil3 = Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C);

            //toil3.AddFailCondition(() => this.ShipFull(ship));
            yield return(toil3);

            yield return(Toils_Haul.JumpToCarryToNextContainerIfPossible(toil2, TargetIndex.C));

            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            ShipBase ship = (ShipBase)TargetB;

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

            yield return(Toils_Reserve.ReserveQueue(TargetIndex.A, 1));

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

            yield return(Toils_Reserve.ReserveQueue(TargetIndex.B, 10));

            Toil toil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(toil);

            yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

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

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(toil, TargetIndex.A));

            Toil toil2 = Toils_Haul.CarryHauledThingToContainer();

            yield return(toil2);

            yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B));

            yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B));

            Toil finalToil = Toils_Haul.DepositHauledThingInContainer(TargetIndex.B);

            finalToil.AddFinishAction(delegate
            {
                ship.compShip.SubtractFromToLoadList(TargetA.Thing);
            });
            yield return(finalToil);

            yield return(Toils_Haul.JumpToCarryToNextContainerIfPossible(toil2));

            yield break;
        }
Exemplo n.º 3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            // This is mostly the same list of toils as HaulToContainer, except without reserving the container,
            // and also added some things from JobDriver_PrepareCaravan_GatherItems that handle coordination between
            // colonists. Many of the toils here seem to be intended for construction jobs and are thus probably not
            // necessary, but I'm leaving them in just in case. Possibly another mod will assume they're there, who knows.
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            this.FailOn(() => TransporterUtility.WasLoadingCanceled(this.Transporter));
            Toil reserve = Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null).FailOnDespawnedOrNull(TargetIndex.A);

            yield return(reserve);

            //yield return Toils_Reserve.ReserveQueue(TargetIndex.A, 1, -1, null);
            Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(getToHaulTarget);

            yield return(DetermineNumToHaul());

            yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

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

            yield return(AddCarriedThingToTransferables());

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserve, TargetIndex.A, TargetIndex.None, true, (Thing x) => Transferable.things.Contains(x)));

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A));

            Toil carryToContainer = Toils_Haul.CarryHauledThingToContainer();

            yield return(carryToContainer);

            yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B));

            yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B, TargetIndex.C));

            yield return(Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C));

            yield return(Toils_Haul.JumpToCarryToNextContainerIfPossible(carryToContainer, TargetIndex.C));
        }