2019-01-24 16:43:03 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2019-05-21 13:27:57 +08:00
using System ;
2018-04-13 17:19:50 +08:00
using osu.Game.Audio ;
namespace osu.Game.Beatmaps.ControlPoints
{
2019-05-21 13:27:57 +08:00
public class SampleControlPoint : ControlPoint , IEquatable < SampleControlPoint >
2018-04-13 17:19:50 +08:00
{
public const string DEFAULT_BANK = "normal" ;
/// <summary>
/// The default sample bank at this control point.
/// </summary>
public string SampleBank = DEFAULT_BANK ;
/// <summary>
/// The default sample volume at this control point.
/// </summary>
public int SampleVolume = 100 ;
/// <summary>
/// Create a SampleInfo based on the sample settings in this control point.
/// </summary>
/// <param name="sampleName">The name of the same.</param>
/// <returns>A populated <see cref="SampleInfo"/>.</returns>
public SampleInfo GetSampleInfo ( string sampleName = SampleInfo . HIT_NORMAL ) = > new SampleInfo
{
Bank = SampleBank ,
Name = sampleName ,
Volume = SampleVolume ,
} ;
2018-06-28 17:08:46 +08:00
2018-06-28 17:20:29 +08:00
/// <summary>
/// Applies <see cref="SampleBank"/> and <see cref="SampleVolume"/> to a <see cref="SampleInfo"/> if necessary, returning the modified <see cref="SampleInfo"/>.
/// </summary>
/// <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>
2018-07-02 13:17:19 +08:00
public virtual SampleInfo ApplyTo ( SampleInfo sampleInfo )
2018-06-28 17:20:29 +08:00
{
2018-07-02 13:17:19 +08:00
var newSampleInfo = sampleInfo . Clone ( ) ;
newSampleInfo . Bank = sampleInfo . Bank ? ? SampleBank ;
newSampleInfo . Volume = sampleInfo . Volume > 0 ? sampleInfo . Volume : SampleVolume ;
return newSampleInfo ;
}
2018-06-28 17:20:29 +08:00
2019-05-21 13:27:57 +08:00
public bool Equals ( SampleControlPoint other )
= > base . Equals ( other )
& & string . Equals ( SampleBank , other ? . SampleBank ) & & SampleVolume = = other ? . SampleVolume ;
2018-04-13 17:19:50 +08:00
}
}