1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Merge pull request #12546 from smoogipoo/gcc-change-source-on-reset

Ensure source is set on GameplayClockContainer.Reset()
This commit is contained in:
Dean Herbert 2021-04-26 14:12:12 +09:00 committed by GitHub
commit 2764a42824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,8 +63,7 @@ namespace osu.Game.Screens.Play
/// </summary>
public virtual void Start()
{
// Ensure that the source clock is set.
ChangeSource(SourceClock);
ensureSourceClockSet();
if (!AdjustableSource.IsRunning)
{
@ -100,6 +99,7 @@ namespace osu.Game.Screens.Play
/// </summary>
public virtual void Reset()
{
ensureSourceClockSet();
Seek(0);
// Manually stop the source in order to not affect the IsPaused state.
@ -115,6 +115,19 @@ namespace osu.Game.Screens.Play
/// <param name="sourceClock">The new source.</param>
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
/// <summary>
/// Ensures that the <see cref="AdjustableSource"/> is set to <see cref="SourceClock"/>, if it hasn't been given a source yet.
/// This is usually done before a seek to avoid accidentally seeking only the adjustable source in decoupled mode,
/// but not the actual source clock.
/// That will pretty much only happen on the very first call of this method, as the source clock is passed in the constructor,
/// but it is not yet set on the adjustable source there.
/// </summary>
private void ensureSourceClockSet()
{
if (AdjustableSource.Source == null)
ChangeSource(SourceClock);
}
protected override void Update()
{
if (!IsPaused.Value)