mirror of
https://github.com/ppy/osu
synced 2025-02-07 13:51:59 +00:00
Add a sane default lifetime end for scrolling hitobjects (#5837)
Add a sane default lifetime end for scrolling hitobjects Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
d11930d90c
@ -12,8 +12,13 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
{
|
||||
public class ScrollingHitObjectContainer : HitObjectContainer
|
||||
{
|
||||
private readonly IBindable<double> timeRange = new BindableDouble();
|
||||
/// <summary>
|
||||
/// A multiplier applied to the length of the scrolling area to determine a safe default lifetime end for hitobjects.
|
||||
/// This is only used to limit the lifetime end within reason, as proper lifetime management should be implemented on hitobjects themselves.
|
||||
/// </summary>
|
||||
private const float safe_lifetime_end_multiplier = 2;
|
||||
|
||||
private readonly IBindable<double> timeRange = new BindableDouble();
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
[Resolved]
|
||||
@ -88,24 +93,29 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
|
||||
private void computeInitialStateRecursive(DrawableHitObject hitObject)
|
||||
{
|
||||
hitObject.LifetimeStart = scrollingInfo.Algorithm.GetDisplayStartTime(hitObject.HitObject.StartTime, timeRange.Value);
|
||||
double endTime = hitObject.HitObject.StartTime;
|
||||
|
||||
if (hitObject.HitObject is IHasEndTime endTime)
|
||||
if (hitObject.HitObject is IHasEndTime e)
|
||||
{
|
||||
endTime = e.EndTime;
|
||||
|
||||
switch (direction.Value)
|
||||
{
|
||||
case ScrollingDirection.Up:
|
||||
case ScrollingDirection.Down:
|
||||
hitObject.Height = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime.EndTime, timeRange.Value, scrollLength);
|
||||
hitObject.Height = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime, timeRange.Value, scrollLength);
|
||||
break;
|
||||
|
||||
case ScrollingDirection.Left:
|
||||
case ScrollingDirection.Right:
|
||||
hitObject.Width = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime.EndTime, timeRange.Value, scrollLength);
|
||||
hitObject.Width = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime, timeRange.Value, scrollLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hitObject.LifetimeStart = scrollingInfo.Algorithm.GetDisplayStartTime(hitObject.HitObject.StartTime, timeRange.Value);
|
||||
hitObject.LifetimeEnd = scrollingInfo.Algorithm.TimeAt(scrollLength * safe_lifetime_end_multiplier, endTime, timeRange.Value, scrollLength);
|
||||
|
||||
foreach (var obj in hitObject.NestedHitObjects)
|
||||
{
|
||||
computeInitialStateRecursive(obj);
|
||||
|
Loading…
Reference in New Issue
Block a user