2020-11-24 18:16:03 +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.
|
|
|
|
|
|
2020-11-30 11:52:58 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2020-11-24 18:16:03 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-11-27 09:55:33 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2020-11-24 18:16:03 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-12-10 18:42:01 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-11-24 18:16:03 +08:00
|
|
|
|
using osuTK;
|
2020-12-08 20:29:03 +08:00
|
|
|
|
using osuTK.Graphics;
|
2020-11-24 18:16:03 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|
|
|
|
{
|
2020-12-08 20:29:03 +08:00
|
|
|
|
[Cached(typeof(IHasCatchObjectState))]
|
2020-12-09 09:25:35 +08:00
|
|
|
|
public abstract class DrawablePalpableCatchHitObject : DrawableCatchHitObject, IHasCatchObjectState
|
2020-11-24 18:16:03 +08:00
|
|
|
|
{
|
2020-11-25 07:07:59 +08:00
|
|
|
|
public new PalpableCatchHitObject HitObject => (PalpableCatchHitObject)base.HitObject;
|
|
|
|
|
|
2020-12-08 20:29:03 +08:00
|
|
|
|
Bindable<Color4> IHasCatchObjectState.AccentColour => AccentColour;
|
2020-11-27 09:55:33 +08:00
|
|
|
|
|
2020-12-08 20:29:03 +08:00
|
|
|
|
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
2020-11-27 09:55:33 +08:00
|
|
|
|
|
2020-12-08 20:29:03 +08:00
|
|
|
|
public Bindable<float> ScaleBindable { get; } = new Bindable<float>(1);
|
|
|
|
|
|
|
|
|
|
public Bindable<int> IndexInBeatmap { get; } = new Bindable<int>();
|
2020-11-27 10:41:39 +08:00
|
|
|
|
|
2020-11-27 09:55:33 +08:00
|
|
|
|
/// <summary>
|
2020-12-08 19:05:18 +08:00
|
|
|
|
/// The multiplicative factor applied to <see cref="Drawable.Scale"/> relative to <see cref="HitObject"/> scale.
|
2020-11-27 09:55:33 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual float ScaleFactor => 1;
|
|
|
|
|
|
2020-12-10 18:42:01 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The container internal transforms (such as scaling based on the circle size) are applied to.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected readonly Container ScalingContainer;
|
|
|
|
|
|
2020-12-10 19:43:01 +08:00
|
|
|
|
public Vector2 DisplaySize => ScalingContainer.Size * ScalingContainer.Scale;
|
2020-12-10 18:42:01 +08:00
|
|
|
|
|
2020-12-10 19:43:01 +08:00
|
|
|
|
public float DisplayRotation => ScalingContainer.Rotation;
|
2020-12-10 18:42:01 +08:00
|
|
|
|
|
2020-12-09 09:25:35 +08:00
|
|
|
|
protected DrawablePalpableCatchHitObject([CanBeNull] CatchHitObject h)
|
2020-11-24 18:57:37 +08:00
|
|
|
|
: base(h)
|
2020-11-24 18:16:03 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2);
|
2020-12-10 18:42:01 +08:00
|
|
|
|
|
|
|
|
|
AddInternal(ScalingContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2)
|
|
|
|
|
});
|
2020-11-24 18:16:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2020-12-14 12:56:46 +08:00
|
|
|
|
OriginalXBindable.BindValueChanged(updateXPosition);
|
|
|
|
|
XOffsetBindable.BindValueChanged(updateXPosition, true);
|
2020-11-27 09:55:33 +08:00
|
|
|
|
|
|
|
|
|
ScaleBindable.BindValueChanged(scale =>
|
|
|
|
|
{
|
2020-12-10 18:42:01 +08:00
|
|
|
|
ScalingContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
|
2020-12-10 19:43:01 +08:00
|
|
|
|
Size = DisplaySize;
|
2020-11-27 09:55:33 +08:00
|
|
|
|
}, true);
|
2020-11-27 10:41:39 +08:00
|
|
|
|
|
|
|
|
|
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
|
2020-11-27 09:55:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 12:56:46 +08:00
|
|
|
|
private void updateXPosition(ValueChangedEvent<float> _)
|
|
|
|
|
{
|
|
|
|
|
X = OriginalXBindable.Value + XOffsetBindable.Value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-27 09:55:33 +08:00
|
|
|
|
protected override void OnApply()
|
|
|
|
|
{
|
|
|
|
|
base.OnApply();
|
|
|
|
|
|
|
|
|
|
HyperDash.BindTo(HitObject.HyperDashBindable);
|
|
|
|
|
ScaleBindable.BindTo(HitObject.ScaleBindable);
|
2020-11-27 10:41:39 +08:00
|
|
|
|
IndexInBeatmap.BindTo(HitObject.IndexInBeatmapBindable);
|
2020-11-27 09:55:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFree()
|
|
|
|
|
{
|
|
|
|
|
HyperDash.UnbindFrom(HitObject.HyperDashBindable);
|
|
|
|
|
ScaleBindable.UnbindFrom(HitObject.ScaleBindable);
|
2020-11-27 10:41:39 +08:00
|
|
|
|
IndexInBeatmap.UnbindFrom(HitObject.IndexInBeatmapBindable);
|
2020-11-27 09:55:33 +08:00
|
|
|
|
|
|
|
|
|
base.OnFree();
|
2020-11-24 18:16:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|