1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 10:22:56 +08:00

Make top-level osu! objects use new methods

This commit is contained in:
smoogipoo 2020-11-06 23:09:23 +09:00
parent 7eceda242b
commit 33b629a87a
4 changed files with 40 additions and 6 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -30,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private Container scaleContainer;
private InputManager inputManager;
public DrawableHitCircle(HitCircle h)
public DrawableHitCircle([CanBeNull] HitCircle h = null)
: base(h)
{
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.UI;
using osuTK;
@ -49,6 +50,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
ShakeDuration = 30,
RelativeSizeAxes = Axes.Both
});
}
protected override void FreeAfterUse()
{
IndexInCurrentComboBindable.UnbindFrom(HitObject.IndexInCurrentComboBindable);
PositionBindable.UnbindFrom(HitObject.PositionBindable);
StackHeightBindable.UnbindFrom(HitObject.StackHeightBindable);
ScaleBindable.UnbindFrom(HitObject.ScaleBindable);
base.FreeAfterUse();
}
public override void Apply(HitObject hitObject)
{
base.Apply(hitObject);
IndexInCurrentComboBindable.BindTo(HitObject.IndexInCurrentComboBindable);
PositionBindable.BindTo(HitObject.PositionBindable);

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using osuTK;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
@ -32,14 +33,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private PlaySliderBody sliderBody => Body.Drawable as PlaySliderBody;
public readonly IBindable<int> PathVersion = new Bindable<int>();
public IBindable<int> PathVersion => pathVersion;
private readonly Bindable<int> pathVersion = new Bindable<int>();
private Container<DrawableSliderHead> headContainer;
private Container<DrawableSliderTail> tailContainer;
private Container<DrawableSliderTick> tickContainer;
private Container<DrawableSliderRepeat> repeatContainer;
public DrawableSlider(Slider s)
public DrawableSlider([CanBeNull] Slider s = null)
: base(s)
{
}
@ -63,8 +65,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both },
};
PathVersion.BindTo(HitObject.Path.Version);
PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition, true);
StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition, true);
ScaleBindable.BindValueChanged(scale => Ball.Scale = new Vector2(scale.NewValue), true);
@ -78,6 +78,22 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Tracking.BindValueChanged(updateSlidingSample);
}
protected override void FreeAfterUse()
{
PathVersion.UnbindFrom(HitObject.Path.Version);
base.FreeAfterUse();
}
public override void Apply(HitObject hitObject)
{
base.Apply(hitObject);
// Ensure that the version will change after the upcoming BindTo().
pathVersion.Value = int.MaxValue;
PathVersion.BindTo(HitObject.Path.Version);
}
private PausableSkinnableSound slidingSample;
protected override void LoadSamples()

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
@ -32,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private Bindable<bool> isSpinning;
private bool spinnerFrequencyModulate;
public DrawableSpinner(Spinner s)
public DrawableSpinner([CanBeNull] Spinner s = null)
: base(s)
{
}