Add better sample fallback logic

Also adds support for null channels at InputDrum level.
This commit is contained in:
Dean Herbert 2017-12-27 21:44:04 +09:00
parent 46ef17354e
commit 3f73a9a693
2 changed files with 14 additions and 4 deletions

View File

@ -152,14 +152,14 @@ namespace osu.Game.Rulesets.Taiko.UI
target = centreHit;
back = centre;
drumSample.Centre.Play();
drumSample.Centre?.Play();
}
else if (action == RimAction)
{
target = rimHit;
back = rim;
drumSample.Rim.Play();
drumSample.Rim?.Play();
}
if (target != null)

View File

@ -17,8 +17,18 @@ namespace osu.Game.Audio
public SampleChannel GetChannel(SampleManager manager, string resourceNamespace = null)
{
SampleChannel channel = manager.Get(Path.Combine("Gameplay", resourceNamespace ?? string.Empty, $"{Bank}-{Name}"));
channel.Volume.Value = Volume / 100.0;
SampleChannel channel = null;
if (resourceNamespace != null)
channel = manager.Get(Path.Combine("Gameplay", resourceNamespace, $"{Bank}-{Name}"));
// try without namespace as a fallback.
if (channel == null)
channel = manager.Get(Path.Combine("Gameplay", $"{Bank}-{Name}"));
if (channel != null)
channel.Volume.Value = Volume / 100.0;
return channel;
}