1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 18:32:56 +08:00

Apply changes to the BreakTracker and more adjustment

This commit is contained in:
Salman Ahmed 2020-04-29 05:07:58 +03:00
parent 587f946dc6
commit 8d899f4e77
No known key found for this signature in database
GPG Key ID: ED81FD33FD9B58BC

View File

@ -2,20 +2,22 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Lists;
using osu.Game.Rulesets.Scoring;
using osu.Game.Utils;
namespace osu.Game.Screens.Play
{
public class BreakTracker : Component
{
private readonly ScoreProcessor scoreProcessor;
private readonly double gameplayStartTime;
private readonly PeriodTracker tracker = new PeriodTracker();
/// <summary>
/// Whether the gameplay is currently in a break.
/// </summary>
@ -23,22 +25,14 @@ namespace osu.Game.Screens.Play
private readonly BindableBool isBreakTime = new BindableBool();
private readonly IntervalList<double> breakIntervals = new IntervalList<double>();
public IReadOnlyList<BreakPeriod> Breaks
{
set
{
isBreakTime.Value = false;
breakIntervals.Clear();
foreach (var b in value)
{
if (!b.HasEffect)
continue;
breakIntervals.Add(b.StartTime, b.EndTime - BreakOverlay.BREAK_FADE_DURATION);
}
tracker.Periods = value?.Where(b => b.HasEffect)
.Select(b => new Period(b.StartTime, b.EndTime - BreakOverlay.BREAK_FADE_DURATION));
}
}
@ -54,7 +48,7 @@ namespace osu.Game.Screens.Play
var time = Clock.CurrentTime;
isBreakTime.Value = breakIntervals.IsInAnyInterval(time)
isBreakTime.Value = tracker.Contains(time)
|| time < gameplayStartTime
|| scoreProcessor?.HasCompleted == true;
}