Implement basic Taiko HitObject conversion.

This commit is contained in:
smoogipooo 2017-03-17 14:39:38 +09:00
parent a292a16c36
commit ccc2253068
1 changed files with 48 additions and 1 deletions

View File

@ -2,8 +2,12 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Types;
using osu.Game.Modes.Taiko.Objects;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Modes.Taiko.Beatmaps
{
@ -11,9 +15,52 @@ internal class TaikoBeatmapConverter : IBeatmapConverter<TaikoHitObject>
{
public Beatmap<TaikoHitObject> Convert(Beatmap original)
{
if (original is IIsLegacy)
original.TimingInfo.ControlPoints.ForEach(c => c.VelocityAdjustment *= 1.4);
return new Beatmap<TaikoHitObject>(original)
{
HitObjects = new List<TaikoHitObject>() // Todo: Implement
HitObjects = convertHitObjects(original.HitObjects)
};
}
private List<TaikoHitObject> convertHitObjects(List<HitObject> hitObjects)
{
return hitObjects.Select(convertHitObject).ToList();
}
private TaikoHitObject convertHitObject(HitObject original)
{
IHasDistance distanceData = original as IHasDistance;
IHasRepeats repeatsData = original as IHasRepeats;
IHasEndTime endTimeData = original as IHasEndTime;
if (distanceData != null)
{
return new DrumRoll
{
StartTime = original.StartTime,
Sample = original.Sample,
Distance = distanceData.Distance * (repeatsData?.RepeatCount ?? 1)
};
}
if (endTimeData != null)
{
return new Bash
{
StartTime = original.StartTime,
Sample = original.Sample,
EndTime = endTimeData.EndTime
};
}
return new TaikoHitObject
{
StartTime = original.StartTime,
Sample = original.Sample,
};
}
}