Initialize some bindables for prevent get the null instance.

This commit is contained in:
為什麼 2022-07-10 23:16:51 +08:00 committed by andy840119
parent 1f9f2b413e
commit ce1bb206c8
4 changed files with 10 additions and 10 deletions

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
{
public abstract class ModBlockFail : Mod, IApplicableFailOverride, IApplicableToHUD, IReadFromConfig
{
private Bindable<bool> showHealthBar;
private readonly Bindable<bool> showHealthBar = new Bindable<bool>();
/// <summary>
/// We never fail, 'yo.
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
public void ReadFromConfig(OsuConfigManager config)
{
showHealthBar = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail);
config.BindWith(OsuSetting.ShowHealthDisplayWhenCantFail, showHealthBar);
}
public void ApplyToHUD(HUDOverlay overlay)

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mods
private int retries;
private BindableNumber<double> health;
private readonly BindableNumber<double> health = new BindableDouble();
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
health = healthProcessor.Health.GetBoundCopy();
health.BindTo(healthProcessor.Health);
}
}
}

View File

@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Mods
private readonly BindableNumber<double> mainVolumeAdjust = new BindableDouble(0.5);
private readonly BindableNumber<double> metronomeVolumeAdjust = new BindableDouble(0.5);
private BindableNumber<int> currentCombo;
private readonly BindableNumber<int> currentCombo = new BindableInt();
[SettingSource("Enable metronome", "Add a metronome beat to help you keep track of the rhythm.")]
public BindableBool EnableMetronome { get; } = new BindableBool
@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
currentCombo = scoreProcessor.Combo.GetBoundCopy();
currentCombo.BindTo(scoreProcessor.Combo);
currentCombo.BindValueChanged(combo =>
{
double dimFactor = MuteComboCount.Value == 0 ? 1 : (double)combo.NewValue / MuteComboCount.Value;

View File

@ -28,9 +28,9 @@ namespace osu.Game.Rulesets.Mods
protected const float TRANSITION_DURATION = 100;
protected BindableNumber<int> CurrentCombo;
protected readonly BindableNumber<int> CurrentCombo = new BindableInt();
protected IBindable<bool> IsBreakTime;
protected readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
protected float ComboBasedAlpha;
@ -40,14 +40,14 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToPlayer(Player player)
{
IsBreakTime = player.IsBreakTime.GetBoundCopy();
IsBreakTime.BindTo(player.IsBreakTime);
}
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
if (HiddenComboCount.Value == 0) return;
CurrentCombo = scoreProcessor.Combo.GetBoundCopy();
CurrentCombo.BindTo(scoreProcessor.Combo);
CurrentCombo.BindValueChanged(combo =>
{
ComboBasedAlpha = Math.Max(MIN_ALPHA, 1 - (float)combo.NewValue / HiddenComboCount.Value);