// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Objects; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps.ControlPoints; using osu.Game.IO.Serialization; using Newtonsoft.Json; using osu.Game.IO.Serialization.Converters; namespace osu.Game.Beatmaps { public interface IBeatmap : IJsonSerializable { /// /// This beatmap's info. /// BeatmapInfo BeatmapInfo { get; } /// /// This beatmap's metadata. /// BeatmapMetadata Metadata { get; } /// /// The control points in this beatmap. /// ControlPointInfo ControlPointInfo { get; } /// /// The breaks in this beatmap. /// List Breaks { get; } /// /// Total amount of break time in the beatmap. /// double TotalBreakTime { get; } /// /// The hitobjects contained by this beatmap. /// IEnumerable HitObjects { get; } /// /// Creates a shallow-clone of this beatmap and returns it. /// /// The shallow-cloned beatmap. IBeatmap Clone(); } /// /// A Beatmap containing converted HitObjects. /// public class Beatmap : IBeatmap where T : HitObject { public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo { Metadata = new BeatmapMetadata { Artist = @"Unknown", Title = @"Unknown", AuthorString = @"Unknown Creator", }, Version = @"Normal", BaseDifficulty = new BeatmapDifficulty() }; [JsonIgnore] public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata; public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo(); public List Breaks { get; set; } = new List(); /// /// Total amount of break time in the beatmap. /// [JsonIgnore] public double TotalBreakTime => Breaks.Sum(b => b.Duration); /// /// The HitObjects this Beatmap contains. /// [JsonConverter(typeof(TypedListConverter))] public List HitObjects = new List(); IEnumerable IBeatmap.HitObjects => HitObjects; public Beatmap Clone() => new Beatmap { BeatmapInfo = BeatmapInfo.DeepClone(), ControlPointInfo = ControlPointInfo, Breaks = Breaks, HitObjects = HitObjects }; IBeatmap IBeatmap.Clone() => Clone(); } public class Beatmap : Beatmap { public new Beatmap Clone() => (Beatmap)base.Clone(); } }