mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Merge branch 'master' into score-processor-enum-getvalue-overhead-reduction
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Performance;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -20,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
{
|
||||
Start = start;
|
||||
LifetimeStart = Start.StartTime;
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
private OsuHitObject? end;
|
||||
@ -41,31 +40,39 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
}
|
||||
}
|
||||
|
||||
private bool wasBound;
|
||||
|
||||
private void bindEvents()
|
||||
{
|
||||
UnbindEvents();
|
||||
|
||||
if (End == null)
|
||||
return;
|
||||
|
||||
// Note: Positions are bound for instantaneous feedback from positional changes from the editor, before ApplyDefaults() is called on hitobjects.
|
||||
Start.DefaultsApplied += onDefaultsApplied;
|
||||
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()
|
||||
{
|
||||
if (!wasBound)
|
||||
return;
|
||||
|
||||
Debug.Assert(End != null);
|
||||
|
||||
Start.DefaultsApplied -= onDefaultsApplied;
|
||||
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();
|
||||
|
@ -42,9 +42,24 @@ namespace osu.Game.Input.Handlers
|
||||
if (!(state is RulesetInputManagerInputState<T> inputState))
|
||||
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
||||
|
||||
var lastPressed = inputState.LastReplayState?.PressedActions ?? new List<T>();
|
||||
var released = lastPressed.Except(PressedActions).ToArray();
|
||||
var pressed = PressedActions.Except(lastPressed).ToArray();
|
||||
T[] released = Array.Empty<T>();
|
||||
T[] pressed = Array.Empty<T>();
|
||||
|
||||
var lastPressed = inputState.LastReplayState?.PressedActions;
|
||||
|
||||
if (lastPressed == null || lastPressed.Count == 0)
|
||||
{
|
||||
pressed = PressedActions.ToArray();
|
||||
}
|
||||
else if (PressedActions.Count == 0)
|
||||
{
|
||||
released = lastPressed.ToArray();
|
||||
}
|
||||
else if (!lastPressed.SequenceEqual(PressedActions))
|
||||
{
|
||||
released = lastPressed.Except(PressedActions).ToArray();
|
||||
pressed = PressedActions.Except(lastPressed).ToArray();
|
||||
}
|
||||
|
||||
inputState.LastReplayState = this;
|
||||
|
||||
|
Reference in New Issue
Block a user