Ejemplo n.º 1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil relax;

            if (this.FromBed)
            {
                this.KeepLyingDown(TargetIndex.A);
                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A, TargetIndex.None));

                yield return(Toils_Bed.GotoBed(TargetIndex.A));

                relax = Toils_LayDown.LayDown(TargetIndex.A, true, false, true, true);
                relax.AddFailCondition(() => !this.pawn.Awake());
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

                relax            = new Toil();
                relax.initAction = delegate
                {
                    this.faceDir = ((!this.job.def.faceDir.IsValid) ? Rot4.Random : this.job.def.faceDir);
                };
                relax.handlingFacing = true;
            }
            relax.defaultCompleteMode = ToilCompleteMode.Delay;
            relax.defaultDuration     = this.job.def.joyDuration;
            relax.AddPreTickAction(delegate
            {
                if (this.faceDir.IsValid)
                {
                    this.pawn.rotationTracker.FaceCell(this.pawn.Position + this.faceDir.FacingCell);
                }
                this.pawn.GainComfortFromCellIfPossible();
                JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f, null);
                PrayUtility.TickCheckEnd(pawn);
            });
            yield return(relax);

            this.AddFinishAction(() =>
            {
                ReligionProperty property = pawn.GetReligionComponent().Religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag).Property;
                PietyUtility.TryApplyOnPawn(property.Subject, pawn);
            });
        }
Ejemplo n.º 2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            base.AddEndCondition(delegate
            {
                Thing thing = this.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing;
                if (thing is Building && !thing.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });
            this.FailOnBurningImmobile(TargetIndex.A);

            if (TargetC.HasThing)
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.OnCell));
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));
            }

            yield return(new Toil()
            {
                defaultCompleteMode = ToilCompleteMode.Never,
                tickAction = delegate
                {
                    PrayUtility.TickCheckEnd(pawn);
                    this.pawn.rotationTracker.FaceCell(base.TargetA.Cell);
                    this.pawn.GainComfortFromCellIfPossible();
                }
            });

            this.AddFinishAction(() =>
            {
                ReligionProperty property = pawn.GetReligionComponent().Religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag).Property;
                PietyUtility.TryApplyOnPawn(property.Subject, pawn);
            });
        }