diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 39ee3d209b..970d68759f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -6,7 +6,6 @@ using System; using System.Linq; using System.Collections.Generic; using System.Threading; -using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; @@ -271,7 +270,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps Duration = endTimeData.Duration, Column = column, Samples = HitObject.Samples, - NodeSamples = (HitObject as IHasRepeats)?.NodeSamples ?? defaultNodeSamples + NodeSamples = (HitObject as IHasRepeats)?.NodeSamples ?? HoldNote.CreateDefaultNodeSamples(HitObject) }); } else if (HitObject is IHasXPosition) @@ -286,16 +285,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return pattern; } - - /// - /// osu!mania-specific beatmaps in stable only play samples at the start of the hold note. - /// - private List> defaultNodeSamples - => new List> - { - HitObject.Samples, - new List() - }; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 6be0ee2d6b..98060dd226 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Threading; using osu.Game.Audio; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; @@ -91,6 +92,10 @@ namespace osu.Game.Rulesets.Mania.Objects { base.CreateNestedHitObjects(cancellationToken); + // Generally node samples will be populated by ManiaBeatmapConverter, but in a case like the editor they may not be. + // Ensure they are set to a sane default here. + NodeSamples ??= CreateDefaultNodeSamples(this); + AddNested(Head = new HeadNote { StartTime = StartTime, @@ -102,7 +107,7 @@ namespace osu.Game.Rulesets.Mania.Objects { StartTime = EndTime, Column = Column, - Samples = GetNodeSamples((NodeSamples?.Count - 1) ?? 1), + Samples = GetNodeSamples(NodeSamples.Count - 1), }); AddNested(Body = new HoldNoteBody @@ -116,7 +121,20 @@ namespace osu.Game.Rulesets.Mania.Objects protected override HitWindows CreateHitWindows() => HitWindows.Empty; - public IList GetNodeSamples(int nodeIndex) => - nodeIndex < NodeSamples?.Count ? NodeSamples[nodeIndex] : Samples; + public IList GetNodeSamples(int nodeIndex) => nodeIndex < NodeSamples?.Count ? NodeSamples[nodeIndex] : Samples; + + /// + /// Create the default note samples for a hold note, based off their main sample. + /// + /// + /// By default, osu!mania beatmaps in only play samples at the start of the hold note. + /// + /// The object to use as a basis for the head sample. + /// Defaults for assigning to . + public static List> CreateDefaultNodeSamples(HitObject obj) => new List> + { + obj.Samples, + new List(), + }; } }