public override void Update(GameTime gameTime) { double totalMinutes = this.Watch.Elapsed.TotalMinutes; foreach (ActiveLoop activeLoop in this.ActiveLoops) { if (activeLoop.Loop.FractionalTime) { float totalBars = (float)(totalMinutes - this.LastTotalMinutes) * (float)this.Song.Tempo / (float)this.Song.TimeSignature; activeLoop.UpdateFractional(totalBars); } activeLoop.UpdatePrecache(); } this.LastTotalMinutes = totalMinutes; double num1 = Math.Floor(totalMinutes * (double)this.Song.Tempo); if (num1 > (double)this.BeatsCounted) { this.BeatsCounted = (long)(int)num1; this.OnBeat(); long num2 = this.BeatsCounted / (long)this.Song.TimeSignature; if (num2 > this.BarsCounted) { this.BarsCounted = num2; this.OnBar(); } } if (this.IgnoreDayPhase) { return; } bool flag1 = this.TimeManager.IsDayPhaseForMusic(DayPhase.Day); bool flag2 = this.TimeManager.IsDayPhaseForMusic(DayPhase.Dawn); bool flag3 = this.TimeManager.IsDayPhaseForMusic(DayPhase.Dusk); bool flag4 = this.TimeManager.IsDayPhaseForMusic(DayPhase.Night); foreach (ActiveLoop activeLoop1 in this.ActiveLoops) { bool activeForDayPhase = activeLoop1.ActiveForDayPhase; activeLoop1.ActiveForDayPhase = false; ActiveLoop activeLoop2 = activeLoop1; int num2 = (activeLoop2.ActiveForDayPhase ? 1 : 0) | (!flag1 ? 0 : (activeLoop1.Loop.Day ? 1 : 0)); activeLoop2.ActiveForDayPhase = num2 != 0; ActiveLoop activeLoop3 = activeLoop1; int num3 = (activeLoop3.ActiveForDayPhase ? 1 : 0) | (!flag4 ? 0 : (activeLoop1.Loop.Night ? 1 : 0)); activeLoop3.ActiveForDayPhase = num3 != 0; ActiveLoop activeLoop4 = activeLoop1; int num4 = (activeLoop4.ActiveForDayPhase ? 1 : 0) | (!flag2 ? 0 : (activeLoop1.Loop.Dawn ? 1 : 0)); activeLoop4.ActiveForDayPhase = num4 != 0; ActiveLoop activeLoop5 = activeLoop1; int num5 = (activeLoop5.ActiveForDayPhase ? 1 : 0) | (!flag3 ? 0 : (activeLoop1.Loop.Dusk ? 1 : 0)); activeLoop5.ActiveForDayPhase = num5 != 0; if (activeForDayPhase != activeLoop1.ActiveForDayPhase) { activeLoop1.OnMuteStateChanged(16f); } } }
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(); })); } }
private void CycleOaaTs() { if (this.CurrentOaaT != null && this.CurrentOaaT.Loop.CutOffTail && !this.CurrentOaaT.WaitedForDelay) { this.CurrentOaaT.CutOff(); } this.CurrentOaaT = this.NextOaaT; if (this.CurrentOaaT != null) { this.CurrentOaaT.ActiveForOoaTs = false; } int index; if (this.Song.RandomOrdering) { index = RandomHelper.Random.Next(0, this.AllOaaTs.Length); if (this.CurrentOaaT != null && index == this.ActiveLoops.IndexOf(this.CurrentOaaT)) { index = RandomHelper.Random.Next(0, this.AllOaaTs.Length); } } else { index = this.Song.CustomOrdering == null || this.Song.CustomOrdering.Length == 0 ? (this.ActiveLoops.IndexOf(this.CurrentOaaT) + 1) % this.ActiveLoops.Count : this.Song.CustomOrdering[this.OoaTIndex = (this.OoaTIndex + 1) % this.Song.CustomOrdering.Length] - 1; } this.NextOaaT = this.AllOaaTs[index]; this.NextOaaT.ActiveForOoaTs = true; this.NextOaaT.SchedulePlay(); if (this.CurrentOaaT != null) { return; } this.NextOaaT.ForcePlay(); if (this.NextOaaT.Loop.Delay != 0) { return; } this.CycleOaaTs(); }