Make SampleControlPoint clone the existing SampleInfo

This commit is contained in:
smoogipoo
2018-07-02 14:17:19 +09:00
parent 37495c34fa
commit 8b0c6a4c85
2 changed files with 9 additions and 5 deletions

View File

@ -32,5 +32,7 @@ namespace osu.Game.Audio
/// The sample volume. /// The sample volume.
/// </summary> /// </summary>
public int Volume; public int Volume;
public SampleInfo Clone() => (SampleInfo)MemberwiseClone();
} }
} }

View File

@ -36,12 +36,14 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
/// <param name="sampleInfo">The <see cref="SampleInfo"/>. This will not be modified.</param> /// <param name="sampleInfo">The <see cref="SampleInfo"/>. This will not be modified.</param>
/// <returns>The modified <see cref="SampleInfo"/>. This does not share a reference with <paramref name="sampleInfo"/>.</returns> /// <returns>The modified <see cref="SampleInfo"/>. This does not share a reference with <paramref name="sampleInfo"/>.</returns>
public virtual SampleInfo ApplyTo(SampleInfo sampleInfo) => new SampleInfo public virtual SampleInfo ApplyTo(SampleInfo sampleInfo)
{ {
Bank = sampleInfo.Bank ?? SampleBank, var newSampleInfo = sampleInfo.Clone();
Name = sampleInfo.Name, newSampleInfo.Bank = sampleInfo.Bank ?? SampleBank;
Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume newSampleInfo.Name = sampleInfo.Name;
}; newSampleInfo.Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume;
return newSampleInfo;
}
public override bool ChangeEquals(ControlPoint other) public override bool ChangeEquals(ControlPoint other)
=> base.ChangeEquals(other) => base.ChangeEquals(other)