mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Cleanups + xmldoc rewordings/improvements.
This commit is contained in:
@ -15,14 +15,16 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// A collection of <see cref="SpeedAdjustmentContainer"/>s.
|
||||
///
|
||||
/// <para>
|
||||
/// This container provides <see cref="VisibleTimeRange"/> for the <see cref="SpeedAdjustmentContainer"/>s.
|
||||
/// This container redirects any <see cref="DrawableHitObject"/>'s added to it to the <see cref="SpeedAdjustmentContainer"/>
|
||||
/// which provides the speed adjustment active at the start time of the hit object. Furthermore, this container provides the
|
||||
/// necessary <see cref="VisibleTimeRange"/> for the contained <see cref="SpeedAdjustmentContainer"/>s.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class SpeedAdjustmentCollection : Container<SpeedAdjustmentContainer>
|
||||
{
|
||||
private readonly BindableDouble visibleTimeRange = new BindableDouble();
|
||||
/// <summary>
|
||||
/// The amount of time visible by span of this container.
|
||||
/// Gets or sets the range of time that is visible by the length of this container.
|
||||
/// For example, only hit objects with start time less than or equal to 1000 will be visible with <see cref="VisibleTimeRange"/> = 1000.
|
||||
/// </summary>
|
||||
public Bindable<double> VisibleTimeRange
|
||||
@ -32,15 +34,16 @@ namespace osu.Game.Rulesets.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a hit object to the most applicable timing section in this container.
|
||||
/// Adds a hit object to the <see cref="SpeedAdjustmentContainer"/> which provides the speed adjustment
|
||||
/// active at the start time of the hit object.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The hit object to add.</param>
|
||||
public void Add(DrawableHitObject hitObject)
|
||||
{
|
||||
var target = timingSectionFor(hitObject);
|
||||
var target = adjustmentContainerFor(hitObject);
|
||||
|
||||
if (target == null)
|
||||
throw new ArgumentException("No timing section could be found that can contain the hit object.", nameof(hitObject));
|
||||
throw new ArgumentException("No speed adjustment could be found that can contain the hit object.", nameof(hitObject));
|
||||
|
||||
target.Add(hitObject);
|
||||
}
|
||||
@ -51,33 +54,34 @@ namespace osu.Game.Rulesets.Timing
|
||||
base.Add(speedAdjustment);
|
||||
}
|
||||
|
||||
protected override IComparer<Drawable> DepthComparer => new TimingSectionReverseStartTimeComparer();
|
||||
protected override IComparer<Drawable> DepthComparer => new SpeedAdjustmentContainerReverseStartTimeComparer();
|
||||
|
||||
/// <summary>
|
||||
/// Finds the most applicable timing section that can contain a hit object. If the hit object occurs before the first (time-wise)
|
||||
/// timing section, then the timing section returned is the first (time-wise) timing section.
|
||||
/// Finds the <see cref="SpeedAdjustmentContainer"/> which provides the speed adjustment active at the start time
|
||||
/// of a hit object. If there is no <see cref="SpeedAdjustmentContainer"/> active at the start time of the hit object,
|
||||
/// then the first (time-wise) speed adjustment is returned.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The hit object to contain.</param>
|
||||
/// <returns>The last (time-wise) timing section which can contain <paramref name="hitObject"/>. Null if no timing section exists.</returns>
|
||||
private SpeedAdjustmentContainer timingSectionFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault();
|
||||
/// <param name="hitObject">The hit object to find the active <see cref="SpeedAdjustmentContainer"/> for.</param>
|
||||
/// <returns>The <see cref="SpeedAdjustmentContainer"/> active at <paramref name="hitObject"/>'s start time. Null if there are no speed adjustments.</returns>
|
||||
private SpeedAdjustmentContainer adjustmentContainerFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Compares two timing sections by their start time, falling back to creation order if their start time is equal.
|
||||
/// This will compare the two timing sections in reverse order.
|
||||
/// Compares two speed adjustment containers by their control point start time, falling back to creation order
|
||||
// if their control point start time is equal. This will compare the two speed adjustment containers in reverse order.
|
||||
/// </summary>
|
||||
private class TimingSectionReverseStartTimeComparer : ReverseCreationOrderDepthComparer
|
||||
private class SpeedAdjustmentContainerReverseStartTimeComparer : ReverseCreationOrderDepthComparer
|
||||
{
|
||||
public override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var timingChangeX = x as SpeedAdjustmentContainer;
|
||||
var timingChangeY = y as SpeedAdjustmentContainer;
|
||||
var speedAdjustmentX = x as SpeedAdjustmentContainer;
|
||||
var speedAdjustmentY = y as SpeedAdjustmentContainer;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (timingChangeX?.MultiplierControlPoint == null || timingChangeY?.MultiplierControlPoint == null)
|
||||
if (speedAdjustmentX?.MultiplierControlPoint == null || speedAdjustmentY?.MultiplierControlPoint == null)
|
||||
return base.Compare(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = timingChangeY.MultiplierControlPoint.StartTime.CompareTo(timingChangeX.MultiplierControlPoint.StartTime);
|
||||
int i = speedAdjustmentY.MultiplierControlPoint.StartTime.CompareTo(speedAdjustmentX.MultiplierControlPoint.StartTime);
|
||||
|
||||
return i != 0 ? i : base.Compare(x, y);
|
||||
}
|
||||
|
Reference in New Issue
Block a user