// 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; using osu.Game.Beatmaps; namespace osu.Game.Modes.Beatmaps { /// /// Converts a Beatmap for another mode. /// /// The type of HitObject stored in the Beatmap. public abstract class BeatmapConverter where T : HitObject { /// /// The types of HitObjects that can be converted to be used for this Beatmap. /// public abstract IEnumerable ValidConversionTypes { get; } /// /// Converts a Beatmap to another mode. /// /// The original Beatmap. /// The converted Beatmap. public abstract Beatmap Convert(Beatmap original); /// /// Checks if a Beatmap can be converted using this Beatmap Converter. /// /// The Beatmap to check. /// Whether the Beatmap can be converted using this Beatmap Converter. public bool CanConvert(Beatmap beatmap) => ValidConversionTypes.All(t => beatmap.HitObjects.Any(h => t.IsAssignableFrom(h.GetType()))); } }