mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 11:22:54 +08:00
bd4ed49c06
* Add failing test coverage for layered hit samples not playing in mania when beatmap is converted Adding the `osu.Game.Rulesets.Osu` reference to the mania test project is required so that `HitObjectSampleTest` base logic doesn't die on https://github.com/ppy/osu/blob/f0aeeeea966f06add12cf2bca3dd48dac8573e82/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs#L88-L91 * Fix layered hit sounds not playing on converted beatmaps in mania Compare https://github.com/peppy/osu-stable-reference/blob/f9e58b4864a10f801393199e7652b2192c7342c3/osu!/GameplayElements/HitObjects/HitObject.cs#L476-L477. In case of converted beatmaps, the last condition there (`BeatmapManager.Current.PlayMode != PlayModes.OsuMania`) fails, and thus layered hitsounds are allowed to play. * Add failing test coverage for mania beatmap conversion assigning wrong samples to spinners * Fix mania beatmap conversion assigning wrong samples to spinners A spinner is never `IHasRepeats`. It was a dead condition, leading to the hitobject generating fallback `NodeSamples`, which in particular feature a silent tail which stable doesn't do. Noticeably, stable also appears to force the head of the generated hold note to have no addition sounds: https://github.com/peppy/osu-stable-reference/blob/f9e58b4864a10f801393199e7652b2192c7342c3/osu!/GameplayElements/HitObjects/Mania/SpinnerMania.cs#L86-L89 * Add failing test coverage for file hit sample not falling back to plain samples if file missing * Allow `FileHitSampleInfo` to fall back to standard samples if the file is not found (or not allowed to be looked up) I'm honestly not 100% as to how closely this matches stable because I reached the point wherein I'd rather not look at stable code anymore, so as long as this passes tests I'm fine to wait for someone else to report new breakage. * Use alternative workaround for lack of osu! ruleset assembly in mania test project * Fix encode stability test failures
109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
// 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.
|
|
|
|
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;
|
|
using osu.Game.Utils;
|
|
|
|
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|
{
|
|
/// <summary>
|
|
/// Converter for legacy "Spinner" hit objects.
|
|
/// </summary>
|
|
internal class SpinnerPatternGenerator : LegacyPatternGenerator
|
|
{
|
|
private readonly int endTime;
|
|
private readonly PatternType convertType;
|
|
|
|
public SpinnerPatternGenerator(LegacyRandom random, HitObject hitObject, IBeatmap beatmap, int totalColumns, Pattern previousPattern)
|
|
: base(random, hitObject, beatmap, previousPattern, totalColumns)
|
|
{
|
|
endTime = (int)((HitObject as IHasDuration)?.EndTime ?? 0);
|
|
|
|
convertType = PreviousPattern.ColumnWithObjects == TotalColumns
|
|
? PatternType.None
|
|
: PatternType.ForceNotStack;
|
|
}
|
|
|
|
public override IEnumerable<Pattern> Generate()
|
|
{
|
|
yield return generate();
|
|
}
|
|
|
|
private Pattern generate()
|
|
{
|
|
var pattern = new Pattern();
|
|
|
|
bool generateHold = endTime - HitObject.StartTime >= 100;
|
|
|
|
switch (TotalColumns)
|
|
{
|
|
case 8 when HitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH) && endTime - HitObject.StartTime < 1000:
|
|
addToPattern(pattern, 0, generateHold);
|
|
break;
|
|
|
|
case 8:
|
|
addToPattern(pattern, getRandomColumn(), generateHold);
|
|
break;
|
|
|
|
default:
|
|
addToPattern(pattern, getRandomColumn(0), generateHold);
|
|
break;
|
|
}
|
|
|
|
return pattern;
|
|
}
|
|
|
|
private int getRandomColumn(int? lowerBound = null)
|
|
{
|
|
if ((convertType & PatternType.ForceNotStack) > 0)
|
|
return FindAvailableColumn(GetRandomColumn(lowerBound), lowerBound, patterns: PreviousPattern);
|
|
|
|
return FindAvailableColumn(GetRandomColumn(lowerBound), lowerBound);
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
newObject = new HoldNote
|
|
{
|
|
StartTime = HitObject.StartTime,
|
|
Duration = endTime - HitObject.StartTime,
|
|
Column = column,
|
|
Samples = HitObject.Samples,
|
|
NodeSamples =
|
|
[
|
|
HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_NORMAL).ToList(),
|
|
HitObject.Samples
|
|
]
|
|
};
|
|
}
|
|
else
|
|
{
|
|
newObject = new Note
|
|
{
|
|
StartTime = HitObject.StartTime,
|
|
Samples = HitObject.Samples,
|
|
Column = column
|
|
};
|
|
}
|
|
|
|
pattern.Add(newObject);
|
|
}
|
|
}
|
|
}
|