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
|
|
|
|
|
|
2017-05-17 12:07:56 +08:00
|
|
|
|
using osu.Game.Rulesets.Beatmaps;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2017-04-17 14:44:46 +08:00
|
|
|
|
using System;
|
2017-05-17 12:07:56 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-05-17 12:07:56 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2017-05-19 15:31:05 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps.Patterns;
|
|
|
|
|
using osu.Game.Rulesets.Mania.MathUtils;
|
|
|
|
|
using osu.Game.Database;
|
2017-03-11 23:34:21 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Mania.Beatmaps
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-05-17 12:07:56 +08:00
|
|
|
|
public class ManiaBeatmapConverter : BeatmapConverter<ManiaHitObject>
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-05-19 16:38:06 +08:00
|
|
|
|
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
|
2017-04-17 14:44:46 +08:00
|
|
|
|
|
2017-05-19 15:31:05 +08:00
|
|
|
|
private Pattern lastPattern = new Pattern();
|
|
|
|
|
private FastRandom random;
|
2017-05-19 15:49:05 +08:00
|
|
|
|
private Beatmap beatmap;
|
2017-05-19 15:31:05 +08:00
|
|
|
|
private bool isForCurrentRuleset;
|
|
|
|
|
|
2017-05-19 14:57:32 +08:00
|
|
|
|
protected override Beatmap<ManiaHitObject> ConvertBeatmap(Beatmap original, bool isForCurrentRuleset)
|
2017-03-11 23:34:21 +08:00
|
|
|
|
{
|
2017-05-19 15:31:05 +08:00
|
|
|
|
this.isForCurrentRuleset = isForCurrentRuleset;
|
2017-05-19 14:57:32 +08:00
|
|
|
|
|
2017-05-19 15:49:05 +08:00
|
|
|
|
beatmap = original;
|
|
|
|
|
|
2017-05-19 15:31:05 +08:00
|
|
|
|
BeatmapDifficulty difficulty = original.BeatmapInfo.Difficulty;
|
2017-05-11 11:32:30 +08:00
|
|
|
|
|
2017-05-19 15:31:05 +08:00
|
|
|
|
int seed = (int)Math.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)Math.Round(difficulty.ApproachRate);
|
|
|
|
|
random = new FastRandom(seed);
|
|
|
|
|
|
|
|
|
|
return base.ConvertBeatmap(original, isForCurrentRuleset);
|
2017-03-11 23:34:21 +08:00
|
|
|
|
}
|
2017-05-17 12:07:56 +08:00
|
|
|
|
|
|
|
|
|
protected override IEnumerable<ManiaHitObject> ConvertHitObject(HitObject original, Beatmap beatmap)
|
|
|
|
|
{
|
2017-05-19 14:57:32 +08:00
|
|
|
|
var maniaOriginal = original as ManiaHitObject;
|
|
|
|
|
if (maniaOriginal != null)
|
|
|
|
|
{
|
|
|
|
|
yield return maniaOriginal;
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 15:49:05 +08:00
|
|
|
|
var objects = isForCurrentRuleset ? generateSpecific(original) : generateConverted(original);
|
2017-05-19 15:31:05 +08:00
|
|
|
|
|
|
|
|
|
if (objects == null)
|
|
|
|
|
yield break;
|
|
|
|
|
|
|
|
|
|
foreach (ManiaHitObject obj in objects)
|
|
|
|
|
yield return obj;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 15:39:02 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Method that generates hit objects for osu!mania specific beatmaps.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="original">The original hit object.</param>
|
|
|
|
|
/// <returns>The hit objects generated.</returns>
|
2017-05-19 15:49:05 +08:00
|
|
|
|
private IEnumerable<ManiaHitObject> generateSpecific(HitObject original)
|
2017-05-19 15:31:05 +08:00
|
|
|
|
{
|
|
|
|
|
var generator = new SpecificBeatmapPatternGenerator(random, original, beatmap, lastPattern);
|
|
|
|
|
|
|
|
|
|
Pattern newPattern = generator.Generate();
|
|
|
|
|
lastPattern = newPattern;
|
|
|
|
|
|
|
|
|
|
return newPattern.HitObjects;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 15:39:02 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Method that generates hit objects for non-osu!mania beatmaps.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="original">The original hit object.</param>
|
|
|
|
|
/// <returns>The hit objects generated.</returns>
|
2017-05-19 15:49:05 +08:00
|
|
|
|
private IEnumerable<ManiaHitObject> generateConverted(HitObject original)
|
2017-05-19 15:31:05 +08:00
|
|
|
|
{
|
|
|
|
|
var endTimeData = original as IHasEndTime;
|
|
|
|
|
var distanceData = original as IHasDistance;
|
|
|
|
|
var positionData = original as IHasPosition;
|
|
|
|
|
|
|
|
|
|
// Following lines currently commented out to appease resharper
|
|
|
|
|
|
|
|
|
|
//Patterns.PatternGenerator conversion = null;
|
|
|
|
|
|
|
|
|
|
if (distanceData != null)
|
|
|
|
|
{
|
|
|
|
|
// Slider
|
|
|
|
|
}
|
|
|
|
|
else if (endTimeData != null)
|
|
|
|
|
{
|
|
|
|
|
// Spinner
|
|
|
|
|
}
|
|
|
|
|
else if (positionData != null)
|
|
|
|
|
{
|
|
|
|
|
// Circle
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (conversion == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
//Pattern newPattern = conversion.Generate();
|
|
|
|
|
//lastPattern = newPattern;
|
|
|
|
|
|
|
|
|
|
//return newPattern.HitObjects;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-05-19 15:39:02 +08:00
|
|
|
|
/// A pattern generator for osu!mania-specific beatmaps.
|
2017-05-19 15:31:05 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
private class SpecificBeatmapPatternGenerator : Patterns.Legacy.PatternGenerator
|
|
|
|
|
{
|
|
|
|
|
public SpecificBeatmapPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern)
|
|
|
|
|
: base(random, hitObject, beatmap, previousPattern)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Pattern Generate()
|
|
|
|
|
{
|
|
|
|
|
var endTimeData = HitObject as IHasEndTime;
|
|
|
|
|
var positionData = HitObject as IHasXPosition;
|
|
|
|
|
|
|
|
|
|
int column = GetColumn(positionData?.X ?? 0);
|
2017-05-19 14:57:32 +08:00
|
|
|
|
|
2017-05-19 15:31:05 +08:00
|
|
|
|
var pattern = new Pattern();
|
2017-05-19 14:57:32 +08:00
|
|
|
|
|
2017-05-19 15:31:05 +08:00
|
|
|
|
if (endTimeData != null)
|
|
|
|
|
{
|
|
|
|
|
pattern.Add(new HoldNote
|
|
|
|
|
{
|
|
|
|
|
StartTime = HitObject.StartTime,
|
|
|
|
|
Samples = HitObject.Samples,
|
|
|
|
|
Duration = endTimeData.Duration,
|
|
|
|
|
Column = column,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (positionData != null)
|
|
|
|
|
{
|
|
|
|
|
pattern.Add(new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = HitObject.StartTime,
|
|
|
|
|
Samples = HitObject.Samples,
|
|
|
|
|
Column = column
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
2017-05-17 12:07:56 +08:00
|
|
|
|
}
|
2017-03-11 23:34:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|