Add ComboIndexWithOffsetsBindable and bind similar to ComboIndexBindable

This commit is contained in:
Salman Ahmed
2021-07-22 16:22:42 +03:00
parent cd7b90363a
commit 523c154f15
7 changed files with 41 additions and 3 deletions

View File

@ -124,7 +124,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
public readonly Bindable<double> StartTimeBindable = new Bindable<double>();
private readonly BindableList<HitSampleInfo> samplesBindable = new BindableList<HitSampleInfo>();
private readonly Bindable<bool> userPositionalHitSounds = new Bindable<bool>();
private readonly Bindable<int> comboIndexBindable = new Bindable<int>();
private readonly Bindable<int> comboIndexWithOffsetsBindable = new Bindable<int>();
protected override bool RequiresChildrenUpdate => true;
@ -186,6 +188,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
base.LoadComplete();
comboIndexBindable.BindValueChanged(_ => UpdateComboColour(), true);
comboIndexWithOffsetsBindable.BindValueChanged(_ => UpdateComboColour(), true);
updateState(ArmedState.Idle, true);
}
@ -250,7 +253,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
StartTimeBindable.BindValueChanged(onStartTimeChanged);
if (HitObject is IHasComboInformation combo)
{
comboIndexBindable.BindTo(combo.ComboIndexBindable);
comboIndexWithOffsetsBindable.BindTo(combo.ComboIndexWithOffsetsBindable);
}
samplesBindable.BindTo(HitObject.SamplesBindable);
samplesBindable.BindCollectionChanged(onSamplesChanged, true);
@ -275,8 +281,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected sealed override void OnFree(HitObjectLifetimeEntry entry)
{
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
if (HitObject is IHasComboInformation combo)
{
comboIndexBindable.UnbindFrom(combo.ComboIndexBindable);
comboIndexWithOffsetsBindable.UnbindFrom(combo.ComboIndexWithOffsetsBindable);
}
samplesBindable.UnbindFrom(HitObject.SamplesBindable);
// Changes in start time trigger state updates. When a new hitobject is applied, OnApply() automatically performs a state update anyway.