1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 13:53:10 +08:00

Attempt to explain source initialisation better

This commit is contained in:
Bartłomiej Dach 2021-04-23 21:56:08 +02:00
parent ae2fd2f2e1
commit fdb5490e51

View File

@ -63,8 +63,7 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public virtual void Start() public virtual void Start()
{ {
// Ensure that the source clock is set. ensureSourceClockSet();
ChangeSource(SourceClock);
if (!AdjustableSource.IsRunning) if (!AdjustableSource.IsRunning)
{ {
@ -100,7 +99,7 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public virtual void Reset() public virtual void Reset()
{ {
ChangeSource(SourceClock); ensureSourceClockSet();
Seek(0); Seek(0);
// Manually stop the source in order to not affect the IsPaused state. // Manually stop the source in order to not affect the IsPaused state.
@ -116,6 +115,15 @@ namespace osu.Game.Screens.Play
/// <param name="sourceClock">The new source.</param> /// <param name="sourceClock">The new source.</param>
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock); protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
/// <summary>
/// Ensures that the <see cref="AdjustableSource"/> is set to <see cref="SourceClock"/>.
/// 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() => ChangeSource(SourceClock);
protected override void Update() protected override void Update()
{ {
if (!IsPaused.Value) if (!IsPaused.Value)