Decouple bar line hitobjects from generator

Introduce an IBarLine interface, which together with generic constraints
helps decouple BarLineGenerator from the actual hitobject types it
creates. Thanks to this, all rulesets that want bar lines can provide
an implementation of IBarLine that also derives from the base hitobject
class.

This allows DrawableBarLines in taiko and mania to be migrated back to
DrawableTaikoHitObject and DrawableManiaHitObject base classes
respectively. This in turn resolves #6215 without code duplication,
since the missing anchoring application is now done in mania's
DrawableBarLine through deriving from DrawableManiaHitObject.
This commit is contained in:
Bartłomiej Dach
2019-09-24 23:03:55 +02:00
parent 09864d7f0e
commit 9323df26a1
9 changed files with 53 additions and 24 deletions

View File

@ -10,12 +10,13 @@ using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects
{
public class BarLineGenerator
public class BarLineGenerator<TBarLine>
where TBarLine : class, IBarLine, new()
{
/// <summary>
/// The generated bar lines.
/// </summary>
public readonly List<BarLine> BarLines = new List<BarLine>();
public readonly List<TBarLine> BarLines = new List<TBarLine>();
/// <summary>
/// Constructs and generates bar lines for provided beatmap.
@ -46,7 +47,7 @@ namespace osu.Game.Rulesets.Objects
for (double t = currentTimingPoint.Time; Precision.DefinitelyBigger(endTime, t); t += barLength, currentBeat++)
{
BarLines.Add(new BarLine
BarLines.Add(new TBarLine
{
StartTime = t,
Major = currentBeat % (int)currentTimingPoint.TimeSignature == 0