Fix slider samples being overwritten by the last node

This commit is contained in:
smoogipoo
2020-10-09 20:50:09 +09:00
parent 07f19342d1
commit 696e3d53af
4 changed files with 20 additions and 10 deletions

View File

@ -184,9 +184,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
result = CreateSlider(pos, combo, comboOffset, convertControlPoints(points, pathType), length, repeatCount, nodeSamples);
// The samples are played when the slider ends, which is the last node
result.Samples = nodeSamples[^1];
}
else if (type.HasFlag(LegacyHitObjectType.Spinner))
{

View File

@ -35,5 +35,15 @@ namespace osu.Game.Rulesets.Objects.Types
/// </summary>
/// <param name="obj">The object that has repeats.</param>
public static int SpanCount(this IHasRepeats obj) => obj.RepeatCount + 1;
/// <summary>
/// Retrieves the samples at a particular node in a <see cref="IHasRepeats"/> object.
/// </summary>
/// <param name="obj">The <see cref="HitObject"/>.</param>
/// <param name="nodeIndex">The node to attempt to retrieve the samples at.</param>
/// <returns>The samples at the given node index, or <paramref name="obj"/>'s default samples if the given node doesn't exist.</returns>
public static IList<HitSampleInfo> GetNodeSamples<T>(this T obj, int nodeIndex)
where T : HitObject, IHasRepeats
=> nodeIndex < obj.NodeSamples.Count ? obj.NodeSamples[nodeIndex] : obj.Samples;
}
}