1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 00:53:10 +08:00

Merge branch 'master' into replay-frame-comparison-array-overhead-reduction

This commit is contained in:
Salman Ahmed 2021-08-26 09:30:58 +03:00 committed by GitHub
commit b0bab4fda6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
#nullable enable #nullable enable
using System; using System;
using System.Diagnostics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Performance; using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -20,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{ {
Start = start; Start = start;
LifetimeStart = Start.StartTime; LifetimeStart = Start.StartTime;
bindEvents();
} }
private OsuHitObject? end; private OsuHitObject? end;
@ -41,31 +40,39 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
} }
} }
private bool wasBound;
private void bindEvents() private void bindEvents()
{ {
UnbindEvents(); UnbindEvents();
if (End == null)
return;
// Note: Positions are bound for instantaneous feedback from positional changes from the editor, before ApplyDefaults() is called on hitobjects. // Note: Positions are bound for instantaneous feedback from positional changes from the editor, before ApplyDefaults() is called on hitobjects.
Start.DefaultsApplied += onDefaultsApplied; Start.DefaultsApplied += onDefaultsApplied;
Start.PositionBindable.ValueChanged += onPositionChanged; Start.PositionBindable.ValueChanged += onPositionChanged;
if (End != null) End.DefaultsApplied += onDefaultsApplied;
{ End.PositionBindable.ValueChanged += onPositionChanged;
End.DefaultsApplied += onDefaultsApplied;
End.PositionBindable.ValueChanged += onPositionChanged; wasBound = true;
}
} }
public void UnbindEvents() public void UnbindEvents()
{ {
if (!wasBound)
return;
Debug.Assert(End != null);
Start.DefaultsApplied -= onDefaultsApplied; Start.DefaultsApplied -= onDefaultsApplied;
Start.PositionBindable.ValueChanged -= onPositionChanged; Start.PositionBindable.ValueChanged -= onPositionChanged;
if (End != null) End.DefaultsApplied -= onDefaultsApplied;
{ End.PositionBindable.ValueChanged -= onPositionChanged;
End.DefaultsApplied -= onDefaultsApplied;
End.PositionBindable.ValueChanged -= onPositionChanged; wasBound = false;
}
} }
private void onDefaultsApplied(HitObject obj) => refreshLifetimes(); private void onDefaultsApplied(HitObject obj) => refreshLifetimes();