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

Remove EffectiveXBindable (setting Value was not handled)

And use orthogonal `OriginalXBindable` and `XOffsetBindable`.
This commit is contained in:
ekrctb 2020-12-14 13:39:07 +09:00
parent 0ad256a762
commit 5b5e883904
4 changed files with 29 additions and 40 deletions

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Catch.Tests
private void attemptCatch(Fruit fruit)
{
fruit.OriginalX += catcher.X;
fruit.X = fruit.OriginalX + catcher.X;
fruit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty
{
CircleSize = circleSize

View File

@ -4,7 +4,6 @@
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
@ -21,46 +20,40 @@ namespace osu.Game.Rulesets.Catch.Objects
/// <summary>
/// The horizontal position of the hit object between 0 and <see cref="CatchPlayfield.WIDTH"/>.
/// </summary>
/// <remarks>
/// This value is the original value specified in the beatmap, not affected by beatmap processing.
/// It should be used instead of <see cref="EffectiveX"/> when working on a beatmap, not a gameplay.
/// </remarks>
public float OriginalX
public float X
{
get => OriginalXBindable.Value;
set => OriginalXBindable.Value = value;
}
float IHasXPosition.X => OriginalX;
float IHasXPosition.X => OriginalXBindable.Value;
public readonly Bindable<float> XOffsetBindable = new Bindable<float>();
/// <summary>
/// An alias of <see cref="OriginalX"/> setter.
/// A random offset applied to the horizontal position, set by the beatmap processing.
/// </summary>
public float X
public float XOffset
{
set => OriginalX = value;
set => XOffsetBindable.Value = value;
}
public readonly Bindable<float> EffectiveXBindable = new Bindable<float>();
/// <summary>
/// The horizontal position of the hit object between 0 and <see cref="CatchPlayfield.WIDTH"/>.
/// </summary>
/// <remarks>
/// This value is the original <see cref="X"/> value specified in the beatmap, not affected by the beatmap processing.
/// Use <see cref="EffectiveX"/> for a gameplay.
/// </remarks>
public float OriginalX => OriginalXBindable.Value;
/// <summary>
/// The effective horizontal position of the hit object between 0 and <see cref="CatchPlayfield.WIDTH"/>.
/// </summary>
public float EffectiveX => EffectiveXBindable.Value;
private float xOffset;
/// <summary>
/// A random offset applied to the horizontal position, set by the <see cref="CatchBeatmapProcessor"/>.
/// </summary>
internal float XOffset
{
set
{
xOffset = value;
EffectiveXBindable.Value = OriginalX + xOffset;
}
}
/// <remarks>
/// This value is the original <see cref="X"/> value plus the offset applied by the beatmap processing.
/// Use <see cref="OriginalX"/> if a value not affected by the offset is desired.
/// </remarks>
public float EffectiveX => OriginalXBindable.Value + XOffsetBindable.Value;
public double TimePreempt = 1000;
@ -127,10 +120,5 @@ namespace osu.Game.Rulesets.Catch.Objects
}
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
protected CatchHitObject()
{
OriginalXBindable.BindValueChanged(change => EffectiveXBindable.Value = change.NewValue + xOffset);
}
}
}

View File

@ -15,7 +15,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
{
public readonly Bindable<float> EffectiveXBindable = new Bindable<float>();
public readonly Bindable<float> OriginalXBindable = new Bindable<float>();
public readonly Bindable<float> XOffsetBindable = new Bindable<float>();
protected override double InitialLifetimeOffset => HitObject.TimePreempt;
@ -38,14 +39,16 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
base.OnApply();
EffectiveXBindable.BindTo(HitObject.EffectiveXBindable);
OriginalXBindable.BindTo(HitObject.OriginalXBindable);
XOffsetBindable.BindTo(HitObject.XOffsetBindable);
}
protected override void OnFree()
{
base.OnFree();
EffectiveXBindable.UnbindFrom(HitObject.EffectiveXBindable);
OriginalXBindable.UnbindFrom(HitObject.OriginalXBindable);
XOffsetBindable.UnbindFrom(HitObject.XOffsetBindable);
}
public Func<CatchHitObject, bool> CheckPosition;

View File

@ -55,10 +55,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
[BackgroundDependencyLoader]
private void load()
{
EffectiveXBindable.BindValueChanged(x =>
{
X = x.NewValue;
}, true);
OriginalXBindable.BindValueChanged(_ => X = OriginalXBindable.Value + XOffsetBindable.Value);
XOffsetBindable.BindValueChanged(_ => X = OriginalXBindable.Value + XOffsetBindable.Value, true);
ScaleBindable.BindValueChanged(scale =>
{