Add IBeatmap<T> interface for typed hitobject retrieval

This commit is contained in:
smoogipoo 2019-08-28 20:19:22 +09:00
parent a91dbe4a50
commit 348d88846d
2 changed files with 13 additions and 8 deletions

View File

@ -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;

View File

@ -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; }
}
}