コード例 #1
0
        protected virtual void ListenTickAction()
        {
            if (!Gramophone.IsOn())
            {
                EndJobWith(JobCondition.Incompletable);
                return;
            }

            pawn.rotationTracker.FaceCell(TargetA.Cell);
            pawn.GainComfortFromCellIfPossible();
            var statValue = TargetThingA.GetStatValue(StatDefOf.JoyGainFactor);

            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, statValue);
        }
コード例 #2
0
        protected virtual void ListenTickAction()
        {
            if (!Gramophone.IsOn())
            {
                base.EndJobWith(JobCondition.Incompletable);
                return;
            }
            this.pawn.rotationTracker.FaceCell(base.TargetA.Cell);
            this.pawn.GainComfortFromCellIfPossible();
            float statValue          = base.TargetThingA.GetStatValue(StatDefOf.JoyGainFactor, true);
            float extraJoyGainFactor = statValue;

            JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor);
        }
コード例 #3
0
        //What should we do?
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Check it out. Can we go there?
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);

            //Wait a minute, is this thing already playing?
            if (!Gramophone.IsOn())
            {
                if (job.targetA.Thing is Building_Radio)
                {
                    report = "playing the radio.";
                }

                // Toil 1:
                // Reserve Target (TargetPack A is selected (It has the info where the target cell is))
                yield return(Toils_Reserve.Reserve(TargetIndex.A));

                // Toil 2:
                // Go to the thing.
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

                // Toil 3:
                // Wind up the gramophone
                var wind = new Toil
                {
                    defaultCompleteMode = ToilCompleteMode.Delay,
                    defaultDuration     = Duration
                };
                wind.WithProgressBarToilDelay(TargetIndex.A);
                wind.PlaySustainerOrSound(job.targetA.Thing is Building_Radio
                    ? DefDatabase <SoundDef> .GetNamed("Estate_RadioSeeking")
                    : DefDatabase <SoundDef> .GetNamed("Estate_GramophoneWindup"));

                wind.initAction = delegate { Gramophone.StopMusic(); };
                yield return(wind);

                // Toil 4:
                // Play music.

                var toilPlayMusic = new Toil
                {
                    defaultCompleteMode = ToilCompleteMode.Instant,
                    initAction          = delegate { Gramophone.PlayMusic(pawn); }
                };
                yield return(toilPlayMusic);
            }

            Toil toil;

            if (TargetC.HasThing && TargetC.Thing is Building_Bed bed) //If we have a bed, lie in bed to listen.
            {
                this.KeepLyingDown(TargetIndex.C);
                yield return(Toils_Reserve.Reserve(TargetIndex.C, bed.SleepingSlotsCount));

                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.C));

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

                toil = Toils_LayDown.LayDown(TargetIndex.C, true, false);
                toil.AddFailCondition(() => !pawn.Awake());
            }
            else
            {
                if (TargetC.HasThing)
                {
                    yield return(Toils_Reserve.Reserve(TargetIndex.C));
                }

                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

                toil = new Toil();
            }

            toil.AddPreTickAction(delegate
            {
                ListenTickAction();
                if (job.targetA.Thing is Building_Radio)
                {
                    report = "Listening to the radio.";
                }
            });
            toil.AddFinishAction(delegate { JoyUtility.TryGainRecRoomThought(pawn); });
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = job.def.joyDuration;
            yield return(toil);
        }