1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Separate asymmetric CatchHitObject.X to EffectiveX and OriginalX

This commit is contained in:
ekrctb 2020-12-09 17:46:36 +09:00
parent 94d737e51b
commit 8da502da44
2 changed files with 16 additions and 13 deletions

View File

@ -16,23 +16,27 @@ namespace osu.Game.Rulesets.Catch.Objects
{
public const float OBJECT_RADIUS = 64;
// This value is after XOffset applied.
public readonly Bindable<float> XBindable = new Bindable<float>();
public readonly Bindable<float> OriginalXBindable = new Bindable<float>();
// This value is before XOffset applied.
private float originalX;
public float OriginalX
{
get => OriginalXBindable.Value;
set => OriginalXBindable.Value = value;
}
/// <summary>
/// The horizontal position of the fruit between 0 and <see cref="CatchPlayfield.WIDTH"/>.
/// </summary>
public float X
{
// TODO: I don't like this asymmetry.
get => XBindable.Value;
// originalX is set by `XBindable.BindValueChanged`
set => XBindable.Value = value + xOffset;
get => EffectiveX;
set => OriginalXBindable.Value = value;
}
public readonly Bindable<float> EffectiveXBindable = new Bindable<float>();
public float EffectiveX => EffectiveXBindable.Value;
private float xOffset;
/// <summary>
@ -40,11 +44,10 @@ namespace osu.Game.Rulesets.Catch.Objects
/// </summary>
internal float XOffset
{
get => xOffset;
set
{
xOffset = value;
XBindable.Value = originalX + xOffset;
EffectiveXBindable.Value = OriginalX + xOffset;
}
}
@ -116,7 +119,7 @@ namespace osu.Game.Rulesets.Catch.Objects
protected CatchHitObject()
{
XBindable.BindValueChanged(x => originalX = x.NewValue - xOffset);
OriginalXBindable.BindValueChanged(change => EffectiveXBindable.Value = change.NewValue + xOffset);
}
}
}

View File

@ -38,14 +38,14 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
base.OnApply();
XBindable.BindTo(HitObject.XBindable);
XBindable.BindTo(HitObject.EffectiveXBindable);
}
protected override void OnFree()
{
base.OnFree();
XBindable.UnbindFrom(HitObject.XBindable);
XBindable.UnbindFrom(HitObject.EffectiveXBindable);
}
public Func<CatchHitObject, bool> CheckPosition;