2020-12-07 12:14:00 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-12-07 12:14:00 +08:00
|
|
|
using System;
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-12-07 17:57:42 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
2020-12-07 12:14:00 +08:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-07 17:57:42 +08:00
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
2020-12-07 12:14:00 +08:00
|
|
|
{
|
2020-12-08 16:02:57 +08:00
|
|
|
public abstract class CatchHitObjectPiece : CompositeDrawable
|
2020-12-07 12:14:00 +08:00
|
|
|
{
|
|
|
|
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
|
|
|
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
2021-06-07 13:49:37 +08:00
|
|
|
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
|
2020-12-07 12:14:00 +08:00
|
|
|
|
2020-12-08 20:29:03 +08:00
|
|
|
[Resolved]
|
|
|
|
protected IHasCatchObjectState ObjectState { get; private set; }
|
2020-12-08 19:34:08 +08:00
|
|
|
|
2020-12-08 16:15:40 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A part of this piece that will be faded out while falling in the playfield.
|
|
|
|
/// </summary>
|
2020-12-07 12:14:00 +08:00
|
|
|
[CanBeNull]
|
2020-12-08 16:15:40 +08:00
|
|
|
protected virtual BorderPiece BorderPiece => null;
|
2020-12-07 12:14:00 +08:00
|
|
|
|
2020-12-08 16:15:40 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A part of this piece that will be only visible when <see cref="HyperDash"/> is true.
|
|
|
|
/// </summary>
|
2020-12-07 12:14:00 +08:00
|
|
|
[CanBeNull]
|
2020-12-08 16:15:40 +08:00
|
|
|
protected virtual HyperBorderPiece HyperBorderPiece => null;
|
2020-12-07 12:14:00 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-12-08 20:29:03 +08:00
|
|
|
AccentColour.BindTo(ObjectState.AccentColour);
|
|
|
|
HyperDash.BindTo(ObjectState.HyperDash);
|
2021-06-07 13:49:37 +08:00
|
|
|
IndexInBeatmap.BindTo(ObjectState.IndexInBeatmap);
|
2020-12-08 19:34:08 +08:00
|
|
|
|
2020-12-07 12:14:00 +08:00
|
|
|
HyperDash.BindValueChanged(hyper =>
|
|
|
|
{
|
|
|
|
if (HyperBorderPiece != null)
|
|
|
|
HyperBorderPiece.Alpha = hyper.NewValue ? 1 : 0;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
2020-12-09 09:28:42 +08:00
|
|
|
if (BorderPiece != null)
|
2020-12-08 20:29:03 +08:00
|
|
|
BorderPiece.Alpha = (float)Math.Clamp((ObjectState.HitObject.StartTime - Time.Current) / 500, 0, 1);
|
2020-12-07 12:14:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|