mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Use GetEndTime() to get storyboard endtime
This commit is contained in:
parent
7f5b1e84a1
commit
e40cb6797d
@ -14,4 +14,17 @@ namespace osu.Game.Storyboards
|
||||
|
||||
Drawable CreateDrawable();
|
||||
}
|
||||
|
||||
public static class StoryboardElementExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the end time of this object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This returns the <see cref="IStoryboardElementHasDuration.EndTime"/> where available, falling back to <see cref="IStoryboardElement.StartTime"/> otherwise.
|
||||
/// </remarks>
|
||||
/// <param name="storyboardElement">The object.</param>
|
||||
/// <returns>The end time of this object.</returns>
|
||||
public static double GetEndTime(this IStoryboardElement storyboardElement) => (storyboardElement as IStoryboardElementHasDuration)?.EndTime ?? storyboardElement.StartTime;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
namespace osu.Game.Storyboards
|
||||
{
|
||||
/// <summary>
|
||||
/// A StoryboardElement that ends at a different time than its start time.
|
||||
/// </summary>
|
||||
public interface IStoryboardElementHasDuration
|
||||
{
|
||||
double EndTime { get; }
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Storyboards
|
||||
/// This iterates all elements and as such should be used sparingly or stored locally.
|
||||
/// Videos and samples return StartTime as their EndTIme.
|
||||
/// </remarks>
|
||||
public double? LatestEventTime => Layers.SelectMany(l => l.Elements.OfType<IStoryboardElementHasDuration>()).OrderByDescending(e => e.EndTime).FirstOrDefault()?.EndTime;
|
||||
public double? LatestEventTime => Layers.SelectMany(l => l.Elements).OrderBy(e => e.GetEndTime()).LastOrDefault()?.GetEndTime();
|
||||
|
||||
/// <summary>
|
||||
/// Depth of the currently front-most storyboard layer, excluding the overlay layer.
|
||||
|
Loading…
Reference in New Issue
Block a user