1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 04:49:40 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs

66 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 23:34:21 +08:00
using OpenTK;
2017-02-09 13:56:39 +08:00
using osu.Game.Beatmaps;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
2017-03-11 23:34:21 +08:00
using System.Collections.Generic;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Objects.Types;
2017-04-17 14:44:46 +08:00
using System;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Beatmaps;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Osu.Beatmaps
{
internal class OsuBeatmapConverter : BeatmapConverter<OsuHitObject>
{
2017-04-18 13:24:16 +08:00
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasPosition) };
2017-04-17 14:44:46 +08:00
2017-04-18 13:24:16 +08:00
protected override IEnumerable<OsuHitObject> ConvertHitObject(HitObject original, Beatmap beatmap)
2017-03-11 23:34:21 +08:00
{
var curveData = original as IHasCurve;
var endTimeData = original as IHasEndTime;
var positionData = original as IHasPosition;
var comboData = original as IHasCombo;
2017-03-14 12:24:07 +08:00
if (curveData != null)
{
2017-04-18 13:24:16 +08:00
yield return new Slider
{
StartTime = original.StartTime,
Samples = original.Samples,
2017-04-21 19:42:13 +08:00
ControlPoints = curveData.ControlPoints,
CurveType = curveData.CurveType,
Distance = curveData.Distance,
RepeatSamples = curveData.RepeatSamples,
RepeatCount = curveData.RepeatCount,
2017-03-14 12:24:07 +08:00
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};
}
2017-04-18 13:24:16 +08:00
else if (endTimeData != null)
{
2017-04-18 13:24:16 +08:00
yield return new Spinner
{
StartTime = original.StartTime,
Samples = original.Samples,
2017-04-17 14:44:46 +08:00
EndTime = endTimeData.EndTime,
2017-04-18 11:19:39 +08:00
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
};
}
2017-04-18 13:24:16 +08:00
else
{
2017-04-18 13:24:16 +08:00
yield return new HitCircle
2017-02-09 13:56:39 +08:00
{
2017-04-18 13:24:16 +08:00
StartTime = original.StartTime,
Samples = original.Samples,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};
2017-02-09 13:56:39 +08:00
}
}
}
}