osu/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs

65 lines
2.4 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-03-11 15:34:21 +00:00
using OpenTK;
2017-02-09 05:56:39 +00:00
using osu.Game.Beatmaps;
2017-04-18 07:05:58 +00:00
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
2017-03-11 15:34:21 +00:00
using System.Collections.Generic;
2017-04-18 07:05:58 +00:00
using osu.Game.Rulesets.Objects.Types;
2017-04-17 06:44:46 +00:00
using System;
2017-04-18 07:05:58 +00:00
using osu.Game.Rulesets.Osu.UI;
2017-04-18 07:05:58 +00:00
namespace osu.Game.Rulesets.Osu.Beatmaps
{
internal class OsuBeatmapConverter : BeatmapConverter<OsuHitObject>
{
2017-04-18 05:24:16 +00:00
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasPosition) };
2017-04-17 06:44:46 +00:00
2017-04-18 05:24:16 +00:00
protected override IEnumerable<OsuHitObject> ConvertHitObject(HitObject original, Beatmap beatmap)
2017-03-11 15:34:21 +00:00
{
var curveData = original as IHasCurve;
var endTimeData = original as IHasEndTime;
var positionData = original as IHasPosition;
var comboData = original as IHasCombo;
2017-03-14 04:24:07 +00:00
if (curveData != null)
{
2017-04-18 05:24:16 +00:00
yield return new Slider
{
StartTime = original.StartTime,
Samples = original.Samples,
2017-04-21 11:42:13 +00:00
ControlPoints = curveData.ControlPoints,
CurveType = curveData.CurveType,
Distance = curveData.Distance,
RepeatSamples = curveData.RepeatSamples,
RepeatCount = curveData.RepeatCount,
2017-03-14 04:24:07 +00:00
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};
}
2017-04-18 05:24:16 +00:00
else if (endTimeData != null)
{
2017-04-18 05:24:16 +00:00
yield return new Spinner
{
StartTime = original.StartTime,
Samples = original.Samples,
2017-04-17 06:44:46 +00:00
EndTime = endTimeData.EndTime,
2017-04-18 03:19:39 +00:00
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
};
}
2017-04-18 05:24:16 +00:00
else
{
2017-04-18 05:24:16 +00:00
yield return new HitCircle
2017-02-09 05:56:39 +00:00
{
2017-04-18 05:24:16 +00:00
StartTime = original.StartTime,
Samples = original.Samples,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};
2017-02-09 05:56:39 +00:00
}
}
}
}