1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Make HitObject.Samples non-nullable

This commit is contained in:
smoogipoo 2017-12-25 16:41:18 +09:00
parent d288d8a51f
commit 0fb620a8d3
2 changed files with 10 additions and 3 deletions

View File

@ -84,10 +84,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
if (HitObject.Samples != null)
if (Samples.Count > 0)
{
if (HitObject.SampleControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
foreach (SampleInfo s in HitObject.Samples)
{

View File

@ -25,6 +25,8 @@ namespace osu.Game.Rulesets.Objects
/// </summary>
public virtual double StartTime { get; set; }
private List<SampleInfo> samples;
/// <summary>
/// The samples to be played when this hit object is hit.
/// <para>
@ -32,7 +34,11 @@ namespace osu.Game.Rulesets.Objects
/// and can be treated as the default samples for the hit object.
/// </para>
/// </summary>
public List<SampleInfo> Samples;
public List<SampleInfo> Samples
{
get => samples ?? (samples = new List<SampleInfo>());
set => samples = value;
}
[JsonIgnore]
public SampleControlPoint SampleControlPoint;