// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable enable using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Replays; namespace osu.Game.Rulesets.Replays { public abstract class FramedAutoGenerator : AutoGenerator where TFrame : ReplayFrame { /// /// The replay frames of the autoplay. /// protected readonly List Frames = new List(); protected TFrame? LastFrame => Frames.Count == 0 ? null : Frames[^1]; protected FramedAutoGenerator(IBeatmap beatmap) : base(beatmap) { } public sealed override Replay Generate() { Frames.Clear(); GenerateFrames(); return new Replay { Frames = Frames.OrderBy(frame => frame.Time).Cast().ToList() }; } /// /// Generate the replay frames of the autoplay and populate . /// protected abstract void GenerateFrames(); } }