Exemple #1
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));
            }
        }
Exemple #2
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)));
 }
Exemple #3
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));
     }
 }
Exemple #4
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();
         }));
     }
 }