1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 15:27:30 +08:00

Adjust logic to avoid creating List<> each playback

This commit is contained in:
Dean Herbert 2023-06-30 15:42:39 +09:00
parent 32c0f13f79
commit 571dbf5ab8

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Game.Audio;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.UI;
@ -23,18 +22,20 @@ namespace osu.Game.Rulesets.Taiko.UI
if (hitObject == null)
return;
List<ISampleInfo> samplesToPlay = new List<ISampleInfo>
{
hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_CLAP : HitSampleInfo.HIT_NORMAL)
};
var baseSample = hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_CLAP : HitSampleInfo.HIT_NORMAL);
// strong + rim always maps to whistle.
if ((hitObject as TaikoStrongableHitObject)?.IsStrong == true || hitObject is StrongNestedHitObject)
{
samplesToPlay.Add(hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_WHISTLE : HitSampleInfo.HIT_FINISH));
PlaySamples(new ISampleInfo[]
{
hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_WHISTLE : HitSampleInfo.HIT_FINISH),
baseSample
});
}
else
{
PlaySamples(new ISampleInfo[] { baseSample });
}
PlaySamples(samplesToPlay.ToArray());
}
public override void Play() => throw new InvalidOperationException(@"Use override with HitType parameter instead");