protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedNullOrForbidden(TargetIndex.B); this.FailOn(() => TransporterUtility.WasLoadingCanceled(this.$this.Container)); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A); yield return(getToHaulTarget); yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false)); 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)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(CarryThingIndex); this.FailOnDestroyedNullOrForbidden(DestIndex); this.FailOn(() => TransporterUtility.WasLoadingCanceled(Container)); this.FailOn(() => { var thingOwner = Container.TryGetInnerInteractableThingOwner(); if (thingOwner != null && !thingOwner.CanAcceptAnyOf(ThingToCarry)) { return(true); } // e.g. grave var haulDestination = Container as IHaulDestination; if (haulDestination != null && !haulDestination.Accepts(ThingToCarry)) { return(true); } return(false); }); var getToHaulTarget = Toils_Goto.GotoThing(CarryThingIndex, PathEndMode.ClosestTouch) .FailOnSomeonePhysicallyInteracting(CarryThingIndex); yield return(getToHaulTarget); yield return(Toils_Construct.UninstallIfMinifiable(CarryThingIndex) .FailOnSomeonePhysicallyInteracting(CarryThingIndex)); yield return(Toils_Haul.StartCarryThing(CarryThingIndex, subtractNumTakenFromJobCount: true)); yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, CarryThingIndex)); Toil carryToContainer = Toils_Haul.CarryHauledThingToContainer(); yield return(carryToContainer); yield return(Toils_Goto.MoveOffTargetBlueprint(DestIndex)); //Prepare { var prepare = Toils_General.Wait(Duration, face: DestIndex); prepare.WithProgressBarToilDelay(DestIndex); yield return(prepare); } yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(DestIndex, PrimaryDestIndex)); yield return(Toils_Haul.DepositHauledThingInContainer(DestIndex, PrimaryDestIndex)); yield return(Toils_Haul.JumpToCarryToNextContainerIfPossible(carryToContainer, PrimaryDestIndex)); }
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() { //Clean up any spare blueprints AddFinishAction(delegate { Blueprint blueprint = TargetB.Thing as Blueprint; if (!blueprint?.Destroyed ?? false) { Log.Message($"Cleaning up {blueprint}"); blueprint.Destroy(DestroyMode.Vanish); } }); job.count = 1; Thing bedroll = pawn.CurJob.targetA.Thing; if (bedroll.Spawned) { Log.Message($"{pawn} needs to pick up {bedroll}"); yield return(Toils_Reserve.Reserve(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); yield return(Toils_Haul.TakeToInventory(TargetIndex.A, 1)); } yield return(Toils_Misc.TakeItemFromInventoryToCarrier(pawn, TargetIndex.A)); yield return(Toils_Haul.CarryHauledThingToContainer()); yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B, TargetIndex.C)); //yield return Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C);//1.0 game destroys minified thing, but its job still does Deposit? Toil restInBed = new Toil(); restInBed.initAction = delegate { Pawn pawn = restInBed.actor; Job curJob = pawn.jobs.curJob; Building_Bed bed = curJob.targetB.Thing as Building_Bed; pawn.Map.GetComponent <PlacedBedsMapComponent>().placedBeds[pawn] = bed; pawn.ownership?.ClaimBedIfNonMedical(bed); Job restJob = new Job(RimWorld.JobDefOf.LayDown, TargetB); pawn.jobs.StartJob(restJob, JobCondition.Succeeded); }; yield return(restInBed); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedNullOrForbidden(TargetIndex.B); this.FailOn(() => TransporterUtility.WasLoadingCanceled(this.Container)); this.FailOn(delegate() { ThingOwner thingOwner = this.Container.TryGetInnerInteractableThingOwner(); bool result; if (thingOwner != null && !thingOwner.CanAcceptAnyOf(this.ThingToCarry, true)) { result = true; } else { IHaulDestination haulDestination = this.Container as IHaulDestination; result = (haulDestination != null && !haulDestination.Accepts(this.ThingToCarry)); } return(result); }); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A); yield return(getToHaulTarget); yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false)); yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A)); Toil carryToContainer = Toils_Haul.CarryHauledThingToContainer(); yield return(carryToContainer); yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B)); Toil prepare = Toils_General.Wait(this.Duration, TargetIndex.B); prepare.WithProgressBarToilDelay(TargetIndex.B, false, -0.5f); yield return(prepare); 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)); 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; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedNullOrForbidden(TargetIndex.B); this.FailOn(() => TransporterUtility.WasLoadingCanceled(Container)); this.FailOn(delegate { ThingOwner thingOwner = Container.TryGetInnerInteractableThingOwner(); if (thingOwner != null && !thingOwner.CanAcceptAnyOf(ThingToCarry)) { return(true); } IHaulDestination haulDestination = Container as IHaulDestination; return((haulDestination != null && !haulDestination.Accepts(ThingToCarry)) ? true : false); }); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A); yield return(getToHaulTarget); yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A, putRemainderInQueue: false, subtractNumTakenFromJobCount: true)); yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A)); Toil carryToContainer = Toils_Haul.CarryHauledThingToContainer(); yield return(carryToContainer); yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B)); Toil toil = Toils_General.Wait(Duration, TargetIndex.B); toil.WithProgressBarToilDelay(TargetIndex.B); yield return(toil); 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)); }
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)); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedNullOrForbidden(TargetIndex.B); this.FailOn(() => TransporterUtility.WasLoadingCanceled(base.Container)); this.FailOn(delegate() { ThingOwner thingOwner = base.Container.TryGetInnerInteractableThingOwner(); bool result; if (thingOwner != null && !thingOwner.CanAcceptAnyOf(base.ThingToCarry, true)) { result = true; } else { IHaulDestination haulDestination = base.Container as IHaulDestination; result = (haulDestination != null && !haulDestination.Accepts(base.ThingToCarry)); } return(result); }); getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A); this.$current = getToHaulTarget; if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: this.$current = Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A); if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$current = Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false); if (!this.$disposing) { this.$PC = 3; } return(true); case 3u: this.$current = Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A); if (!this.$disposing) { this.$PC = 4; } return(true); case 4u: carryToContainer = Toils_Haul.CarryHauledThingToContainer(); this.$current = carryToContainer; if (!this.$disposing) { this.$PC = 5; } return(true); case 5u: this.$current = Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B); if (!this.$disposing) { this.$PC = 6; } return(true); case 6u: prepare = Toils_General.Wait(base.Duration, TargetIndex.B); prepare.WithProgressBarToilDelay(TargetIndex.B, false, -0.5f); this.$current = prepare; if (!this.$disposing) { this.$PC = 7; } return(true); case 7u: this.$current = Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B, TargetIndex.C); if (!this.$disposing) { this.$PC = 8; } return(true); case 8u: this.$current = Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C); if (!this.$disposing) { this.$PC = 9; } return(true); case 9u: this.$current = Toils_Haul.JumpToCarryToNextContainerIfPossible(carryToContainer, TargetIndex.C); if (!this.$disposing) { this.$PC = 10; } return(true); case 10u: this.$PC = -1; break; } return(false); }