Determine SampleInfo defaults in DrawableHitObject

This commit is contained in:
smoogipoo
2017-12-21 16:02:33 +09:00
parent 58859f2ffb
commit cb7e192aff
9 changed files with 73 additions and 42 deletions

View File

@ -86,12 +86,23 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
foreach (SampleInfo sample in HitObject.Samples)
{
SampleChannel channel = audio.Sample.Get($@"Gameplay/{sample.Bank}-{sample.Name}");
if (HitObject.SoundControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SoundControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SoundControlPoint)}.");
var bank = sample.Bank;
if (string.IsNullOrEmpty(bank))
bank = HitObject.SoundControlPoint.SampleBank;
int volume = sample.Volume;
if (volume == 0)
volume = HitObject.SoundControlPoint.SampleVolume;
SampleChannel channel = audio.Sample.Get($@"Gameplay/{bank}-{sample.Name}");
if (channel == null)
continue;
channel.Volume.Value = sample.Volume;
channel.Volume.Value = volume;
Samples.Add(channel);
}
}

View File

@ -31,6 +31,9 @@ namespace osu.Game.Rulesets.Objects
/// </summary>
public SampleInfoList Samples = new SampleInfoList();
[JsonIgnore]
public SoundControlPoint SoundControlPoint;
/// <summary>
/// Whether this <see cref="HitObject"/> is in Kiai time.
/// </summary>
@ -48,13 +51,7 @@ namespace osu.Game.Rulesets.Objects
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
Kiai = effectPoint.KiaiMode;
// Initialize first sample
Samples.ForEach(s => s.ControlPoint = soundPoint);
// Initialize any repeat samples
var repeatData = this as IHasRepeats;
repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => s.ControlPoint = soundPoint));
SoundControlPoint = soundPoint;
}
}
}