mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 11:12:59 +08:00
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>
|
/// <summary>
|
||||||
/// A Beatmap containing converted HitObjects.
|
/// A Beatmap containing converted HitObjects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Beatmap<T> : IBeatmap
|
public class Beatmap<T> : IBeatmap<T>
|
||||||
where T : HitObject
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo
|
public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo
|
||||||
@ -36,17 +36,13 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Total amount of break time in the beatmap.
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The HitObjects this Beatmap contains.
|
|
||||||
/// </summary>
|
|
||||||
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
[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;
|
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
||||||
|
|
||||||
|
@ -53,4 +53,13 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <returns>The shallow-cloned beatmap.</returns>
|
/// <returns>The shallow-cloned beatmap.</returns>
|
||||||
IBeatmap Clone();
|
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
Block a user