2019-06-29 16:28:40 +00: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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2019-06-29 16:28:40 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-06-30 12:58:30 +00:00
|
|
|
using osu.Game.Audio;
|
2020-04-19 09:23:41 +00:00
|
|
|
using osu.Game.Configuration;
|
2019-06-29 16:28:40 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
|
|
|
public partial class ComboEffects : CompositeDrawable
|
|
|
|
{
|
2019-06-30 12:58:30 +00:00
|
|
|
private readonly ScoreProcessor processor;
|
|
|
|
|
|
|
|
private SkinnableSound comboBreakSample;
|
2019-06-29 16:28:40 +00:00
|
|
|
|
2020-11-13 04:35:01 +00:00
|
|
|
private Bindable<bool> alwaysPlayFirst;
|
|
|
|
|
|
|
|
private double? firstBreakTime;
|
2020-04-19 09:23:41 +00:00
|
|
|
|
2019-06-29 16:28:40 +00:00
|
|
|
public ComboEffects(ScoreProcessor processor)
|
|
|
|
{
|
2019-06-30 12:58:30 +00:00
|
|
|
this.processor = processor;
|
2019-06-29 16:28:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-30 12:58:30 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2020-04-19 09:23:41 +00:00
|
|
|
private void load(OsuConfigManager config)
|
2019-06-29 16:28:40 +00:00
|
|
|
{
|
2020-10-30 02:52:25 +00:00
|
|
|
InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("Gameplay/combobreak"));
|
2020-11-13 04:35:01 +00:00
|
|
|
alwaysPlayFirst = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak);
|
2019-06-29 16:28:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-30 12:58:30 +00:00
|
|
|
protected override void LoadComplete()
|
2019-06-29 16:28:40 +00:00
|
|
|
{
|
2019-06-30 12:58:30 +00:00
|
|
|
base.LoadComplete();
|
2020-04-19 09:23:41 +00:00
|
|
|
processor.Combo.BindValueChanged(onComboChange);
|
2019-06-30 12:58:30 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 04:15:54 +00:00
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
private ISamplePlaybackDisabler samplePlaybackDisabler { get; set; }
|
|
|
|
|
2020-11-13 04:35:01 +00:00
|
|
|
[Resolved]
|
2022-08-15 08:11:22 +00:00
|
|
|
private IGameplayClock gameplayClock { get; set; }
|
2020-11-13 04:35:01 +00:00
|
|
|
|
2019-06-30 12:58:30 +00:00
|
|
|
private void onComboChange(ValueChangedEvent<int> combo)
|
|
|
|
{
|
2020-11-13 04:35:01 +00:00
|
|
|
// handle the case of rewinding before the first combo break time.
|
|
|
|
if (gameplayClock.CurrentTime < firstBreakTime)
|
|
|
|
firstBreakTime = null;
|
|
|
|
|
2023-07-07 06:21:24 +00:00
|
|
|
if (gameplayClock.IsRewinding)
|
2020-11-13 04:35:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (combo.NewValue == 0 && (combo.OldValue > 20 || (alwaysPlayFirst.Value && firstBreakTime == null)))
|
2020-04-19 09:23:41 +00:00
|
|
|
{
|
2020-11-13 04:35:01 +00:00
|
|
|
firstBreakTime = gameplayClock.CurrentTime;
|
2020-11-13 04:15:54 +00:00
|
|
|
|
|
|
|
// combo break isn't a pausable sound itself as we want to let it play out.
|
|
|
|
// we still need to disable during seeks, though.
|
|
|
|
if (samplePlaybackDisabler?.SamplePlaybackDisabled.Value == true)
|
|
|
|
return;
|
|
|
|
|
|
|
|
comboBreakSample?.Play();
|
2020-04-19 09:23:41 +00:00
|
|
|
}
|
2019-06-29 16:28:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-30 12:58:30 +00:00
|
|
|
}
|