mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 06:47:19 +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:
commit
2764a42824
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user