From 2af025e630256e510c72070df391ea322971b087 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:09:13 +0900 Subject: [PATCH 01/12] Add IHasDistance object pattern generation. --- .../Legacy/DistanceObjectPatternGenerator.cs | 463 ++++++++++++++++++ .../osu.Game.Rulesets.Mania.csproj | 1 + 2 files changed, 464 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs new file mode 100644 index 0000000000..03240a2be4 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -0,0 +1,463 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Game.Audio; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Timing; +using osu.Game.Rulesets.Mania.MathUtils; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; + +namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy +{ + /// + /// A pattern generator for IHasDistance hit objects. + /// + internal class DistanceObjectPatternGenerator : PatternGenerator + { + /// + /// Base osu! slider scoring distance. + /// + private const float osu_base_scoring_distance = 100; + + private readonly double endTime; + private readonly int repeatCount; + + private PatternType convertType; + + public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) + : base(random, hitObject, beatmap, previousPattern) + { + ControlPoint overridePoint; + ControlPoint controlPoint = Beatmap.TimingInfo.TimingPointAt(hitObject.StartTime, out overridePoint); + + convertType = PatternType.None; + if ((overridePoint ?? controlPoint)?.KiaiMode == false) + convertType = PatternType.LowProbability; + + var distanceData = hitObject as IHasDistance; + var repeatsData = hitObject as IHasRepeats; + + repeatCount = repeatsData?.RepeatCount ?? 1; + + double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(hitObject.StartTime); + double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(hitObject.StartTime) * speedAdjustment; + + // The true distance, accounting for any repeats. This ends up being the drum roll distance later + double distance = distanceData.Distance * repeatCount; + + // The velocity of the osu! hit object - calculated as the velocity of a slider + double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength; + // The duration of the osu! hit object + double osuDuration = distance / osuVelocity; + + endTime = hitObject.StartTime + osuDuration; + } + + public override Pattern Generate() + { + double segmentDuration = endTime / repeatCount; + + if (repeatCount > 1) + { + if (segmentDuration <= 90) + return generateRandomHoldNotes(HitObject.StartTime, endTime, 1); + + if (segmentDuration <= 120) + { + convertType |= PatternType.ForceNotStack; + return generateRandomNotes(HitObject.StartTime, segmentDuration, repeatCount); + } + + if (segmentDuration <= 160) + return generateStair(HitObject.StartTime, segmentDuration); + + if (segmentDuration <= 200 && ConversionDifficulty > 3) + return generateRandomMultipleNotes(HitObject.StartTime, segmentDuration, repeatCount); + + double duration = endTime - HitObject.StartTime; + if (duration >= 4000) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.23, 0, 0); + + if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) + return generateTiledHoldNotes(HitObject.StartTime, segmentDuration, repeatCount); + + return generateHoldAndNormalNotes(HitObject.StartTime, segmentDuration); + } + + if (segmentDuration <= 110) + { + if (PreviousPattern.ColumnsFilled < AvailableColumns) + convertType |= PatternType.ForceNotStack; + else + convertType &= ~PatternType.ForceNotStack; + return generateRandomNotes(HitObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); + } + + if (ConversionDifficulty > 6.5) + { + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.78, 0.3, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.85, 0.36, 0.03); + } + + if (ConversionDifficulty > 4) + { + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.43, 0.08, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.56, 0.18, 0); + } + + if (ConversionDifficulty > 2.5) + { + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.3, 0, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.37, 0.08, 0); + } + + if ((convertType & PatternType.LowProbability) > 0) + return generateNRandomNotes(HitObject.StartTime, endTime, 0.17, 0, 0); + return generateNRandomNotes(HitObject.StartTime, endTime, 0.27, 0, 0); + } + + /// + /// Generates random hold notes that start at an span the same amount of rows. + /// + /// Start time of each hold note. + /// End time of the hold notes. + /// Number of hold notes. + /// The containing the hit objects. + private Pattern generateRandomHoldNotes(double startTime, double endTime, int noteCount) + { + // - - - - + // ■ - ■ ■ + // □ - □ □ + // ■ - ■ ■ + + var pattern = new Pattern(); + + int usableColumns = AvailableColumns - RandomStart - PreviousPattern.ColumnsFilled; + int nextColumn = Random.Next(RandomStart, AvailableColumns); + for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) + { + while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column + nextColumn = Random.Next(RandomStart, AvailableColumns); + AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + } + + // This is can't be combined with the above loop due to RNG + for (int i = 0; i < noteCount - usableColumns; i++) + { + while (pattern.IsFilled(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + } + + return pattern; + } + + /// + /// Generates random notes, with one note per row and no stacking. + /// + /// The start time. + /// The separation of notes between rows. + /// The number of rows. + /// The containing the hit objects. + private Pattern generateRandomNotes(double startTime, double separationTime, int repeatCount) + { + // - - - - + // x - - - + // - - x - + // - - - x + // x - - - + + var pattern = new Pattern(); + + int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) + { + while (PreviousPattern.IsFilled(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + } + + int lastColumn = nextColumn; + for (int i = 0; i <= repeatCount; i++) + { + AddToPattern(pattern, HitObject, nextColumn, startTime, startTime); + while (nextColumn == lastColumn) + nextColumn = Random.Next(RandomStart, AvailableColumns); + + lastColumn = nextColumn; + startTime += separationTime; + } + + return pattern; + } + + /// + /// Generates a stair of notes, with one note per row. + /// + /// The start time. + /// The separation of notes between rows. + /// The containing the hit objects. + private Pattern generateStair(double startTime, double separationTime) + { + // - - - - + // x - - - + // - x - - + // - - x - + // - - - x + // - - x - + // - x - - + // x - - - + + var pattern = new Pattern(); + + int column = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + bool increasing = Random.NextDouble() > 0.5; + + for (int i = 0; i <= repeatCount; i++) + { + AddToPattern(pattern, HitObject, column, startTime, startTime); + startTime += separationTime; + + // Check if we're at the borders of the stage, and invert the pattern if so + if (increasing) + { + if (column >= AvailableColumns - 1) + { + increasing = false; + column--; + } + else + column++; + } + else + { + if (column <= RandomStart) + { + increasing = true; + column++; + } + else + column--; + } + } + + return pattern; + } + + /// + /// Generates random notes with 1-2 notes per row and no stacking. + /// + /// The start time. + /// The separation of notes between rows. + /// The number of rows. + /// The containing the hit objects. + private Pattern generateRandomMultipleNotes(double startTime, double separationTime, int repeatCount) + { + // - - - - + // x - - + // - x x - + // - - - x + // x - x - + + var pattern = new Pattern(); + + bool legacy = AvailableColumns >= 4 && AvailableColumns <= 8; + int interval = Random.Next(1, AvailableColumns - (legacy ? 1 : 0)); + + int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + for (int i = 0; i <= repeatCount; i++) + { + AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); + + nextColumn += interval; + if (nextColumn >= AvailableColumns - RandomStart) + nextColumn = nextColumn - AvailableColumns - RandomStart + (legacy ? 1 : 0); + nextColumn += RandomStart; + + // If we're in 2K, let's not add many consecutive doubles + if (AvailableColumns > 2) + AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); + + nextColumn = Random.Next(RandomStart, AvailableColumns); + startTime += separationTime; + } + + return pattern; + } + + /// + /// Generates random hold notes. The amount of hold notes generated is determined by probabilities. + /// + /// The hold note start time. + /// The hold note end time. + /// The probability required for 2 hold notes to be generated. + /// The probability required for 3 hold notes to be generated. + /// The probability required for 4 hold notes to be generated. + /// The containing the hit objects. + private Pattern generateNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) + { + // - - - - + // ■ - ■ ■ + // □ - □ □ + // ■ - ■ ■ + + switch (AvailableColumns) + { + case 2: + p2 = 0; + p3 = 0; + p4 = 0; + break; + case 3: + p2 = Math.Max(p2, 0.1); + p3 = 0; + p4 = 0; + break; + case 4: + p2 = Math.Max(p2, 0.3); + p3 = Math.Max(p3, 0.04); + p4 = 0; + break; + case 5: + p2 = Math.Max(p2, 0.34); + p3 = Math.Max(p3, 0.1); + p4 = Math.Max(p4, 0.03); + break; + } + + Func isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; + + bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0; + canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample); + + if (canGenerateTwoNotes) + p2 = 1; + + return generateRandomHoldNotes(startTime, endTime, GetRandomNoteCount(p2, p3, p4)); + } + + /// + /// Generates tiled hold notes. You can think of this as a stair of hold notes. + /// + /// The first hold note start time. + /// The separation time between hold notes. + /// The amount of hold notes. + /// The containing the hit objects. + private Pattern generateTiledHoldNotes(double startTime, double separationTime, int noteCount) + { + // - - - - + // ■ ■ ■ ■ + // □ □ □ □ + // □ □ □ □ + // □ □ □ ■ + // □ □ ■ - + // □ ■ - - + // ■ - - - + + var pattern = new Pattern(); + + int columnRepeat = Math.Min(noteCount, AvailableColumns); + + int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) + { + while (PreviousPattern.IsFilled(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + } + + for (int i = 0; i < columnRepeat; i++) + { + while (pattern.IsFilled(nextColumn)) + nextColumn = Random.Next(RandomStart, AvailableColumns); + + AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + startTime += separationTime; + } + + return pattern; + } + + /// + /// Generates a hold note alongside normal notes. + /// + /// The start time of notes. + /// The separation time between notes. + /// The containing the hit objects. + private Pattern generateHoldAndNormalNotes(double startTime, double separationTime) + { + // - - - - + // ■ x x - + // ■ - x x + // ■ x - x + // ■ - x x + + var pattern = new Pattern(); + + int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) + { + while (PreviousPattern.IsFilled(holdColumn)) + holdColumn = Random.Next(RandomStart, AvailableColumns); + } + + // Create the hold note + AddToPattern(pattern, HitObject, holdColumn, startTime, separationTime * repeatCount); + + int noteCount = 1; + if (ConversionDifficulty > 6.5) + noteCount = GetRandomNoteCount(0.63, 0); + else if (ConversionDifficulty > 4) + noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0.12 : 0.45, 0); + else if (ConversionDifficulty > 2.5) + noteCount = GetRandomNoteCount(AvailableColumns < 6 ? 0 : 0.24, 0); + noteCount = Math.Min(AvailableColumns - 1, noteCount); + + bool ignoreHead = !sampleInfoListAt(startTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP); + int nextColumn = Random.Next(RandomStart, AvailableColumns); + + var rowPattern = new Pattern(); + for (int i = 0; i <= repeatCount; i++) + { + if (!(ignoreHead && startTime == HitObject.StartTime)) + { + for (int j = 0; j < noteCount; j++) + { + while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) + nextColumn = Random.Next(RandomStart, AvailableColumns); + AddToPattern(rowPattern, HitObject, nextColumn, startTime, startTime, noteCount + 1); + } + } + + pattern.Add(rowPattern); + rowPattern.Clear(); + + startTime += separationTime; + } + + return pattern; + } + + /// + /// Retrieves the sample info list at a point in time. + /// + /// The time to retrieve the sample info list from. + /// + private SampleInfoList sampleInfoListAt(double time) + { + var curveData = HitObject as IHasCurve; + + if (curveData == null) + return HitObject.Samples; + + double segmentTime = (curveData.EndTime - HitObject.StartTime) / repeatCount; + + int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); + return curveData.RepeatSamples[index]; + } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index ea65588a81..9de9cd703f 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -47,6 +47,7 @@ + From eae4f8b4127cb98a1717cd590ab4ac2dd2f83c4a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:11:09 +0900 Subject: [PATCH 02/12] Fix compilation due to previously-removed function. --- .../Legacy/DistanceObjectPatternGenerator.cs | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 03240a2be4..304a32a51b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -9,6 +9,7 @@ using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Mania.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { @@ -144,7 +145,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); } // This is can't be combined with the above loop due to RNG @@ -152,7 +153,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); } return pattern; @@ -185,7 +186,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int lastColumn = nextColumn; for (int i = 0; i <= repeatCount; i++) { - AddToPattern(pattern, HitObject, nextColumn, startTime, startTime); + addToPattern(pattern, HitObject, nextColumn, startTime, startTime); while (nextColumn == lastColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); @@ -220,7 +221,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy for (int i = 0; i <= repeatCount; i++) { - AddToPattern(pattern, HitObject, column, startTime, startTime); + addToPattern(pattern, HitObject, column, startTime, startTime); startTime += separationTime; // Check if we're at the borders of the stage, and invert the pattern if so @@ -272,7 +273,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i <= repeatCount; i++) { - AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); + addToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); nextColumn += interval; if (nextColumn >= AvailableColumns - RandomStart) @@ -281,7 +282,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy // If we're in 2K, let's not add many consecutive doubles if (AvailableColumns > 2) - AddToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); + addToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); nextColumn = Random.Next(RandomStart, AvailableColumns); startTime += separationTime; @@ -375,7 +376,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); startTime += separationTime; } @@ -406,7 +407,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } // Create the hold note - AddToPattern(pattern, HitObject, holdColumn, startTime, separationTime * repeatCount); + addToPattern(pattern, HitObject, holdColumn, startTime, separationTime * repeatCount); int noteCount = 1; if (ConversionDifficulty > 6.5) @@ -429,7 +430,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); - AddToPattern(rowPattern, HitObject, nextColumn, startTime, startTime, noteCount + 1); + addToPattern(rowPattern, HitObject, nextColumn, startTime, startTime, noteCount + 1); } } @@ -459,5 +460,44 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); return curveData.RepeatSamples[index]; } + + + /// + /// Constructs and adds a note to a pattern. + /// + /// The pattern to add to. + /// The original hit object (used for samples). + /// The column to add the note to. + /// The start time of the note. + /// The end time of the note (set to for a non-hold note). + /// The number of children alongside this note (these will not be generated, but are used for volume calculations). + private void addToPattern(Pattern pattern, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) + { + ManiaHitObject newObject; + + if (startTime == endTime) + { + newObject = new Note + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column + }; + } + else + { + newObject = new HoldNote + { + StartTime = startTime, + Samples = originalObject.Samples, + Column = column, + Duration = endTime - startTime + }; + } + + // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) + + pattern.Add(newObject); + } } } From 53a2f34f8b891e4e084b5351eb5fef1b629cc989 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:15:09 +0900 Subject: [PATCH 03/12] Set siblings, removing warning. --- .../Patterns/Legacy/DistanceObjectPatternGenerator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 304a32a51b..adb0966b81 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -481,7 +481,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { StartTime = startTime, Samples = originalObject.Samples, - Column = column + Column = column, + Siblings = siblings }; } else @@ -491,12 +492,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy StartTime = startTime, Samples = originalObject.Samples, Column = column, - Duration = endTime - startTime + Duration = endTime - startTime, + Siblings = siblings }; } - // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) - pattern.Add(newObject); } } From a30e49d21bf925586fdc19a43d760e631046c5c1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:19:29 +0900 Subject: [PATCH 04/12] Add hold end samples. --- .../Patterns/Legacy/DistanceObjectPatternGenerator.cs | 5 +++-- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index adb0966b81..b2a9de4b54 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -480,7 +480,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy newObject = new Note { StartTime = startTime, - Samples = originalObject.Samples, + Samples = sampleInfoListAt(startTime), Column = column, Siblings = siblings }; @@ -490,7 +490,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy newObject = new HoldNote { StartTime = startTime, - Samples = originalObject.Samples, + Samples = sampleInfoListAt(startTime), + EndSamples = sampleInfoListAt(endTime), Column = column, Duration = endTime - startTime, Siblings = siblings diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index a25b8fbf2a..701947c381 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Audio; using osu.Game.Beatmaps.Timing; using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; @@ -22,6 +23,11 @@ namespace osu.Game.Rulesets.Mania.Objects public double Duration { get; set; } public double EndTime => StartTime + Duration; + /// + /// The samples to be played when this hold note is released. + /// + public SampleInfoList EndSamples = new SampleInfoList(); + /// /// The key-release hit windows for this hold note. /// From 35bd608a4ac5c6a74fe466bfa96f865b06c6976f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 18:41:44 +0900 Subject: [PATCH 05/12] Simplify method parameters, make conversion work again. --- .../Beatmaps/LegacyBeatmapConverter.cs | 4 +- .../Legacy/DistanceObjectPatternGenerator.cs | 83 +++++++++---------- 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index 3aa88af62d..a69145ba75 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -9,6 +9,7 @@ using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Mania.Beatmaps.Patterns; using osu.Game.Rulesets.Mania.MathUtils; +using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -74,10 +75,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var distanceData = original as IHasDistance; var positionData = original as IHasPosition; - PatternGenerator conversion = null; + Patterns.PatternGenerator conversion = null; if (distanceData != null) { + conversion = new DistanceObjectPatternGenerator(random, original, beatmap, lastPattern); // Slider } else if (endTimeData != null) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index b2a9de4b54..238e25f0c4 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy private const float osu_base_scoring_distance = 100; private readonly double endTime; + private readonly double segmentDuration; private readonly int repeatCount; private PatternType convertType; @@ -55,37 +56,36 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy double osuDuration = distance / osuVelocity; endTime = hitObject.StartTime + osuDuration; + segmentDuration = (endTime - HitObject.StartTime) / repeatCount; } public override Pattern Generate() { - double segmentDuration = endTime / repeatCount; - if (repeatCount > 1) { if (segmentDuration <= 90) - return generateRandomHoldNotes(HitObject.StartTime, endTime, 1); + return generateRandomHoldNotes(HitObject.StartTime, 1); if (segmentDuration <= 120) { convertType |= PatternType.ForceNotStack; - return generateRandomNotes(HitObject.StartTime, segmentDuration, repeatCount); + return generateRandomNotes(HitObject.StartTime, repeatCount + 1); } if (segmentDuration <= 160) - return generateStair(HitObject.StartTime, segmentDuration); + return generateStair(HitObject.StartTime); if (segmentDuration <= 200 && ConversionDifficulty > 3) - return generateRandomMultipleNotes(HitObject.StartTime, segmentDuration, repeatCount); + return generateRandomMultipleNotes(HitObject.StartTime); double duration = endTime - HitObject.StartTime; if (duration >= 4000) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.23, 0, 0); + return generateNRandomNotes(HitObject.StartTime, 0.23, 0, 0); if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) - return generateTiledHoldNotes(HitObject.StartTime, segmentDuration, repeatCount); + return generateTiledHoldNotes(HitObject.StartTime); - return generateHoldAndNormalNotes(HitObject.StartTime, segmentDuration); + return generateHoldAndNormalNotes(HitObject.StartTime); } if (segmentDuration <= 110) @@ -94,43 +94,42 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy convertType |= PatternType.ForceNotStack; else convertType &= ~PatternType.ForceNotStack; - return generateRandomNotes(HitObject.StartTime, segmentDuration, segmentDuration < 80 ? 0 : 1); + return generateRandomNotes(HitObject.StartTime, segmentDuration < 80 ? 1 : 2); } if (ConversionDifficulty > 6.5) { if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.78, 0.3, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.85, 0.36, 0.03); + return generateNRandomNotes(HitObject.StartTime, 0.78, 0.3, 0); + return generateNRandomNotes(HitObject.StartTime, 0.85, 0.36, 0.03); } if (ConversionDifficulty > 4) { if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.43, 0.08, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.56, 0.18, 0); + return generateNRandomNotes(HitObject.StartTime, 0.43, 0.08, 0); + return generateNRandomNotes(HitObject.StartTime, 0.56, 0.18, 0); } if (ConversionDifficulty > 2.5) { if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.3, 0, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.37, 0.08, 0); + return generateNRandomNotes(HitObject.StartTime, 0.3, 0, 0); + return generateNRandomNotes(HitObject.StartTime, 0.37, 0.08, 0); } if ((convertType & PatternType.LowProbability) > 0) - return generateNRandomNotes(HitObject.StartTime, endTime, 0.17, 0, 0); - return generateNRandomNotes(HitObject.StartTime, endTime, 0.27, 0, 0); + return generateNRandomNotes(HitObject.StartTime, 0.17, 0, 0); + return generateNRandomNotes(HitObject.StartTime, 0.27, 0, 0); } /// /// Generates random hold notes that start at an span the same amount of rows. /// /// Start time of each hold note. - /// End time of the hold notes. /// Number of hold notes. /// The containing the hit objects. - private Pattern generateRandomHoldNotes(double startTime, double endTime, int noteCount) + private Pattern generateRandomHoldNotes(double startTime, int noteCount) { // - - - - // ■ - ■ ■ @@ -163,10 +162,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// Generates random notes, with one note per row and no stacking. /// /// The start time. - /// The separation of notes between rows. - /// The number of rows. + /// The number of notes. /// The containing the hit objects. - private Pattern generateRandomNotes(double startTime, double separationTime, int repeatCount) + private Pattern generateRandomNotes(double startTime, int noteCount) { // - - - - // x - - - @@ -184,14 +182,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } int lastColumn = nextColumn; - for (int i = 0; i <= repeatCount; i++) + for (int i = 0; i < noteCount; i++) { addToPattern(pattern, HitObject, nextColumn, startTime, startTime); while (nextColumn == lastColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); lastColumn = nextColumn; - startTime += separationTime; + startTime += segmentDuration; } return pattern; @@ -201,9 +199,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// Generates a stair of notes, with one note per row. /// /// The start time. - /// The separation of notes between rows. /// The containing the hit objects. - private Pattern generateStair(double startTime, double separationTime) + private Pattern generateStair(double startTime) { // - - - - // x - - - @@ -222,7 +219,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy for (int i = 0; i <= repeatCount; i++) { addToPattern(pattern, HitObject, column, startTime, startTime); - startTime += separationTime; + startTime += segmentDuration; // Check if we're at the borders of the stage, and invert the pattern if so if (increasing) @@ -254,10 +251,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// Generates random notes with 1-2 notes per row and no stacking. /// /// The start time. - /// The separation of notes between rows. - /// The number of rows. /// The containing the hit objects. - private Pattern generateRandomMultipleNotes(double startTime, double separationTime, int repeatCount) + private Pattern generateRandomMultipleNotes(double startTime) { // - - - - // x - - @@ -285,7 +280,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy addToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); nextColumn = Random.Next(RandomStart, AvailableColumns); - startTime += separationTime; + startTime += segmentDuration; } return pattern; @@ -295,12 +290,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// Generates random hold notes. The amount of hold notes generated is determined by probabilities. /// /// The hold note start time. - /// The hold note end time. /// The probability required for 2 hold notes to be generated. /// The probability required for 3 hold notes to be generated. /// The probability required for 4 hold notes to be generated. /// The containing the hit objects. - private Pattern generateNRandomNotes(double startTime, double endTime, double p2, double p3, double p4) + private Pattern generateNRandomNotes(double startTime, double p2, double p3, double p4) { // - - - - // ■ - ■ ■ @@ -339,17 +333,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (canGenerateTwoNotes) p2 = 1; - return generateRandomHoldNotes(startTime, endTime, GetRandomNoteCount(p2, p3, p4)); + return generateRandomHoldNotes(startTime, GetRandomNoteCount(p2, p3, p4)); } /// /// Generates tiled hold notes. You can think of this as a stair of hold notes. /// /// The first hold note start time. - /// The separation time between hold notes. - /// The amount of hold notes. /// The containing the hit objects. - private Pattern generateTiledHoldNotes(double startTime, double separationTime, int noteCount) + private Pattern generateTiledHoldNotes(double startTime) { // - - - - // ■ ■ ■ ■ @@ -362,7 +354,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy var pattern = new Pattern(); - int columnRepeat = Math.Min(noteCount, AvailableColumns); + int columnRepeat = Math.Min(repeatCount, AvailableColumns); int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) @@ -376,8 +368,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); - startTime += separationTime; + addToPattern(pattern, HitObject, nextColumn, startTime, endTime, repeatCount); + startTime += segmentDuration; } return pattern; @@ -387,9 +379,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// Generates a hold note alongside normal notes. /// /// The start time of notes. - /// The separation time between notes. /// The containing the hit objects. - private Pattern generateHoldAndNormalNotes(double startTime, double separationTime) + private Pattern generateHoldAndNormalNotes(double startTime) { // - - - - // ■ x x - @@ -407,7 +398,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } // Create the hold note - addToPattern(pattern, HitObject, holdColumn, startTime, separationTime * repeatCount); + addToPattern(pattern, HitObject, holdColumn, startTime, endTime); int noteCount = 1; if (ConversionDifficulty > 6.5) @@ -437,7 +428,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy pattern.Add(rowPattern); rowPattern.Clear(); - startTime += separationTime; + startTime += segmentDuration; } return pattern; @@ -455,7 +446,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (curveData == null) return HitObject.Samples; - double segmentTime = (curveData.EndTime - HitObject.StartTime) / repeatCount; + double segmentTime = (endTime - HitObject.StartTime) / repeatCount; int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); return curveData.RepeatSamples[index]; From a239411808b14df9a90895bc331e798010c28861 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 18 May 2017 19:09:02 +0900 Subject: [PATCH 06/12] Fix warnings/errors. --- .../Beatmaps/LegacyBeatmapConverter.cs | 10 ++++---- .../Legacy/DistanceObjectPatternGenerator.cs | 23 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs index 17552c05ef..de826063b0 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs @@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Following lines currently commented out to appease resharper - //PatternGenerator conversion = null; + Patterns.PatternGenerator conversion = null; if (distanceData != null) { @@ -93,13 +93,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Circle } - //if (conversion == null) + if (conversion == null) return null; - //Pattern newPattern = conversion.Generate(); - //lastPattern = newPattern; + Pattern newPattern = conversion.Generate(); + lastPattern = newPattern; - //return newPattern.HitObjects; + return newPattern.HitObjects; } /// diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 238e25f0c4..04e2b30816 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(hitObject.StartTime) * speedAdjustment; // The true distance, accounting for any repeats. This ends up being the drum roll distance later - double distance = distanceData.Distance * repeatCount; + double distance = (distanceData?.Distance ?? 0) * repeatCount; // The velocity of the osu! hit object - calculated as the velocity of a slider double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength; @@ -144,7 +144,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, nextColumn, startTime, endTime, noteCount); } // This is can't be combined with the above loop due to RNG @@ -152,7 +152,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, HitObject, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, nextColumn, startTime, endTime, noteCount); } return pattern; @@ -184,7 +184,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int lastColumn = nextColumn; for (int i = 0; i < noteCount; i++) { - addToPattern(pattern, HitObject, nextColumn, startTime, startTime); + addToPattern(pattern, nextColumn, startTime, startTime); while (nextColumn == lastColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); @@ -218,7 +218,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy for (int i = 0; i <= repeatCount; i++) { - addToPattern(pattern, HitObject, column, startTime, startTime); + addToPattern(pattern, column, startTime, startTime); startTime += segmentDuration; // Check if we're at the borders of the stage, and invert the pattern if so @@ -268,7 +268,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i <= repeatCount; i++) { - addToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); + addToPattern(pattern, nextColumn, startTime, startTime, 2); nextColumn += interval; if (nextColumn >= AvailableColumns - RandomStart) @@ -277,7 +277,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy // If we're in 2K, let's not add many consecutive doubles if (AvailableColumns > 2) - addToPattern(pattern, HitObject, nextColumn, startTime, startTime, 2); + addToPattern(pattern, nextColumn, startTime, startTime, 2); nextColumn = Random.Next(RandomStart, AvailableColumns); startTime += segmentDuration; @@ -368,7 +368,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, HitObject, nextColumn, startTime, endTime, repeatCount); + addToPattern(pattern, nextColumn, startTime, endTime, repeatCount); startTime += segmentDuration; } @@ -398,7 +398,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } // Create the hold note - addToPattern(pattern, HitObject, holdColumn, startTime, endTime); + addToPattern(pattern, holdColumn, startTime, endTime); int noteCount = 1; if (ConversionDifficulty > 6.5) @@ -421,7 +421,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(rowPattern, HitObject, nextColumn, startTime, startTime, noteCount + 1); + addToPattern(rowPattern, nextColumn, startTime, startTime, noteCount + 1); } } @@ -457,12 +457,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// Constructs and adds a note to a pattern. /// /// The pattern to add to. - /// The original hit object (used for samples). /// The column to add the note to. /// The start time of the note. /// The end time of the note (set to for a non-hold note). /// The number of children alongside this note (these will not be generated, but are used for volume calculations). - private void addToPattern(Pattern pattern, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) + private void addToPattern(Pattern pattern, int column, double startTime, double endTime, int siblings = 1) { ManiaHitObject newObject; From b5674c8f300720c8bdd60072e0011cf60ba2b580 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 18 May 2017 19:33:02 +0900 Subject: [PATCH 07/12] Update DistanceObjectPatternGenerator.cs --- .../Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 04e2b30816..d1cc638fe2 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -220,7 +220,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { addToPattern(pattern, column, startTime, startTime); startTime += segmentDuration; - + // Check if we're at the borders of the stage, and invert the pattern if so if (increasing) { From e52b87bc586512735493f1b76ce8b2e74e400ec5 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 18 May 2017 19:47:16 +0900 Subject: [PATCH 08/12] Fix incorrect comment. --- .../Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index d1cc638fe2..9ea4353317 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -255,7 +255,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy private Pattern generateRandomMultipleNotes(double startTime) { // - - - - - // x - - + // x - - - // - x x - // - - - x // x - x - From 90270ac5869d5ddb8212c67d603cacbc061b45c0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 19 May 2017 17:48:23 +0900 Subject: [PATCH 09/12] Update to match base branch. --- .../Beatmaps/ManiaBeatmapConverter.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 933fe0787c..46ca90e02b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -11,6 +11,7 @@ using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Mania.Beatmaps.Patterns; using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Database; +using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -83,12 +84,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Following lines currently commented out to appease resharper - //Patterns.PatternGenerator conversion = null; + Patterns.PatternGenerator conversion = null; if (distanceData != null) - { - // Slider - } + conversion = new DistanceObjectPatternGenerator(random, original, beatmap, lastPattern); else if (endTimeData != null) { // Spinner @@ -98,13 +97,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps // Circle } - //if (conversion == null) - return null; + if (conversion == null) + return null; - //Pattern newPattern = conversion.Generate(); - //lastPattern = newPattern; + Pattern newPattern = conversion.Generate(); + lastPattern = newPattern; - //return newPattern.HitObjects; + return newPattern.HitObjects; } /// From ecf81fa8d2bc802631212b24c44907e85244798f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 22 May 2017 08:25:48 +0900 Subject: [PATCH 10/12] Cleanup. --- .../Patterns/Legacy/DistanceObjectPatternGenerator.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 9ea4353317..4b063be222 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -47,9 +47,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(hitObject.StartTime); double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(hitObject.StartTime) * speedAdjustment; - // The true distance, accounting for any repeats. This ends up being the drum roll distance later + // The true distance, accounting for any repeats double distance = (distanceData?.Distance ?? 0) * repeatCount; - // The velocity of the osu! hit object - calculated as the velocity of a slider double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength; // The duration of the osu! hit object @@ -82,7 +81,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (duration >= 4000) return generateNRandomNotes(HitObject.StartTime, 0.23, 0, 0); - if (segmentDuration > 400 && duration < 4000 && repeatCount < AvailableColumns - 1 - RandomStart) + if (segmentDuration > 400 && repeatCount < AvailableColumns - 1 - RandomStart) return generateTiledHoldNotes(HitObject.StartTime); return generateHoldAndNormalNotes(HitObject.StartTime); From 3041b55aacd53b8ae4fc227f2d60f2373b856694 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 22 May 2017 09:50:36 +0900 Subject: [PATCH 11/12] Remove siblings. --- .../Legacy/DistanceObjectPatternGenerator.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 4b063be222..ece278e64b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -143,7 +143,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, nextColumn, startTime, endTime); } // This is can't be combined with the above loop due to RNG @@ -151,7 +151,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, nextColumn, startTime, endTime, noteCount); + addToPattern(pattern, nextColumn, startTime, endTime); } return pattern; @@ -267,7 +267,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i <= repeatCount; i++) { - addToPattern(pattern, nextColumn, startTime, startTime, 2); + addToPattern(pattern, nextColumn, startTime, startTime); nextColumn += interval; if (nextColumn >= AvailableColumns - RandomStart) @@ -276,7 +276,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy // If we're in 2K, let's not add many consecutive doubles if (AvailableColumns > 2) - addToPattern(pattern, nextColumn, startTime, startTime, 2); + addToPattern(pattern, nextColumn, startTime, startTime); nextColumn = Random.Next(RandomStart, AvailableColumns); startTime += segmentDuration; @@ -367,7 +367,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy while (pattern.IsFilled(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(pattern, nextColumn, startTime, endTime, repeatCount); + addToPattern(pattern, nextColumn, startTime, endTime); startTime += segmentDuration; } @@ -420,7 +420,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); - addToPattern(rowPattern, nextColumn, startTime, startTime, noteCount + 1); + addToPattern(rowPattern, nextColumn, startTime, startTime); } } @@ -459,8 +459,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// The column to add the note to. /// The start time of the note. /// The end time of the note (set to for a non-hold note). - /// The number of children alongside this note (these will not be generated, but are used for volume calculations). - private void addToPattern(Pattern pattern, int column, double startTime, double endTime, int siblings = 1) + private void addToPattern(Pattern pattern, int column, double startTime, double endTime) { ManiaHitObject newObject; @@ -470,8 +469,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { StartTime = startTime, Samples = sampleInfoListAt(startTime), - Column = column, - Siblings = siblings + Column = column }; } else @@ -482,8 +480,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy Samples = sampleInfoListAt(startTime), EndSamples = sampleInfoListAt(endTime), Column = column, - Duration = endTime - startTime, - Siblings = siblings + Duration = endTime - startTime }; } From cd66e2af140763698f50af017052564c4d22bece Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 22 May 2017 10:17:08 +0900 Subject: [PATCH 12/12] Update with pattern changes. --- .../Legacy/DistanceObjectPatternGenerator.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index ece278e64b..0cad23304e 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (segmentDuration <= 110) { - if (PreviousPattern.ColumnsFilled < AvailableColumns) + if (PreviousPattern.ColumnWithObjects < AvailableColumns) convertType |= PatternType.ForceNotStack; else convertType &= ~PatternType.ForceNotStack; @@ -137,11 +137,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy var pattern = new Pattern(); - int usableColumns = AvailableColumns - RandomStart - PreviousPattern.ColumnsFilled; + int usableColumns = AvailableColumns - RandomStart - PreviousPattern.ColumnWithObjects; int nextColumn = Random.Next(RandomStart, AvailableColumns); for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) { - while (pattern.IsFilled(nextColumn) || PreviousPattern.IsFilled(nextColumn)) //find available column + while (pattern.ColumnHasObject(nextColumn) || PreviousPattern.ColumnHasObject(nextColumn)) //find available column nextColumn = Random.Next(RandomStart, AvailableColumns); addToPattern(pattern, nextColumn, startTime, endTime); } @@ -149,7 +149,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy // This is can't be combined with the above loop due to RNG for (int i = 0; i < noteCount - usableColumns; i++) { - while (pattern.IsFilled(nextColumn)) + while (pattern.ColumnHasObject(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); addToPattern(pattern, nextColumn, startTime, endTime); } @@ -174,9 +174,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy var pattern = new Pattern(); int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnWithObjects < AvailableColumns) { - while (PreviousPattern.IsFilled(nextColumn)) + while (PreviousPattern.ColumnHasObject(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); } @@ -356,15 +356,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int columnRepeat = Math.Min(repeatCount, AvailableColumns); int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnWithObjects < AvailableColumns) { - while (PreviousPattern.IsFilled(nextColumn)) + while (PreviousPattern.ColumnHasObject(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); } for (int i = 0; i < columnRepeat; i++) { - while (pattern.IsFilled(nextColumn)) + while (pattern.ColumnHasObject(nextColumn)) nextColumn = Random.Next(RandomStart, AvailableColumns); addToPattern(pattern, nextColumn, startTime, endTime); @@ -390,9 +390,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy var pattern = new Pattern(); int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); - if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnsFilled < AvailableColumns) + if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnWithObjects < AvailableColumns) { - while (PreviousPattern.IsFilled(holdColumn)) + while (PreviousPattern.ColumnHasObject(holdColumn)) holdColumn = Random.Next(RandomStart, AvailableColumns); } @@ -418,7 +418,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { for (int j = 0; j < noteCount; j++) { - while (rowPattern.IsFilled(nextColumn) || nextColumn == holdColumn) + while (rowPattern.ColumnHasObject(nextColumn) || nextColumn == holdColumn) nextColumn = Random.Next(RandomStart, AvailableColumns); addToPattern(rowPattern, nextColumn, startTime, startTime); }