public static Toil DoRecipeWorkDrawing(TargetIndex billGiverIndex) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; jobDriver_DoBill.workLeft = curJob.bill.recipe.WorkAmountTotal(null); jobDriver_DoBill.billStartTick = Find.TickManager.TicksGame; jobDriver_DoBill.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); }; toil.tickAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; jobDriver_DoBill.ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); IBillGiverWithTickAction billGiverWithTickAction = actor.CurJob.GetTarget(billGiverIndex).Thing as IBillGiverWithTickAction; if (billGiverWithTickAction != null) { // 設備の時間経過処理 billGiverWithTickAction.UsedThisTick(); } // 工数を進める処理 float num = (curJob.RecipeDef.workSpeedStat != null) ? actor.GetStatValue(curJob.RecipeDef.workSpeedStat, true) : 1f; Building_WorkTable building_WorkTable = jobDriver_DoBill.BillGiver as Building_WorkTable; if (building_WorkTable != null) { num *= building_WorkTable.GetStatValue(StatDefOf.WorkTableWorkSpeedFactor, true); } if (DebugSettings.fastCrafting) { num *= 30f; } jobDriver_DoBill.workLeft -= num; // 椅子から快適さを得る actor.GainComfortFromCellIfPossible(); // 完了チェック if (jobDriver_DoBill.workLeft <= 0f) { jobDriver_DoBill.ReadyForNextToil(); } }; toil.defaultCompleteMode = ToilCompleteMode.Never; toil.WithEffect(() => toil.actor.CurJob.bill.recipe.effectWorking, billGiverIndex); toil.PlaySustainerOrSound(() => toil.actor.CurJob.bill.recipe.soundWorking); toil.WithProgressBar(billGiverIndex, delegate { Pawn actor = toil.actor; Job curJob = actor.CurJob; return(1f - ((JobDriver_DoBill)actor.jobs.curDriver).workLeft / curJob.bill.recipe.WorkAmountTotal(null)); }, false, -0.5f); toil.FailOn(() => toil.actor.CurJob.bill.suspended); return(toil); }
// Token: 0x060000EE RID: 238 RVA: 0x00008574 File Offset: 0x00006774 public static void DoRecipeWork_Prefix(ref Toil __result) { Toil toil = new Toil(); toil.initAction = delegate() { Log.Message("init delegated.", false); Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; bool animal = actor.RaceProps.Animal; if (animal) { Log.Message("I am in.", false); JobDriver curDriver = actor.jobs.curDriver; JobDriver_WPDoBill jobDriver_WPDoBill = curDriver as JobDriver_WPDoBill; UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; jobDriver_WPDoBill.workLeft = curJob.bill.recipe.WorkAmountTotal(unfinishedThing.def); bool flag = unfinishedThing != null; if (flag) { unfinishedThing.workLeft = jobDriver_WPDoBill.workLeft; } jobDriver_WPDoBill.billStartTick = Find.TickManager.TicksGame; jobDriver_WPDoBill.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); } else { Log.Message("I am here instead.", false); JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; UnfinishedThing unfinishedThing2 = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; bool flag2 = unfinishedThing2 != null && unfinishedThing2.Initialized; if (flag2) { jobDriver_DoBill.workLeft = unfinishedThing2.workLeft; } else { jobDriver_DoBill.workLeft = curJob.bill.recipe.WorkAmountTotal((unfinishedThing2 == null) ? null : unfinishedThing2.Stuff); bool flag3 = unfinishedThing2 != null; if (flag3) { unfinishedThing2.workLeft = jobDriver_DoBill.workLeft; } } jobDriver_DoBill.billStartTick = Find.TickManager.TicksGame; jobDriver_DoBill.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); } }; toil.tickAction = delegate() { Log.Message("tick delegated.", false); Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver curDriver = actor.jobs.curDriver; bool animal = actor.RaceProps.Animal; if (animal) { JobDriver_WPDoBill jobDriver_WPDoBill = curDriver as JobDriver_WPDoBill; UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; bool flag = unfinishedThing != null && unfinishedThing.Destroyed; if (flag) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true, true); return; } jobDriver_WPDoBill.ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); IBillGiverWithTickAction billGiverWithTickAction = toil.actor.CurJob.GetTarget(TargetIndex.A).Thing as IBillGiverWithTickAction; bool flag2 = billGiverWithTickAction != null; if (flag2) { billGiverWithTickAction.UsedThisTick(); } float num = (curJob.RecipeDef.workSpeedStat != null) ? actor.GetStatValue(curJob.RecipeDef.workSpeedStat, true) : 1f; Building_WorkTable building_WorkTable = jobDriver_WPDoBill.BillGiver as Building_WorkTable; bool flag3 = building_WorkTable != null; if (flag3) { num *= building_WorkTable.GetStatValue(StatDefOf.WorkTableWorkSpeedFactor, true); } bool fastCrafting = DebugSettings.fastCrafting; if (fastCrafting) { num *= 30f; } jobDriver_WPDoBill.workLeft -= num; bool flag4 = unfinishedThing != null; if (flag4) { unfinishedThing.workLeft = jobDriver_WPDoBill.workLeft; } actor.GainComfortFromCellIfPossible(false); bool flag5 = jobDriver_WPDoBill.workLeft <= 0f; if (flag5) { jobDriver_WPDoBill.ReadyForNextToil(); } bool usesUnfinishedThing = curJob.bill.recipe.UsesUnfinishedThing; if (usesUnfinishedThing) { int num2 = Find.TickManager.TicksGame - jobDriver_WPDoBill.billStartTick; bool flag6 = num2 >= 3000 && num2 % 1000 == 0; if (flag6) { actor.jobs.CheckForJobOverride(); } } } bool flag7 = !actor.RaceProps.Animal; if (flag7) { JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; UnfinishedThing unfinishedThing2 = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; bool flag8 = unfinishedThing2 != null && unfinishedThing2.Destroyed; if (flag8) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true, true); } else { jobDriver_DoBill.ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); IBillGiverWithTickAction billGiverWithTickAction2 = toil.actor.CurJob.GetTarget(TargetIndex.A).Thing as IBillGiverWithTickAction; bool flag9 = billGiverWithTickAction2 != null; if (flag9) { billGiverWithTickAction2.UsedThisTick(); } bool flag10 = curJob.RecipeDef.workSkill != null && curJob.RecipeDef.UsesUnfinishedThing; if (flag10) { actor.skills.GetSkill(curJob.RecipeDef.workSkill).Learn(0.11f * curJob.RecipeDef.workSkillLearnFactor, false); } float num3 = (curJob.RecipeDef.workSpeedStat != null) ? actor.GetStatValue(curJob.RecipeDef.workSpeedStat, true) : 1f; Building_WorkTable building_WorkTable2 = jobDriver_DoBill.BillGiver as Building_WorkTable; bool flag11 = building_WorkTable2 != null; if (flag11) { num3 *= building_WorkTable2.GetStatValue(StatDefOf.WorkTableWorkSpeedFactor, true); } bool fastCrafting2 = DebugSettings.fastCrafting; if (fastCrafting2) { num3 *= 30f; } jobDriver_DoBill.workLeft -= num3; bool flag12 = unfinishedThing2 != null; if (flag12) { unfinishedThing2.workLeft = jobDriver_DoBill.workLeft; } actor.GainComfortFromCellIfPossible(false); bool flag13 = jobDriver_DoBill.workLeft <= 0f; if (flag13) { jobDriver_DoBill.ReadyForNextToil(); } bool usesUnfinishedThing2 = curJob.bill.recipe.UsesUnfinishedThing; if (usesUnfinishedThing2) { int num4 = Find.TickManager.TicksGame - jobDriver_DoBill.billStartTick; bool flag14 = num4 >= 3000 && num4 % 1000 == 0; if (flag14) { 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(TargetIndex.A, delegate { Pawn actor = toil.actor; Job curJob = actor.CurJob; UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; bool animal = actor.RaceProps.Animal; float result; if (animal) { result = 1f - ((JobDriver_WPDoBill)actor.jobs.curDriver).workLeft / curJob.bill.recipe.WorkAmountTotal((unfinishedThing == null) ? null : unfinishedThing.Stuff); } else { result = 1f - ((JobDriver_DoBill)actor.jobs.curDriver).workLeft / curJob.bill.recipe.WorkAmountTotal((unfinishedThing == null) ? null : unfinishedThing.Stuff); } return(result); }, false, -0.5f); toil.FailOn(() => toil.actor.CurJob.bill.suspended); __result = toil; }
public static Toil DoDissectionRecipeWork() { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver = (JobDriver_DoBill)actor.jobs.curDriver; jobDriver.workLeft = curJob.bill.recipe.WorkAmountTotal(null); jobDriver.billStartTick = Find.TickManager.TicksGame; jobDriver.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); }; toil.tickAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; jobDriver_DoBill.ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); if (toil.actor.CurJob.GetTarget(TargetIndex.A).Thing is IBillGiverWithTickAction billGiverWithTickAction) { billGiverWithTickAction.UsedThisTick(); } if (!curJob.playerForced) { } var passion = actor.skills.GetSkill(SkillDefOf.Medicine).passion; float workDone = 1f * actor.GetStatValue(StatDefOf.WorkSpeedGlobal, true); if (DebugSettings.fastCrafting) { workDone *= 30f; } jobDriver_DoBill.workLeft -= workDone; actor.GainComfortFromCellIfPossible(); if (jobDriver_DoBill.workLeft <= 0f) { jobDriver_DoBill.ReadyForNextToil(); } }; toil.defaultCompleteMode = ToilCompleteMode.Never; toil.WithEffect(() => toil.actor.CurJob.bill.recipe.effectWorking, TargetIndex.A); toil.PlaySustainerOrSound(() => toil.actor.CurJob.bill.recipe.soundWorking); toil.WithProgressBar(TargetIndex.A, delegate { Pawn actor = toil.actor; Job curJob = actor.CurJob; return(1f - ((JobDriver_DoBill)actor.jobs.curDriver).workLeft / curJob.bill.recipe.WorkAmountTotal(null)); }, false, -0.5f); toil.FailOn(() => toil.actor.CurJob.bill.suspended); toil.activeSkill = (() => toil.actor.CurJob.bill.recipe.workSkill); return(toil); }
public override IEnumerable <Toil> MakeNewToils() { AddEndCondition(delegate { Thing thing = GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate() { IBillGiver billGiver = job.GetTarget(TargetIndex.A).Thing as IBillGiver; if (billGiver != null) { if (job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } if (project == null) { Log.Warning("[HumanResources] " + pawn + " tried to document a null project."); TryMakePreToilReservations(true); return(true); } if (!techComp.homework.Contains(project)) { return(true); } } return(false); }); Toil gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); yield return(gotoBillGiver); Toil document = new Toil(); document.initAction = delegate() { Pawn actor = document.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; jobDriver_DoBill.billStartTick = Find.TickManager.TicksGame; jobDriver_DoBill.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); }; document.tickAction = delegate() { Pawn actor = document.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill jobDriver_DoBill = (JobDriver_DoBill)actor.jobs.curDriver; jobDriver_DoBill.ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); IBillGiverWithTickAction billGiverWithTickAction = document.actor.CurJob.GetTarget(TargetIndex.A).Thing as IBillGiverWithTickAction; if (billGiverWithTickAction != null) { billGiverWithTickAction.UsedThisTick(); } SkillDef skill = curJob.RecipeDef.workSkill != null ? curJob.RecipeDef.workSkill : SkillDefOf.Intellectual; actor.skills.Learn(skill, 0.1f * curJob.RecipeDef.workSkillLearnFactor, false); float num = (curJob.RecipeDef.workSpeedStat == null) ? 1f : actor.GetStatValue(curJob.RecipeDef.workSpeedStat, true); if (curJob.RecipeDef.workTableSpeedStat != null) { Building_WorkTable building_WorkTable = jobDriver_DoBill.BillGiver as Building_WorkTable; if (building_WorkTable != null) { num *= building_WorkTable.GetStatValue(curJob.RecipeDef.workTableSpeedStat, true); } } if (DebugSettings.fastCrafting) { num *= 30f; } project.Uploaded(num, TargetThingA); actor.GainComfortFromCellIfPossible(true); if (project.IsFinished) { curJob.bill.Notify_IterationCompleted(actor, new List <Thing>() { }); project.Unlock(jobDriver_DoBill.BillGiver as Thing, false); techComp.homework.Remove(project); jobDriver_DoBill.ReadyForNextToil(); return; } }; document.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); document.WithEffect(EffecterDefOf.Research, TargetIndex.A); document.WithProgressBar(TargetIndex.A, delegate { if (project == null) { return(0f); } return(project.ProgressPercent); }, false, -0.5f); document.defaultCompleteMode = ToilCompleteMode.Delay; document.defaultDuration = 4000; document.activeSkill = (() => SkillDefOf.Intellectual); yield return(document); yield return(Toils_General.Wait(2, TargetIndex.None)); yield break; }
static bool Prefix(ref Toil __result) { Toil toil = new Toil(); toil.initAction = (Action)(() => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill curDriver = (JobDriver_DoBill)actor.jobs.curDriver; UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; if (unfinishedThing != null && unfinishedThing.Initialized) { curDriver.workLeft = unfinishedThing.workLeft; } else { curDriver.workLeft = curJob.bill.recipe.WorkAmountTotal(unfinishedThing?.Stuff); if (unfinishedThing != null) { unfinishedThing.workLeft = curDriver.workLeft; } } curDriver.billStartTick = Find.TickManager.TicksGame; curDriver.ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); }); toil.tickAction = (Action)(() => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; JobDriver_DoBill curDriver = (JobDriver_DoBill)actor.jobs.curDriver; UnfinishedThing unfinishedThing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; if (unfinishedThing != null && unfinishedThing.Destroyed) { actor.jobs.EndCurrentJob(JobCondition.Incompletable); } else { ++curDriver.ticksSpentDoingRecipeWork; curJob.bill.Notify_PawnDidWork(actor); if (toil.actor.CurJob.GetTarget(TargetIndex.A).Thing is IBillGiverWithTickAction thing2) { thing2.UsedThisTick(); } if (curJob.RecipeDef.workSkill != null && curJob.RecipeDef.UsesUnfinishedThing) { actor.skills.Learn(curJob.RecipeDef.workSkill, 0.1f * curJob.RecipeDef.workSkillLearnFactor); } float num1 = curJob.RecipeDef.workSpeedStat == null ? 1f : actor.GetStatValue(curJob.RecipeDef.workSpeedStat); num1 *= RefcellRespeedConfig.currentTimeMultiplier;//작업속도 조절 부분 Building_WorkTable billGiver = curDriver.BillGiver as Building_WorkTable; if (curJob.RecipeDef.workTableSpeedStat != null) { num1 *= billGiver.GetStatValue(curJob.RecipeDef.workTableSpeedStat); } if (DebugSettings.fastCrafting) { num1 *= 30f; } curDriver.workLeft -= num1; if (unfinishedThing != null) { unfinishedThing.workLeft = curDriver.workLeft; } actor.GainComfortFromCellIfPossible(true); if ((double)curDriver.workLeft <= 0.0) { curDriver.ReadyForNextToil(); } else { if (!curJob.bill.recipe.UsesUnfinishedThing) { return; } int num2 = Find.TickManager.TicksGame - curDriver.billStartTick; if (num2 < 3000 || num2 % 1000 != 0) { return; } actor.jobs.CheckForJobOverride(); } } }); toil.defaultCompleteMode = ToilCompleteMode.Never; toil.WithEffect((Func <EffecterDef>)(() => toil.actor.CurJob.bill.recipe.effectWorking), TargetIndex.A); toil.PlaySustainerOrSound((Func <SoundDef>)(() => toil.actor.CurJob.bill.recipe.soundWorking)); toil.WithProgressBar(TargetIndex.A, (Func <float>)(() => { Pawn actor = toil.actor; Job curJob = actor.CurJob; UnfinishedThing thing = curJob.GetTarget(TargetIndex.B).Thing as UnfinishedThing; return((float)(1.0 - (double)((JobDriver_DoBill)actor.jobs.curDriver).workLeft / (double)curJob.bill.recipe.WorkAmountTotal(thing?.Stuff))); })); toil.FailOn <Toil>((Func <bool>)(() => { RecipeDef recipeDef = toil.actor.CurJob.RecipeDef; if (recipeDef != null && recipeDef.interruptIfIngredientIsRotting) { LocalTargetInfo target = toil.actor.CurJob.GetTarget(TargetIndex.B); if (target.HasThing && target.Thing.GetRotStage() > RotStage.Fresh) { return(true); } } return(toil.actor.CurJob.bill.suspended); })); toil.activeSkill = (Func <SkillDef>)(() => toil.actor.CurJob.bill.recipe.workSkill); __result = toil; return(false); }