2017-03-11 23:34:21 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-04-17 14:44:46 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-03-11 23:34:21 +08:00
|
|
|
|
using osu.Game.Modes.Objects;
|
2017-04-18 08:32:22 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-11 23:34:21 +08:00
|
|
|
|
|
2017-04-18 08:32:22 +08:00
|
|
|
|
namespace osu.Game.Modes.Beatmaps
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-03-13 18:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts a Beatmap for another mode.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">The type of HitObject stored in the Beatmap.</typeparam>
|
2017-04-18 08:38:52 +08:00
|
|
|
|
public abstract class BeatmapConverter<T> where T : HitObject
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-04-17 14:44:46 +08:00
|
|
|
|
/// <summary>
|
2017-04-17 16:25:29 +08:00
|
|
|
|
/// The types of HitObjects that can be converted to be used for this Beatmap.
|
2017-04-17 14:44:46 +08:00
|
|
|
|
/// </summary>
|
2017-04-18 08:38:52 +08:00
|
|
|
|
public abstract IEnumerable<Type> ValidConversionTypes { get; }
|
2017-04-17 14:44:46 +08:00
|
|
|
|
|
2017-03-13 18:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts a Beatmap to another mode.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="original">The original Beatmap.</param>
|
|
|
|
|
/// <returns>The converted Beatmap.</returns>
|
2017-04-18 08:38:52 +08:00
|
|
|
|
public abstract Beatmap<T> Convert(Beatmap original);
|
2017-04-17 14:44:46 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-18 08:13:36 +08:00
|
|
|
|
/// Checks if a Beatmap can be converted using this Beatmap Converter.
|
2017-04-17 14:44:46 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="beatmap">The Beatmap to check.</param>
|
2017-04-18 08:38:52 +08:00
|
|
|
|
/// <returns>Whether the Beatmap can be converted using this Beatmap Converter.</returns>
|
2017-04-18 09:23:49 +08:00
|
|
|
|
public bool CanConvert(Beatmap beatmap) => ValidConversionTypes.All(t => beatmap.HitObjects.Any(h => t.IsInstanceOfType(h)));
|
2017-04-17 14:44:46 +08:00
|
|
|
|
}
|
2017-03-11 23:34:21 +08:00
|
|
|
|
}
|