2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-18 17:09:13 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-12-25 14:35:28 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Audio;
|
2018-03-05 19:14:06 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.MathUtils;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2017-05-18 17:11:09 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2017-05-23 12:55:18 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A pattern generator for IHasDistance hit objects.
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal class DistanceObjectPatternGenerator : PatternGenerator
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base osu! slider scoring distance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float osu_base_scoring_distance = 100;
|
|
|
|
|
|
|
|
|
|
private readonly double endTime;
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private readonly double segmentDuration;
|
2018-01-23 12:37:25 +08:00
|
|
|
|
private readonly int spanCount;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
private PatternType convertType;
|
|
|
|
|
|
2018-03-05 19:14:06 +08:00
|
|
|
|
public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, ManiaBeatmap beatmap, Pattern previousPattern, Beatmap originalBeatmap)
|
|
|
|
|
: base(random, hitObject, beatmap, previousPattern, originalBeatmap)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
convertType = PatternType.None;
|
2018-03-05 19:14:34 +08:00
|
|
|
|
if (!Beatmap.ControlPointInfo.EffectPointAt(hitObject.StartTime).KiaiMode)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
convertType = PatternType.LowProbability;
|
|
|
|
|
|
|
|
|
|
var distanceData = hitObject as IHasDistance;
|
|
|
|
|
var repeatsData = hitObject as IHasRepeats;
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
spanCount = repeatsData?.SpanCount() ?? 1;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2017-05-23 12:55:18 +08:00
|
|
|
|
TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime);
|
|
|
|
|
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(hitObject.StartTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2017-05-22 07:25:48 +08:00
|
|
|
|
// The true distance, accounting for any repeats
|
2018-01-23 12:37:25 +08:00
|
|
|
|
double distance = (distanceData?.Distance ?? 0) * spanCount;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
// The velocity of the osu! hit object - calculated as the velocity of a slider
|
2017-10-19 13:05:11 +08:00
|
|
|
|
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier / timingPoint.BeatLength;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
// The duration of the osu! hit object
|
|
|
|
|
double osuDuration = distance / osuVelocity;
|
|
|
|
|
|
|
|
|
|
endTime = hitObject.StartTime + osuDuration;
|
2018-01-23 12:37:25 +08:00
|
|
|
|
segmentDuration = (endTime - HitObject.StartTime) / spanCount;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Pattern Generate()
|
|
|
|
|
{
|
2018-01-23 12:37:25 +08:00
|
|
|
|
if (spanCount > 1)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
if (segmentDuration <= 90)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateRandomHoldNotes(HitObject.StartTime, 1);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
if (segmentDuration <= 120)
|
|
|
|
|
{
|
|
|
|
|
convertType |= PatternType.ForceNotStack;
|
2018-01-23 12:37:25 +08:00
|
|
|
|
return generateRandomNotes(HitObject.StartTime, spanCount + 1);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (segmentDuration <= 160)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateStair(HitObject.StartTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
if (segmentDuration <= 200 && ConversionDifficulty > 3)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateRandomMultipleNotes(HitObject.StartTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
double duration = endTime - HitObject.StartTime;
|
|
|
|
|
if (duration >= 4000)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.23, 0, 0);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
if (segmentDuration > 400 && spanCount < TotalColumns - 1 - RandomStart)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateTiledHoldNotes(HitObject.StartTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateHoldAndNormalNotes(HitObject.StartTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (segmentDuration <= 110)
|
|
|
|
|
{
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if (PreviousPattern.ColumnWithObjects < TotalColumns)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
convertType |= PatternType.ForceNotStack;
|
|
|
|
|
else
|
|
|
|
|
convertType &= ~PatternType.ForceNotStack;
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateRandomNotes(HitObject.StartTime, segmentDuration < 80 ? 1 : 2);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionDifficulty > 6.5)
|
|
|
|
|
{
|
|
|
|
|
if ((convertType & PatternType.LowProbability) > 0)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.78, 0.3, 0);
|
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.85, 0.36, 0.03);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionDifficulty > 4)
|
|
|
|
|
{
|
|
|
|
|
if ((convertType & PatternType.LowProbability) > 0)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.43, 0.08, 0);
|
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.56, 0.18, 0);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionDifficulty > 2.5)
|
|
|
|
|
{
|
|
|
|
|
if ((convertType & PatternType.LowProbability) > 0)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.3, 0, 0);
|
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.37, 0.08, 0);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((convertType & PatternType.LowProbability) > 0)
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.17, 0, 0);
|
|
|
|
|
return generateNRandomNotes(HitObject.StartTime, 0.27, 0, 0);
|
2017-05-18 17:09:13 +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>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateRandomHoldNotes(double startTime, int noteCount)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
// □ - □ □
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
2018-01-03 17:44:25 +08:00
|
|
|
|
int usableColumns = TotalColumns - RandomStart - PreviousPattern.ColumnWithObjects;
|
|
|
|
|
int nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
for (int i = 0; i < Math.Min(usableColumns, noteCount); i++)
|
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (pattern.ColumnHasObject(nextColumn) || PreviousPattern.ColumnHasObject(nextColumn)) //find available column
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-22 08:50:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, endTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is can't be combined with the above loop due to RNG
|
|
|
|
|
for (int i = 0; i < noteCount - usableColumns; i++)
|
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (pattern.ColumnHasObject(nextColumn))
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-22 08:50:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, endTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates random notes, with one note per row and no stacking.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The start time.</param>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
/// <param name="noteCount">The number of notes.</param>
|
2017-05-18 17:09:13 +08:00
|
|
|
|
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateRandomNotes(double startTime, int noteCount)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// x - - -
|
|
|
|
|
// - - x -
|
|
|
|
|
// - - - x
|
|
|
|
|
// x - - -
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnWithObjects < TotalColumns)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (PreviousPattern.ColumnHasObject(nextColumn))
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int lastColumn = nextColumn;
|
2017-05-18 17:41:44 +08:00
|
|
|
|
for (int i = 0; i < noteCount; i++)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
2017-05-18 18:09:02 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, startTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
while (nextColumn == lastColumn)
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
lastColumn = nextColumn;
|
2017-05-18 17:41:44 +08:00
|
|
|
|
startTime += segmentDuration;
|
2017-05-18 17:09:13 +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>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateStair(double startTime)
|
2017-05-18 17:09:13 +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;
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
for (int i = 0; i <= spanCount; i++)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
2017-05-18 18:09:02 +08:00
|
|
|
|
addToPattern(pattern, column, startTime, startTime);
|
2017-05-18 17:41:44 +08:00
|
|
|
|
startTime += segmentDuration;
|
2017-05-18 18:33:02 +08:00
|
|
|
|
|
2017-05-18 17:09:13 +08:00
|
|
|
|
// Check if we're at the borders of the stage, and invert the pattern if so
|
|
|
|
|
if (increasing)
|
|
|
|
|
{
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if (column >= TotalColumns - 1)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
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>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateRandomMultipleNotes(double startTime)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
2017-05-18 18:47:16 +08:00
|
|
|
|
// x - - -
|
2017-05-18 17:09:13 +08:00
|
|
|
|
// - x x -
|
|
|
|
|
// - - - x
|
|
|
|
|
// x - x -
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
2018-01-03 17:44:25 +08:00
|
|
|
|
bool legacy = TotalColumns >= 4 && TotalColumns <= 8;
|
|
|
|
|
int interval = Random.Next(1, TotalColumns - (legacy ? 1 : 0));
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2018-01-23 12:37:25 +08:00
|
|
|
|
for (int i = 0; i <= spanCount; i++)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
2017-05-22 08:50:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, startTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
nextColumn += interval;
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if (nextColumn >= TotalColumns - RandomStart)
|
|
|
|
|
nextColumn = nextColumn - TotalColumns - RandomStart + (legacy ? 1 : 0);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
nextColumn += RandomStart;
|
|
|
|
|
|
|
|
|
|
// If we're in 2K, let's not add many consecutive doubles
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if (TotalColumns > 2)
|
2017-05-22 08:50:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, startTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:41:44 +08:00
|
|
|
|
startTime += segmentDuration;
|
2017-05-18 17:09:13 +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>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateNRandomNotes(double startTime, double p2, double p3, double p4)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
// □ - □ □
|
|
|
|
|
// ■ - ■ ■
|
|
|
|
|
|
2018-01-03 17:44:25 +08:00
|
|
|
|
switch (TotalColumns)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
case 2:
|
|
|
|
|
p2 = 0;
|
|
|
|
|
p3 = 0;
|
|
|
|
|
p4 = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2018-03-05 18:35:57 +08:00
|
|
|
|
p2 = Math.Min(p2, 0.1);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
p3 = 0;
|
|
|
|
|
p4 = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2018-03-05 18:35:57 +08:00
|
|
|
|
p2 = Math.Min(p2, 0.3);
|
|
|
|
|
p3 = Math.Min(p3, 0.04);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
p4 = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
2018-03-05 18:35:57 +08:00
|
|
|
|
p2 = Math.Min(p2, 0.34);
|
|
|
|
|
p3 = Math.Min(p3, 0.1);
|
|
|
|
|
p4 = Math.Min(p4, 0.03);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-16 02:42:17 +08:00
|
|
|
|
bool isDoubleSample(SampleInfo sample) => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0;
|
|
|
|
|
canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample);
|
|
|
|
|
|
|
|
|
|
if (canGenerateTwoNotes)
|
|
|
|
|
p2 = 1;
|
|
|
|
|
|
2017-05-18 17:41:44 +08:00
|
|
|
|
return generateRandomHoldNotes(startTime, GetRandomNoteCount(p2, p3, p4));
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateTiledHoldNotes(double startTime)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ ■ ■ ■
|
|
|
|
|
// □ □ □ □
|
|
|
|
|
// □ □ □ □
|
|
|
|
|
// □ □ □ ■
|
|
|
|
|
// □ □ ■ -
|
|
|
|
|
// □ ■ - -
|
|
|
|
|
// ■ - - -
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
int columnRepeat = Math.Min(spanCount, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnWithObjects < TotalColumns)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (PreviousPattern.ColumnHasObject(nextColumn))
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < columnRepeat; i++)
|
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (pattern.ColumnHasObject(nextColumn))
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2017-05-22 08:50:36 +08:00
|
|
|
|
addToPattern(pattern, nextColumn, startTime, endTime);
|
2017-05-18 17:41:44 +08:00
|
|
|
|
startTime += segmentDuration;
|
2017-05-18 17:09:13 +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>
|
2017-05-18 17:41:44 +08:00
|
|
|
|
private Pattern generateHoldAndNormalNotes(double startTime)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
// - - - -
|
|
|
|
|
// ■ x x -
|
|
|
|
|
// ■ - x x
|
|
|
|
|
// ■ x - x
|
|
|
|
|
// ■ - x x
|
|
|
|
|
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
2018-01-03 17:44:25 +08:00
|
|
|
|
if ((convertType & PatternType.ForceNotStack) > 0 && PreviousPattern.ColumnWithObjects < TotalColumns)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (PreviousPattern.ColumnHasObject(holdColumn))
|
2018-01-03 17:44:25 +08:00
|
|
|
|
holdColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the hold note
|
2017-05-18 18:09:02 +08:00
|
|
|
|
addToPattern(pattern, holdColumn, startTime, endTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
2018-03-05 18:06:43 +08:00
|
|
|
|
int nextColumn = Random.Next(RandomStart, TotalColumns);
|
2018-03-05 18:05:30 +08:00
|
|
|
|
int noteCount;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
if (ConversionDifficulty > 6.5)
|
|
|
|
|
noteCount = GetRandomNoteCount(0.63, 0);
|
|
|
|
|
else if (ConversionDifficulty > 4)
|
2018-01-03 17:44:25 +08:00
|
|
|
|
noteCount = GetRandomNoteCount(TotalColumns < 6 ? 0.12 : 0.45, 0);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
else if (ConversionDifficulty > 2.5)
|
2018-01-03 17:44:25 +08:00
|
|
|
|
noteCount = GetRandomNoteCount(TotalColumns < 6 ? 0 : 0.24, 0);
|
2018-03-05 18:05:30 +08:00
|
|
|
|
else
|
|
|
|
|
noteCount = 0;
|
2018-01-03 17:44:25 +08:00
|
|
|
|
noteCount = Math.Min(TotalColumns - 1, noteCount);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
bool ignoreHead = !sampleInfoListAt(startTime).Any(s => s.Name == SampleInfo.HIT_WHISTLE || s.Name == SampleInfo.HIT_FINISH || s.Name == SampleInfo.HIT_CLAP);
|
|
|
|
|
|
|
|
|
|
var rowPattern = new Pattern();
|
2018-01-23 12:37:25 +08:00
|
|
|
|
for (int i = 0; i <= spanCount; i++)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
if (!(ignoreHead && startTime == HitObject.StartTime))
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < noteCount; j++)
|
|
|
|
|
{
|
2017-05-22 09:17:08 +08:00
|
|
|
|
while (rowPattern.ColumnHasObject(nextColumn) || nextColumn == holdColumn)
|
2018-01-03 17:44:25 +08:00
|
|
|
|
nextColumn = Random.Next(RandomStart, TotalColumns);
|
2017-05-22 08:50:36 +08:00
|
|
|
|
addToPattern(rowPattern, nextColumn, startTime, startTime);
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pattern.Add(rowPattern);
|
|
|
|
|
rowPattern.Clear();
|
|
|
|
|
|
2017-05-18 17:41:44 +08:00
|
|
|
|
startTime += segmentDuration;
|
2017-05-18 17:09:13 +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>
|
|
|
|
|
/// <returns></returns>
|
2017-12-25 14:35:28 +08:00
|
|
|
|
private List<SampleInfo> sampleInfoListAt(double time)
|
2017-05-18 17:09:13 +08:00
|
|
|
|
{
|
|
|
|
|
var curveData = HitObject as IHasCurve;
|
|
|
|
|
|
|
|
|
|
if (curveData == null)
|
|
|
|
|
return HitObject.Samples;
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
double segmentTime = (endTime - HitObject.StartTime) / spanCount;
|
2017-05-18 17:09:13 +08:00
|
|
|
|
|
|
|
|
|
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
|
|
|
|
return curveData.RepeatSamples[index];
|
|
|
|
|
}
|
2017-05-18 17:11:09 +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>
|
2017-05-22 08:50:36 +08:00
|
|
|
|
private void addToPattern(Pattern pattern, int column, double startTime, double endTime)
|
2017-05-18 17:11:09 +08:00
|
|
|
|
{
|
|
|
|
|
ManiaHitObject newObject;
|
|
|
|
|
|
|
|
|
|
if (startTime == endTime)
|
|
|
|
|
{
|
|
|
|
|
newObject = new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = startTime,
|
2017-05-18 17:19:29 +08:00
|
|
|
|
Samples = sampleInfoListAt(startTime),
|
2017-05-22 08:50:36 +08:00
|
|
|
|
Column = column
|
2017-05-18 17:11:09 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-24 19:45:01 +08:00
|
|
|
|
var holdNote = new HoldNote
|
2017-05-18 17:11:09 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
Column = column,
|
2017-05-26 15:29:20 +08:00
|
|
|
|
Duration = endTime - startTime,
|
|
|
|
|
Head = { Samples = sampleInfoListAt(startTime) },
|
|
|
|
|
Tail = { Samples = sampleInfoListAt(endTime) }
|
2017-05-18 17:11:09 +08:00
|
|
|
|
};
|
2017-05-24 19:45:01 +08:00
|
|
|
|
|
|
|
|
|
newObject = holdNote;
|
2017-05-18 17:11:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pattern.Add(newObject);
|
|
|
|
|
}
|
2017-05-18 17:09:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|