2019-01-24 16:43:03 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using osu.Game.IO.Serialization.Converters;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A Beatmap containing converted HitObjects.
|
|
|
|
/// </summary>
|
2019-08-28 19:19:22 +08:00
|
|
|
public class Beatmap<T> : IBeatmap<T>
|
2018-04-13 17:19:50 +08:00
|
|
|
where T : HitObject
|
|
|
|
{
|
2018-04-19 17:14:21 +08:00
|
|
|
public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo
|
|
|
|
{
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
{
|
|
|
|
Artist = @"Unknown",
|
|
|
|
Title = @"Unknown",
|
|
|
|
AuthorString = @"Unknown Creator",
|
|
|
|
},
|
|
|
|
Version = @"Normal",
|
|
|
|
BaseDifficulty = new BeatmapDifficulty()
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
|
|
|
|
2018-04-19 17:14:21 +08:00
|
|
|
public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo();
|
|
|
|
|
|
|
|
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
|
|
|
|
2018-04-19 17:14:21 +08:00
|
|
|
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
2019-08-28 19:19:22 +08:00
|
|
|
public List<T> HitObjects { get; set; } = new List<T>();
|
|
|
|
|
|
|
|
IReadOnlyList<T> IBeatmap<T>.HitObjects => HitObjects;
|
2018-04-19 17:14:21 +08:00
|
|
|
|
2018-10-11 18:53:07 +08:00
|
|
|
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
2018-04-19 17:14:21 +08:00
|
|
|
|
2018-05-07 09:51:17 +08:00
|
|
|
public virtual IEnumerable<BeatmapStatistic> GetStatistics() => Enumerable.Empty<BeatmapStatistic>();
|
|
|
|
|
2018-04-19 17:50:21 +08:00
|
|
|
IBeatmap IBeatmap.Clone() => Clone();
|
|
|
|
|
2021-01-07 22:52:04 +08:00
|
|
|
public Beatmap<T> Clone()
|
|
|
|
{
|
|
|
|
var clone = (Beatmap<T>)MemberwiseClone();
|
|
|
|
|
|
|
|
clone.ControlPointInfo = ControlPointInfo.CreateCopy();
|
|
|
|
// todo: deep clone other elements as required.
|
|
|
|
|
|
|
|
return clone;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public class Beatmap : Beatmap<HitObject>
|
|
|
|
{
|
2018-05-17 11:59:48 +08:00
|
|
|
public new Beatmap Clone() => (Beatmap)base.Clone();
|
2019-08-11 22:41:56 +08:00
|
|
|
|
2019-08-12 00:40:11 +08:00
|
|
|
public override string ToString() => BeatmapInfo?.ToString() ?? base.ToString();
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|