mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Separate asymmetric CatchHitObject.X to EffectiveX and OriginalX
This commit is contained in:
parent
94d737e51b
commit
8da502da44
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user