protected override IEnumerable <Toil> MakeNewToils() { /// //Set fail conditions /// this.FailOnDestroyedOrNull(CartInd); //Note we only fail on forbidden if the target doesn't start that way //This helps haul-aside jobs on forbidden items if (!TargetThingA.IsForbidden(pawn.Faction)) { this.FailOnForbidden(CartInd); } Vehicle_Cart cart = TargetThingA as Vehicle_Cart; /// //Define Toil /// Toil toilGoToCell = Toils_Goto.GotoCell(StoreCellInd, PathEndMode.ClosestTouch); /// //Toils Start /// //Reserve thing to be stored and storage cell yield return(Toils_Reserve.Reserve(CartInd)); yield return(Toils_Reserve.Reserve(StoreCellInd)); //JumpIf already mounted yield return(Toils_Jump.JumpIf(toilGoToCell, () => { return (cart.GetComp <CompMountable>().Driver == pawn) ? true : false; })); //Mount on Target yield return(Toils_Goto.GotoThing(CartInd, PathEndMode.ClosestTouch) .FailOnDestroyedOrNull(CartInd)); yield return(Toils_Cart.MountOn(CartInd)); //Dismount yield return(toilGoToCell); yield return(Toils_Cart.DismountAt(CartInd, StoreCellInd)); }
protected override IEnumerable <Toil> MakeNewToils() { //this.FailOnDespawnedNullOrForbidden(TargetIndex.A); //this.FailOn(() => !this.Patient.InBed() || !this.Patient.Awake()); //if (WheelChair != null) //{ // this.FailOnDespawnedNullOrForbidden(TargetIndex.B); //} //yield return Toils_Reserve.Reserve(TargetIndex.A, 1); //if (WheelChair != null) //{ // yield return Toils_Reserve.Reserve(TargetIndex.B, 1); // yield return Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell); //} //else //{ // yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); //} //yield return Toils_Interpersonal.WaitToBeAbleToInteract(this.pawn); //yield return new Toil //{ // tickAction = delegate // { // this.Patient.needs.joy.GainJoy(this.CurJob.def.joyGainRate * 0.000144f, this.CurJob.def.joyKind); // if (this.pawn.IsHashIntervalTick(320)) // { // InteractionDef intDef = (Rand.Value >= 0.8f) ? InteractionDefOf.DeepTalk : InteractionDefOf.Chitchat; // this.pawn.interactions.TryInteractWith(this.Patient, intDef); // } // this.pawn.Drawer.rotator.FaceCell(this.Patient.Position); // this.pawn.GainComfortFromCellIfPossible(); // JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.None, 1f); // if (this.pawn.needs.joy.CurLevelPercentage > 0.9999f && this.Patient.needs.joy.CurLevelPercentage > 0.9999f) // { // this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded); // } // }, // socialMode = RandomSocialMode.Off, // defaultCompleteMode = ToilCompleteMode.Delay, // defaultDuration = base.CurJob.def.joyDuration //}; //yield break; this.FailOn(() => !Patient.InBed() || !Patient.Awake()); this.FailOnDestroyedOrNull(TakeeIndex); this.FailOnDestroyedOrNull(WheelChairIndex); this.FailOnAggroMentalState(TakeeIndex); yield return(Toils_Reserve.Reserve(TakeeIndex)); yield return(Toils_Reserve.Reserve(WheelChairIndex)); yield return(Toils_Goto.GotoThing(WheelChairIndex, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(WheelChairIndex).FailOnDespawnedNullOrForbidden(TakeeIndex).FailOn(() => CurJob.def == JobDefOf.Arrest && !Patient.CanBeArrested()).FailOn(() => !pawn.CanReach(WheelChair, PathEndMode.OnCell, Danger.Some)).FailOnSomeonePhysicallyInteracting(WheelChairIndex)); yield return(Toils_Haul.StartCarryThing(WheelChairIndex)); yield return(Toils_Goto.GotoThing(TakeeIndex, PathEndMode.InteractionCell)); yield return(Toils_Reserve.Release(WheelChairIndex)); yield return(new Toil { initAction = delegate { IntVec3 position = WheelChair.InteractionCell; Thing thing; pawn.carrier.TryDropCarriedThing(position, ThingPlaceMode.Direct, out thing); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield return(Toils_Cart.MountOtherOn(WheelChairIndex, Patient)); yield return(new Toil { initAction = delegate { foreach (var missingPart in Patient.health.hediffSet.GetMissingPartsCommonAncestors()) { if (missingPart.Part.def == BodyPartDefOf.LeftLeg || missingPart.Part.def == BodyPartDefOf.RightLeg) { Patient.health.RestorePart(missingPart.Part); Patient.health.AddHediff(HediffDef.Named("HediffWheelChair"), missingPart.Part); break; } } }, defaultCompleteMode = ToilCompleteMode.Delay }); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { Vehicle_Cart cart = CurJob.GetTarget(CartInd).Thing as Vehicle_Cart; /// //Set fail conditions /// this.FailOnDestroyedOrNull(CartInd); //Note we only fail on forbidden if the target doesn't start that way //This helps haul-aside jobs on forbidden items if (!TargetThingA.IsForbidden(pawn.Faction)) { this.FailOnForbidden(CartInd); } /// //Define Toil /// Toil findStoreCellForCart = Toils_Cart.FindStoreCellForCart(CartInd); Toil checkCartEmpty = Toils_Jump.JumpIf(findStoreCellForCart, () => cart.storage.Count <= 0); Toil checkStoreCellEmpty = Toils_Jump.JumpIf(findStoreCellForCart, () => CurJob.GetTargetQueue(StoreCellInd).NullOrEmpty()); Toil checkHaulableEmpty = Toils_Jump.JumpIf(checkStoreCellEmpty, () => CurJob.GetTargetQueue(HaulableInd).NullOrEmpty()); /// //Toils Start /// //Reserve thing to be stored and storage cell yield return(Toils_Reserve.Reserve(CartInd)); yield return(Toils_Reserve.ReserveQueue(HaulableInd)); yield return(Toils_Reserve.ReserveQueue(StoreCellInd)); //JumpIf already mounted yield return(Toils_Jump.JumpIf(checkHaulableEmpty, () => { return (cart.GetComp <CompMountable>().Driver == pawn) ? true : false; })); //Mount on Target yield return(Toils_Goto.GotoThing(CartInd, PathEndMode.ClosestTouch) .FailOnDestroyedOrNull(CartInd)); yield return(Toils_Cart.MountOn(CartInd)); //JumpIf checkStoreCellEmpty yield return(checkHaulableEmpty); //Collect TargetQueue { Toil extractA = Toils_Collect.Extract(HaulableInd); yield return(extractA); Toil gotoThing = Toils_Goto.GotoThing(HaulableInd, PathEndMode.ClosestTouch) .FailOnDestroyedOrNull(HaulableInd); yield return(gotoThing); yield return(Toils_Collect.CollectInCarrier(CartInd, HaulableInd)); yield return(Toils_Collect.CheckDuplicates(gotoThing, CartInd, HaulableInd)); yield return(Toils_Jump.JumpIfHaveTargetInQueue(HaulableInd, extractA)); } //JumpIf findStoreCellForCart yield return(checkStoreCellEmpty); //Drop TargetQueue { yield return(checkCartEmpty); Toil extractB = Toils_Collect.Extract(StoreCellInd); yield return(extractB); Toil gotoCell = Toils_Goto.GotoCell(StoreCellInd, PathEndMode.ClosestTouch); yield return(gotoCell); yield return(Toils_Collect.DropTheCarriedInCell(StoreCellInd, ThingPlaceMode.Direct, CartInd)); yield return(Toils_Jump.JumpIfHaveTargetInQueue(StoreCellInd, checkCartEmpty)); yield return(Toils_Collect.CheckNeedStorageCell(gotoCell, CartInd, StoreCellInd)); } yield return(findStoreCellForCart); yield return(Toils_Goto.GotoCell(StoreCellInd, PathEndMode.OnCell)); yield return(Toils_Cart.DismountAt(CartInd, StoreCellInd)); }
protected override IEnumerable <Toil> MakeNewToils() { Vehicle_Cart cart = CurJob.GetTarget(CartInd).Thing as Vehicle_Cart; Job jobNew = new Job(); /// //Set fail conditions /// this.FailOnDestroyed(CartInd); this.FailOn(() => !cart.mountableComp.IsMounted); //Note we only fail on forbidden if the target doesn't start that way //This helps haul-aside jobs on forbidden items if (!TargetThingA.IsForbidden(pawn.Faction)) { this.FailOnForbidden(CartInd); } /// //Define Toil /// Toil releaseAnimalCart = Toils_Cart.ReleaseAnimalCart(CartInd); Toil checkCartEmpty = Toils_Jump.JumpIf(releaseAnimalCart, () => cart.storage.Count <= 0); Toil checkStoreCellEmpty = Toils_Jump.JumpIf(releaseAnimalCart, () => CurJob.GetTargetQueue(StoreCellInd).NullOrEmpty()); Toil checkHaulableEmpty = Toils_Jump.JumpIf(checkStoreCellEmpty, () => CurJob.GetTargetQueue(HaulableInd).NullOrEmpty()); /// //Toils Start /// //Reserve thing to be stored and storage cell yield return(Toils_Reserve.Reserve(CartInd)); yield return(Toils_Reserve.ReserveQueue(HaulableInd)); yield return(Toils_Reserve.ReserveQueue(StoreCellInd)); yield return(Toils_Goto.GotoThing(CartInd, PathEndMode.Touch) .FailOn(() => cart.Destroyed || !cart.TryGetComp <CompMountable>().IsMounted)); //JumpIf toilCheckStoreCellEmpty yield return(checkHaulableEmpty); //Collect TargetQueue { Toil extractA = Toils_Collect.Extract(HaulableInd); yield return(extractA); Toil callAnimalCartForCollect = Toils_Cart.CallAnimalCart(CartInd, HaulableInd) .FailOnDestroyed(HaulableInd); yield return(callAnimalCartForCollect); yield return(Toils_Goto.GotoThing(HaulableInd, PathEndMode.ClosestTouch) .FailOnDestroyed(HaulableInd)); yield return(Toils_Cart.WaitAnimalCart(CartInd, HaulableInd)); yield return(Toils_Collect.CollectInCarrier(CartInd, HaulableInd)); yield return(Toils_Collect.CheckDuplicates(callAnimalCartForCollect, CartInd, HaulableInd)); yield return(Toils_Jump.JumpIfHaveTargetInQueue(HaulableInd, extractA)); } //JumpIf releaseAnimalCart yield return(checkStoreCellEmpty); //Drop TargetQueue { yield return(checkCartEmpty); Toil extractB = Toils_Collect.Extract(StoreCellInd); yield return(extractB); Toil callAnimalCartForDrop = Toils_Cart.CallAnimalCart(CartInd, StoreCellInd); yield return(callAnimalCartForDrop); yield return(Toils_Goto.GotoCell(StoreCellInd, PathEndMode.ClosestTouch) .FailOnBurningImmobile(StoreCellInd)); yield return(Toils_Cart.WaitAnimalCart(CartInd, HaulableInd)); yield return(Toils_Collect.DropTheCarriedInCell(StoreCellInd, ThingPlaceMode.Direct, CartInd)); yield return(Toils_Jump.JumpIfHaveTargetInQueue(StoreCellInd, checkCartEmpty)); yield return(Toils_Collect.CheckNeedStorageCell(callAnimalCartForDrop, CartInd, StoreCellInd)); } yield return(releaseAnimalCart); }