Only initialise when required

This commit is contained in:
Dean Herbert
2019-09-02 18:18:59 +09:00
parent eaeecfb300
commit 9c53430a0f

View File

@ -16,7 +16,7 @@ namespace osu.Game.Skinning
{ {
private readonly ISampleInfo[] hitSamples; private readonly ISampleInfo[] hitSamples;
private readonly List<(AdjustableProperty, BindableDouble)> adjustments = new List<(AdjustableProperty, BindableDouble)>(); private List<(AdjustableProperty, BindableDouble)> adjustments;
private SampleChannel[] channels; private SampleChannel[] channels;
@ -56,13 +56,15 @@ namespace osu.Game.Skinning
public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
{ {
if (adjustments == null) adjustments = new List<(AdjustableProperty, BindableDouble)>();
adjustments.Add((type, adjustBindable)); adjustments.Add((type, adjustBindable));
channels?.ForEach(c => c.AddAdjustment(type, adjustBindable)); channels?.ForEach(c => c.AddAdjustment(type, adjustBindable));
} }
public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable) public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
{ {
adjustments.Remove((type, adjustBindable)); adjustments?.Remove((type, adjustBindable));
channels?.ForEach(c => c.RemoveAdjustment(type, adjustBindable)); channels?.ForEach(c => c.RemoveAdjustment(type, adjustBindable));
} }
@ -84,6 +86,7 @@ namespace osu.Game.Skinning
ch.Looping = looping; ch.Looping = looping;
ch.Volume.Value = s.Volume / 100.0; ch.Volume.Value = s.Volume / 100.0;
if (adjustments != null)
foreach (var adjustment in adjustments) foreach (var adjustment in adjustments)
ch.AddAdjustment(adjustment.Item1, adjustment.Item2); ch.AddAdjustment(adjustment.Item1, adjustment.Item2);
} }