1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 10:27:35 +08:00
osu-lazer/osu.Game/Modes/Beatmaps/BeatmapConverter.cs

38 lines
1.5 KiB
C#
Raw Normal View History

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;
using osu.Game.Beatmaps;
2017-03-11 23:34:21 +08:00
namespace osu.Game.Modes.Beatmaps
2017-03-11 23:34:21 +08:00
{
/// <summary>
/// Converts a Beatmap for another mode.
/// </summary>
/// <typeparam name="T">The type of HitObject stored in the Beatmap.</typeparam>
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>
/// The types of HitObjects that can be converted to be used for this Beatmap.
2017-04-17 14:44:46 +08:00
/// </summary>
public abstract IEnumerable<Type> ValidConversionTypes { get; }
2017-04-17 14:44:46 +08:00
/// <summary>
/// Converts a Beatmap to another mode.
/// </summary>
/// <param name="original">The original Beatmap.</param>
/// <returns>The converted Beatmap.</returns>
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>
/// <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.IsInstanceOfType(h)));
2017-04-17 14:44:46 +08:00
}
2017-03-11 23:34:21 +08:00
}