2017-03-12 00:34:21 +09: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 15:44:46 +09:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-03-12 00:34:21 +09:00
|
|
|
|
using osu.Game.Modes.Objects;
|
2017-04-18 09:32:22 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-12 00:34:21 +09:00
|
|
|
|
|
2017-04-18 09:32:22 +09:00
|
|
|
|
namespace osu.Game.Modes.Beatmaps
|
2017-03-12 00:34:21 +09:00
|
|
|
|
{
|
2017-03-13 19:15:25 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts a Beatmap for another mode.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">The type of HitObject stored in the Beatmap.</typeparam>
|
2017-04-18 09:38:52 +09:00
|
|
|
|
public abstract class BeatmapConverter<T> where T : HitObject
|
2017-03-12 00:34:21 +09:00
|
|
|
|
{
|
2017-04-17 15:44:46 +09:00
|
|
|
|
/// <summary>
|
2017-04-17 17:25:29 +09:00
|
|
|
|
/// The types of HitObjects that can be converted to be used for this Beatmap.
|
2017-04-17 15:44:46 +09:00
|
|
|
|
/// </summary>
|
2017-04-18 09:38:52 +09:00
|
|
|
|
public abstract IEnumerable<Type> ValidConversionTypes { get; }
|
2017-04-17 15:44:46 +09:00
|
|
|
|
|
2017-03-13 19:15:25 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts a Beatmap to another mode.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="original">The original Beatmap.</param>
|
|
|
|
|
/// <returns>The converted Beatmap.</returns>
|
2017-04-18 09:38:52 +09:00
|
|
|
|
public abstract Beatmap<T> Convert(Beatmap original);
|
2017-04-17 15:44:46 +09:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-18 09:13:36 +09:00
|
|
|
|
/// Checks if a Beatmap can be converted using this Beatmap Converter.
|
2017-04-17 15:44:46 +09:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="beatmap">The Beatmap to check.</param>
|
2017-04-18 09:38:52 +09:00
|
|
|
|
/// <returns>Whether the Beatmap can be converted using this Beatmap Converter.</returns>
|
|
|
|
|
public bool CanConvert(Beatmap beatmap) => ValidConversionTypes.All(t => beatmap.HitObjects.Any(h => t.IsAssignableFrom(h.GetType())));
|
2017-04-17 15:44:46 +09:00
|
|
|
|
}
|
2017-03-12 00:34:21 +09:00
|
|
|
|
}
|