1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:23:22 +08:00

Bring back scheduling of follow point update

This commit is contained in:
ekrctb 2021-06-04 18:41:02 +09:00
parent 0098ac2760
commit d7da66d876
2 changed files with 11 additions and 8 deletions

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
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;
@ -26,26 +25,30 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{ {
base.OnApply(entry); base.OnApply(entry);
entry.Invalidated += refreshPoints; entry.Invalidated += onEntryInvalidated;
refreshPoints(entry); refreshPoints();
} }
protected override void OnFree(FollowPointLifetimeEntry entry) protected override void OnFree(FollowPointLifetimeEntry entry)
{ {
base.OnFree(entry); base.OnFree(entry);
entry.Invalidated -= refreshPoints; entry.Invalidated -= onEntryInvalidated;
// Return points to the pool. // Return points to the pool.
ClearInternal(false); ClearInternal(false);
} }
private void refreshPoints(FollowPointLifetimeEntry entry) private void onEntryInvalidated() => Scheduler.AddOnce(refreshPoints);
private void refreshPoints()
{ {
ClearInternal(false); ClearInternal(false);
var entry = Entry;
if (entry?.End == null) return;
OsuHitObject start = entry.Start; OsuHitObject start = entry.Start;
OsuHitObject end = entry.End; OsuHitObject end = entry.End;
Debug.Assert(end != null, $"{nameof(FollowPointLifetimeEntry)} without end hit object should never be alive");
double startTime = start.GetEndTime(); double startTime = start.GetEndTime();

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{ {
public class FollowPointLifetimeEntry : LifetimeEntry public class FollowPointLifetimeEntry : LifetimeEntry
{ {
public event Action<FollowPointLifetimeEntry>? Invalidated; public event Action? Invalidated;
public readonly OsuHitObject Start; public readonly OsuHitObject Start;
public FollowPointLifetimeEntry(OsuHitObject start) public FollowPointLifetimeEntry(OsuHitObject start)
@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
LifetimeStart = fadeInTime; LifetimeStart = fadeInTime;
LifetimeEnd = double.MaxValue; // This will be set by the connection. LifetimeEnd = double.MaxValue; // This will be set by the connection.
Invalidated?.Invoke(this); Invalidated?.Invoke();
} }
} }
} }