Use bindable for DrawableDroplet HyperDash state

This commit is contained in:
ekrctb
2020-11-27 11:40:38 +09:00
parent 23109f5bbc
commit dbf67f82c0
2 changed files with 15 additions and 4 deletions

View File

@ -21,7 +21,17 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
ScaleContainer.Child = new SkinnableDrawable(new CatchSkinComponent(CatchSkinComponents.Droplet), _ => new DropletPiece()); HyperDash.BindValueChanged(_ => updatePiece(), true);
}
private void updatePiece()
{
ScaleContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Droplet),
_ => new DropletPiece
{
HyperDash = { BindTarget = HyperDash }
});
} }
protected override void UpdateInitialTransforms() protected override void UpdateInitialTransforms()

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -11,6 +12,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
{ {
public class DropletPiece : CompositeDrawable public class DropletPiece : CompositeDrawable
{ {
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
public DropletPiece() public DropletPiece()
{ {
Size = new Vector2(CatchHitObject.OBJECT_RADIUS / 2); Size = new Vector2(CatchHitObject.OBJECT_RADIUS / 2);
@ -19,15 +22,13 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject) private void load(DrawableHitObject drawableObject)
{ {
var drawableCatchObject = (DrawablePalpableCatchHitObject)drawableObject;
InternalChild = new Pulp InternalChild = new Pulp
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
AccentColour = { BindTarget = drawableObject.AccentColour } AccentColour = { BindTarget = drawableObject.AccentColour }
}; };
if (drawableCatchObject.HitObject.HyperDash) if (HyperDash.Value)
{ {
AddInternal(new HyperDropletBorderPiece()); AddInternal(new HyperDropletBorderPiece());
} }