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
|
|
|
|
|
|
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
using osu.Game.Beatmaps.Legacy;
|
2017-03-23 18:14:21 +08:00
|
|
|
|
using osu.Game.Beatmaps.Samples;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
using osu.Game.Modes.Objects;
|
|
|
|
|
using osu.Game.Modes.Objects.Types;
|
2017-03-11 23:34:21 +08:00
|
|
|
|
using osu.Game.Modes.Taiko.Objects;
|
2017-04-03 09:54:13 +08:00
|
|
|
|
using System;
|
2017-03-11 23:34:21 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
using System.Linq;
|
2017-04-03 14:02:21 +08:00
|
|
|
|
using osu.Game.Database;
|
2017-03-11 23:34:21 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Modes.Taiko.Beatmaps
|
|
|
|
|
{
|
2017-03-17 12:33:48 +08:00
|
|
|
|
internal class TaikoBeatmapConverter : IBeatmapConverter<TaikoHitObject>
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-03-17 13:44:48 +08:00
|
|
|
|
private const float legacy_velocity_scale = 1.4f;
|
2017-03-17 18:52:24 +08:00
|
|
|
|
private const float bash_convert_factor = 1.65f;
|
2017-03-17 13:44:48 +08:00
|
|
|
|
|
2017-04-03 14:24:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float base_distance = 100;
|
|
|
|
|
|
2017-03-17 12:33:48 +08:00
|
|
|
|
public Beatmap<TaikoHitObject> Convert(Beatmap original)
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-03-18 17:34:45 +08:00
|
|
|
|
if (original is LegacyBeatmap)
|
2017-03-17 13:44:48 +08:00
|
|
|
|
original.TimingInfo.ControlPoints.ForEach(c => c.VelocityAdjustment /= legacy_velocity_scale);
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-03-17 12:33:48 +08:00
|
|
|
|
return new Beatmap<TaikoHitObject>(original)
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-04-03 09:54:13 +08:00
|
|
|
|
HitObjects = original.HitObjects.SelectMany(h => convertHitObject(h, original)).ToList()
|
2017-03-17 13:39:38 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-03 09:54:13 +08:00
|
|
|
|
private IEnumerable<TaikoHitObject> convertHitObject(HitObject obj, Beatmap beatmap)
|
2017-03-17 13:39:38 +08:00
|
|
|
|
{
|
2017-03-17 18:51:56 +08:00
|
|
|
|
// Check if this HitObject is already a TaikoHitObject, and return it if so
|
2017-04-03 09:54:13 +08:00
|
|
|
|
var originalTaiko = obj as TaikoHitObject;
|
2017-03-17 18:51:56 +08:00
|
|
|
|
if (originalTaiko != null)
|
2017-04-03 09:54:13 +08:00
|
|
|
|
yield return originalTaiko;
|
2017-03-17 18:51:56 +08:00
|
|
|
|
|
2017-04-03 09:54:13 +08:00
|
|
|
|
var distanceData = obj as IHasDistance;
|
|
|
|
|
var repeatsData = obj as IHasRepeats;
|
|
|
|
|
var endTimeData = obj as IHasEndTime;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-03-29 09:59:35 +08:00
|
|
|
|
// Old osu! used hit sounding to determine various hit type information
|
2017-04-03 09:54:13 +08:00
|
|
|
|
SampleType sample = obj.Sample?.Type ?? SampleType.None;
|
2017-03-29 09:59:35 +08:00
|
|
|
|
|
|
|
|
|
bool strong = (sample & SampleType.Finish) > 0;
|
2017-03-23 18:14:21 +08:00
|
|
|
|
|
2017-03-17 13:39:38 +08:00
|
|
|
|
if (distanceData != null)
|
|
|
|
|
{
|
2017-04-03 14:24:30 +08:00
|
|
|
|
double sv = base_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier * beatmap.TimingInfo.BeatLengthAt(obj.StartTime) / 1000;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-04-03 09:54:13 +08:00
|
|
|
|
double l = distanceData.Distance * legacy_velocity_scale;
|
|
|
|
|
double v = sv * legacy_velocity_scale;
|
|
|
|
|
double bl = beatmap.TimingInfo.BeatLengthAt(obj.StartTime);
|
|
|
|
|
|
|
|
|
|
int repeats = repeatsData?.RepeatCount ?? 1;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-04-03 09:54:13 +08:00
|
|
|
|
double skipPeriod = Math.Min(bl / beatmap.BeatmapInfo.Difficulty.SliderTickRate, distanceData.Duration / repeats);
|
|
|
|
|
|
|
|
|
|
if (skipPeriod > 0 && l / v * 1000 < 2 * bl)
|
|
|
|
|
{
|
|
|
|
|
for (double j = obj.StartTime; j <= distanceData.EndTime + skipPeriod / 8; j += skipPeriod)
|
|
|
|
|
{
|
|
|
|
|
// Todo: This should generate different type of hits (including strongs)
|
|
|
|
|
// depending on hitobject sound additions (not implemented fully yet)
|
|
|
|
|
yield return new CentreHit
|
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
|
|
|
|
Sample = obj.Sample,
|
|
|
|
|
IsStrong = strong
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yield return new DrumRoll
|
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
|
|
|
|
Sample = obj.Sample,
|
|
|
|
|
IsStrong = strong,
|
2017-04-03 14:32:38 +08:00
|
|
|
|
Distance = distanceData.Distance * (repeatsData?.RepeatCount ?? 1) * legacy_velocity_scale,
|
|
|
|
|
TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4
|
2017-04-03 09:54:13 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (endTimeData != null)
|
2017-03-17 13:39:38 +08:00
|
|
|
|
{
|
2017-04-03 14:02:21 +08:00
|
|
|
|
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.OverallDifficulty, 3, 5, 7.5) * bash_convert_factor;
|
|
|
|
|
|
2017-04-03 09:54:13 +08:00
|
|
|
|
yield return new Swell
|
2017-03-17 13:39:38 +08:00
|
|
|
|
{
|
2017-04-03 09:54:13 +08:00
|
|
|
|
StartTime = obj.StartTime,
|
|
|
|
|
Sample = obj.Sample,
|
2017-03-28 09:02:41 +08:00
|
|
|
|
IsStrong = strong,
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-04-03 14:05:12 +08:00
|
|
|
|
EndTime = endTimeData.EndTime,
|
2017-04-03 14:02:21 +08:00
|
|
|
|
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
|
2017-03-17 13:39:38 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-04-03 09:54:13 +08:00
|
|
|
|
else
|
2017-03-30 14:51:16 +08:00
|
|
|
|
{
|
2017-04-03 09:54:13 +08:00
|
|
|
|
bool isCentre = (sample & ~(SampleType.Finish | SampleType.Normal)) == 0;
|
|
|
|
|
|
|
|
|
|
if (isCentre)
|
2017-03-30 14:51:16 +08:00
|
|
|
|
{
|
2017-04-03 09:54:13 +08:00
|
|
|
|
yield return new CentreHit
|
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
|
|
|
|
Sample = obj.Sample,
|
|
|
|
|
IsStrong = strong
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yield return new RimHit
|
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
|
|
|
|
Sample = obj.Sample,
|
|
|
|
|
IsStrong = strong,
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-03-30 14:51:16 +08:00
|
|
|
|
}
|
2017-03-11 23:34:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|