Esempio n. 1
0
 public void Pause()
 {
     if (!this.Enabled)
     {
         return;
     }
     Waiters.Interpolate(0.25, (Action <float>)(step =>
     {
         ActiveTrackedSong temp_10 = this;
         int temp_15         = (temp_10.cancelPause ? 1 : 0) | (this.resumeRequested ? 1 : (!this.Enabled ? 1 : 0));
         temp_10.cancelPause = temp_15 != 0;
         if (this.cancelPause)
         {
             return;
         }
         this.SoundManager.MusicVolumeFactor = FezMath.Saturate(1f - Easing.EaseOut((double)step, EasingType.Sine));
     }), (Action)(() =>
     {
         if (!this.cancelPause && !this.resumeRequested)
         {
             this.Watch.Stop();
             foreach (ActiveLoop item_0 in this.ActiveLoops)
             {
                 item_0.Pause();
             }
             this.Enabled = false;
             this.SoundManager.MusicVolumeFactor = 1f;
         }
         this.cancelPause = this.resumeRequested = false;
     }));
 }
Esempio n. 2
0
        public void UpdateAction()
        {
            if (this.Emitter != null)
            {
                if (this.Emitter.Cue != null && this.Emitter.Cue.IsLooped)
                {
                    this.Emitter.Cue.Stop(true);
                }
                this.Emitter = (SoundEmitter)null;
            }
            AnimatedTexture animation = this.Npc.Actions[this.CurrentAction].Animation;
            SoundEffect     sound     = this.Npc.Actions[this.CurrentAction].Sound;

            if (this.CurrentAction == NpcAction.Talk && this.CurrentLine != null && this.CurrentLine.OverrideContent != null)
            {
                if (this.CurrentLine.OverrideContent.Animation != null)
                {
                    animation = this.CurrentLine.OverrideContent.Animation;
                }
                if (this.CurrentLine.OverrideContent.Sound != null)
                {
                    sound = this.CurrentLine.OverrideContent.Sound;
                }
            }
            this.CurrentTiming    = animation.Timing.Clone();
            this.CurrentAnimation = animation;
            this.Group.Texture    = (Texture)animation.Texture;
            this.UpdateScale();
            if (sound == null || this.Npc.ActorType == ActorType.Owl && this.OwlInvisible || !this.initialized)
            {
                return;
            }
            if (this.CurrentAction == NpcAction.Talk)
            {
                if (this.talkEmitter == null || this.talkEmitter.Dead)
                {
                    this.talkEmitter = SoundEffectExtensions.EmitAt(sound, this.Position, true, RandomHelper.Centered(0.05));
                }
                else
                {
                    this.talkEmitter.Position = this.Position;
                    Waiters.Wait(0.100000001490116, (Action)(() =>
                    {
                        this.talkEmitter.Cue.Resume();
                        this.talkEmitter.VolumeFactor = 1f;
                    })).AutoPause = true;
                }
            }
            else
            {
                this.Emitter = SoundEffectExtensions.EmitAt(sound, this.Position, true, RandomHelper.Centered(0.05));
            }
        }
Esempio n. 3
0
 public void FadeOutAndRemoveComponent(float fadeDuration)
 {
     if (!this.Enabled)
     {
         return;
     }
     foreach (ActiveLoop activeLoop in this.ActiveLoops)
     {
         activeLoop.Muted = true;
         activeLoop.OnMuteStateChanged(fadeDuration);
     }
     this.Enabled = false;
     Waiters.Wait((double)fadeDuration, (Action)(() => ServiceHelper.RemoveComponent <ActiveTrackedSong>(this)));
 }
Esempio n. 4
0
 public void ChangeTracks(IEnumerable <AmbienceTrack> tracks)
 {
     foreach (ActiveAmbienceTrack activeAmbienceTrack in this.ActiveTracks)
     {
         foreach (AmbienceTrack ambienceTrack in tracks)
         {
             if (ambienceTrack.Name == activeAmbienceTrack.Track.Name)
             {
                 activeAmbienceTrack.Track = ambienceTrack;
                 bool flag1 = activeAmbienceTrack.ActiveForDayPhase && (!activeAmbienceTrack.ForceMuted && !activeAmbienceTrack.WasMuted);
                 activeAmbienceTrack.WasMuted = false;
                 bool flag2 = ((((((!this.TimeManager.IsDayPhaseForMusic(DayPhase.Day) ? (false ? 1 : 0) : (ambienceTrack.Day ? 1 : 0)) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Night) ? 0 : (ambienceTrack.Night ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Dawn) ? 0 : (ambienceTrack.Dawn ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Dusk) ? 0 : (ambienceTrack.Dusk ? 1 : 0))) != 0;
                 activeAmbienceTrack.ActiveForDayPhase = flag2;
                 if (flag1 != activeAmbienceTrack.ActiveForDayPhase)
                 {
                     if (!activeAmbienceTrack.ForceMuted)
                     {
                         activeAmbienceTrack.OnMuteStateChanged(2f);
                         break;
                     }
                     else
                     {
                         break;
                     }
                 }
                 else
                 {
                     break;
                 }
             }
         }
     }
     foreach (ActiveAmbienceTrack activeAmbienceTrack in Enumerable.Where <ActiveAmbienceTrack>((IEnumerable <ActiveAmbienceTrack>) this.ActiveTracks, (Func <ActiveAmbienceTrack, bool>)(x => !Enumerable.Any <AmbienceTrack>(tracks, (Func <AmbienceTrack, bool>)(y => y.Name == x.Track.Name)))))
     {
         activeAmbienceTrack.ForceMuted = true;
         activeAmbienceTrack.OnMuteStateChanged(2f);
         ActiveAmbienceTrack t1 = activeAmbienceTrack;
         Waiters.Wait(2.0, (Action)(() =>
         {
             t1.Dispose();
             this.ActiveTracks.Remove(t1);
         }));
     }
     foreach (AmbienceTrack track in Enumerable.Where <AmbienceTrack>(tracks, (Func <AmbienceTrack, bool>)(x => !Enumerable.Any <ActiveAmbienceTrack>((IEnumerable <ActiveAmbienceTrack>) this.ActiveTracks, (Func <ActiveAmbienceTrack, bool>)(y => y.Track.Name == x.Name)))))
     {
         bool activeForDayPhase = ((((((!this.TimeManager.IsDayPhaseForMusic(DayPhase.Day) ? (false ? 1 : 0) : (track.Day ? 1 : 0)) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Night) ? 0 : (track.Night ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Dawn) ? 0 : (track.Dawn ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Dusk) ? 0 : (track.Dusk ? 1 : 0))) != 0;
         this.ActiveTracks.Add(new ActiveAmbienceTrack(track, activeForDayPhase));
     }
 }
Esempio n. 5
0
 public override void Initialize()
 {
     if (this.Song == null)
     {
         this.Song = this.LevelManager.Song;
     }
     if (this.MutedLoops == null)
     {
         this.MutedLoops = this.LevelManager.MutedLoops;
     }
     if (this.Song == null)
     {
         this.Enabled = false;
         ServiceHelper.RemoveComponent <ActiveTrackedSong>(this);
     }
     else
     {
         this.BarsCounted = this.BeatsCounted = 0L;
         this.Enabled     = false;
         Waiters.Wait(0.1, (Action)(() =>
         {
             foreach (Loop item_0 in this.Song.Loops)
             {
                 bool local_1 = this.IgnoreDayPhase;
                 if (!this.IgnoreDayPhase)
                 {
                     local_1 = ((((((((local_1 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Day) ? 0 : (item_0.Day ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Night) ? 0 : (item_0.Night ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Dawn) ? 0 : (item_0.Dawn ? 1 : 0))) != 0 ? 1 : 0) | (!this.TimeManager.IsDayPhaseForMusic(DayPhase.Dusk) ? 0 : (item_0.Dusk ? 1 : 0))) != 0;
                 }
                 ActiveLoop local_2 = new ActiveLoop(item_0, this.MutedLoops.Contains(item_0.Name), local_1, item_0.OneAtATime);
                 if (item_0.OneAtATime)
                 {
                     local_2.CycleLink = new Action(this.CycleOaaTs);
                 }
                 this.ActiveLoops.Add(local_2);
             }
             this.AllOaaTs = Enumerable.ToArray <ActiveLoop>(Enumerable.Where <ActiveLoop>((IEnumerable <ActiveLoop>) this.ActiveLoops, (Func <ActiveLoop, bool>)(x => x.Loop.OneAtATime)));
             if (this.Song.Loops.Count > 0 && this.AllOaaTs.Length > 0)
             {
                 this.CycleOaaTs();
             }
             this.Enabled = true;
             this.Watch.Start();
         }));
     }
 }
Esempio n. 6
0
 public void Resume()
 {
     if (this.Enabled)
     {
         return;
     }
     foreach (ActiveAmbienceTrack activeAmbienceTrack in this.ActiveTracks)
     {
         activeAmbienceTrack.Resume();
     }
     this.Enabled         = true;
     this.resumeRequested = true;
     Waiters.Interpolate(0.125, (Action <float>)(step =>
     {
         if (!this.Enabled)
         {
             return;
         }
         this.resumeRequested = false;
     }));
 }
Esempio n. 7
0
 public void Resume()
 {
     if (this.Enabled || this.Watch == null)
     {
         return;
     }
     this.Watch.Start();
     foreach (ActiveLoop activeLoop in this.ActiveLoops)
     {
         activeLoop.Resume();
     }
     this.Enabled         = true;
     this.resumeRequested = true;
     Waiters.Interpolate(0.125, (Action <float>)(step =>
     {
         if (!this.Enabled)
         {
             return;
         }
         this.SoundManager.MusicVolumeFactor = FezMath.Saturate(Easing.EaseOut((double)step, EasingType.Sine));
         this.resumeRequested = false;
     }), (Action)(() => this.SoundManager.MusicVolumeFactor = 1f));
 }
Esempio n. 8
0
 public void Pause()
 {
     if (!this.Enabled)
     {
         return;
     }
     Waiters.Interpolate(0.25, (Action <float>)(step =>
     {
         ActiveAmbience temp_10 = this;
         int temp_15            = (temp_10.cancelPause ? 1 : 0) | (this.resumeRequested ? 1 : (!this.Enabled ? 1 : 0));
         temp_10.cancelPause    = temp_15 != 0;
     }), (Action)(() =>
     {
         if (!this.cancelPause && !this.resumeRequested)
         {
             foreach (ActiveAmbienceTrack item_0 in this.ActiveTracks)
             {
                 item_0.Pause();
             }
             this.Enabled = false;
         }
         this.cancelPause = this.resumeRequested = false;
     }));
 }
Esempio n. 9
0
 public void OnMuteStateChanged(float fadeDuration)
 {
     if (this.ActiveForDayPhase && !this.ForceMuted && (double)this.volume != 1.0)
     {
         float   originalVolume = this.volume;
         IWaiter thisWaiter     = (IWaiter)null;
         this.volume          += 1.0 / 1000.0;
         this.transitionWaiter = thisWaiter = Waiters.Interpolate((double)fadeDuration * (1.0 - (double)this.volume), (Action <float>)(s =>
         {
             if (this.transitionWaiter != thisWaiter)
             {
                 return;
             }
             this.volume = originalVolume + s * (1f - originalVolume);
             if (this.cue == null || this.cue.IsDisposed)
             {
                 return;
             }
             this.cue.Volume = this.volume;
         }), (Action)(() =>
         {
             if (this.transitionWaiter != thisWaiter)
             {
                 return;
             }
             this.volume = 1f;
             if (this.cue == null || this.cue.IsDisposed)
             {
                 return;
             }
             this.cue.Volume = this.volume;
         }));
     }
     else
     {
         if (this.ActiveForDayPhase && !this.ForceMuted || (double)this.volume == 0.0)
         {
             return;
         }
         float   originalVolume = this.volume;
         IWaiter thisWaiter     = (IWaiter)null;
         this.volume          -= 1.0 / 1000.0;
         this.transitionWaiter = thisWaiter = Waiters.Interpolate((double)fadeDuration * (double)this.volume, (Action <float>)(s =>
         {
             if (this.transitionWaiter != thisWaiter)
             {
                 return;
             }
             this.volume = originalVolume * (1f - s);
             if (this.cue == null || this.cue.IsDisposed)
             {
                 return;
             }
             this.cue.Volume = this.volume;
         }), (Action)(() =>
         {
             if (this.transitionWaiter != thisWaiter)
             {
                 return;
             }
             this.volume = 0.0f;
             if (this.cue == null || this.cue.IsDisposed)
             {
                 return;
             }
             this.cue.Volume = this.volume;
         }));
     }
 }
Esempio n. 10
0
 public static IWaiter Interpolate(double durationSeconds, Action <float> assignation)
 {
     return(Waiters.Interpolate(durationSeconds, assignation, new Action(Util.NullAction)));
 }
Esempio n. 11
0
 public static IWaiter DoUntil(Func <bool> endCondition, Action <float> action)
 {
     return(Waiters.DoUntil(endCondition, action, new Action(Util.NullAction)));
 }