Fix Reset() potentially not resetting to the intended start position

This commit is contained in:
smoogipoo
2021-04-20 13:01:42 +09:00
parent acbf4580a4
commit a92ae8ce76
2 changed files with 16 additions and 9 deletions

View File

@ -29,6 +29,11 @@ namespace osu.Game.Screens.Play
/// </summary>
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
/// <summary>
/// The offset at which to start playing. Affects the time which the clock is reset to via <see cref="Reset"/>.
/// </summary>
protected virtual double StartOffset => 0;
/// <summary>
/// The source clock.
/// </summary>
@ -93,9 +98,12 @@ namespace osu.Game.Screens.Play
{
ChangeSource(SourceClock);
AdjustableSource.Seek(0);
AdjustableSource.Seek(StartOffset);
AdjustableSource.Stop();
// Make sure the gameplay clock takes on the new time, otherwise the adjustable source will be seeked to the gameplay clock time in Start().
GameplayClock.UnderlyingClock.ProcessFrame();
if (!IsPaused.Value)
Start();
}