// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using System.Collections.Generic; using System.Linq; using osu.Game.Modes.Objects; namespace osu.Game.Beatmaps { /// /// Converts a Beatmap for another mode. /// /// The type of HitObject stored in the Beatmap. public interface IBeatmapConverter where T : HitObject { /// /// The types of HitObjects that can be converted to be used for this Beatmap. /// IEnumerable ValidConversionTypes { get; } /// /// Converts a Beatmap to another mode. /// /// The original Beatmap. /// The converted Beatmap. Beatmap Convert(Beatmap original); } public static class BeatmapConverterExtensions { /// /// Checks if a Beatmap can be converted using a Beatmap Converter. /// /// The Converter to use. /// The Beatmap to check. /// Whether the Beatmap can be converted using . public static bool CanConvert(this IBeatmapConverter converter, Beatmap beatmap) where TObject : HitObject => converter.ValidConversionTypes.All(t => beatmap.HitObjects.Any(h => t.IsAssignableFrom(h.GetType()))); } }