1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 09:32:55 +08:00

Tidy up implementation in DrawableNote

This commit is contained in:
Dean Herbert 2021-05-01 20:39:10 +09:00
parent 0b06c5bcb1
commit db815f7930

View File

@ -35,8 +35,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
private readonly Drawable headPiece; private readonly Drawable headPiece;
private readonly Bindable<int> snap = new Bindable<int>();
public DrawableNote(Note hitObject) public DrawableNote(Note hitObject)
: base(hitObject) : base(hitObject)
{ {
@ -58,17 +56,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected override void LoadComplete() protected override void LoadComplete()
{ {
if (beatmap != null) HitObject.StartTimeBindable.BindValueChanged(_ => updateSnapColour());
{
HitObject.StartTimeBindable.BindValueChanged(startTime =>
{
snap.Value = beatmap.ControlPointInfo.GetClosestBeatDivisor(startTime.NewValue);
},
true
);
}
snap.BindValueChanged(_ => updateSnapColour());
configTimingBasedNoteColouring.BindValueChanged(_ => updateSnapColour(), true); configTimingBasedNoteColouring.BindValueChanged(_ => updateSnapColour(), true);
} }
@ -114,9 +102,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
private void updateSnapColour() private void updateSnapColour()
{ {
Colour = configTimingBasedNoteColouring.Value if (beatmap == null) return;
? BindableBeatDivisor.GetColourFor(snap.Value, colours)
: Color4.White; int snapDivisor = beatmap.ControlPointInfo.GetClosestBeatDivisor(HitObject.StartTime);
Colour = configTimingBasedNoteColouring.Value ? BindableBeatDivisor.GetColourFor(snapDivisor, colours) : Color4.White;
} }
} }
} }