Add a sane default lifetime end for scrolling hitobjects

This commit is contained in:
smoogipoo 2019-08-26 16:47:23 +09:00
parent 7fd63b39fe
commit fb1cd9e5e7

View File

@ -12,8 +12,13 @@ namespace osu.Game.Rulesets.UI.Scrolling
{ {
public class ScrollingHitObjectContainer : HitObjectContainer 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>(); private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
[Resolved] [Resolved]
@ -92,6 +97,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (hitObject.HitObject is IHasEndTime endTime) if (hitObject.HitObject is IHasEndTime endTime)
{ {
hitObject.LifetimeEnd = scrollingInfo.Algorithm.TimeAt(scrollLength * safe_lifetime_end_multiplier, endTime.EndTime, timeRange.Value, scrollLength);
switch (direction.Value) switch (direction.Value)
{ {
case ScrollingDirection.Up: case ScrollingDirection.Up:
@ -105,6 +112,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
break; break;
} }
} }
else
hitObject.LifetimeEnd = scrollingInfo.Algorithm.TimeAt(scrollLength * safe_lifetime_end_multiplier, hitObject.HitObject.StartTime, timeRange.Value, scrollLength);
foreach (var obj in hitObject.NestedHitObjects) foreach (var obj in hitObject.NestedHitObjects)
{ {