diff --git a/osu.Game/Storyboards/Commands/StoryboardCommandGroup.cs b/osu.Game/Storyboards/Commands/StoryboardCommandGroup.cs index 40dd8f78e6..0925231412 100644 --- a/osu.Game/Storyboards/Commands/StoryboardCommandGroup.cs +++ b/osu.Game/Storyboards/Commands/StoryboardCommandGroup.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Linq; using Newtonsoft.Json; using osu.Framework.Graphics; using osu.Framework.Lists; @@ -12,20 +13,45 @@ namespace osu.Game.Storyboards.Commands { public class StoryboardCommandGroup { - public SortedList> X = new SortedList>(); - public SortedList> Y = new SortedList>(); - public SortedList> Scale = new SortedList>(); - public SortedList> VectorScale = new SortedList>(); - public SortedList> Rotation = new SortedList>(); - public SortedList> Colour = new SortedList>(); - public SortedList> Alpha = new SortedList>(); - public SortedList> BlendingParameters = new SortedList>(); - public SortedList> FlipH = new SortedList>(); - public SortedList> FlipV = new SortedList>(); + private readonly SortedList> x = new SortedList>(); - public IReadOnlyList AllCommands => allCommands; + public IReadOnlyList> X => x; - private readonly List allCommands = new List(); + private readonly SortedList> y = new SortedList>(); + + public IReadOnlyList> Y => y; + + private readonly SortedList> scale = new SortedList>(); + + public IReadOnlyList> Scale => scale; + + private readonly SortedList> vectorScale = new SortedList>(); + + public IReadOnlyList> VectorScale => vectorScale; + + private readonly SortedList> rotation = new SortedList>(); + + public IReadOnlyList> Rotation => rotation; + + private readonly SortedList> colour = new SortedList>(); + + public IReadOnlyList> Colour => colour; + + private readonly SortedList> alpha = new SortedList>(); + + public IReadOnlyList> Alpha => alpha; + + private readonly SortedList> blendingParameters = new SortedList>(); + + public IReadOnlyList> BlendingParameters => blendingParameters; + + private readonly SortedList> flipH = new SortedList>(); + + public IReadOnlyList> FlipH => flipH; + + private readonly SortedList> flipV = new SortedList>(); + + public IReadOnlyList> FlipV => flipV; /// /// Returns the earliest start time of the commands added to this group. @@ -45,35 +71,44 @@ namespace osu.Game.Storyboards.Commands [JsonIgnore] public bool HasCommands { get; private set; } + private readonly IReadOnlyList[] lists; + + public IEnumerable AllCommands => lists.SelectMany(g => g); + + public StoryboardCommandGroup() + { + lists = new IReadOnlyList[] { X, Y, Scale, VectorScale, Rotation, Colour, Alpha, BlendingParameters, FlipH, FlipV }; + } + public void AddX(Easing easing, double startTime, double endTime, float startValue, float endValue) - => AddCommand(X, new StoryboardXCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(x, new StoryboardXCommand(easing, startTime, endTime, startValue, endValue)); public void AddY(Easing easing, double startTime, double endTime, float startValue, float endValue) - => AddCommand(Y, new StoryboardYCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(y, new StoryboardYCommand(easing, startTime, endTime, startValue, endValue)); public void AddScale(Easing easing, double startTime, double endTime, float startValue, float endValue) - => AddCommand(Scale, new StoryboardScaleCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(scale, new StoryboardScaleCommand(easing, startTime, endTime, startValue, endValue)); public void AddVectorScale(Easing easing, double startTime, double endTime, Vector2 startValue, Vector2 endValue) - => AddCommand(VectorScale, new StoryboardVectorScaleCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(vectorScale, new StoryboardVectorScaleCommand(easing, startTime, endTime, startValue, endValue)); public void AddRotation(Easing easing, double startTime, double endTime, float startValue, float endValue) - => AddCommand(Rotation, new StoryboardRotationCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(rotation, new StoryboardRotationCommand(easing, startTime, endTime, startValue, endValue)); public void AddColour(Easing easing, double startTime, double endTime, Color4 startValue, Color4 endValue) - => AddCommand(Colour, new StoryboardColourCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(colour, new StoryboardColourCommand(easing, startTime, endTime, startValue, endValue)); public void AddAlpha(Easing easing, double startTime, double endTime, float startValue, float endValue) - => AddCommand(Alpha, new StoryboardAlphaCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(alpha, new StoryboardAlphaCommand(easing, startTime, endTime, startValue, endValue)); public void AddBlendingParameters(Easing easing, double startTime, double endTime, BlendingParameters startValue, BlendingParameters endValue) - => AddCommand(BlendingParameters, new StoryboardBlendingParametersCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(blendingParameters, new StoryboardBlendingParametersCommand(easing, startTime, endTime, startValue, endValue)); public void AddFlipH(Easing easing, double startTime, double endTime, bool startValue, bool endValue) - => AddCommand(FlipH, new StoryboardFlipHCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(flipH, new StoryboardFlipHCommand(easing, startTime, endTime, startValue, endValue)); public void AddFlipV(Easing easing, double startTime, double endTime, bool startValue, bool endValue) - => AddCommand(FlipV, new StoryboardFlipVCommand(easing, startTime, endTime, startValue, endValue)); + => AddCommand(flipV, new StoryboardFlipVCommand(easing, startTime, endTime, startValue, endValue)); /// /// Adds the given storyboard to the target . @@ -83,7 +118,6 @@ namespace osu.Game.Storyboards.Commands protected virtual void AddCommand(ICollection> list, StoryboardCommand command) { list.Add(command); - allCommands.Add(command); HasCommands = true; if (command.StartTime < StartTime)