Use FramedAutoGenerator in Taiko, Catch, Mania

OsuAutoGenerator is not included in this change because it uses SortedList-like thing
This commit is contained in:
ekrctb
2021-05-06 21:53:34 +09:00
parent ea35b72436
commit cf39178099
3 changed files with 11 additions and 38 deletions

View File

@ -5,7 +5,6 @@ using System;
using System.Linq; using System.Linq;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Catch.Beatmaps; using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
@ -13,26 +12,19 @@ using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Catch.Replays namespace osu.Game.Rulesets.Catch.Replays
{ {
internal class CatchAutoGenerator : AutoGenerator internal class CatchAutoGenerator : FramedAutoGenerator<CatchReplayFrame>
{ {
public const double RELEASE_DELAY = 20;
public new CatchBeatmap Beatmap => (CatchBeatmap)base.Beatmap; public new CatchBeatmap Beatmap => (CatchBeatmap)base.Beatmap;
public CatchAutoGenerator(IBeatmap beatmap) public CatchAutoGenerator(IBeatmap beatmap)
: base(beatmap) : base(beatmap)
{ {
Replay = new Replay();
} }
protected Replay Replay; protected override void GenerateFrames()
private CatchReplayFrame currentFrame;
public override Replay Generate()
{ {
if (Beatmap.HitObjects.Count == 0) if (Beatmap.HitObjects.Count == 0)
return Replay; return;
// todo: add support for HT DT // todo: add support for HT DT
const double dash_speed = Catcher.BASE_SPEED; const double dash_speed = Catcher.BASE_SPEED;
@ -119,15 +111,11 @@ namespace osu.Game.Rulesets.Catch.Replays
} }
} }
} }
return Replay;
} }
private void addFrame(double time, float? position = null, bool dashing = false) private void addFrame(double time, float? position = null, bool dashing = false)
{ {
var last = currentFrame; Frames.Add(new CatchReplayFrame(time, position, dashing, LastFrame));
currentFrame = new CatchReplayFrame(time, position, dashing, last);
Replay.Frames.Add(currentFrame);
} }
} }
} }

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Replays;
using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -11,7 +10,7 @@ using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Mania.Replays namespace osu.Game.Rulesets.Mania.Replays
{ {
internal class ManiaAutoGenerator : AutoGenerator internal class ManiaAutoGenerator : FramedAutoGenerator<ManiaReplayFrame>
{ {
public const double RELEASE_DELAY = 20; public const double RELEASE_DELAY = 20;
@ -22,8 +21,6 @@ namespace osu.Game.Rulesets.Mania.Replays
public ManiaAutoGenerator(ManiaBeatmap beatmap) public ManiaAutoGenerator(ManiaBeatmap beatmap)
: base(beatmap) : base(beatmap)
{ {
Replay = new Replay();
columnActions = new ManiaAction[Beatmap.TotalColumns]; columnActions = new ManiaAction[Beatmap.TotalColumns];
var normalAction = ManiaAction.Key1; var normalAction = ManiaAction.Key1;
@ -43,12 +40,10 @@ namespace osu.Game.Rulesets.Mania.Replays
} }
} }
protected Replay Replay; protected override void GenerateFrames()
public override Replay Generate()
{ {
if (Beatmap.HitObjects.Count == 0) if (Beatmap.HitObjects.Count == 0)
return Replay; return;
var pointGroups = generateActionPoints().GroupBy(a => a.Time).OrderBy(g => g.First().Time); var pointGroups = generateActionPoints().GroupBy(a => a.Time).OrderBy(g => g.First().Time);
@ -70,10 +65,8 @@ namespace osu.Game.Rulesets.Mania.Replays
} }
} }
Replay.Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray())); Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray()));
} }
return Replay;
} }
private IEnumerable<IActionPoint> generateActionPoints() private IEnumerable<IActionPoint> generateActionPoints()

View File

@ -2,10 +2,8 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Taiko.Beatmaps; using osu.Game.Rulesets.Taiko.Beatmaps;
@ -13,7 +11,7 @@ using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Replays namespace osu.Game.Rulesets.Taiko.Replays
{ {
public class TaikoAutoGenerator : AutoGenerator public class TaikoAutoGenerator : FramedAutoGenerator<TaikoReplayFrame>
{ {
public new TaikoBeatmap Beatmap => (TaikoBeatmap)base.Beatmap; public new TaikoBeatmap Beatmap => (TaikoBeatmap)base.Beatmap;
@ -22,16 +20,12 @@ namespace osu.Game.Rulesets.Taiko.Replays
public TaikoAutoGenerator(IBeatmap beatmap) public TaikoAutoGenerator(IBeatmap beatmap)
: base(beatmap) : base(beatmap)
{ {
Replay = new Replay();
} }
protected Replay Replay; protected override void GenerateFrames()
protected List<ReplayFrame> Frames => Replay.Frames;
public override Replay Generate()
{ {
if (Beatmap.HitObjects.Count == 0) if (Beatmap.HitObjects.Count == 0)
return Replay; return;
bool hitButton = true; bool hitButton = true;
@ -128,8 +122,6 @@ namespace osu.Game.Rulesets.Taiko.Replays
hitButton = !hitButton; hitButton = !hitButton;
} }
return Replay;
} }
} }
} }