Move first tick tracking logic inside TickPiece

This commit is contained in:
Dean Herbert
2022-11-07 15:21:58 +09:00
parent cb6b9898c1
commit 1975385cc7
2 changed files with 31 additions and 17 deletions

View File

@ -1,9 +1,13 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osuTK;
using osuTK.Graphics;
@ -22,20 +26,10 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
/// </summary>
private const float tick_size = 0.35f;
private bool filled;
public bool Filled
{
get => filled;
set
{
filled = value;
fillBox.Alpha = filled ? 1 : 0;
}
}
private readonly Box fillBox;
private Bindable<bool> isFirstTick = null!;
public TickPiece()
{
Anchor = Anchor.Centre;
@ -62,5 +56,19 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
}
};
}
[Resolved]
private DrawableHitObject drawableHitObject { get; set; } = null!;
protected override void LoadComplete()
{
base.LoadComplete();
if (drawableHitObject is DrawableDrumRollTick drumRollTick)
{
isFirstTick = drumRollTick.IsFirstTick.GetBoundCopy();
isFirstTick.BindValueChanged(first => fillBox.Alpha = first.NewValue ? 1 : 0, true);
}
}
}
}