protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.B);
            this.FailOn(() => !FoodUtility.ShouldBeFedBySomeone(Deliveree));
            if (pawn.inventory != null && pawn.inventory.Contains(base.TargetThingA))
            {
                yield return(Toils_Misc.TakeItemFromInventoryToCarrier(pawn, TargetIndex.A));
            }
            else if (base.TargetThingA is Building_NutrientPasteDispenser)
            {
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnForbidden(TargetIndex.A));

                yield return(Toils_Ingest.TakeMealFromDispenser(TargetIndex.A, pawn));
            }
            else
            {
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnForbidden(TargetIndex.A));

                yield return(Toils_Ingest.PickupIngestible(TargetIndex.A, Deliveree));
            }
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch));

            yield return(Toils_Ingest.ChewIngestible(Deliveree, 1.5f, TargetIndex.A).FailOnCannotTouch(TargetIndex.B, PathEndMode.Touch));

            yield return(Toils_Ingest.FinalizeIngest(Deliveree, TargetIndex.A));
        }
        // Token: 0x0600003F RID: 63 RVA: 0x00004036 File Offset: 0x00002236
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.B);
            this.FailOn(() => !FoodUtility.ShouldBeFedBySomeone(this.Deliveree));
            bool flag = base.TargetThingA is Building_NutrientPasteDispenser;

            if (flag)
            {
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnForbidden(TargetIndex.A));

                yield return(Toils_Ingest.TakeMealFromDispenser(TargetIndex.A, this.pawn));
            }
            else
            {
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnForbidden(TargetIndex.A));

                yield return(Toils_Ingest.PickupIngestible(TargetIndex.A, this.Deliveree));
            }
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch));

            yield return(Toils_Ingest.ChewIngestible(this.Deliveree, 1.5f, TargetIndex.A, TargetIndex.None).FailOnCannotTouch(TargetIndex.B, PathEndMode.Touch));

            yield return(Toils_Ingest.FinalizeIngest(this.Deliveree, TargetIndex.A));

            yield break;
        }
예제 #3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (!this.usingNutrientPasteDispenser)
            {
                this.FailOn(() => !this.$this.IngestibleSource.Destroyed && !this.$this.IngestibleSource.IngestibleNow);
            }
            Toil chew = Toils_Ingest.ChewIngestible(this.pawn, this.ChewDurationMultiplier, TargetIndex.A, TargetIndex.B).FailOn((Toil x) => !this.$this.IngestibleSource.Spawned && (this.$this.pawn.carryTracker == null || this.$this.pawn.carryTracker.CarriedThing != this.$this.IngestibleSource)).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);

            foreach (Toil toil in this.PrepareToIngestToils(chew))
            {
                yield return(toil);
            }
            yield return(chew);

            yield return(Toils_Ingest.FinalizeIngest(this.pawn, TargetIndex.A));

            yield return(Toils_Jump.JumpIf(chew, () => this.$this.job.GetTarget(TargetIndex.A).Thing is Corpse && this.$this.pawn.needs.food.CurLevelPercentage < 0.9f));
        }
예제 #4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (!usingNutrientPasteDispenser)
            {
                this.FailOn(() => !((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0045: stateMachine*/)._0024this.IngestibleSource.Destroyed && !((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0045: stateMachine*/)._0024this.IngestibleSource.IngestibleNow);
            }
            Toil chew = Toils_Ingest.ChewIngestible(pawn, ChewDurationMultiplier, TargetIndex.A, TargetIndex.B).FailOn((Toil x) => !((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0075: stateMachine*/)._0024this.IngestibleSource.Spawned && (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0075: stateMachine*/)._0024this.pawn.carryTracker == null || ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0075: stateMachine*/)._0024this.pawn.carryTracker.CarriedThing != ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0075: stateMachine*/)._0024this.IngestibleSource)).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);

            using (IEnumerator <Toil> enumerator = PrepareToIngestToils(chew).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Toil toil = enumerator.Current;
                    yield return(toil);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield return(chew);

            /*Error: Unable to find new state assignment for yield return*/;
IL_01aa:
            /*Error near IL_01ab: Unexpected return in MoveNext()*/;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            base.AddFinishAction(delegate
            {
                this.$this.Map.attackTargetsCache.UpdateTarget(this.$this.pawn);
            });
            Toil prepareToEatCorpse = new Toil();

            prepareToEatCorpse.initAction = delegate
            {
                Pawn   actor  = prepareToEatCorpse.actor;
                Corpse corpse = this.$this.Corpse;
                if (corpse == null)
                {
                    Pawn prey = this.$this.Prey;
                    if (prey == null)
                    {
                        actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        return;
                    }
                    corpse = prey.Corpse;
                    if (corpse == null || !corpse.Spawned)
                    {
                        actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        return;
                    }
                }
                if (actor.Faction == Faction.OfPlayer)
                {
                    corpse.SetForbidden(false, false);
                }
                else
                {
                    corpse.SetForbidden(true, false);
                }
                actor.CurJob.SetTarget(TargetIndex.A, corpse);
            };
            yield return(Toils_General.DoAtomic(delegate
            {
                this.$this.Map.attackTargetsCache.UpdateTarget(this.$this.pawn);
            }));

            Action onHitAction = delegate
            {
                Pawn prey           = this.$this.Prey;
                bool surpriseAttack = this.$this.firstHit && !prey.IsColonist;
                if (this.$this.pawn.meleeVerbs.TryMeleeAttack(prey, this.$this.job.verbToUse, surpriseAttack))
                {
                    if (!this.$this.notifiedPlayerAttacked && PawnUtility.ShouldSendNotificationAbout(prey))
                    {
                        this.$this.notifiedPlayerAttacked = true;
                        Messages.Message("MessageAttackedByPredator".Translate(prey.LabelShort, this.$this.pawn.LabelIndefinite(), prey.Named("PREY"), this.$this.pawn.Named("PREDATOR")).CapitalizeFirst(), prey, MessageTypeDefOf.ThreatSmall, true);
                    }
                    this.$this.Map.attackTargetsCache.UpdateTarget(this.$this.pawn);
                    this.$this.firstHit = false;
                }
            };
            Toil followAndAttack = Toils_Combat.FollowAndMeleeAttack(TargetIndex.A, onHitAction).JumpIfDespawnedOrNull(TargetIndex.A, prepareToEatCorpse).JumpIf(() => this.$this.Corpse != null, prepareToEatCorpse).FailOn(() => Find.TickManager.TicksGame > this.$this.startTick + 5000 && (float)(this.$this.job.GetTarget(TargetIndex.A).Cell - this.$this.pawn.Position).LengthHorizontalSquared > 4f);

            followAndAttack.AddPreTickAction(new Action(this.CheckWarnPlayer));
            yield return(followAndAttack);

            yield return(prepareToEatCorpse);

            Toil gotoCorpse = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);

            yield return(gotoCorpse);

            float durationMultiplier = 1f / this.pawn.GetStatValue(StatDefOf.EatingSpeed, true);

            yield return(Toils_Ingest.ChewIngestible(this.pawn, durationMultiplier, TargetIndex.A, TargetIndex.None).FailOnDespawnedOrNull(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_Ingest.FinalizeIngest(this.pawn, TargetIndex.A));

            yield return(Toils_Jump.JumpIf(gotoCorpse, () => this.$this.pawn.needs.food.CurLevelPercentage < 0.9f));
        }
예제 #6
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDespawnedNullOrForbidden(TargetIndex.B);
                    this.FailOn(() => !FoodUtility.ShouldBeFedBySomeone(base.Deliveree));
                    if (this.pawn.inventory != null && this.pawn.inventory.Contains(base.TargetThingA))
                    {
                        this.$current = Toils_Misc.TakeItemFromInventoryToCarrier(this.pawn, TargetIndex.A);
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        return(true);
                    }
                    if (base.TargetThingA is Building_NutrientPasteDispenser)
                    {
                        this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnForbidden(TargetIndex.A);
                        if (!this.$disposing)
                        {
                            this.$PC = 2;
                        }
                        return(true);
                    }
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnForbidden(TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 1u:
                    break;

                case 2u:
                    this.$current = Toils_Ingest.TakeMealFromDispenser(TargetIndex.A, this.pawn);
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 3u:
                    break;

                case 4u:
                    this.$current = Toils_Ingest.PickupIngestible(TargetIndex.A, base.Deliveree);
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

                case 5u:
                    break;

                case 6u:
                    this.$current = Toils_Ingest.ChewIngestible(base.Deliveree, 1.5f, TargetIndex.A, TargetIndex.None).FailOnCannotTouch(TargetIndex.B, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 7;
                    }
                    return(true);

                case 7u:
                    this.$current = Toils_Ingest.FinalizeIngest(base.Deliveree, TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 8;
                    }
                    return(true);

                case 8u:
                    this.$PC = -1;
                    return(false);

                default:
                    return(false);
                }
                this.$current = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch);
                if (!this.$disposing)
                {
                    this.$PC = 6;
                }
                return(true);
            }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    if (!this.usingNutrientPasteDispenser)
                    {
                        this.FailOn(() => !base.IngestibleSource.Destroyed && !base.IngestibleSource.IngestibleNow);
                    }
                    chew       = Toils_Ingest.ChewIngestible(this.pawn, base.ChewDurationMultiplier, TargetIndex.A, TargetIndex.B).FailOn((Toil x) => !base.IngestibleSource.Spawned && (this.pawn.carryTracker == null || this.pawn.carryTracker.CarriedThing != base.IngestibleSource)).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
                    enumerator = base.PrepareToIngestToils(chew).GetEnumerator();
                    num        = 4294967293u;
                    break;

                case 1u:
                    break;

                case 2u:
                    this.$current = Toils_Ingest.FinalizeIngest(this.pawn, TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 3u:
                    this.$current = Toils_Jump.JumpIf(chew, () => this.job.GetTarget(TargetIndex.A).Thing is Corpse && this.pawn.needs.food.CurLevelPercentage < 0.9f);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    this.$PC = -1;
                    return(false);

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        toil          = enumerator.Current;
                        this.$current = toil;
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                }
                this.$current = chew;
                if (!this.$disposing)
                {
                    this.$PC = 2;
                }
                return(true);
            }