1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Simplify condition from two to one operand

This commit is contained in:
Bartłomiej Dach 2021-01-22 20:17:21 +01:00
parent e0f8f6a23f
commit b692abd3c2
2 changed files with 13 additions and 6 deletions

View File

@ -18,7 +18,13 @@ namespace osu.Game.Skinning
protected bool RequestedPlaying { get; private set; }
protected virtual bool AllowNonLoopingCutOff => false;
/// <summary>
/// Whether this <see cref="PausableSkinnableSound"/> is affected by
/// a higher-level <see cref="ISamplePlaybackDisabler"/>'s state changes.
/// By default only looping samples are started/stopped on sample disable
/// to prevent one-time samples from cutting off abruptly.
/// </summary>
protected virtual bool AffectedBySamplePlaybackDisable => Looping;
public PausableSkinnableSound()
{
@ -48,10 +54,7 @@ namespace osu.Game.Skinning
samplePlaybackDisabled.BindValueChanged(disabled =>
{
if (!RequestedPlaying) return;
// if the sample is non-looping, and non-looping cut off is not allowed,
// let the sample play out to completion (sounds better than abruptly cutting off).
if (!Looping && !AllowNonLoopingCutOff) return;
if (!AffectedBySamplePlaybackDisable) return;
cancelPendingStart();

View File

@ -21,7 +21,11 @@ namespace osu.Game.Storyboards.Drawables
public override bool RemoveWhenNotAlive => false;
protected override bool AllowNonLoopingCutOff => true;
/// <remarks>
/// Contrary to <see cref="PausableSkinnableSound"/>, all <see cref="DrawableStoryboardSample"/>s are affected
/// by sample disables, as they are oftentimes longer-running sound effects. This also matches stable behaviour.
/// </remarks>
protected override bool AffectedBySamplePlaybackDisable => true;
public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
: base(sampleInfo)