Track path type changes for PointsInSegment

This commit is contained in:
Naxess 2021-04-07 17:19:12 +02:00
parent 9d02930709
commit b8ab1c7682

View File

@ -50,6 +50,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
[Resolved]
private OsuColour colours { get; set; }
private readonly List<IBindable<PathType?>> pathTypes;
private IBindable<int> sliderVersion;
private IBindable<Vector2> sliderPosition;
private IBindable<float> sliderScale;
@ -59,8 +61,19 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
this.slider = slider;
ControlPoint = controlPoint;
pathTypes = new List<IBindable<PathType?>>();
slider.Path.ControlPoints.BindCollectionChanged((_, args) =>
{
pathTypes.Clear();
foreach (var point in slider.Path.ControlPoints)
{
IBindable<PathType?> boundTypeCopy = point.Type.GetBoundCopy();
pathTypes.Add(boundTypeCopy);
boundTypeCopy.BindValueChanged(_ => PointsInSegment = slider.Path.PointsInSegment(controlPoint));
}
PointsInSegment = slider.Path.PointsInSegment(controlPoint);
}, runOnceImmediately: true);