mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Encapsulate the method to apply SampleControlPoints to SampleInfos
This commit is contained in:
@ -31,6 +31,18 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
Volume = SampleVolume,
|
Volume = SampleVolume,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
public virtual SampleInfo ApplyTo(SampleInfo sampleInfo) => new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = sampleInfo.Bank ?? SampleBank,
|
||||||
|
Name = sampleInfo.Name,
|
||||||
|
Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume
|
||||||
|
};
|
||||||
|
|
||||||
public override bool Equals(ControlPoint other)
|
public override bool Equals(ControlPoint other)
|
||||||
=> base.Equals(other)
|
=> base.Equals(other)
|
||||||
&& other is SampleControlPoint sample
|
&& other is SampleControlPoint sample
|
||||||
|
@ -90,13 +90,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
if (HitObject.SampleControlPoint == null)
|
if (HitObject.SampleControlPoint == null)
|
||||||
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s 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}.");
|
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
|
||||||
AddInternal(Samples = new SkinnableSound(samples.Select(s => new SampleInfo
|
|
||||||
{
|
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray();
|
||||||
Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank,
|
foreach (var s in samples)
|
||||||
Name = s.Name,
|
s.Namespace = SampleNamespace;
|
||||||
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume,
|
|
||||||
Namespace = SampleNamespace
|
AddInternal(Samples = new SkinnableSound(samples));
|
||||||
}).ToArray()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user