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

Make Samples null by default and prepopulate in mania

This commit is contained in:
Dean Herbert 2017-12-23 18:06:46 +09:00
parent 298ac5468f
commit aeafa5645a
3 changed files with 21 additions and 15 deletions

View File

@ -50,7 +50,10 @@ namespace osu.Game.Rulesets.Mania.Objects
/// <summary>
/// The head note of the hold.
/// </summary>
public readonly Note Head = new Note();
public readonly Note Head = new Note
{
Samples = new Audio.SampleInfoList()
};
/// <summary>
/// The tail note of the hold.

View File

@ -84,24 +84,27 @@ namespace osu.Game.Rulesets.Objects.Drawables
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
if (HitObject.SampleControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
foreach (SampleInfo s in HitObject.Samples)
if (HitObject.Samples != null)
{
SampleInfo localSampleInfo = new SampleInfo
if (HitObject.SampleControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
foreach (SampleInfo s in HitObject.Samples)
{
Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank,
Name = s.Name,
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume
};
SampleInfo localSampleInfo = new SampleInfo
{
Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank,
Name = s.Name,
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume
};
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample);
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample);
if (channel == null)
continue;
if (channel == null)
continue;
Samples.Add(channel);
Samples.Add(channel);
}
}
}

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Objects
/// and can be treated as the default samples for the hit object.
/// </para>
/// </summary>
public SampleInfoList Samples = new SampleInfoList();
public SampleInfoList Samples;
[JsonIgnore]
public SampleControlPoint SampleControlPoint;