mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 19:12:56 +08:00
NRT refactorings + rename generators to match usage
In particular, "EndTimeObject" is no longer correct - it's strictly used for spinners and not holds.
This commit is contained in:
parent
1bbf32d567
commit
e703d9e814
@ -154,7 +154,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
{
|
{
|
||||||
// Note: The density is used during the pattern generator constructor, and intentionally computed first.
|
// Note: The density is used during the pattern generator constructor, and intentionally computed first.
|
||||||
computeDensity(startTime);
|
computeDensity(startTime);
|
||||||
conversion = new HitObjectPatternGenerator(Random, original, beatmap, TotalColumns, lastPattern, lastTime, lastPosition, density, lastStair);
|
conversion = new HitCirclePatternGenerator(Random, original, beatmap, TotalColumns, lastPattern, lastTime, lastPosition, density, lastStair);
|
||||||
recordNote(startTime, position);
|
recordNote(startTime, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var generator = new PathObjectPatternGenerator(Random, original, beatmap, TotalColumns, lastPattern);
|
var generator = new SliderPatternGenerator(Random, original, beatmap, TotalColumns, lastPattern);
|
||||||
conversion = generator;
|
conversion = generator;
|
||||||
|
|
||||||
for (int i = 0; i <= generator.SpanCount; i++)
|
for (int i = 0; i <= generator.SpanCount; i++)
|
||||||
@ -185,7 +185,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
case LegacyHitObjectType.Spinner:
|
case LegacyHitObjectType.Spinner:
|
||||||
// Note: Some older mania-specific beatmaps can have spinners that are converted rather than passed through.
|
// Note: Some older mania-specific beatmaps can have spinners that are converted rather than passed through.
|
||||||
// Newer beatmaps will usually use the "hold" hitobject type below.
|
// Newer beatmaps will usually use the "hold" hitobject type below.
|
||||||
conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, TotalColumns, lastPattern);
|
conversion = new SpinnerPatternGenerator(Random, original, beatmap, TotalColumns, lastPattern);
|
||||||
recordNote(endTime, new Vector2(256, 192));
|
recordNote(endTime, new Vector2(256, 192));
|
||||||
computeDensity(endTime);
|
computeDensity(endTime);
|
||||||
break;
|
break;
|
||||||
@ -202,8 +202,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
|
|
||||||
foreach (var newPattern in conversion.Generate())
|
foreach (var newPattern in conversion.Generate())
|
||||||
{
|
{
|
||||||
lastPattern = conversion is EndTimeObjectPatternGenerator ? lastPattern : newPattern;
|
lastPattern = conversion is SpinnerPatternGenerator ? lastPattern : newPattern;
|
||||||
lastStair = (conversion as HitObjectPatternGenerator)?.StairType ?? lastStair;
|
lastStair = (conversion as HitCirclePatternGenerator)?.StairType ?? lastStair;
|
||||||
|
|
||||||
foreach (var obj in newPattern.HitObjects)
|
foreach (var obj in newPattern.HitObjects)
|
||||||
yield return obj;
|
yield return obj;
|
||||||
|
@ -16,13 +16,16 @@ using osu.Game.Utils;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||||
{
|
{
|
||||||
internal class HitObjectPatternGenerator : LegacyPatternGenerator
|
/// <summary>
|
||||||
|
/// Converter for legacy "HitCircle" hit objects.
|
||||||
|
/// </summary>
|
||||||
|
internal class HitCirclePatternGenerator : LegacyPatternGenerator
|
||||||
{
|
{
|
||||||
public PatternType StairType { get; private set; }
|
public PatternType StairType { get; private set; }
|
||||||
|
|
||||||
private readonly PatternType convertType;
|
private readonly PatternType convertType;
|
||||||
|
|
||||||
public HitObjectPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern, double previousTime, Vector2 previousPosition,
|
public HitCirclePatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern, double previousTime, Vector2 previousPosition,
|
||||||
double density, PatternType lastStair)
|
double density, PatternType lastStair)
|
||||||
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
||||||
{
|
{
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@ -96,8 +94,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
if (conversionDifficulty != null)
|
if (conversionDifficulty != null)
|
||||||
return conversionDifficulty.Value;
|
return conversionDifficulty.Value;
|
||||||
|
|
||||||
HitObject lastObject = Beatmap.HitObjects.LastOrDefault();
|
HitObject? lastObject = Beatmap.HitObjects.LastOrDefault();
|
||||||
HitObject firstObject = Beatmap.HitObjects.FirstOrDefault();
|
HitObject? firstObject = Beatmap.HitObjects.FirstOrDefault();
|
||||||
|
|
||||||
// Drain time in seconds
|
// Drain time in seconds
|
||||||
int drainTime = (int)(((lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0) - Beatmap.TotalBreakTime) / 1000);
|
int drainTime = (int)(((lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0) - Beatmap.TotalBreakTime) / 1000);
|
||||||
@ -138,7 +136,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
/// <returns>A column which has passed the <paramref name="validation"/> check and for which there are no
|
/// <returns>A column which has passed the <paramref name="validation"/> check and for which there are no
|
||||||
/// <see cref="HitObject"/>s in any of <paramref name="patterns"/> occupying the same column.</returns>
|
/// <see cref="HitObject"/>s in any of <paramref name="patterns"/> occupying the same column.</returns>
|
||||||
/// <exception cref="NotEnoughColumnsException">If there are no valid candidate columns.</exception>
|
/// <exception cref="NotEnoughColumnsException">If there are no valid candidate columns.</exception>
|
||||||
protected int FindAvailableColumn(int initialColumn, int? lowerBound = null, int? upperBound = null, Func<int, int> nextColumn = null, [InstantHandle] Func<int, bool> validation = null,
|
protected int FindAvailableColumn(int initialColumn, int? lowerBound = null, int? upperBound = null, Func<int, int>? nextColumn = null, [InstantHandle] Func<int, bool>? validation = null,
|
||||||
params Pattern[] patterns)
|
params Pattern[] patterns)
|
||||||
{
|
{
|
||||||
lowerBound ??= RandomStart;
|
lowerBound ??= RandomStart;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -19,9 +17,9 @@ using osu.Game.Utils;
|
|||||||
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pattern generator for IHasDistance hit objects.
|
/// Converter for legacy "Slider" hit objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class PathObjectPatternGenerator : LegacyPatternGenerator
|
internal class SliderPatternGenerator : LegacyPatternGenerator
|
||||||
{
|
{
|
||||||
public readonly int StartTime;
|
public readonly int StartTime;
|
||||||
public readonly int EndTime;
|
public readonly int EndTime;
|
||||||
@ -30,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
|
|
||||||
private PatternType convertType;
|
private PatternType convertType;
|
||||||
|
|
||||||
public PathObjectPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern)
|
public SliderPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern)
|
||||||
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
||||||
{
|
{
|
||||||
convertType = PatternType.None;
|
convertType = PatternType.None;
|
||||||
@ -484,9 +482,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
/// Retrieves the list of node samples that occur at time greater than or equal to <paramref name="time"/>.
|
/// Retrieves the list of node samples that occur at time greater than or equal to <paramref name="time"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The time to retrieve node samples at.</param>
|
/// <param name="time">The time to retrieve node samples at.</param>
|
||||||
private IList<IList<HitSampleInfo>> nodeSamplesAt(int time)
|
private IList<IList<HitSampleInfo>>? nodeSamplesAt(int time)
|
||||||
{
|
{
|
||||||
if (!(HitObject is IHasPathWithRepeats curveData))
|
if (HitObject is not IHasPathWithRepeats curveData)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
int index = SegmentDuration == 0 ? 0 : (time - StartTime) / SegmentDuration;
|
int index = SegmentDuration == 0 ? 0 : (time - StartTime) / SegmentDuration;
|
@ -12,12 +12,15 @@ using osu.Game.Utils;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||||
{
|
{
|
||||||
internal class EndTimeObjectPatternGenerator : LegacyPatternGenerator
|
/// <summary>
|
||||||
|
/// Converter for legacy "Spinner" hit objects.
|
||||||
|
/// </summary>
|
||||||
|
internal class SpinnerPatternGenerator : LegacyPatternGenerator
|
||||||
{
|
{
|
||||||
private readonly int endTime;
|
private readonly int endTime;
|
||||||
private readonly PatternType convertType;
|
private readonly PatternType convertType;
|
||||||
|
|
||||||
public EndTimeObjectPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern)
|
public SpinnerPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern)
|
||||||
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
||||||
{
|
{
|
||||||
endTime = (int)((HitObject as IHasDuration)?.EndTime ?? 0);
|
endTime = (int)((HitObject as IHasDuration)?.EndTime ?? 0);
|
@ -1,9 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
|
||||||
@ -14,8 +13,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class Pattern
|
internal class Pattern
|
||||||
{
|
{
|
||||||
private List<ManiaHitObject> hitObjects;
|
private List<ManiaHitObject>? hitObjects;
|
||||||
private HashSet<int> containedColumns;
|
private HashSet<int>? containedColumns;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All the hit objects contained in this pattern.
|
/// All the hit objects contained in this pattern.
|
||||||
@ -72,6 +71,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns
|
|||||||
containedColumns?.Clear();
|
containedColumns?.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MemberNotNull(nameof(hitObjects), nameof(containedColumns))]
|
||||||
private void prepareStorage()
|
private void prepareStorage()
|
||||||
{
|
{
|
||||||
hitObjects ??= new List<ManiaHitObject>();
|
hitObjects ??= new List<ManiaHitObject>();
|
||||||
|
Loading…
Reference in New Issue
Block a user