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;
|
|
|
|
|
using System.Collections.Generic;
|
2017-03-17 13:39:38 +08:00
|
|
|
|
using System.Linq;
|
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-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-03-17 13:39:38 +08:00
|
|
|
|
HitObjects = convertHitObjects(original.HitObjects)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TaikoHitObject> convertHitObjects(List<HitObject> hitObjects)
|
|
|
|
|
{
|
|
|
|
|
return hitObjects.Select(convertHitObject).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TaikoHitObject convertHitObject(HitObject original)
|
|
|
|
|
{
|
2017-03-17 18:51:56 +08:00
|
|
|
|
// Check if this HitObject is already a TaikoHitObject, and return it if so
|
|
|
|
|
TaikoHitObject originalTaiko = original as TaikoHitObject;
|
|
|
|
|
if (originalTaiko != null)
|
|
|
|
|
return originalTaiko;
|
|
|
|
|
|
2017-03-17 13:39:38 +08:00
|
|
|
|
IHasDistance distanceData = original as IHasDistance;
|
|
|
|
|
IHasRepeats repeatsData = original as IHasRepeats;
|
|
|
|
|
IHasEndTime endTimeData = original as IHasEndTime;
|
|
|
|
|
|
2017-03-28 09:02:41 +08:00
|
|
|
|
bool strong = ((original.Sample?.Type ?? SampleType.None) & SampleType.Finish) > 0;
|
2017-03-23 18:14:21 +08:00
|
|
|
|
|
2017-03-17 13:39:38 +08:00
|
|
|
|
if (distanceData != null)
|
|
|
|
|
{
|
|
|
|
|
return new DrumRoll
|
|
|
|
|
{
|
|
|
|
|
StartTime = original.StartTime,
|
|
|
|
|
Sample = original.Sample,
|
2017-03-28 09:02:41 +08:00
|
|
|
|
IsStrong = strong,
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
|
|
|
|
Distance = distanceData.Distance * (repeatsData?.RepeatCount ?? 1)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (endTimeData != null)
|
|
|
|
|
{
|
2017-03-17 18:52:24 +08:00
|
|
|
|
// We compute the end time manually to add in the Bash convert factor
|
2017-03-25 19:57:49 +08:00
|
|
|
|
return new Swell
|
2017-03-17 13:39:38 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = original.StartTime,
|
|
|
|
|
Sample = original.Sample,
|
2017-03-28 09:02:41 +08:00
|
|
|
|
IsStrong = strong,
|
2017-03-17 13:39:38 +08:00
|
|
|
|
|
2017-03-17 18:52:24 +08:00
|
|
|
|
EndTime = original.StartTime + endTimeData.Duration * bash_convert_factor
|
2017-03-17 13:39:38 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 10:25:38 +08:00
|
|
|
|
return new Hit
|
2017-03-17 13:39:38 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = original.StartTime,
|
|
|
|
|
Sample = original.Sample,
|
2017-03-28 09:02:41 +08:00
|
|
|
|
IsStrong = strong
|
2017-03-11 23:34:21 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|