Esempio n. 1
0
        public Toil BashIt()
        {
            Toil bashIt = new Toil();

            bashIt.tickAction = delegate()
            {
                Pawn  actor  = bashIt.actor;
                Job   curJob = actor.jobs.curJob;
                Thing thing  = curJob.GetTarget(TargetIndex.B).Thing;
                bool  flag   = actor.meleeVerbs.TryMeleeAttack(thing, null, false);
                bool  flag2  = flag;
                if (flag2)
                {
                    this.numMeleeAttacksMade++;
                    bool flag3 = this.numMeleeAttacksMade >= curJob.maxNumMeleeAttacks;
                    bool flag4 = flag3;
                    if (flag4)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                }
            };
            bashIt.defaultCompleteMode = ToilCompleteMode.Never;
            ToilFailConditions.EndOnDespawnedOrNull <Toil>(bashIt, TargetIndex.B, JobCondition.Succeeded);
            ToilFailConditions.FailOn <Toil>(bashIt, new Func <bool>(this.hunterIsKilled));
            return(bashIt);
        }
Esempio n. 2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil followAndAttack = new Toil();

            followAndAttack.tickAction = delegate()
            {
                Pawn  actor  = followAndAttack.actor;
                Job   curJob = actor.jobs.curJob;
                Thing thing  = curJob.GetTarget(TargetIndex.A).Thing;
                Pawn  pawn   = thing as Pawn;
                bool  flag   = this.pawn.Faction != Faction.OfPlayer;
                bool  flag2  = flag;
                if (flag2)
                {
                    actor.mindState.mentalStateHandler.TryStartMentalState(DefDatabase <MentalStateDef> .GetNamed("MurderousRage", true), null, false, false, null);
                }
                bool flag3 = thing != actor.pather.Destination.Thing || (!this.pawn.pather.Moving && !GenAdj.AdjacentTo8WayOrInside(this.pawn.Position, thing));
                bool flag4 = flag3;
                if (flag4)
                {
                    actor.pather.StartPath(thing, PathEndMode.Touch);
                }
                else
                {
                    bool flag5 = GenAdj.AdjacentTo8WayOrInside(this.pawn.Position, thing);
                    bool flag6 = flag5;
                    if (flag6)
                    {
                        bool flag7 = thing is Pawn && pawn.Downed && !curJob.killIncappedTarget;
                        bool flag8 = flag7;
                        if (flag8)
                        {
                            this.EndJobWith(JobCondition.Succeeded);
                        }
                        bool flag9  = actor.meleeVerbs.TryMeleeAttack(thing, null, false);
                        bool flag10 = flag9;
                        if (flag10)
                        {
                            this.numMeleeAttacksLanded += 1;
                            bool flag11 = this.numMeleeAttacksLanded >= curJob.maxNumMeleeAttacks;
                            bool flag12 = flag11;
                            if (flag12)
                            {
                                this.EndJobWith(JobCondition.Succeeded);
                            }
                        }
                    }
                }
            };
            followAndAttack.defaultCompleteMode = ToilCompleteMode.Never;
            ToilFailConditions.EndOnDespawnedOrNull <Toil>(followAndAttack, TargetIndex.A, JobCondition.Succeeded);
            ToilFailConditions.FailOn <Toil>(followAndAttack, new Func <bool>(this.hunterIsKilled));
            yield return(followAndAttack);

            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            ToilFailConditions.FailOnDestroyedOrNull <JobDriver_Segmentation>(this, TargetIndex.A);
            ToilFailConditions.FailOnDespawnedOrNull <JobDriver_Segmentation>(this, TargetIndex.A);
            ToilFailConditions.FailOn <JobDriver_Segmentation>(this, new Func <bool>(this.eaterIsKilled));
            Toil resCorpse = new Toil();

            resCorpse.initAction = delegate()
            {
                Pawn  actor = resCorpse.actor;
                Thing thing = resCorpse.actor.CurJob.GetTarget(TargetIndex.A).Thing;
                bool  flag  = !thing.Spawned || !this.Map.reservationManager.CanReserve(actor, thing, 1);
                bool  flag2 = flag;
                if (flag2)
                {
                    actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                }
                else
                {
                    this.Map.reservationManager.Reserve(actor, actor.CurJob, thing, 1);
                }
            };
            resCorpse.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(resCorpse);

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(400));

            Toil toil = new Toil
            {
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            toil.initAction = new Action(this.doStripCorpse);
            yield return(toil);

            yield return(Toils_General.Wait(60));

            Toil toil2 = new Toil
            {
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            toil2.initAction = new Action(this.doChewCorpse);
            ToilEffects.WithEffect(toil2, EffecterDefOf.EatMeat, TargetIndex.A);
            ToilFailConditions.EndOnDespawnedOrNull <Toil>(toil2, TargetIndex.A, JobCondition.Incompletable);
            yield return(toil2);

            yield break;
        }