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

Fix follow point animations in legacy skins not always starting at correct point in time

This commit is contained in:
Dean Herbert 2022-09-16 15:12:05 +09:00
parent cbf55732da
commit 289e6ad977

View File

@ -1,9 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Diagnostics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -21,32 +20,36 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
public const int SPACING = 32; public const int SPACING = 32;
public const double PREEMPT = 800; public const double PREEMPT = 800;
public DrawablePool<FollowPoint> Pool; public DrawablePool<FollowPoint>? Pool { private get; set; }
protected override void OnApply(FollowPointLifetimeEntry entry) protected override void OnApply(FollowPointLifetimeEntry entry)
{ {
base.OnApply(entry); base.OnApply(entry);
entry.Invalidated += onEntryInvalidated; entry.Invalidated += scheduleRefresh;
refreshPoints();
// Our clock may not be correct at this point if `LoadComplete` has not run yet.
// Without a schedule, animations referencing FollowPoint's clock (see `IAnimationTimeReference`) would be incorrect on first pool usage.
scheduleRefresh();
} }
protected override void OnFree(FollowPointLifetimeEntry entry) protected override void OnFree(FollowPointLifetimeEntry entry)
{ {
base.OnFree(entry); base.OnFree(entry);
entry.Invalidated -= onEntryInvalidated; entry.Invalidated -= scheduleRefresh;
// Return points to the pool. // Return points to the pool.
ClearInternal(false); ClearInternal(false);
} }
private void onEntryInvalidated() => Scheduler.AddOnce(refreshPoints); private void scheduleRefresh() => Scheduler.AddOnce(() =>
private void refreshPoints()
{ {
Debug.Assert(Pool != null);
ClearInternal(false); ClearInternal(false);
var entry = Entry; var entry = Entry;
if (entry?.End == null) return; if (entry?.End == null) return;
OsuHitObject start = entry.Start; OsuHitObject start = entry.Start;
@ -95,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
} }
entry.LifetimeEnd = finalTransformEndTime; entry.LifetimeEnd = finalTransformEndTime;
} });
/// <summary> /// <summary>
/// Computes the fade time of follow point positioned between two hitobjects. /// Computes the fade time of follow point positioned between two hitobjects.