1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Ensure populated node samples so new objects have unique node sample lists

This commit is contained in:
OliBomby 2023-08-16 20:48:52 +02:00
parent f06b203067
commit cc4e11a5ac
3 changed files with 19 additions and 0 deletions

View File

@ -72,6 +72,8 @@ namespace osu.Game.Rulesets.Catch.Objects
{
base.CreateNestedHitObjects(cancellationToken);
this.PopulateNodeSamples();
var dropletSamples = Samples.Select(s => s.With(@"slidertick")).ToList();
int nodeIndex = 0;

View File

@ -246,6 +246,8 @@ namespace osu.Game.Rulesets.Osu.Objects
protected void UpdateNestedSamples()
{
this.PopulateNodeSamples();
var firstSample = Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)
?? Samples.FirstOrDefault(); // TODO: remove this when guaranteed sort is present for samples (https://github.com/ppy/osu/issues/1933)
var sampleList = new List<HitSampleInfo>();

View File

@ -3,6 +3,7 @@
using osu.Game.Audio;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Rulesets.Objects.Types
{
@ -45,5 +46,19 @@ namespace osu.Game.Rulesets.Objects.Types
public static IList<HitSampleInfo> GetNodeSamples<T>(this T obj, int nodeIndex)
where T : HitObject, IHasRepeats
=> nodeIndex < obj.NodeSamples.Count ? obj.NodeSamples[nodeIndex] : obj.Samples;
/// <summary>
/// Ensures that the list of node samples is at least as long as the number of nodes.
/// </summary>
/// <param name="obj">The <see cref="HitObject"/>.</param>
public static void PopulateNodeSamples<T>(this T obj)
where T : HitObject, IHasRepeats
{
if (obj.NodeSamples.Count >= obj.RepeatCount + 2)
return;
while (obj.NodeSamples.Count < obj.RepeatCount + 2)
obj.NodeSamples.Add(obj.Samples.Select(o => o.With()).ToList());
}
}
}