mirror of
https://github.com/ppy/osu
synced 2025-01-06 14:20:03 +00:00
Move sample playback logic local to avoid edge case with no bonus ticks
Can't see a better way of doing this.
This commit is contained in:
parent
86cf0a36cf
commit
b219a371a9
@ -45,6 +45,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
private const float spinning_sample_initial_frequency = 1.0f;
|
private const float spinning_sample_initial_frequency = 1.0f;
|
||||||
private const float spinning_sample_modulated_base_frequency = 0.5f;
|
private const float spinning_sample_modulated_base_frequency = 0.5f;
|
||||||
|
|
||||||
|
private SkinnableSound maxBonusSample;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of bonus score gained from spinning after the required number of spins, for display purposes.
|
/// The amount of bonus score gained from spinning after the required number of spins, for display purposes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -109,6 +111,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||||
Looping = true,
|
Looping = true,
|
||||||
Frequency = { Value = spinning_sample_initial_frequency }
|
Frequency = { Value = spinning_sample_initial_frequency }
|
||||||
|
},
|
||||||
|
maxBonusSample = new SkinnableSound
|
||||||
|
{
|
||||||
|
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,6 +134,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
base.OnFree();
|
base.OnFree();
|
||||||
|
|
||||||
spinningSample.ClearSamples();
|
spinningSample.ClearSamples();
|
||||||
|
maxBonusSample.ClearSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadSamples()
|
protected override void LoadSamples()
|
||||||
@ -136,6 +143,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
spinningSample.Samples = HitObject.CreateSpinningSamples().Cast<ISampleInfo>().ToArray();
|
spinningSample.Samples = HitObject.CreateSpinningSamples().Cast<ISampleInfo>().ToArray();
|
||||||
spinningSample.Frequency.Value = spinning_sample_initial_frequency;
|
spinningSample.Frequency.Value = spinning_sample_initial_frequency;
|
||||||
|
|
||||||
|
maxBonusSample.Samples = new ISampleInfo[] { HitObject.CreateHitSampleInfo("spinnerbonus") };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
||||||
@ -157,6 +166,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.StopAllSamples();
|
base.StopAllSamples();
|
||||||
spinningSample?.Stop();
|
spinningSample?.Stop();
|
||||||
|
maxBonusSample?.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
@ -303,8 +313,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
private static readonly int score_per_tick = new SpinnerBonusTick.OsuSpinnerBonusTickJudgement().MaxNumericResult;
|
private static readonly int score_per_tick = new SpinnerBonusTick.OsuSpinnerBonusTickJudgement().MaxNumericResult;
|
||||||
|
|
||||||
private int lastMaxSamplePlayback;
|
|
||||||
|
|
||||||
private void updateBonusScore()
|
private void updateBonusScore()
|
||||||
{
|
{
|
||||||
if (ticks.Count == 0)
|
if (ticks.Count == 0)
|
||||||
@ -327,9 +335,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
if (tick == null)
|
if (tick == null)
|
||||||
{
|
{
|
||||||
// we still want to play a sound. this will probably be a new sound in the future, but for now let's continue playing the bonus sound.
|
// we still want to play a sound. this will probably be a new sound in the future, but for now let's continue playing the bonus sound.
|
||||||
// round robin to avoid hitting playback concurrency.
|
// TODO: this doesn't concurrency. i can't figure out how to make it concurrency. samples are bad and need a refactor.
|
||||||
tick = ticks.OfType<DrawableSpinnerBonusTick>().Skip(lastMaxSamplePlayback++ % HitObject.MaximumBonusSpins).First();
|
maxBonusSample.Play();
|
||||||
tick.PlaySamples();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tick.TriggerResult(true);
|
tick.TriggerResult(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user