2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-10-09 20:22:13 +08:00
|
|
|
|
using System.Diagnostics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
2021-02-25 14:38:56 +08:00
|
|
|
|
using osu.Framework.Extensions.EnumExtensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2023-09-07 16:41:28 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2023-09-15 16:38:34 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Legacy;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2022-04-28 16:46:00 +08:00
|
|
|
|
using osu.Game.Utils;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A pattern generator for IHasDistance hit objects.
|
|
|
|
|
/// </summary>
|
2023-11-29 16:30:21 +08:00
|
|
|
|
internal class PathObjectPatternGenerator : PatternGenerator
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-10-09 20:22:13 +08:00
|
|
|
|
public readonly int StartTime;
|
|
|
|
|
public readonly int EndTime;
|
|
|
|
|
public readonly int SegmentDuration;
|
2020-09-07 15:30:05 +08:00
|
|
|
|
public readonly int SpanCount;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private PatternType convertType;
|
|
|
|
|
|
2024-03-28 21:32:27 +08:00
|
|
|
|
public PathObjectPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern)
|
|
|
|
|
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
convertType = PatternType.None;
|
|
|
|
|
if (!Beatmap.ControlPointInfo.EffectPointAt(hitObject.StartTime).KiaiMode)
|
|
|
|
|
convertType = PatternType.LowProbability;
|
|
|
|
|
|
2023-11-29 16:30:21 +08:00
|
|
|
|
var pathData = hitObject as IHasPath;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var repeatsData = hitObject as IHasRepeats;
|
|
|
|
|
|
2023-11-29 16:30:21 +08:00
|
|
|
|
Debug.Assert(pathData != null);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime);
|
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
double beatLength;
|
2023-09-07 16:41:28 +08:00
|
|
|
|
|
|
|
|
|
if (hitObject is IHasSliderVelocity hasSliderVelocity)
|
2023-09-15 17:13:04 +08:00
|
|
|
|
beatLength = LegacyRulesetExtensions.GetPrecisionAdjustedBeatLength(hasSliderVelocity, timingPoint, ManiaRuleset.SHORT_NAME);
|
2020-10-09 20:22:13 +08:00
|
|
|
|
else
|
2023-04-25 17:34:09 +08:00
|
|
|
|
beatLength = timingPoint.BeatLength;
|
2020-10-09 20:22:13 +08:00
|
|
|
|
|
|
|
|
|
SpanCount = repeatsData?.SpanCount() ?? 1;
|
|
|
|
|
StartTime = (int)Math.Round(hitObject.StartTime);
|
2020-10-12 14:27:33 +08:00
|
|
|
|
|
2023-11-29 16:30:21 +08:00
|
|
|
|
double distance = pathData.Path.ExpectedDistance.Value ?? 0;
|
2023-11-28 20:14:56 +08:00
|
|
|
|
|
2020-10-12 14:27:33 +08:00
|
|
|
|
// This matches stable's calculation.
|
2023-11-28 20:14:56 +08:00
|
|
|
|
EndTime = (int)Math.Floor(StartTime + distance * beatLength * SpanCount * 0.01 / beatmap.Difficulty.SliderMultiplier);
|
2020-10-09 20:22:13 +08:00
|
|
|
|
|
|
|
|
|
SegmentDuration = (EndTime - StartTime) / SpanCount;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 21:10:57 +08:00
|
|
|
|
public override IEnumerable<Pattern> Generate()
|
|
|
|
|
{
|
|
|
|
|
var originalPattern = generate();
|
|
|
|
|
|
2018-06-18 19:17:49 +08:00
|
|
|
|
if (originalPattern.HitObjects.Count() == 1)
|
|
|
|
|
{
|
|
|
|
|
yield return originalPattern;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-06-18 19:17:49 +08:00
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 21:10:57 +08:00
|
|
|
|
// We need to split the intermediate pattern into two new patterns:
|
|
|
|
|
// 1. A pattern containing all objects that do not end at our EndTime.
|
|
|
|
|
// 2. A pattern containing all objects that end at our EndTime. This will be used for further pattern generation.
|
|
|
|
|
var intermediatePattern = new Pattern();
|
|
|
|
|
var endTimePattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
foreach (var obj in originalPattern.HitObjects)
|
|
|
|
|
{
|
2020-10-09 20:22:13 +08:00
|
|
|
|
if (EndTime != (int)Math.Round(obj.GetEndTime()))
|
2018-06-15 21:10:57 +08:00
|
|
|
|
intermediatePattern.Add(obj);
|
|
|
|
|
else
|
|
|
|
|
endTimePattern.Add(obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return intermediatePattern;
|
|
|
|
|
yield return endTimePattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Pattern generate()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-14 18:37:21 +08:00
|
|
|
|
if (TotalColumns == 1)
|
|
|
|
|
{
|
|
|
|
|
var pattern = new Pattern();
|
2020-10-09 20:22:13 +08:00
|
|
|
|
addToPattern(pattern, 0, StartTime, EndTime);
|
2018-06-14 18:37:21 +08:00
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-07 15:30:05 +08:00
|
|
|
|
if (SpanCount > 1)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-15 19:52:36 +08:00
|
|
|
|
if (SegmentDuration <= 90)
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateRandomHoldNotes(StartTime, 1);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-15 19:52:36 +08:00
|
|
|
|
if (SegmentDuration <= 120)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
convertType |= PatternType.ForceNotStack;
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateRandomNotes(StartTime, SpanCount + 1);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 19:52:36 +08:00
|
|
|
|
if (SegmentDuration <= 160)
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateStair(StartTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-15 19:52:36 +08:00
|
|
|
|
if (SegmentDuration <= 200 && ConversionDifficulty > 3)
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateRandomMultipleNotes(StartTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
double duration = EndTime - StartTime;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
if (duration >= 4000)
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.23, 0, 0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-09-07 15:30:05 +08:00
|
|
|
|
if (SegmentDuration > 400 && SpanCount < TotalColumns - 1 - RandomStart)
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateTiledHoldNotes(StartTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateHoldAndNormalNotes(StartTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 19:52:36 +08:00
|
|
|
|
if (SegmentDuration <= 110)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (PreviousPattern.ColumnWithObjects < TotalColumns)
|
|
|
|
|
convertType |= PatternType.ForceNotStack;
|
|
|
|
|
else
|
|
|
|
|
convertType &= ~PatternType.ForceNotStack;
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateRandomNotes(StartTime, SegmentDuration < 80 ? 1 : 2);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionDifficulty > 6.5)
|
|
|
|
|
{
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.LowProbability))
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.78, 0.3, 0);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.85, 0.36, 0.03);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionDifficulty > 4)
|
|
|
|
|
{
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.LowProbability))
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.43, 0.08, 0);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.56, 0.18, 0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionDifficulty > 2.5)
|
|
|
|
|
{
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.LowProbability))
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.3, 0, 0);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.37, 0.08, 0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.LowProbability))
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.17, 0, 0);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
return generateNRandomNotes(StartTime, 0.27, 0, 0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates random hold notes that start at an span the same amount of rows.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">Start time of each hold note.</param>
|
|
|
|
|
/// <param name="noteCount">Number of hold notes.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateRandomHoldNotes(int startTime, int noteCount)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
// □ - □ □
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
int usableColumns = TotalColumns - RandomStart - PreviousPattern.ColumnWithObjects;
|
2018-08-24 22:57:44 +08:00
|
|
|
|
int nextColumn = GetRandomColumn();
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
for (int i = 0; i < Math.Min(usableColumns, noteCount); i++)
|
|
|
|
|
{
|
2018-08-14 15:40:17 +08:00
|
|
|
|
// Find available column
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, pattern, PreviousPattern);
|
2018-06-15 19:52:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, EndTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is can't be combined with the above loop due to RNG
|
|
|
|
|
for (int i = 0; i < noteCount - usableColumns; i++)
|
|
|
|
|
{
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, pattern);
|
2018-06-15 19:52:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, EndTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates random notes, with one note per row and no stacking.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The start time.</param>
|
|
|
|
|
/// <param name="noteCount">The number of notes.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateRandomNotes(int startTime, int noteCount)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// x - - -
|
|
|
|
|
// - - x -
|
|
|
|
|
// - - - x
|
|
|
|
|
// x - - -
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, PreviousPattern);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
int lastColumn = nextColumn;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
for (int i = 0; i < noteCount; i++)
|
|
|
|
|
{
|
|
|
|
|
addToPattern(pattern, nextColumn, startTime, startTime);
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, validation: c => c != lastColumn);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
lastColumn = nextColumn;
|
2018-06-15 19:52:36 +08:00
|
|
|
|
startTime += SegmentDuration;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates a stair of notes, with one note per row.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The start time.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateStair(int startTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// 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;
|
|
|
|
|
|
2020-09-07 15:30:05 +08:00
|
|
|
|
for (int i = 0; i <= SpanCount; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
addToPattern(pattern, column, startTime, startTime);
|
2018-06-15 19:52:36 +08:00
|
|
|
|
startTime += SegmentDuration;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
// Check if we're at the borders of the stage, and invert the pattern if so
|
|
|
|
|
if (increasing)
|
|
|
|
|
{
|
|
|
|
|
if (column >= TotalColumns - 1)
|
|
|
|
|
{
|
|
|
|
|
increasing = false;
|
|
|
|
|
column--;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
column++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (column <= RandomStart)
|
|
|
|
|
{
|
|
|
|
|
increasing = true;
|
|
|
|
|
column++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
column--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates random notes with 1-2 notes per row and no stacking.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The start time.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateRandomMultipleNotes(int startTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// x - - -
|
|
|
|
|
// - x x -
|
|
|
|
|
// - - - x
|
|
|
|
|
// x - x -
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
bool legacy = TotalColumns >= 4 && TotalColumns <= 8;
|
|
|
|
|
int interval = Random.Next(1, TotalColumns - (legacy ? 1 : 0));
|
|
|
|
|
|
|
|
|
|
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2020-09-07 15:30:05 +08:00
|
|
|
|
for (int i = 0; i <= SpanCount; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
addToPattern(pattern, nextColumn, startTime, startTime);
|
|
|
|
|
|
|
|
|
|
nextColumn += interval;
|
|
|
|
|
if (nextColumn >= TotalColumns - RandomStart)
|
|
|
|
|
nextColumn = nextColumn - TotalColumns - RandomStart + (legacy ? 1 : 0);
|
|
|
|
|
nextColumn += RandomStart;
|
|
|
|
|
|
|
|
|
|
// If we're in 2K, let's not add many consecutive doubles
|
|
|
|
|
if (TotalColumns > 2)
|
|
|
|
|
addToPattern(pattern, nextColumn, startTime, startTime);
|
|
|
|
|
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = GetRandomColumn();
|
2018-06-15 19:52:36 +08:00
|
|
|
|
startTime += SegmentDuration;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates random hold notes. The amount of hold notes generated is determined by probabilities.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The hold note start time.</param>
|
|
|
|
|
/// <param name="p2">The probability required for 2 hold notes to be generated.</param>
|
|
|
|
|
/// <param name="p3">The probability required for 3 hold notes to be generated.</param>
|
|
|
|
|
/// <param name="p4">The probability required for 4 hold notes to be generated.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateNRandomNotes(int startTime, double p2, double p3, double p4)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
// □ - □ □
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
|
|
|
|
|
switch (TotalColumns)
|
|
|
|
|
{
|
|
|
|
|
case 2:
|
|
|
|
|
p2 = 0;
|
|
|
|
|
p3 = 0;
|
|
|
|
|
p4 = 0;
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case 3:
|
|
|
|
|
p2 = Math.Min(p2, 0.1);
|
|
|
|
|
p3 = 0;
|
|
|
|
|
p4 = 0;
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case 4:
|
|
|
|
|
p2 = Math.Min(p2, 0.3);
|
|
|
|
|
p3 = Math.Min(p3, 0.04);
|
|
|
|
|
p4 = 0;
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case 5:
|
|
|
|
|
p2 = Math.Min(p2, 0.34);
|
|
|
|
|
p3 = Math.Min(p3, 0.1);
|
|
|
|
|
p4 = Math.Min(p4, 0.03);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-12 18:37:20 +08:00
|
|
|
|
static bool isDoubleSample(HitSampleInfo sample) => sample.Name == HitSampleInfo.HIT_CLAP || sample.Name == HitSampleInfo.HIT_FINISH;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 14:38:56 +08:00
|
|
|
|
bool canGenerateTwoNotes = !convertType.HasFlagFast(PatternType.LowProbability);
|
2020-10-09 20:22:13 +08:00
|
|
|
|
canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(StartTime).Any(isDoubleSample);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
if (canGenerateTwoNotes)
|
|
|
|
|
p2 = 1;
|
|
|
|
|
|
|
|
|
|
return generateRandomHoldNotes(startTime, GetRandomNoteCount(p2, p3, p4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates tiled hold notes. You can think of this as a stair of hold notes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The first hold note start time.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateTiledHoldNotes(int startTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ ■ ■ ■
|
|
|
|
|
// □ □ □ □
|
|
|
|
|
// □ □ □ □
|
|
|
|
|
// □ □ □ ■
|
|
|
|
|
// □ □ ■ -
|
|
|
|
|
// □ ■ - -
|
|
|
|
|
// ■ - - -
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
2020-09-07 15:30:05 +08:00
|
|
|
|
int columnRepeat = Math.Min(SpanCount, TotalColumns);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-09 20:22:13 +08:00
|
|
|
|
// Due to integer rounding, this is not guaranteed to be the same as EndTime (the class-level variable).
|
|
|
|
|
int endTime = startTime + SegmentDuration * SpanCount;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, PreviousPattern);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < columnRepeat; i++)
|
|
|
|
|
{
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, pattern);
|
2020-10-09 20:22:13 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, endTime);
|
2018-06-15 19:52:36 +08:00
|
|
|
|
startTime += SegmentDuration;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates a hold note alongside normal notes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The start time of notes.</param>
|
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private Pattern generateHoldAndNormalNotes(int startTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ x x -
|
|
|
|
|
// ■ - x x
|
|
|
|
|
// ■ x - x
|
|
|
|
|
// ■ - x x
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2021-02-25 14:38:56 +08:00
|
|
|
|
if (convertType.HasFlagFast(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
2018-08-24 22:57:44 +08:00
|
|
|
|
holdColumn = FindAvailableColumn(holdColumn, PreviousPattern);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
// Create the hold note
|
2018-06-15 19:52:36 +08:00
|
|
|
|
addToPattern(pattern, holdColumn, startTime, EndTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-24 22:57:44 +08:00
|
|
|
|
int nextColumn = GetRandomColumn();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
int noteCount;
|
|
|
|
|
if (ConversionDifficulty > 6.5)
|
|
|
|
|
noteCount = GetRandomNoteCount(0.63, 0);
|
|
|
|
|
else if (ConversionDifficulty > 4)
|
|
|
|
|
noteCount = GetRandomNoteCount(TotalColumns < 6 ? 0.12 : 0.45, 0);
|
|
|
|
|
else if (ConversionDifficulty > 2.5)
|
|
|
|
|
noteCount = GetRandomNoteCount(TotalColumns < 6 ? 0 : 0.24, 0);
|
|
|
|
|
else
|
|
|
|
|
noteCount = 0;
|
|
|
|
|
noteCount = Math.Min(TotalColumns - 1, noteCount);
|
|
|
|
|
|
2019-06-30 20:58:30 +08:00
|
|
|
|
bool ignoreHead = !sampleInfoListAt(startTime).Any(s => s.Name == HitSampleInfo.HIT_WHISTLE || s.Name == HitSampleInfo.HIT_FINISH || s.Name == HitSampleInfo.HIT_CLAP);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
var rowPattern = new Pattern();
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2020-09-07 15:30:05 +08:00
|
|
|
|
for (int i = 0; i <= SpanCount; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-10-09 20:22:13 +08:00
|
|
|
|
if (!(ignoreHead && startTime == StartTime))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < noteCount; j++)
|
|
|
|
|
{
|
2018-08-24 22:57:44 +08:00
|
|
|
|
nextColumn = FindAvailableColumn(nextColumn, validation: c => c != holdColumn, patterns: rowPattern);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
addToPattern(rowPattern, nextColumn, startTime, startTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pattern.Add(rowPattern);
|
|
|
|
|
rowPattern.Clear();
|
|
|
|
|
|
2018-06-15 19:52:36 +08:00
|
|
|
|
startTime += SegmentDuration;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the sample info list at a point in time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="time">The time to retrieve the sample info list from.</param>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private IList<HitSampleInfo> sampleInfoListAt(int time) => nodeSamplesAt(time)?.First() ?? HitObject.Samples;
|
2020-06-05 04:47:14 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the list of node samples that occur at time greater than or equal to <paramref name="time"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="time">The time to retrieve node samples at.</param>
|
2021-10-23 16:59:07 +08:00
|
|
|
|
private IList<IList<HitSampleInfo>> nodeSamplesAt(int time)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-05-26 16:44:47 +08:00
|
|
|
|
if (!(HitObject is IHasPathWithRepeats curveData))
|
2020-06-05 04:47:14 +08:00
|
|
|
|
return null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
int index = SegmentDuration == 0 ? 0 : (time - StartTime) / SegmentDuration;
|
2020-06-05 06:07:27 +08:00
|
|
|
|
|
|
|
|
|
// avoid slicing the list & creating copies, if at all possible.
|
|
|
|
|
return index == 0 ? curveData.NodeSamples : curveData.NodeSamples.Skip(index).ToList();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs and adds a note to a pattern.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pattern">The pattern to add to.</param>
|
|
|
|
|
/// <param name="column">The column to add the note to.</param>
|
|
|
|
|
/// <param name="startTime">The start time of the note.</param>
|
|
|
|
|
/// <param name="endTime">The end time of the note (set to <paramref name="startTime"/> for a non-hold note).</param>
|
2020-10-09 20:22:13 +08:00
|
|
|
|
private void addToPattern(Pattern pattern, int column, int startTime, int endTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
ManiaHitObject newObject;
|
|
|
|
|
|
|
|
|
|
if (startTime == endTime)
|
|
|
|
|
{
|
|
|
|
|
newObject = new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
Samples = sampleInfoListAt(startTime),
|
|
|
|
|
Column = column
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-21 15:33:19 +08:00
|
|
|
|
newObject = new HoldNote
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
Duration = endTime - startTime,
|
2020-04-21 15:33:19 +08:00
|
|
|
|
Column = column,
|
|
|
|
|
Samples = HitObject.Samples,
|
2020-06-05 06:07:27 +08:00
|
|
|
|
NodeSamples = nodeSamplesAt(startTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pattern.Add(newObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|