1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:02:55 +08:00

Use DHO.HitObjectApplied to invalidate computation

This commit is contained in:
ekrctb 2020-11-26 14:07:40 +09:00
parent f6faf95e33
commit e43f928588
2 changed files with 13 additions and 5 deletions

View File

@ -147,7 +147,10 @@ namespace osu.Game.Rulesets.UI.Scrolling
}
}
private void onHitObjectUsageBegin(DrawableHitObject hitObject)
/// <summary>
/// Make this <see cref="DrawableHitObject"/> lifetime and layout computed in next update.
/// </summary>
internal void InvalidateHitObject(DrawableHitObject hitObject)
{
// Lifetime computation is delayed until next update because
// when the hit object is not pooled this container is not loaded here and `scrollLength` cannot be computed.

View File

@ -15,6 +15,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
{
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
public new ScrollingHitObjectContainer HitObjectContainer => (ScrollingHitObjectContainer)base.HitObjectContainer;
[Resolved]
protected IScrollingInfo ScrollingInfo { get; private set; }
@ -24,17 +26,20 @@ namespace osu.Game.Rulesets.UI.Scrolling
Direction.BindTo(ScrollingInfo.Direction);
}
protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
{
drawableHitObject.HitObjectApplied += d => HitObjectContainer.InvalidateHitObject(d);
}
/// <summary>
/// Given a position in screen space, return the time within this column.
/// </summary>
public virtual double TimeAtScreenSpacePosition(Vector2 screenSpacePosition) =>
((ScrollingHitObjectContainer)HitObjectContainer).TimeAtScreenSpacePosition(screenSpacePosition);
public virtual double TimeAtScreenSpacePosition(Vector2 screenSpacePosition) => HitObjectContainer.TimeAtScreenSpacePosition(screenSpacePosition);
/// <summary>
/// Given a time, return the screen space position within this column.
/// </summary>
public virtual Vector2 ScreenSpacePositionAtTime(double time)
=> ((ScrollingHitObjectContainer)HitObjectContainer).ScreenSpacePositionAtTime(time);
public virtual Vector2 ScreenSpacePositionAtTime(double time) => HitObjectContainer.ScreenSpacePositionAtTime(time);
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
}