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.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-04-06 14:55:08 +08:00
|
|
|
|
using osu.Game.IO.Serialization;
|
2017-04-06 10:41:16 +08:00
|
|
|
|
using osu.Game.Audio;
|
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-04-03 19:32:03 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// osu! is generally slower than taiko, so a factor is added to increase
|
|
|
|
|
/// speed. This must be used everywhere slider length or beat length is used.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float legacy_velocity_multiplier = 1.4f;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Because swells are easier in taiko than spinners are in osu!,
|
|
|
|
|
/// legacy taiko multiplies a factor when converting the number of required hits.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float swell_hit_multiplier = 1.65f;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base osu! slider scoring distance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float osu_base_scoring_distance = 100;
|
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>
|
2017-04-03 19:32:03 +08:00
|
|
|
|
private const float taiko_base_distance = 100;
|
2017-04-03 14:24:30 +08:00
|
|
|
|
|
2017-03-17 12:33:48 +08:00
|
|
|
|
public Beatmap<TaikoHitObject> Convert(Beatmap original)
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-04-06 14:55:08 +08:00
|
|
|
|
BeatmapInfo info = original.BeatmapInfo.DeepClone<BeatmapInfo>();
|
|
|
|
|
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
|
|
|
|
|
|
2017-03-17 12:33:48 +08:00
|
|
|
|
return new Beatmap<TaikoHitObject>(original)
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-04-06 14:55:08 +08:00
|
|
|
|
BeatmapInfo = info,
|
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-06 10:41:16 +08:00
|
|
|
|
List<SampleInfo> samples = obj.Samples;
|
2017-03-29 09:59:35 +08:00
|
|
|
|
|
2017-04-06 11:14:06 +08:00
|
|
|
|
bool strong = samples.Any(s => s.Name == SampleInfo.HIT_FINISH);
|
2017-03-23 18:14:21 +08:00
|
|
|
|
|
2017-03-17 13:39:38 +08:00
|
|
|
|
if (distanceData != null)
|
|
|
|
|
{
|
2017-04-03 16:20:46 +08:00
|
|
|
|
int repeats = repeatsData?.RepeatCount ?? 1;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-04-03 19:27:11 +08:00
|
|
|
|
double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(obj.StartTime);
|
|
|
|
|
double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(obj.StartTime) * speedAdjustment;
|
2017-04-06 16:21:18 +08:00
|
|
|
|
|
2017-04-03 19:27:11 +08:00
|
|
|
|
// The true distance, accounting for any repeats. This ends up being the drum roll distance later
|
2017-04-03 19:32:03 +08:00
|
|
|
|
double distance = distanceData.Distance * repeats * legacy_velocity_multiplier;
|
2017-04-03 09:54:13 +08:00
|
|
|
|
|
2017-04-03 19:27:11 +08:00
|
|
|
|
// The velocity of the taiko hit object - calculated as the velocity of a drum roll
|
2017-04-06 14:55:08 +08:00
|
|
|
|
double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength;
|
2017-04-03 19:27:11 +08:00
|
|
|
|
// The duration of the taiko hit object
|
2017-04-03 16:20:46 +08:00
|
|
|
|
double taikoDuration = distance / taikoVelocity;
|
|
|
|
|
|
2017-04-03 19:27:11 +08:00
|
|
|
|
// For some reason, old osu! always uses speedAdjustment to determine the taiko velocity, but
|
|
|
|
|
// only uses it to determine osu! velocity if beatmap version < 8. Let's account for that here.
|
|
|
|
|
if (beatmap.BeatmapInfo.BeatmapVersion >= 8)
|
|
|
|
|
speedAdjustedBeatLength /= speedAdjustment;
|
|
|
|
|
|
|
|
|
|
// The velocity of the osu! hit object - calculated as the velocity of a slider
|
2017-04-06 14:55:08 +08:00
|
|
|
|
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength;
|
2017-04-03 19:27:11 +08:00
|
|
|
|
// The duration of the osu! hit object
|
2017-04-03 16:20:46 +08:00
|
|
|
|
double osuDuration = distance / osuVelocity;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-04-03 19:27:11 +08:00
|
|
|
|
// If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
|
|
|
|
|
double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.Difficulty.SliderTickRate, taikoDuration / repeats) / 8;
|
2017-04-03 09:54:13 +08:00
|
|
|
|
|
2017-04-03 19:27:11 +08:00
|
|
|
|
if (tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
|
2017-04-03 09:54:13 +08:00
|
|
|
|
{
|
2017-04-03 19:27:11 +08:00
|
|
|
|
for (double j = obj.StartTime; j <= distanceData.EndTime + tickSpacing; j += tickSpacing)
|
2017-04-03 09:54:13 +08:00
|
|
|
|
{
|
|
|
|
|
// Todo: This should generate different type of hits (including strongs)
|
|
|
|
|
// depending on hitobject sound additions (not implemented fully yet)
|
|
|
|
|
yield return new CentreHit
|
|
|
|
|
{
|
2017-04-03 16:54:48 +08:00
|
|
|
|
StartTime = j,
|
2017-04-06 10:41:16 +08:00
|
|
|
|
Samples = obj.Samples,
|
2017-04-03 16:19:46 +08:00
|
|
|
|
IsStrong = strong,
|
2017-04-03 09:54:13 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yield return new DrumRoll
|
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
2017-04-06 10:41:16 +08:00
|
|
|
|
Samples = obj.Samples,
|
2017-04-03 09:54:13 +08:00
|
|
|
|
IsStrong = strong,
|
2017-04-05 12:52:53 +08:00
|
|
|
|
Duration = taikoDuration,
|
2017-04-03 16:19:46 +08:00
|
|
|
|
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 19:32:03 +08:00
|
|
|
|
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
|
2017-04-03 14:02:21 +08:00
|
|
|
|
|
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,
|
2017-04-06 10:41:16 +08:00
|
|
|
|
Samples = obj.Samples,
|
2017-03-28 09:02:41 +08:00
|
|
|
|
IsStrong = strong,
|
2017-04-05 12:52:53 +08:00
|
|
|
|
Duration = endTimeData.Duration,
|
2017-04-03 16:19:46 +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-06 11:14:06 +08:00
|
|
|
|
bool isRim = samples.Any(s => s.Name == SampleInfo.HIT_CLAP || s.Name == SampleInfo.HIT_WHISTLE);
|
2017-04-03 09:54:13 +08:00
|
|
|
|
|
2017-04-06 10:41:16 +08:00
|
|
|
|
if (isRim)
|
2017-03-30 14:51:16 +08:00
|
|
|
|
{
|
2017-04-06 10:41:16 +08:00
|
|
|
|
yield return new RimHit
|
2017-04-03 09:54:13 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
2017-04-06 10:41:16 +08:00
|
|
|
|
Samples = obj.Samples,
|
2017-04-03 16:19:46 +08:00
|
|
|
|
IsStrong = strong,
|
2017-04-03 09:54:13 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-04-06 10:41:16 +08:00
|
|
|
|
yield return new CentreHit
|
2017-04-03 09:54:13 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = obj.StartTime,
|
2017-04-06 10:41:16 +08:00
|
|
|
|
Samples = obj.Samples,
|
2017-04-03 09:54:13 +08:00
|
|
|
|
IsStrong = strong,
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-03-30 14:51:16 +08:00
|
|
|
|
}
|
2017-03-11 23:34:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|