mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Make HitSampleInfo immutable
This commit is contained in:
@ -58,12 +58,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// </summary>
|
||||
/// <param name="sampleName">The name of the same.</param>
|
||||
/// <returns>A populated <see cref="HitSampleInfo"/>.</returns>
|
||||
public HitSampleInfo GetSampleInfo(string sampleName = HitSampleInfo.HIT_NORMAL) => new HitSampleInfo
|
||||
{
|
||||
Bank = SampleBank,
|
||||
Name = sampleName,
|
||||
Volume = SampleVolume,
|
||||
};
|
||||
public HitSampleInfo GetSampleInfo(string sampleName = HitSampleInfo.HIT_NORMAL) => new HitSampleInfo(sampleName, SampleBank, volume: SampleVolume);
|
||||
|
||||
/// <summary>
|
||||
/// Applies <see cref="SampleBank"/> and <see cref="SampleVolume"/> to a <see cref="HitSampleInfo"/> if necessary, returning the modified <see cref="HitSampleInfo"/>.
|
||||
@ -71,12 +66,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// <param name="hitSampleInfo">The <see cref="HitSampleInfo"/>. This will not be modified.</param>
|
||||
/// <returns>The modified <see cref="HitSampleInfo"/>. This does not share a reference with <paramref name="hitSampleInfo"/>.</returns>
|
||||
public virtual HitSampleInfo ApplyTo(HitSampleInfo hitSampleInfo)
|
||||
{
|
||||
var newSampleInfo = hitSampleInfo.Clone();
|
||||
newSampleInfo.Bank = hitSampleInfo.Bank ?? SampleBank;
|
||||
newSampleInfo.Volume = hitSampleInfo.Volume > 0 ? hitSampleInfo.Volume : SampleVolume;
|
||||
return newSampleInfo;
|
||||
}
|
||||
=> hitSampleInfo.With(bank: hitSampleInfo.Bank ?? SampleBank, volume: hitSampleInfo.Volume > 0 ? hitSampleInfo.Volume : SampleVolume);
|
||||
|
||||
public override bool IsRedundant(ControlPoint existing)
|
||||
=> existing is SampleControlPoint existingSample
|
||||
|
Reference in New Issue
Block a user