// Token: 0x0600001C RID: 28 RVA: 0x00002779 File Offset: 0x00000979 protected override IEnumerable <Toil> MakeNewToils() { bool haveChair = this.job.GetTarget(TargetIndex.A).HasThing; bool flag = haveChair; if (flag) { this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable); } yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell)); yield return(new Toil { tickAction = delegate() { JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.None, 1f, null); this.pawn.rotationTracker.FaceCell(this.job.GetTarget(TargetIndex.B).Cell); PawnUtility.GainComfortFromCellIfPossible(this.pawn); bool flag3 = this.pawn.IsHashIntervalTick(100); if (flag3) { this.pawn.jobs.CheckForJobOverride(); } }, defaultCompleteMode = ToilCompleteMode.Never, handlingFacing = true }); yield break; }
// Token: 0x06000015 RID: 21 RVA: 0x0000239B File Offset: 0x0000059B protected override IEnumerable <Toil> MakeNewToils() { yield return(this.InteractToil()); yield return(new Toil { tickAction = delegate() { bool flag = ((Building_Bell)this.pawn.mindState.duty.focus.Thing).currentState == Building_Bell.State.fight; if (flag) { JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.None, 1f, null); } PawnUtility.GainComfortFromCellIfPossible(this.pawn); bool flag2 = this.pawn.IsHashIntervalTick(100); if (flag2) { this.pawn.jobs.CheckForJobOverride(); } }, defaultCompleteMode = ToilCompleteMode.Never, handlingFacing = true }); yield break; }
// Token: 0x06000011 RID: 17 RVA: 0x0000232F File Offset: 0x0000052F protected override IEnumerable <Toil> MakeNewToils() { yield return(new Toil { tickAction = delegate() { PawnUtility.GainComfortFromCellIfPossible(this.pawn); bool flag = this.pawn.IsHashIntervalTick(100); if (flag) { this.pawn.jobs.CheckForJobOverride(); } }, defaultCompleteMode = ToilCompleteMode.Never }); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { base.AddEndCondition(delegate() { var thing = base.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile <JobDriver_DoBill>(TargetIndex.A); this.FailOn <JobDriver_DoBill>(delegate() { if (!(this.job.GetTarget(TargetIndex.A).Thing is IBillGiver billGiver)) { return(false); } if (this.job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } return(false); }); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); var tableThing = this.job.GetTarget(TargetIndex.A).Thing as Building_СontainmentBreach; CompRefuelable refuelableComp = tableThing.GetComp <CompRefuelable>(); Toil toil = new Toil(); toil.initAction = delegate() { this.job.bill.Notify_DoBillStarted(this.pawn); this.workCycleProgress = this.job.bill.recipe.workAmount; }; toil.tickAction = delegate() { this.workCycleProgress -= StatExtension.GetStatValue(this.pawn, StatDefOf.WorkToMake, true); tableThing.UsedThisTick(); if (!tableThing.CurrentlyUsableForBills() || (refuelableComp != null && !refuelableComp.HasFuel)) { this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true, true); } if (this.workCycleProgress <= 0f) { SkillDef workSkill = this.job.bill.recipe.workSkill; if (workSkill != null) { SkillRecord skill = this.pawn.skills.GetSkill(workSkill); if (skill != null) { skill.Learn(0.11f * this.job.bill.recipe.workSkillLearnFactor, false); } } GenSpawn.Spawn(tableThing.GetKorsolianToxin(this.job.bill.recipe), tableThing.InteractionCell, tableThing.Map, 0); Toils_Reserve.Release(TargetIndex.A); PawnUtility.GainComfortFromCellIfPossible(this.pawn, false); this.job.bill.Notify_IterationCompleted(this.pawn, null); this.ReadyForNextToil(); } }; toil.defaultCompleteMode = ToilCompleteMode.Never; ToilEffects.WithEffect(toil, () => this.job.bill.recipe.effectWorking, TargetIndex.A); ToilEffects.PlaySustainerOrSound(toil, () => toil.actor.CurJob.bill.recipe.soundWorking); ToilEffects.WithProgressBar(toil, TargetIndex.A, delegate() { return(PurpleIvyUtils.GetPercentageFromPartWhole (this.job.bill.recipe.workAmount - this.workCycleProgress, (int)this.job.bill.recipe.workAmount) / 100f); }, false, 0.5f); ToilFailConditions.FailOn <Toil>(toil, delegate() { IBillGiver billGiver = this.job.GetTarget(TargetIndex.A).Thing as IBillGiver; return(this.job.bill.suspended || this.job.bill.DeletedOrDereferenced || (billGiver != null && !billGiver.CurrentlyUsableForBills())); }); yield return(toil); yield break; }
public static Toil DoRecipeWork() { const int MinWorkDuration = 3000; const int CheckOverrideInterval = 1000; Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill driver = ((JobDriver_DoBill)actor.jobs.curDriver); UnfinishedThing uft = curJob.GetTarget(JobDriver_DoBill.IngredientInd).Thing as UnfinishedThing; //Set our work left //If we're starting from an already-initialized UnfinishedThing, just copy its workLeft into the driver //Otherwise, generate a new workLeft and copy it into the UnfinishedThing if (uft != null && uft.Initialized) { driver.workLeft = uft.workLeft; } else { driver.workLeft = curJob.bill.recipe.WorkAmountTotal(uft != null ? uft.Stuff : null); if (uft != null) { uft.workLeft = driver.workLeft; } } driver.billStartTick = Find.TickManager.TicksGame; driver.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); }; toil.tickAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill driver = ((JobDriver_DoBill)actor.jobs.curDriver); UnfinishedThing uft = curJob.GetTarget(JobDriver_DoBill.IngredientInd).Thing as UnfinishedThing; if (uft != null && uft.Destroyed) { actor.jobs.EndCurrentJob(JobCondition.Incompletable); return; } driver.ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); //Bill giver gets notification that we're working on it var bga = toil.actor.CurJob.GetTarget(JobDriver_DoBill.BillGiverInd).Thing as IBillGiverWithTickAction; if (bga != null) { bga.UsedThisTick(); } //Learn (only if the recipe uses unfinished thing to prevent the exploit with drafting/undrafting colonists and getting unlimited xp) if (curJob.RecipeDef.workSkill != null && curJob.RecipeDef.UsesUnfinishedThing) { actor.skills.Learn(curJob.RecipeDef.workSkill, SkillTuning.XpPerTickRecipeBase * curJob.RecipeDef.workSkillLearnFactor); } //Make some progress //Apply it to both the driver's workLeft and, if it exists, the UnfinishedThing's workLeft float progress = (curJob.RecipeDef.workSpeedStat == null) ? 1f : actor.GetStatValue(curJob.RecipeDef.workSpeedStat); if (curJob.RecipeDef.workTableSpeedStat != null) { var t = driver.BillGiver as Building_WorkTable; if (t != null) { progress *= t.GetStatValue(curJob.RecipeDef.workTableSpeedStat); } } if (DebugSettings.fastCrafting) { progress *= 30; } driver.workLeft -= progress; if (uft != null) { uft.workLeft = driver.workLeft; } PawnUtility.GainComfortFromCellIfPossible(actor); //End the toil if there is no more work left if (driver.workLeft <= 0) { driver.ReadyForNextToil(); } //Allow job override periodically if (curJob.bill.recipe.UsesUnfinishedThing) { int billTicks = Find.TickManager.TicksGame - driver.billStartTick; if (billTicks >= MinWorkDuration && billTicks % CheckOverrideInterval == 0) { actor.jobs.CheckForJobOverride(); } } }; toil.defaultCompleteMode = ToilCompleteMode.Never; toil.WithEffect(() => toil.actor.CurJob.bill.recipe.effectWorking, TargetIndex.A); toil.PlaySustainerOrSound(() => toil.actor.CurJob.bill.recipe.soundWorking); toil.WithProgressBar(JobDriver_DoBill.BillGiverInd, () => { var actor = toil.actor; var curJob = actor.CurJob; var uft = curJob.GetTarget(JobDriver_DoBill.IngredientInd).Thing as UnfinishedThing; return(1f - ((JobDriver_DoBill)actor.jobs.curDriver).workLeft / curJob.bill.recipe.WorkAmountTotal(uft != null ? uft.Stuff : null)); }); toil.FailOn(() => toil.actor.CurJob.bill.suspended); toil.activeSkill = () => toil.actor.CurJob.bill.recipe.workSkill; return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { base.AddEndCondition(delegate() { var thing = base.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile <JobDriver_DoBill>(TargetIndex.A); this.FailOn <JobDriver_DoBill>(delegate() { if (!(this.job.GetTarget(TargetIndex.A).Thing is IBillGiver billGiver)) { return(false); } if (this.job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } return(false); }); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); var tableThing = this.job.GetTarget(TargetIndex.A).Thing as Building_СontainmentBreach; CompRefuelable refuelableComp = tableThing.GetComp <CompRefuelable>(); Toil toil = new Toil(); toil.initAction = delegate() { this.job.bill.Notify_DoBillStarted(this.pawn); this.workCycleProgress = this.job.bill.recipe.workAmount; }; toil.tickAction = delegate() { this.workCycleProgress -= StatExtension.GetStatValue(this.pawn, StatDefOf.WorkToMake, true); tableThing.UsedThisTick(); if (!tableThing.CurrentlyUsableForBills() || (refuelableComp != null && !refuelableComp.HasFuel)) { this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true, true); } if (this.workCycleProgress <= 0f) { SkillDef workSkill = this.job.bill.recipe.workSkill; if (workSkill != null) { SkillRecord skill = this.pawn.skills.GetSkill(workSkill); if (skill != null) { skill.Learn(0.11f * this.job.bill.recipe.workSkillLearnFactor, false); } } var research = PurpleIvyData.AlienStudy.Where(x => x.TechprintsApplied == 0 && GetActor().Map.listerThings.ThingsOfDef (ThingDef.Named("Techprint_" + x.defName)).Count == 0).RandomElement(); if (research != null) { GenSpawn.Spawn(ThingDef.Named("Techprint_" + research.defName), GetActor().Position, GetActor().Map); } job.bill.Notify_PawnDidWork(GetActor()); Bill_Production bill_Production = this.pawn.jobs.curJob.bill as Bill_Production; if (bill_Production != null && bill_Production.repeatMode == BillRepeatModeDefOf.TargetCount) { this.Map.resourceCounter.UpdateResourceCounts(); } Toils_Recipe.FinishRecipeAndStartStoringProduct(); job.bill.Notify_IterationCompleted(GetActor(), null); Toils_Reserve.Release(TargetIndex.A); PawnUtility.GainComfortFromCellIfPossible(this.pawn, false); this.ReadyForNextToil(); } }; toil.defaultCompleteMode = ToilCompleteMode.Never; ToilEffects.WithEffect(toil, () => this.job.bill.recipe.effectWorking, TargetIndex.A); ToilEffects.PlaySustainerOrSound(toil, () => toil.actor.CurJob.bill.recipe.soundWorking); ToilEffects.WithProgressBar(toil, TargetIndex.A, delegate() { return(PurpleIvyUtils.GetPercentageFromPartWhole (this.job.bill.recipe.workAmount - this.workCycleProgress, (int)this.job.bill.recipe.workAmount) / 100f); }, false, 0.5f); ToilFailConditions.FailOn <Toil>(toil, delegate() { IBillGiver billGiver = this.job.GetTarget(TargetIndex.A).Thing as IBillGiver; return(this.job.bill.suspended || this.job.bill.DeletedOrDereferenced || (billGiver != null && !billGiver.CurrentlyUsableForBills())); }); yield return(toil); yield break; }