mirror of https://github.com/ppy/osu
Add IBeatmap<T> interface for typed hitobject retrieval
This commit is contained in:
parent
a91dbe4a50
commit
348d88846d
|
@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps
|
|||
/// <summary>
|
||||
/// A Beatmap containing converted HitObjects.
|
||||
/// </summary>
|
||||
public class Beatmap<T> : IBeatmap
|
||||
public class Beatmap<T> : IBeatmap<T>
|
||||
where T : HitObject
|
||||
{
|
||||
public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo
|
||||
|
@ -36,17 +36,13 @@ public class Beatmap<T> : IBeatmap
|
|||
|
||||
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
||||
|
||||
/// <summary>
|
||||
/// Total amount of break time in the beatmap.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||
|
||||
/// <summary>
|
||||
/// The HitObjects this Beatmap contains.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
||||
public List<T> HitObjects = new List<T>();
|
||||
public List<T> HitObjects { get; set; } = new List<T>();
|
||||
|
||||
IReadOnlyList<T> IBeatmap<T>.HitObjects => HitObjects;
|
||||
|
||||
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
||||
|
||||
|
|
|
@ -53,4 +53,13 @@ public interface IBeatmap : IJsonSerializable
|
|||
/// <returns>The shallow-cloned beatmap.</returns>
|
||||
IBeatmap Clone();
|
||||
}
|
||||
|
||||
public interface IBeatmap<out T> : IBeatmap
|
||||
where T : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The hitobjects contained by this beatmap.
|
||||
/// </summary>
|
||||
new IReadOnlyList<T> HitObjects { get; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue