mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge branch 'master' into skin-components-list
This commit is contained in:
@ -1,40 +1,36 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Replays
|
||||
{
|
||||
public abstract class AutoGenerator : IAutoGenerator
|
||||
public abstract class AutoGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the auto replay and returns it.
|
||||
/// Every subclass of OsuAutoGeneratorBase should implement this!
|
||||
/// The default duration of a key press in milliseconds.
|
||||
/// </summary>
|
||||
public abstract Replay Generate();
|
||||
|
||||
#region Parameters
|
||||
public const double KEY_UP_DELAY = 50;
|
||||
|
||||
/// <summary>
|
||||
/// The beatmap we're making.
|
||||
/// The beatmap the autoplay is generated for.
|
||||
/// </summary>
|
||||
protected IBeatmap Beatmap;
|
||||
|
||||
#endregion
|
||||
protected IBeatmap Beatmap { get; }
|
||||
|
||||
protected AutoGenerator(IBeatmap beatmap)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
}
|
||||
|
||||
#region Constants
|
||||
|
||||
// Shared amongst all modes
|
||||
public const double KEY_UP_DELAY = 50;
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Generate the replay of the autoplay.
|
||||
/// </summary>
|
||||
public abstract Replay Generate();
|
||||
|
||||
protected virtual HitObject GetNextObject(int currentIndex)
|
||||
{
|
||||
@ -44,4 +40,37 @@ namespace osu.Game.Rulesets.Replays
|
||||
return Beatmap.HitObjects[currentIndex + 1];
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AutoGenerator<TFrame> : AutoGenerator
|
||||
where TFrame : ReplayFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// The replay frames of the autoplay.
|
||||
/// </summary>
|
||||
protected readonly List<TFrame> Frames = new List<TFrame>();
|
||||
|
||||
[CanBeNull]
|
||||
protected TFrame LastFrame => Frames.Count == 0 ? null : Frames[^1];
|
||||
|
||||
protected AutoGenerator(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override Replay Generate()
|
||||
{
|
||||
Frames.Clear();
|
||||
GenerateFrames();
|
||||
|
||||
return new Replay
|
||||
{
|
||||
Frames = Frames.OrderBy(frame => frame.Time).Cast<ReplayFrame>().ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate the replay frames of the autoplay and populate <see cref="Frames"/>.
|
||||
/// </summary>
|
||||
protected abstract void GenerateFrames();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Replays;
|
||||
|
||||
namespace osu.Game.Rulesets.Replays
|
||||
{
|
||||
public interface IAutoGenerator
|
||||
{
|
||||
Replay Generate();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user