From db815f793038ca0c0f58a7a70d831a4ff21d8b63 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 1 May 2021 20:39:10 +0900 Subject: [PATCH] Tidy up implementation in `DrawableNote` --- .../Objects/Drawables/DrawableNote.cs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index d67c360301..36565e14aa 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -35,8 +35,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Drawable headPiece; - private readonly Bindable snap = new Bindable(); - public DrawableNote(Note hitObject) : base(hitObject) { @@ -58,17 +56,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override void LoadComplete() { - if (beatmap != null) - { - HitObject.StartTimeBindable.BindValueChanged(startTime => - { - snap.Value = beatmap.ControlPointInfo.GetClosestBeatDivisor(startTime.NewValue); - }, - true - ); - } - - snap.BindValueChanged(_ => updateSnapColour()); + HitObject.StartTimeBindable.BindValueChanged(_ => updateSnapColour()); configTimingBasedNoteColouring.BindValueChanged(_ => updateSnapColour(), true); } @@ -114,9 +102,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private void updateSnapColour() { - Colour = configTimingBasedNoteColouring.Value - ? BindableBeatDivisor.GetColourFor(snap.Value, colours) - : Color4.White; + if (beatmap == null) return; + + int snapDivisor = beatmap.ControlPointInfo.GetClosestBeatDivisor(HitObject.StartTime); + + Colour = configTimingBasedNoteColouring.Value ? BindableBeatDivisor.GetColourFor(snapDivisor, colours) : Color4.White; } } }