Improve command sorting.

This commit is contained in:
Damnae 2017-09-09 11:00:58 +02:00
parent 12de737084
commit 8d55cb7f92
2 changed files with 11 additions and 3 deletions

View File

@ -3,6 +3,7 @@
using osu.Framework.Caching; using osu.Framework.Caching;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -47,6 +48,13 @@ namespace osu.Game.Storyboards
public T StartValue; public T StartValue;
public T EndValue; public T EndValue;
public int CompareTo(ICommand other)
{
var result = StartTime.CompareTo(other.StartTime);
if (result != 0) return result;
return EndTime.CompareTo(other.EndTime);
}
public override string ToString() public override string ToString()
=> $"{StartTime} -> {EndTime}, {StartValue} -> {EndValue} {Easing}"; => $"{StartTime} -> {EndTime}, {StartValue} -> {EndValue} {Easing}";
} }
@ -59,7 +67,7 @@ namespace osu.Game.Storyboards
bool HasCommands { get; } bool HasCommands { get; }
} }
public interface ICommand public interface ICommand : IComparable<ICommand>
{ {
Easing Easing { get; set; } Easing Easing { get; set; }
double StartTime { get; set; } double StartTime { get; set; }

View File

@ -78,7 +78,7 @@ namespace osu.Game.Storyboards
CommandTimelineSelector<T> timelineSelector, DrawablePropertyInitializer<T> initializeProperty, DrawableTransformer<T> transform) CommandTimelineSelector<T> timelineSelector, DrawablePropertyInitializer<T> initializeProperty, DrawableTransformer<T> transform)
{ {
var initialized = false; var initialized = false;
foreach (var command in getAggregatedCommands(timelineSelector, triggeredGroups)) foreach (var command in getAggregatedCommands(timelineSelector, triggeredGroups).OrderBy(l => l))
{ {
if (!initialized) if (!initialized)
{ {
@ -99,7 +99,7 @@ namespace osu.Game.Storyboards
if (triggeredGroups != null) if (triggeredGroups != null)
foreach (var pair in triggeredGroups) foreach (var pair in triggeredGroups)
commands = commands.Concat(pair.Item1.GetCommands(timelineSelector, pair.Item2)); commands = commands.Concat(pair.Item1.GetCommands(timelineSelector, pair.Item2));
return commands.OrderBy(l => l.StartTime); return commands;
} }
public override string ToString() public override string ToString()