public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnDowned(TargetIndex.A); this.FailOnNotCasualInterruptible(TargetIndex.A); this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); if (!this.$disposing) { this.$PC = 1; } return true; case 1u: <MakeNewToils>c__AnonStorey.wait = new Toil(); <MakeNewToils>c__AnonStorey.wait.initAction = delegate() { Pawn actor = <MakeNewToils>c__AnonStorey.wait.actor; Pawn pawn = (Pawn)<MakeNewToils>c__AnonStorey.<>f__ref$0.$this.job.GetTarget(TargetIndex.A).Thing; actor.pather.StopDead(); PawnUtility.ForceWait(pawn, 15000, null, true); };
// Token: 0x06000046 RID: 70 RVA: 0x000040B9 File Offset: 0x000022B9 protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnDowned(TargetIndex.A); this.FailOnNotCasualInterruptible(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil wait = new Toil(); wait.initAction = delegate() { Pawn actor = wait.actor; Pawn pawn = (Pawn)wait.actor.CurJob.GetTarget(TargetIndex.A).Thing; actor.pather.StopDead(); PawnUtility.ForceWait(pawn, 15000, null, true); }; wait.tickAction = delegate() { Pawn actor = wait.actor; this.gatherProgress += actor.GetStatValue(StatDefOf.AnimalGatherSpeed, true); bool flag = this.gatherProgress >= this.WorkTotal; if (flag) { this.GetComp((Pawn)((Thing)this.job.GetTarget(TargetIndex.A))).Gathered(this.pawn); actor.jobs.EndCurrentJob(JobCondition.Succeeded, true, true); } }; wait.AddFinishAction(delegate { Pawn pawn = (Pawn)wait.actor.CurJob.GetTarget(TargetIndex.A).Thing; bool flag = pawn.jobs.curJob.def == JobDefOf.Wait_MaintainPosture; if (flag) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true, true); } }); wait.FailOnDespawnedOrNull(TargetIndex.A); wait.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); wait.AddEndCondition(delegate { bool flag = !this.GetComp((Pawn)((Thing)this.job.GetTarget(TargetIndex.A))).ActiveAndFull; JobCondition result; if (flag) { result = JobCondition.Incompletable; } else { result = JobCondition.Ongoing; } return(result); }); wait.defaultCompleteMode = ToilCompleteMode.Never; wait.WithProgressBar(TargetIndex.A, () => this.gatherProgress / this.WorkTotal, false, -0.5f); yield return(wait); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnDowned(TargetIndex.A); this.FailOnNotCasualInterruptible(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil wait = new Toil(); wait.initAction = delegate { Pawn actor2 = wait.actor; Pawn pawn2 = (Pawn)job.GetTarget(TargetIndex.A).Thing; actor2.pather.StopDead(); PawnUtility.ForceWait(pawn2, 15000, null, maintainPosture: true); }; wait.tickAction = delegate { Pawn actor = wait.actor; actor.skills.Learn(SkillDefOf.Animals, 0.13f); gatherProgress += actor.GetStatValue(StatDefOf.AnimalGatherSpeed); if (gatherProgress >= WorkTotal) { GetComp((Pawn)(Thing)job.GetTarget(TargetIndex.A)).Gathered(pawn); actor.jobs.EndCurrentJob(JobCondition.Succeeded); } }; wait.AddFinishAction(delegate { Pawn pawn = (Pawn)job.GetTarget(TargetIndex.A).Thing; if (pawn != null && pawn.CurJobDef == JobDefOf.Wait_MaintainPosture) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } }); wait.FailOnDespawnedOrNull(TargetIndex.A); wait.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); wait.AddEndCondition(() => GetComp((Pawn)(Thing)job.GetTarget(TargetIndex.A)).ActiveAndFull ? JobCondition.Ongoing : JobCondition.Incompletable); wait.defaultCompleteMode = ToilCompleteMode.Never; wait.WithProgressBar(TargetIndex.A, () => gatherProgress / WorkTotal); wait.activeSkill = (() => SkillDefOf.Animals); yield return(wait); }
private Toil StartFeedAnimal(TargetIndex tameeInd) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.GetActor(); Pawn pawn = (Pawn)(Thing)actor.CurJob.GetTarget(tameeInd); PawnUtility.ForceWait(pawn, 270, actor); Thing thing = FoodUtility.BestFoodInInventory(actor, pawn, FoodPreferability.NeverForNutrition, FoodPreferability.RawTasty); if (thing == null) { actor.jobs.EndCurrentJob(JobCondition.Incompletable); } else { actor.mindState.lastInventoryRawFoodUseTick = Find.TickManager.TicksGame; int num = FoodUtility.StackCountForNutrition(feedNutritionLeft, thing.GetStatValue(StatDefOf.Nutrition)); int stackCount = thing.stackCount; Thing thing2 = actor.inventory.innerContainer.Take(thing, Mathf.Min(num, stackCount)); actor.carryTracker.TryStartCarry(thing2); actor.CurJob.SetTarget(TargetIndex.B, thing2); float num2 = (float)thing2.stackCount * thing2.GetStatValue(StatDefOf.Nutrition); ticksLeftThisToil = Mathf.CeilToInt(270f * (num2 / RequiredNutritionPerFeed(pawn))); if (num <= stackCount) { feedNutritionLeft = 0f; } else { feedNutritionLeft -= num2; if (feedNutritionLeft < 0.001f) { feedNutritionLeft = 0f; } } } }; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.activeSkill = () => SkillDefOf.Animals; return(toil); }
private Toil StartFeedAnimal(TargetIndex tameeInd) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.GetActor(); Pawn pawn = (Pawn)(Thing)actor.CurJob.GetTarget(tameeInd); PawnUtility.ForceWait(pawn, 270, actor, false); Thing thing = FoodUtility.BestFoodInInventory(actor, pawn, FoodPreferability.NeverForNutrition, FoodPreferability.RawTasty, 0f, false); if (thing == null) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); } else { actor.mindState.lastInventoryRawFoodUseTick = Find.TickManager.TicksGame; int num = FoodUtility.StackCountForNutrition(thing.def, this.feedNutritionLeft); int stackCount = thing.stackCount; Thing thing2 = actor.inventory.innerContainer.Take(thing, Mathf.Min(num, stackCount)); actor.carryTracker.TryStartCarry(thing2); actor.CurJob.SetTarget(TargetIndex.B, thing2); float num2 = (float)thing2.stackCount * thing2.def.ingestible.nutrition; base.ticksLeftThisToil = Mathf.CeilToInt((float)(270.0 * (num2 / JobDriver_InteractAnimal.RequiredNutritionPerFeed(pawn)))); if (num <= stackCount) { this.feedNutritionLeft = 0f; } else { this.feedNutritionLeft -= num2; if (this.feedNutritionLeft < 0.0010000000474974513) { this.feedNutritionLeft = 0f; } } } }; toil.defaultCompleteMode = ToilCompleteMode.Delay; return(toil); }