Beispiel #1
0
        //What should we do?
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Check it out. Can we go there?
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);

            if (this.job.targetA.Thing is Building_Radio)
            {
                report = "Turning off 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, 1));

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

            // Toil 3:
            // Turn off music.

            Toil toilStopMusic = new Toil();

            toilStopMusic.defaultCompleteMode = ToilCompleteMode.Instant;
            toilStopMusic.initAction          = delegate
            {
                Building_Gramophone gramophone = this.job.targetA.Thing as Building_Gramophone;
                gramophone.StopMusic();
            };
            yield return(toilStopMusic);

            yield break;
        }
        //What should we do?
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Check it out. Can we go there?
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);

            if (this.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, 1));

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

            // Toil 3:
            // Wind up the gramophone
            Toil toil = new Toil();

            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = this.Duration;
            toil.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            if (this.job.targetA.Thing is Building_Radio)
            {
                toil.PlaySustainerOrSound(DefDatabase <SoundDef> .GetNamed("Estate_RadioSeeking"));
            }
            else
            {
                toil.PlaySustainerOrSound(DefDatabase <SoundDef> .GetNamed("Estate_GramophoneWindup"));
            }
            toil.initAction = delegate
            {
                Building_Gramophone gramophone = this.job.targetA.Thing as Building_Gramophone;
                gramophone.StopMusic();
            };
            yield return(toil);

            // Toil 4:
            // Play music.

            Toil toilPlayMusic = new Toil();

            toilPlayMusic.defaultCompleteMode = ToilCompleteMode.Instant;
            toilPlayMusic.initAction          = delegate
            {
                Building_Gramophone gramophone = this.job.targetA.Thing as Building_Gramophone;
                gramophone.PlayMusic(this.pawn);
            };
            yield return(toilPlayMusic);

            yield break;
        }