1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:43:21 +08:00
osu-lazer/osu.Game/Screens/Play/ComboEffects.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
2.3 KiB
C#
Raw Normal View History

2019-06-30 00:28:40 +08: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 15:37:17 +08:00
#nullable disable
2019-06-30 00:28:40 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
2019-06-30 20:58:30 +08:00
using osu.Game.Audio;
using osu.Game.Configuration;
2019-06-30 00:28:40 +08:00
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
namespace osu.Game.Screens.Play
{
public partial class ComboEffects : CompositeDrawable
{
2019-06-30 20:58:30 +08:00
private readonly ScoreProcessor processor;
private SkinnableSound comboBreakSample;
2019-06-30 00:28:40 +08:00
private Bindable<bool> alwaysPlayFirst;
private double? firstBreakTime;
2019-06-30 00:28:40 +08:00
public ComboEffects(ScoreProcessor processor)
{
2019-06-30 20:58:30 +08:00
this.processor = processor;
2019-06-30 00:28:40 +08:00
}
2019-06-30 20:58:30 +08:00
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
2019-06-30 00:28:40 +08:00
{
InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("Gameplay/combobreak"));
alwaysPlayFirst = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak);
2019-06-30 00:28:40 +08:00
}
2019-06-30 20:58:30 +08:00
protected override void LoadComplete()
2019-06-30 00:28:40 +08:00
{
2019-06-30 20:58:30 +08:00
base.LoadComplete();
processor.Combo.BindValueChanged(onComboChange);
2019-06-30 20:58:30 +08:00
}
[Resolved(canBeNull: true)]
private ISamplePlaybackDisabler samplePlaybackDisabler { get; set; }
[Resolved]
private IGameplayClock gameplayClock { get; set; }
2019-06-30 20:58:30 +08:00
private void onComboChange(ValueChangedEvent<int> combo)
{
// handle the case of rewinding before the first combo break time.
if (gameplayClock.CurrentTime < firstBreakTime)
firstBreakTime = null;
if (gameplayClock.IsRewinding)
return;
if (combo.NewValue == 0 && (combo.OldValue > 20 || (alwaysPlayFirst.Value && firstBreakTime == null)))
{
firstBreakTime = gameplayClock.CurrentTime;
// 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();
}
2019-06-30 00:28:40 +08:00
}
}
2019-06-30 20:58:30 +08:00
}