Only set initial source in Reset()

This commit is contained in:
smoogipoo 2021-04-19 19:55:59 +09:00
parent c7183f92f7
commit acbf4580a4
2 changed files with 17 additions and 4 deletions

View File

@ -29,17 +29,22 @@ public abstract class GameplayClockContainer : Container
/// </summary>
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
/// <summary>
/// The source clock.
/// </summary>
protected IClock SourceClock { get; private set; }
/// <summary>
/// Creates a new <see cref="GameplayClockContainer"/>.
/// </summary>
/// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param>
protected GameplayClockContainer(IClock sourceClock)
{
SourceClock = sourceClock;
RelativeSizeAxes = Axes.Both;
AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
AdjustableSource.ChangeSource(sourceClock);
IsPaused.BindValueChanged(OnIsPausedChanged);
}
@ -86,6 +91,8 @@ public virtual void Start()
/// </summary>
public virtual void Reset()
{
ChangeSource(SourceClock);
AdjustableSource.Seek(0);
AdjustableSource.Stop();
@ -93,6 +100,12 @@ public virtual void Reset()
Start();
}
/// <summary>
/// Changes the source clock.
/// </summary>
/// <param name="sourceClock">The new source.</param>
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
protected override void Update()
{
if (!IsPaused.Value)

View File

@ -33,7 +33,7 @@ public class MasterGameplayClockContainer : GameplayClockContainer
/// </summary>
public const double MINIMUM_SKIP_TIME = 1000;
protected Track Track => (Track)AdjustableSource.Source;
protected Track Track => (Track)SourceClock;
public readonly BindableNumber<double> UserPlaybackRate = new BindableDouble(1)
{
@ -164,7 +164,7 @@ protected override GameplayClock CreateGameplayClock(IFrameBasedClock source)
public void StopUsingBeatmapClock()
{
removeSourceClockAdjustments();
AdjustableSource.ChangeSource(new TrackVirtual(beatmap.Track.Length));
ChangeSource(new TrackVirtual(beatmap.Track.Length));
}
private bool speedAdjustmentsApplied;