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.Collections.Generic;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
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
|
|
|
|
|
{
|
|
|
|
|
internal class EndTimeObjectPatternGenerator : PatternGenerator
|
|
|
|
|
{
|
2020-10-09 20:12:38 +08:00
|
|
|
|
private readonly int endTime;
|
|
|
|
|
private readonly PatternType convertType;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-04-28 16:46:00 +08:00
|
|
|
|
public EndTimeObjectPatternGenerator(LegacyRandom random, HitObject hitObject, ManiaBeatmap beatmap, Pattern previousPattern, IBeatmap originalBeatmap)
|
2020-10-09 20:12:38 +08:00
|
|
|
|
: base(random, hitObject, beatmap, previousPattern, originalBeatmap)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-10-09 20:12:38 +08:00
|
|
|
|
endTime = (int)((HitObject as IHasDuration)?.EndTime ?? 0);
|
|
|
|
|
|
|
|
|
|
convertType = PreviousPattern.ColumnWithObjects == TotalColumns
|
|
|
|
|
? PatternType.None
|
|
|
|
|
: PatternType.ForceNotStack;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 21:10:57 +08:00
|
|
|
|
public override IEnumerable<Pattern> Generate()
|
|
|
|
|
{
|
|
|
|
|
yield return generate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Pattern generate()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var pattern = new Pattern();
|
|
|
|
|
|
|
|
|
|
bool generateHold = endTime - HitObject.StartTime >= 100;
|
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
switch (TotalColumns)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-30 20:58:30 +08:00
|
|
|
|
case 8 when HitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH) && endTime - HitObject.StartTime < 1000:
|
2018-04-13 17:19:50 +08:00
|
|
|
|
addToPattern(pattern, 0, generateHold);
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
case 8:
|
2020-10-09 20:12:38 +08:00
|
|
|
|
addToPattern(pattern, getRandomColumn(), generateHold);
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
default:
|
2020-10-09 20:12:38 +08:00
|
|
|
|
addToPattern(pattern, getRandomColumn(0), generateHold);
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-09 20:12:38 +08:00
|
|
|
|
private int getRandomColumn(int? lowerBound = null)
|
|
|
|
|
{
|
|
|
|
|
if ((convertType & PatternType.ForceNotStack) > 0)
|
|
|
|
|
return FindAvailableColumn(GetRandomColumn(lowerBound), lowerBound, patterns: PreviousPattern);
|
|
|
|
|
|
|
|
|
|
return FindAvailableColumn(GetRandomColumn(lowerBound), lowerBound);
|
|
|
|
|
}
|
|
|
|
|
|
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="holdNote">Whether to add a hold note.</param>
|
|
|
|
|
private void addToPattern(Pattern pattern, int column, bool holdNote)
|
|
|
|
|
{
|
|
|
|
|
ManiaHitObject newObject;
|
|
|
|
|
|
|
|
|
|
if (holdNote)
|
|
|
|
|
{
|
2020-04-21 15:33:19 +08:00
|
|
|
|
newObject = new HoldNote
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = HitObject.StartTime,
|
2020-04-21 15:33:19 +08:00
|
|
|
|
Duration = endTime - HitObject.StartTime,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Column = column,
|
2020-04-21 15:33:19 +08:00
|
|
|
|
Samples = HitObject.Samples,
|
|
|
|
|
NodeSamples = (HitObject as IHasRepeats)?.NodeSamples
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newObject = new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = HitObject.StartTime,
|
|
|
|
|
Samples = HitObject.Samples,
|
|
|
|
|
Column = column
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pattern.Add(newObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|