Introduce IHasCatchObjectState implemented by DHO and CaughtObject

This commit is contained in:
ekrctb
2020-12-08 21:29:03 +09:00
parent c301223d8c
commit a32dac00dd
11 changed files with 70 additions and 86 deletions

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Catch.Skinning.Default
@ -17,13 +16,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
[Resolved(canBeNull: true)]
[CanBeNull]
protected DrawableHitObject DrawableHitObject { get; private set; }
[Resolved(canBeNull: true)]
[CanBeNull]
protected CaughtObject CaughtObject { get; private set; }
[Resolved]
protected IHasCatchObjectState ObjectState { get; private set; }
/// <summary>
/// A part of this piece that will be faded out while falling in the playfield.
@ -41,16 +35,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
{
base.LoadComplete();
var hitObject = (DrawablePalpableCatchHitObject)DrawableHitObject;
if (hitObject != null)
{
AccentColour.BindTo(hitObject.AccentColour);
HyperDash.BindTo(hitObject.HyperDash);
}
if (CaughtObject != null)
AccentColour.BindTo(CaughtObject.AccentColour);
AccentColour.BindTo(ObjectState.AccentColour);
HyperDash.BindTo(ObjectState.HyperDash);
HyperDash.BindValueChanged(hyper =>
{
@ -61,13 +47,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
protected override void Update()
{
if (BorderPiece != null)
{
if (DrawableHitObject?.HitObject != null)
BorderPiece.Alpha = (float)Math.Clamp((DrawableHitObject.HitObject.StartTime - Time.Current) / 500, 0, 1);
else
BorderPiece.Alpha = 0;
}
if (BorderPiece != null && ObjectState?.HitObject != null)
BorderPiece.Alpha = (float)Math.Clamp((ObjectState.HitObject.StartTime - Time.Current) / 500, 0, 1);
}
}
}