public override IEnumerable <Toil> MakeNewToils() { this.FailOn(() => Comrade.Dead); this.FailOnNotDowned(TargetIndex.A); this.FailOnDestroyedOrNull(TargetIndex.A); yield return(Toils_Goto.Goto(TargetIndex.A, PathEndMode.ClosestTouch)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A)); yield return(Toils_Goto.GotoCell(Position, PathEndMode.OnCell)); yield return(Toils_Haul.PlaceCarriedThingInCellFacing(TargetIndex.B)); yield return(Toils_General.Do(() => { var factionStore = pawn.factionInt.GetDataStore(); factionStore.alreadyRescuedPawns.Add(new PawnTimeSignature(Comrade)); pawn.GetLord().Notify_ReachedDutyLocation(pawn); })); }
protected override IEnumerable <Toil> MakeNewToils() { var ingList = job.GetTargetQueue(IngredientInd); var ingCountList = job.countQueue; // this.job.SetTarget(IngredientPlaceCellInd, this.TargetA.Thing.InteractionCell); var startToil = Toils_General.Do( () => { job.SetTarget(IngredientInd, ingList[0].Thing); job.count = ingCountList[0]; ingList.RemoveAt(0); ingCountList.RemoveAt(0); }); // 材料キューの先頭を取り出してセット yield return(startToil); // 材料の置き場所へ移動 var gotoToil = Toils_Goto.GotoThing(IngredientInd, PathEndMode.Touch); yield return(gotoToil); // 材料を運ぶ yield return(Toils_Haul.StartCarryThing(IngredientInd)); // 運ぶものリストの中に同種の材料があり、まだ物を持てる場合、設備へ持っていく前に取りに行く yield return(Toils_General.Do( () => { var actor = pawn; var curJob = actor.jobs.curJob; var targetQueue = curJob.GetTargetQueue(IngredientInd); if (targetQueue.NullOrEmpty()) { return; } if (curJob.count <= 0) { return; } if (actor.carryTracker.CarriedThing == null) { Log.Error( "JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something."); return; } if (actor.carryTracker.AvailableStackSpace(actor.carryTracker.CarriedThing.def) <= 0) { return; } for (var i = 0; i < targetQueue.Count; i++) { if (!GenAI.CanUseItemForWork(actor, targetQueue[i].Thing)) { actor.jobs.EndCurrentJob(JobCondition.Incompletable); return; } if (targetQueue[i].Thing.def != actor.carryTracker.CarriedThing.def) { continue; } curJob.SetTarget(IngredientInd, targetQueue[i].Thing); curJob.count = curJob.countQueue[i]; targetQueue.RemoveAt(i); curJob.countQueue.RemoveAt(i); actor.jobs.curDriver.JumpToToil(gotoToil); break; } })); // 運ぶ yield return(Toils_Haul.CarryHauledThingToCell(IngredientPlaceCellInd)); // 運んだものリスト(使用素材)に追加 yield return(Toils_Mizu.AddPlacedThing()); // 運んだものを置く yield return(Toils_Haul.PlaceCarriedThingInCellFacing(BillGiverInd)); // まだ材料があるならさらに運ぶ yield return(Toils_General.Do( () => { if (job.GetTargetQueue(IngredientInd).Count > 0) { pawn.jobs.curDriver.JumpToToil(startToil); } })); // レシピ実行 yield return(Toils_Recipe.DoRecipeWork()); // 水の注入完了処理 yield return(Toils_Mizu.FinishPourRecipe(BillGiverInd)); }
protected override IEnumerable <Toil> MakeNewToils() { this.AddFinishAction(delegate() { if (Patient.CurrentBed() == Bed && Patient.CurJobDef == JobDefOf.LayDown) { Patient.jobs.EndCurrentJob(JobCondition.Succeeded); } }); this.FailOnDestroyedNullOrForbidden(TargetIndex.A); this.FailOnDestroyedNullOrForbidden(TargetIndex.B); this.FailOnDestroyedNullOrForbidden(TargetIndex.C); yield return(Toils_Reserve.Reserve(TargetIndex.A)); yield return(Toils_Reserve.Reserve(TargetIndex.B)); yield return(Toils_Reserve.Reserve(TargetIndex.C)); //Go and get the thing to carry. yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.C, PathEndMode.ClosestTouch)); yield return(Toils_Haul.PlaceCarriedThingInCellFacing(TargetIndex.C)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.C, PathEndMode.ClosestTouch)); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, null, false)); yield return(Toils_Reserve.Release(TargetIndex.C)); Toil applyBrainTemplateToil = new Toil() { defaultCompleteMode = ToilCompleteMode.Never, initAction = delegate() { Patient.pather.StopDead(); Patient.jobs.StartJob(new Job(JobDefOf.LayDown, TargetC) { forceSleep = true }); }, tickAction = delegate() { ticksWork -= 1f * pawn.GetStatValue(StatDefOf.ResearchSpeed); if (ticksWork <= 0) { BrainManipUtility.ApplyBrainScanTemplateOnPawn(Patient, BrainTemplate); Patient.jobs.EndCurrentJob(JobCondition.Succeeded); //Give headache Patient.health.AddHediff(QEHediffDefOf.QE_Headache, Patient.health.hediffSet.GetBrain()); } } }.WithProgressBar(TargetIndex.A, () => (workRequired - ticksWork) / workRequired).WithEffect(EffecterDefOf.Research, TargetIndex.A); applyBrainTemplateToil.AddPreInitAction(delegate() { ticksWork = workRequired; workStarted = true; //Log.Message("preInitAction: ticksWork = " + ticksWork); }); applyBrainTemplateToil.AddEndCondition(delegate() { if (workStarted && ticksWork <= 0) { //Log.Message("Succeeded: ticksWork = " + ticksWork); return(JobCondition.Succeeded); } //Log.Message("Ongoing: ticksWork = " + ticksWork); return(JobCondition.Ongoing); }); applyBrainTemplateToil.AddFailCondition(() => workStarted && Patient.CurJobDef != JobDefOf.LayDown); yield return(applyBrainTemplateToil); }