mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Implement things a bit more to remove warnings.
This commit is contained in:
parent
873ff34487
commit
afd3eb4b8d
@ -7,7 +7,8 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using OpenTK;
|
using osu.Game.Rulesets.Mania.Beatmaps.Patterns;
|
||||||
|
using osu.Game.Rulesets.Mania.MathUtils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps
|
namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||||
{
|
{
|
||||||
@ -16,17 +17,18 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class LegacyBeatmapConverter
|
internal class LegacyBeatmapConverter
|
||||||
{
|
{
|
||||||
private readonly int availableColumns;
|
private Pattern lastPattern = new Pattern();
|
||||||
private readonly float localXDivisor;
|
|
||||||
|
|
||||||
|
private readonly FastRandom random;
|
||||||
private readonly Beatmap beatmap;
|
private readonly Beatmap beatmap;
|
||||||
|
|
||||||
public LegacyBeatmapConverter(Beatmap beatmap)
|
public LegacyBeatmapConverter(Beatmap beatmap)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
|
||||||
availableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize);
|
int seed = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.DrainRate + beatmap.BeatmapInfo.Difficulty.CircleSize)
|
||||||
localXDivisor = 512.0f / availableColumns;
|
* 20 + (int)(beatmap.BeatmapInfo.Difficulty.OverallDifficulty * 41.2) + (int)Math.Round(beatmap.BeatmapInfo.Difficulty.ApproachRate);
|
||||||
|
random = new FastRandom(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<ManiaHitObject> Convert(HitObject original)
|
public IEnumerable<ManiaHitObject> Convert(HitObject original)
|
||||||
@ -38,44 +40,32 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (beatmap.BeatmapInfo.RulesetID == 3)
|
IEnumerable<ManiaHitObject> objects = null;
|
||||||
yield return generateSpecific(original);
|
switch (beatmap.BeatmapInfo.RulesetID)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
foreach (ManiaHitObject c in generateConverted(original))
|
default:
|
||||||
yield return c;
|
objects = generateConverted(original);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
objects = generateSpecific(original);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objects == null)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
foreach (ManiaHitObject obj in objects)
|
||||||
|
yield return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ManiaHitObject generateSpecific(HitObject original)
|
private IEnumerable<ManiaHitObject> generateSpecific(HitObject original)
|
||||||
{
|
{
|
||||||
var endTimeData = original as IHasEndTime;
|
var generator = new SpecificPatternGenerator(random, original, beatmap, lastPattern);
|
||||||
var positionData = original as IHasXPosition;
|
|
||||||
|
|
||||||
int column = getColumn(positionData?.X ?? 0);
|
Pattern newPattern = generator.Generate();
|
||||||
|
lastPattern = newPattern;
|
||||||
|
|
||||||
if (endTimeData != null)
|
return newPattern.HitObjects;
|
||||||
{
|
|
||||||
return new HoldNote
|
|
||||||
{
|
|
||||||
StartTime = original.StartTime,
|
|
||||||
Samples = original.Samples,
|
|
||||||
Duration = endTimeData.Duration,
|
|
||||||
Column = column,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (positionData != null)
|
|
||||||
{
|
|
||||||
return new Note
|
|
||||||
{
|
|
||||||
StartTime = original.StartTime,
|
|
||||||
Samples = original.Samples,
|
|
||||||
Column = column
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<ManiaHitObject> generateConverted(HitObject original)
|
private IEnumerable<ManiaHitObject> generateConverted(HitObject original)
|
||||||
@ -84,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
var distanceData = original as IHasDistance;
|
var distanceData = original as IHasDistance;
|
||||||
var positionData = original as IHasPosition;
|
var positionData = original as IHasPosition;
|
||||||
|
|
||||||
Patterns.PatternGenerator conversion = null;
|
PatternGenerator conversion = null;
|
||||||
|
|
||||||
if (distanceData != null)
|
if (distanceData != null)
|
||||||
{
|
{
|
||||||
@ -100,14 +90,53 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conversion == null)
|
if (conversion == null)
|
||||||
yield break;
|
return new ManiaHitObject[0];
|
||||||
|
|
||||||
Patterns.Pattern newPattern = conversion.Generate();
|
Pattern newPattern = conversion.Generate();
|
||||||
|
lastPattern = newPattern;
|
||||||
|
|
||||||
foreach (ManiaHitObject obj in newPattern.HitObjects)
|
return newPattern.HitObjects;
|
||||||
yield return obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColumn(float position) => MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, availableColumns - 1);
|
/// <summary>
|
||||||
|
/// A pattern generator for mania-specific beatmaps.
|
||||||
|
/// </summary>
|
||||||
|
private class SpecificPatternGenerator : Patterns.Legacy.PatternGenerator
|
||||||
|
{
|
||||||
|
public SpecificPatternGenerator(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;
|
||||||
|
|
||||||
|
var pattern = new Pattern();
|
||||||
|
|
||||||
|
if (endTimeData != null)
|
||||||
|
{
|
||||||
|
pattern.Add(new HoldNote
|
||||||
|
{
|
||||||
|
StartTime = HitObject.StartTime,
|
||||||
|
Samples = HitObject.Samples,
|
||||||
|
Duration = endTimeData.Duration,
|
||||||
|
Column = GetColumn(positionData?.X ?? 0),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (positionData != null)
|
||||||
|
{
|
||||||
|
pattern.Add(new Note
|
||||||
|
{
|
||||||
|
StartTime = HitObject.StartTime,
|
||||||
|
Samples = HitObject.Samples,
|
||||||
|
Column = GetColumn(positionData?.X ?? 0)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns
|
||||||
|
@ -22,5 +22,12 @@ namespace osu.Game.Beatmaps.Events
|
|||||||
/// Total duration of all breaks.
|
/// Total duration of all breaks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the active background at a time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The time to retrieve the background at.</param>
|
||||||
|
/// <returns>The background.</returns>
|
||||||
|
public BackgroundEvent BackgroundAt(double time) => Backgrounds.FirstOrDefault(b => b.StartTime <= time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user