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;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public abstract class DrawablePalpableCatchHitObject : DrawableCatchHitObject
|
|
|
|
|
{
|
2020-11-25 07:07:59 +08:00
|
|
|
|
public new PalpableCatchHitObject HitObject => (PalpableCatchHitObject)base.HitObject;
|
|
|
|
|
|
2020-11-30 12:00:01 +08:00
|
|
|
|
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
2020-11-27 09:55:33 +08:00
|
|
|
|
|
2020-11-30 12:00:01 +08:00
|
|
|
|
public readonly Bindable<float> ScaleBindable = new Bindable<float>(1);
|
2020-11-27 09:55:33 +08:00
|
|
|
|
|
2020-11-27 10:41:39 +08:00
|
|
|
|
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
|
|
|
|
|
|
2020-11-27 09:55:33 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The multiplicative factor applied to <see cref="ScaleContainer"/> scale relative to <see cref="HitObject"/> scale.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual float ScaleFactor => 1;
|
|
|
|
|
|
2020-11-25 07:00:11 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether this hit object should stay on the catcher plate when the object is caught by the catcher.
|
|
|
|
|
/// </summary>
|
2020-11-24 18:57:37 +08:00
|
|
|
|
public virtual bool StaysOnPlate => true;
|
2020-11-24 18:16:03 +08:00
|
|
|
|
|
2020-11-24 18:57:37 +08:00
|
|
|
|
protected readonly Container ScaleContainer;
|
|
|
|
|
|
2020-11-30 11:52:58 +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-11-24 18:57:37 +08:00
|
|
|
|
|
|
|
|
|
AddInternal(ScaleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
});
|
2020-11-24 18:16:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2020-11-27 09:55:33 +08:00
|
|
|
|
XBindable.BindValueChanged(x =>
|
|
|
|
|
{
|
|
|
|
|
if (!IsOnPlate) X = x.NewValue;
|
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
ScaleBindable.BindValueChanged(scale =>
|
|
|
|
|
{
|
|
|
|
|
ScaleContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
|
|
|
|
|
}, true);
|
2020-11-27 10:41:39 +08:00
|
|
|
|
|
|
|
|
|
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|