// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; 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.Beatmaps.Formats; using osu.Game.IO.Serialization.Converters; namespace osu.Game.Beatmaps { /// /// A Beatmap containing converted HitObjects. /// public class Beatmap : IJsonSerializable, IHasComboColours where T : HitObject { public BeatmapInfo BeatmapInfo = new BeatmapInfo(); public ControlPointInfo ControlPointInfo = new ControlPointInfo(); public List Breaks = new List(); public List ComboColours { get; set; } = new List { new Color4(17, 136, 170, 255), new Color4(102, 136, 0, 255), new Color4(204, 102, 0, 255), new Color4(121, 9, 13, 255) }; [JsonIgnore] public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata; /// /// The HitObjects this Beatmap contains. /// [JsonConverter(typeof(TypedListConverter))] public List HitObjects = new List(); /// /// Total amount of break time in the beatmap. /// [JsonIgnore] public double TotalBreakTime => Breaks.Sum(b => b.Duration); /// /// Constructs a new beatmap. /// /// The original beatmap to use the parameters of. public Beatmap(Beatmap original = null) { BeatmapInfo = original?.BeatmapInfo.DeepClone() ?? BeatmapInfo; ControlPointInfo = original?.ControlPointInfo ?? ControlPointInfo; Breaks = original?.Breaks ?? Breaks; ComboColours = original?.ComboColours ?? ComboColours; HitObjects = original?.HitObjects ?? HitObjects; if (original == null && Metadata == null) { // we may have no metadata in cases we weren't sourced from the database. // let's fill it (and other related fields) so we don't need to null-check it in future usages. BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Artist = @"Unknown", Title = @"Unknown", AuthorString = @"Unknown Creator", }, Version = @"Normal", BaseDifficulty = new BeatmapDifficulty() }; } } } /// /// A Beatmap containing un-converted HitObjects. /// public class Beatmap : Beatmap { /// /// Constructs a new beatmap. /// /// The original beatmap to use the parameters of. public Beatmap(Beatmap original) : base(original) { } public Beatmap() { } } }